Repository: sharkdp/bat (language: rust)

Issue:
`bat` does not print colored output on `debsources` filetype files
First off, thanks so much for making this! I use this as well as your `bat-extras` tools everyday in my development workflow. I'm not sure if this is a bug or a feature request, but figured I would put this out there either way - I couldn't find any similar issues listed atm.

**What steps will reproduce the bug?**

1. Install `bat` with `sudo apt install bat`
2. Create a symlink with: `ln -s /usr/bin/batcat ~/.local/bin/bat`
3. `cd /etc/apt`
4. `bat sources.list`

**What happens?**
See that you do not get a colored output of the `sources.list` file

**What did you expect to happen instead?**
I would expect that since I am able to get syntax highlighting for `debsources` filetypes in my editor (`neovim`) that I would also be able to get them with `bat`


**How did you install `bat`?**

apt-get

**bat version and environment**

```bash
**$ uname -srm**
Linux 6.1.0-31-amd64 x86_64  

**$ lsb_release -a**
Distributor ID: Debian  
Description:    Debian GNU/Linux 12 (bookworm)  
Release:        12  
Codename:       bookworm  

bat
---

**$ bat --version**
bat 0.22.1  

**$ env**

bat_config
----------

bat_wrapper
-----------

No wrapper script for 'bat'.

bat_wrapper_function
--------------------

No wrapper function for 'bat'.

No wrapper function for 'cat'.

tool
----

**$ less --version**
less 590 (GNU regular expressions) 
```

![Image](https://github.com/user-attachments/assets/7d5c5b34-7c6f-478e-bcc1-85c6859a2ebf)

![Image](https://github.com/user-attachments/assets/a63ed6af-465e-43a9-b1ac-e0c57b08e02d)



Discussion / hints:

Fix patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 55fb6c5d69..b4a8184cd3 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 0000000000..d5ede5b50a
--- /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


Test patch:
diff --git a/tests/syntax-tests/highlighted/debsources/sources.list b/tests/syntax-tests/highlighted/debsources/sources.list
new file mode 100644
index 0000000000..ef89d137a7
--- /dev/null
+++ b/tests/syntax-tests/highlighted/debsources/sources.list
@@ -0,0 +1,15 @@
+[38;2;117;113;94m#[0m[38;2;117;113;94m See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to[0m
+[38;2;117;113;94m#[0m[38;2;117;113;94m newer versions of the distribution.[0m
+
+[38;2;190;132;255mdeb[0m[38;2;248;248;242m [0m[4;38;2;166;226;46mhttps://deb.debian.org/debian[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mbookworm[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mmain[0m[38;2;248;248;242m [0m[38;2;190;132;255mnon-free-firmware[0m
+[38;2;117;113;94m#[0m[38;2;117;113;94mdeb-src https://deb.debian.org/debian bookworm main non-free-firmware[0m
+
+[38;2;117;113;94m#[0m[38;2;117;113;94m# Major bug fix updates produced after the final release of the[0m
+[38;2;117;113;94m#[0m[38;2;117;113;94m# distribution.[0m
+[38;2;117;113;94m#[0m[38;2;117;113;94m deb-src http://lt.archive.ubuntu.com/ubuntu/ xenial-updates main restricted[0m
+
+[38;2;190;132;255mdeb[0m[38;2;248;248;242m [0m[4;38;2;166;226;46mhttps://security.debian.org/debian-security[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mbookworm-security[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mmain[0m[38;2;248;248;242m [0m[38;2;190;132;255mnon-free-firmware[0m
+[38;2;190;132;255mdeb-src[0m[38;2;248;248;242m [0m[4;38;2;166;226;46mhttps://security.debian.org/debian-security[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mbookworm-security[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mmain[0m[38;2;248;248;242m [0m[38;2;190;132;255mnon-free-firmware[0m
+
+[38;2;190;132;255mdeb[0m[38;2;248;248;242m [0m[4;38;2;166;226;46mhttps://deb.debian.org/debian[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mbookworm-updates[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mmain[0m[38;2;248;248;242m [0m[38;2;190;132;255mnon-free-firmware[0m
+[38;2;190;132;255mdeb-src[0m[38;2;248;248;242m [0m[4;38;2;166;226;46mhttps://deb.debian.org/debian[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mbookworm-updates[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mmain[0m[38;2;248;248;242m [0m[38;2;190;132;255mnon-free-firmware[0m
diff --git a/tests/syntax-tests/source/debsources/sources.list b/tests/syntax-tests/source/debsources/sources.list
new file mode 100644
index 0000000000..2bdc6ef172
--- /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