Add tree-sitter-git-diff (#1373)
* add submodule on tree-sitter-git-diff
* add git-diff highlights
* inject git-diff into git-commit
* update tree-sitter-git-commit with fix for bad diff case
* add git-diff to language support docs
* include-children in diff injections
This ensures that children nodes of $.message are included in the
injection, such as $.user or issue/pr numbers. Without this change,
diffs containing '#' or '@' characters can trip up the injection and
be parsed separately.
See https://github.com/helix-editor/helix/pull/1373#issuecomment-1001215629
* set diff language's scope as source.diff
commitbcf3808e9763bfe1bbf70f6053f890c80639d7c9
authorMichael Davis <mcarsondavis@gmail.com>
dateWed 29 Dec 2021, 09:31 (5 years ago)
parent49444f9
.gitmodules+4
@@ -174,3 +174,7 @@
174174 path = helix-syntax/languages/tree-sitter-git-commit
175175 url = https://github.com/the-mikedavis/tree-sitter-git-commit.git
176176 shallow = true
177+[submodule "helix-syntax/languages/tree-sitter-git-diff"]
178+ path = helix-syntax/languages/tree-sitter-git-diff
179+ url = https://github.com/the-mikedavis/tree-sitter-git-diff.git
180+ shallow = true
book/src/generated/lang-support.md+1
@@ -12,6 +12,7 @@
1212| elixir | ✓ | | | `elixir-ls` |
1313| fish | ✓ | ✓ | ✓ | |
1414| git-commit | ✓ | | | |
15+| git-diff | ✓ | | | |
1516| glsl | ✓ | | ✓ | |
1617| go | ✓ | ✓ | ✓ | `gopls` |
1718| html | ✓ | | | |
helix-syntax/languages/tree-sitter-git-commit+1−1
Submodule changed.
helix-syntax/languages/tree-sitter-git-diffnew file+1
Submodule changed.
languages.toml+9
@@ -481,3 +481,12 @@ roots = []
481481file-types = ["COMMIT_EDITMSG"]
482482comment-token = "#"
483483indent = { tab-width = 2, unit = " " }
484+
485+[[language]]
486+name = "git-diff"
487+scope = "source.diff"
488+roots = []
489+file-types = ["diff"]
490+injection-regex = "diff"
491+comment-token = "#"
492+indent = { tab-width = 2, unit = " " }
runtime/queries/git-commit/highlights.scm−4
@@ -13,7 +13,3 @@
1313
1414[":" "->"] @punctuation.delimeter
1515(comment) @comment
16−
17−; once we have diff injections, @comment should become @none
18−((comment (scissors))
19− (message)+ @comment)
runtime/queries/git-commit/injections.scm+4−9
@@ -1,12 +1,7 @@
1−; once a diff grammar is available, we can inject diff highlighting into the
2−; trailer after scissors (git commit --verbose)
3−; see https://github.com/helix-editor/helix/pull/1338#issuecomment-1000013539
4−;
5−; ((comment (scissors))
6−; (message) @injection.content
7−; (#set! injection.language "diff"))
8−
9−; ---
1+((comment (scissors))
2+ (message) @injection.content
3+ (#set! injection.include-children)
4+ (#set! injection.language "diff"))
105
116; once a rebase grammar is available, we can inject rebase highlighting into
127; interactive rebase summary sections like so:
runtime/queries/git-diff/highlights.scmnew file+6
@@ -0,0 +1,6 @@
1+[(addition) (new_file)] @diff.plus
2+[(deletion) (old_file)] @diff.minus
3+
4+(commit) @constant
5+(location) @attribute
6+(command) @markup.bold