Unnamed repository; edit this file 'description' to name the repository.
Change tree-sitter parser for Git commit message files
The gbprod grammar is more complete and featureful than mine, and more actively maintained. I will archive my tree-sitter-git-commit in favor of gbprod's. The new queries are based on the ones in the repo upstream but I modified them to look similar to the highlights before this commit. Also I've updated the tab-width so that change nodes in the generated message are indented correctly.
Michael Davis 8 months ago
parent a9d51ef · commit 44293df
-rw-r--r--languages.toml7
-rw-r--r--runtime/queries/git-commit/highlights.scm30
-rw-r--r--runtime/queries/git-commit/injections.scm4
3 files changed, 20 insertions, 21 deletions
diff --git a/languages.toml b/languages.toml
index 63b53842..a2dc2053 100644
--- a/languages.toml
+++ b/languages.toml
@@ -1859,13 +1859,14 @@ name = "git-commit"
scope = "git.commitmsg"
file-types = [{ glob = "COMMIT_EDITMSG" }, { glob = "MERGE_MSG" }]
comment-token = "#"
-indent = { tab-width = 2, unit = " " }
+indent = { tab-width = 4, unit = " " }
rulers = [51, 73]
text-width = 72
+grammar = "gitcommit"
[[grammar]]
-name = "git-commit"
-source = { git = "https://github.com/the-mikedavis/tree-sitter-git-commit", rev = "6f193a66e9aa872760823dff020960c6cedc37b3" }
+name = "gitcommit"
+source = { git = "https://github.com/gbprod/tree-sitter-gitcommit", rev = "a716678c0f00645fed1e6f1d0eb221481dbd6f6d" }
[[language]]
name = "diff"
diff --git a/runtime/queries/git-commit/highlights.scm b/runtime/queries/git-commit/highlights.scm
index 319d7656..bc84d037 100644
--- a/runtime/queries/git-commit/highlights.scm
+++ b/runtime/queries/git-commit/highlights.scm
@@ -1,18 +1,18 @@
+[(comment) (generated_comment) (scissor)] @comment
(subject) @markup.heading
-(path) @string.special.path
(branch) @string.special.symbol
-(commit) @constant
-(item) @markup.link.url
-(header) @tag
+(filepath) @string.special.path
+(arrow) @punctuation.delimiter
+(subject (subject_prefix) @function)
+(prefix (type) @keyword)
+(prefix (scope) @variable.parameter)
+(prefix [ "(" ")" ":" ] @punctuation.delimiter)
+(prefix "!" @punctuation.special)
+(trailer (token) @variable.other.member)
+(trailer (value) @string)
+(breaking_change (token) @special)
-(change kind: "new file" @diff.plus)
-(change kind: "deleted" @diff.minus)
-(change kind: "modified" @diff.delta)
-(change kind: "renamed" @diff.delta.moved)
-
-(trailer
- key: (trailer_key) @variable.other.member
- value: (trailer_value) @string)
-
-[":" "=" "->" (scissors)] @punctuation.delimiter
-(comment) @comment
+(change kind: (new)) @diff.plus
+(change kind: (deleted)) @diff.minus
+(change kind: (modified)) @diff.delta
+(change kind: [(renamed) (typechange)]) @diff.delta.moved
diff --git a/runtime/queries/git-commit/injections.scm b/runtime/queries/git-commit/injections.scm
index 79f7691a..823188e0 100644
--- a/runtime/queries/git-commit/injections.scm
+++ b/runtime/queries/git-commit/injections.scm
@@ -1,6 +1,4 @@
-(((scissors)
- (message) @injection.content)
- (#set! injection.include-children)
+((diff) @injection.content
(#set! injection.language "diff"))
((rebase_command) @injection.content