From 8cad3638b9059f38d9fa9c04ca2c03cdbdb83ccc Mon Sep 17 00:00:00 2001 From: Jen-Chieh Shen Date: Thu, 5 Oct 2023 16:28:45 -0700 Subject: [PATCH] feat: Add gitignore support (#260) --- .gitmodules | 6 ++++++ CHANGELOG.md | 1 + queries/gitignore/highlights.scm | 31 +++++++++++++++++++++++++++++++ repos/gitignore | 1 + tree-sitter-langs.el | 1 + 5 files changed, 40 insertions(+) create mode 100644 queries/gitignore/highlights.scm create mode 160000 repos/gitignore diff --git a/.gitmodules b/.gitmodules index 34870515..62fb3b1b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -424,3 +424,9 @@ branch = master update = none ignore = dirty +[submodule "repos/gitignore"] + path = repos/gitignore + url = https://github.com/shunsambongi/tree-sitter-gitignore + branch = main + update = none + ignore = dirty diff --git a/CHANGELOG.md b/CHANGELOG.md index e76ec0ac..6ee24fb6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Changelog ## Unreleased +- Add `gitignore` support ## 0.12.56 - 2023-10-05 - Add `gitattributes` support diff --git a/queries/gitignore/highlights.scm b/queries/gitignore/highlights.scm new file mode 100644 index 00000000..6e83ea6f --- /dev/null +++ b/queries/gitignore/highlights.scm @@ -0,0 +1,31 @@ +(comment) @comment @spell + +[ + (directory_separator) + (directory_separator_escaped) +] @punctuation.delimiter + +[ + (wildcard_char_single) + (wildcard_chars) + (wildcard_chars_allow_slash) + (bracket_negation) +] @operator + +(negation) @punctuation.special + +[ + (pattern_char_escaped) + (bracket_char_escaped) +] @string.escape + +;; bracket expressions +[ + "[" + "]" +] @punctuation.bracket + +(bracket_char) @constant +(bracket_range + "-" @operator) +(bracket_char_class) @constant.builtin diff --git a/repos/gitignore b/repos/gitignore new file mode 160000 index 00000000..f4685bf1 --- /dev/null +++ b/repos/gitignore @@ -0,0 +1 @@ +Subproject commit f4685bf11ac466dd278449bcfe5fd014e94aa504 diff --git a/tree-sitter-langs.el b/tree-sitter-langs.el index 1c8315d2..133beb38 100644 --- a/tree-sitter-langs.el +++ b/tree-sitter-langs.el @@ -127,6 +127,7 @@ See `tree-sitter-langs-repos'." (fortran-mode . fortran) (gdscript-mode . gdscript) (gitattributes-mode . gitattributes) + (gitignore-mode . gitignore) (go-mode . go) (haskell-mode . haskell) (hcl-mode . hcl)