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.
pull/13848/head
Michael Davis 2025-06-27 10:39:38 -04:00
parent a9d51ef258
commit 44293dfd22
No known key found for this signature in database
3 changed files with 20 additions and 21 deletions

View File

@ -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"

View File

@ -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

View File

@ -1,6 +1,4 @@
(((scissors)
(message) @injection.content)
(#set! injection.include-children)
((diff) @injection.content
(#set! injection.language "diff"))
((rebase_command) @injection.content