From ffc094bd91027162c550ad19998b734271a79ca3 Mon Sep 17 00:00:00 2001 From: Keith Hall Date: Tue, 25 Feb 2025 22:17:00 +0200 Subject: [PATCH] Add debsources syntax --- CHANGELOG.md | 1 + .../02_Extra/apt-source-list.sublime-syntax | 42 +++++++++++++++++++ .../highlighted/debsources/sources.list | 15 +++++++ .../source/debsources/sources.list | 15 +++++++ 4 files changed, 73 insertions(+) create mode 100644 assets/syntaxes/02_Extra/apt-source-list.sublime-syntax create mode 100644 tests/syntax-tests/highlighted/debsources/sources.list create mode 100644 tests/syntax-tests/source/debsources/sources.list diff --git a/CHANGELOG.md b/CHANGELOG.md index 55fb6c5d..b4a8184c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ - Improve (Sys)log error highlighting, see #3205 (@keith-hall) - Map `ndjson` extension to JSON syntax, see #3209 (@keith-hall) - Map files with `csproj`, `vbproj`, `props` and `targets` extensions to XML syntax, see #3213 (@keith-hall) +- Add debsources syntax to highlight `/etc/apt/sources.list` files, see #3215 (@keith-hall) ## Themes diff --git a/assets/syntaxes/02_Extra/apt-source-list.sublime-syntax b/assets/syntaxes/02_Extra/apt-source-list.sublime-syntax new file mode 100644 index 00000000..d5ede5b5 --- /dev/null +++ b/assets/syntaxes/02_Extra/apt-source-list.sublime-syntax @@ -0,0 +1,42 @@ +%YAML 1.2 +--- +# See http://www.sublimetext.com/docs/syntax.html +name: debsources +file_extensions: + - sources.list +scope: text.apt-source-list +contexts: + main: + - include: comments + - match: ^[\w-]+ + scope: constant.language.apt-source-list + - match: \w+://\S+ + scope: markup.underline.link.apt-source-list + push: distribution + - match: \bmain\b + scope: support.class.apt-source-list + - match: \buniverse\b + scope: support.constant.apt-source-list + - match: \brestricted\b + scope: storage.modifier.apt-source-list + - match: \bmultiverse\b + scope: keyword.other.apt-source-list + - match: '[\w-]+' + scope: constant.other.apt-source-list + + comments: + - match: '#' + scope: punctuation.definition.comment.apt-source-list + push: line_comment + + line_comment: + - meta_scope: comment.line.apt-source-list + - match: $ + pop: true + + distribution: + - match: \S+ + scope: support.type.apt-source-list + pop: 1 + - match: $ + pop: 1 diff --git a/tests/syntax-tests/highlighted/debsources/sources.list b/tests/syntax-tests/highlighted/debsources/sources.list new file mode 100644 index 00000000..ef89d137 --- /dev/null +++ b/tests/syntax-tests/highlighted/debsources/sources.list @@ -0,0 +1,15 @@ +# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to +# newer versions of the distribution. + +deb https://deb.debian.org/debian bookworm main non-free-firmware +#deb-src https://deb.debian.org/debian bookworm main non-free-firmware + +## Major bug fix updates produced after the final release of the +## distribution. +# deb-src http://lt.archive.ubuntu.com/ubuntu/ xenial-updates main restricted + +deb https://security.debian.org/debian-security bookworm-security main non-free-firmware +deb-src https://security.debian.org/debian-security bookworm-security main non-free-firmware + +deb https://deb.debian.org/debian bookworm-updates main non-free-firmware +deb-src https://deb.debian.org/debian bookworm-updates main non-free-firmware diff --git a/tests/syntax-tests/source/debsources/sources.list b/tests/syntax-tests/source/debsources/sources.list new file mode 100644 index 00000000..2bdc6ef1 --- /dev/null +++ b/tests/syntax-tests/source/debsources/sources.list @@ -0,0 +1,15 @@ +# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to +# newer versions of the distribution. + +deb https://deb.debian.org/debian bookworm main non-free-firmware +#deb-src https://deb.debian.org/debian bookworm main non-free-firmware + +## Major bug fix updates produced after the final release of the +## distribution. +# deb-src http://lt.archive.ubuntu.com/ubuntu/ xenial-updates main restricted + +deb https://security.debian.org/debian-security bookworm-security main non-free-firmware +deb-src https://security.debian.org/debian-security bookworm-security main non-free-firmware + +deb https://deb.debian.org/debian bookworm-updates main non-free-firmware +deb-src https://deb.debian.org/debian bookworm-updates main non-free-firmware