aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitmodules4
-rw-r--r--book/src/generated/lang-support.md1
m---------helix-syntax/languages/tree-sitter-git-commit0
m---------helix-syntax/languages/tree-sitter-git-diff0
-rw-r--r--languages.toml9
-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
8 files changed, 24 insertions, 13 deletions
diff --git a/.gitmodules b/.gitmodules
index d5bd61c9..422671b4 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -174,3 +174,7 @@
path = helix-syntax/languages/tree-sitter-git-commit
url = https://github.com/the-mikedavis/tree-sitter-git-commit.git
shallow = true
+[submodule "helix-syntax/languages/tree-sitter-git-diff"]
+ path = helix-syntax/languages/tree-sitter-git-diff
+ url = https://github.com/the-mikedavis/tree-sitter-git-diff.git
+ shallow = true
diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md
index 5d172751..91575c62 100644
--- a/book/src/generated/lang-support.md
+++ b/book/src/generated/lang-support.md
@@ -12,6 +12,7 @@
| elixir | ✓ | | | `elixir-ls` |
| fish | ✓ | ✓ | ✓ | |
| git-commit | ✓ | | | |
+| git-diff | ✓ | | | |
| glsl | ✓ | | ✓ | |
| go | ✓ | ✓ | ✓ | `gopls` |
| html | ✓ | | | |
diff --git a/helix-syntax/languages/tree-sitter-git-commit b/helix-syntax/languages/tree-sitter-git-commit
-Subproject 5cd4776c86c82d9d6afdc8c73a47a08057aef61
+Subproject 066e395e1107df17183cf3ae4230f1a1406cc97
diff --git a/helix-syntax/languages/tree-sitter-git-diff b/helix-syntax/languages/tree-sitter-git-diff
new file mode 160000
+Subproject c12e6ecb54485f764250556ffd7ccb18f8e2942
diff --git a/languages.toml b/languages.toml
index 616ef234..c3ae9f62 100644
--- a/languages.toml
+++ b/languages.toml
@@ -481,3 +481,12 @@ roots = []
file-types = ["COMMIT_EDITMSG"]
comment-token = "#"
indent = { tab-width = 2, unit = " " }
+
+[[language]]
+name = "git-diff"
+scope = "source.diff"
+roots = []
+file-types = ["diff"]
+injection-regex = "diff"
+comment-token = "#"
+indent = { tab-width = 2, unit = " " }
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