Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add tree-sitter-git-diff #1373

Merged
merged 7 commits into from
Dec 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions book/src/generated/lang-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
| elixir | ✓ | | | `elixir-ls` |
| fish | ✓ | ✓ | ✓ | |
| git-commit | ✓ | | | |
| git-diff | ✓ | | | |
| glsl | ✓ | | ✓ | |
| go | ✓ | ✓ | ✓ | `gopls` |
| html | ✓ | | | |
Expand Down
1 change: 1 addition & 0 deletions helix-syntax/languages/tree-sitter-git-diff
Submodule tree-sitter-git-diff added at c12e6e
9 changes: 9 additions & 0 deletions languages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = " " }
4 changes: 0 additions & 4 deletions runtime/queries/git-commit/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,3 @@

[":" "->"] @punctuation.delimeter
(comment) @comment

; once we have diff injections, @comment should become @none
((comment (scissors))
(message)+ @comment)
13 changes: 4 additions & 9 deletions runtime/queries/git-commit/injections.scm
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
6 changes: 6 additions & 0 deletions runtime/queries/git-diff/highlights.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[(addition) (new_file)] @diff.plus
[(deletion) (old_file)] @diff.minus

(commit) @constant
(location) @attribute
(command) @markup.bold