aboutsummaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authorMichael Davis2021-12-29 15:31:23 +0000
committerGitHub2021-12-29 15:31:23 +0000
commitbcf3808e9763bfe1bbf70f6053f890c80639d7c9 (patch)
tree638a8c46ccdcd65de529b1f0a5c146fa7d355313 /runtime
parent49444f9c0569a070ffd3c82cee6146656a0ac63c (diff)
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
Diffstat (limited to 'runtime')
-rw-r--r--runtime/queries/git-commit/highlights.scm4
-rw-r--r--runtime/queries/git-commit/injections.scm13
-rw-r--r--runtime/queries/git-diff/highlights.scm6
3 files changed, 10 insertions, 13 deletions
diff --git a/runtime/queries/git-commit/highlights.scm b/runtime/queries/git-commit/highlights.scm
index a74bb381..ffcc31ae 100644
--- a/runtime/queries/git-commit/highlights.scm
+++ b/runtime/queries/git-commit/highlights.scm
@@ -13,7 +13,3 @@
[":" "->"] @punctuation.delimeter
(comment) @comment
-
-; once we have diff injections, @comment should become @none
-((comment (scissors))
- (message)+ @comment)
diff --git a/runtime/queries/git-commit/injections.scm b/runtime/queries/git-commit/injections.scm
index 2837a586..bd96f1de 100644
--- a/runtime/queries/git-commit/injections.scm
+++ b/runtime/queries/git-commit/injections.scm
@@ -1,12 +1,7 @@
-; once a diff grammar is available, we can inject diff highlighting into the
-; trailer after scissors (git commit --verbose)
-; see https://github.com/helix-editor/helix/pull/1338#issuecomment-1000013539
-;
-; ((comment (scissors))
-; (message) @injection.content
-; (#set! injection.language "diff"))
-
-; ---
+((comment (scissors))
+ (message) @injection.content
+ (#set! injection.include-children)
+ (#set! injection.language "diff"))
; once a rebase grammar is available, we can inject rebase highlighting into
; interactive rebase summary sections like so:
diff --git a/runtime/queries/git-diff/highlights.scm b/runtime/queries/git-diff/highlights.scm
new file mode 100644
index 00000000..1c1a8829
--- /dev/null
+++ b/runtime/queries/git-diff/highlights.scm
@@ -0,0 +1,6 @@
+[(addition) (new_file)] @diff.plus
+[(deletion) (old_file)] @diff.minus
+
+(commit) @constant
+(location) @attribute
+(command) @markup.bold