Skip to content

Commit

Permalink
add tree-sitter-git-rebase (#1402)
Browse files Browse the repository at this point in the history
* add submodule on tree-sitter-rebase, add to languages

* add basic highlights query

* inject bash in execute statements

* update tree-sitter-rebase

* tree-sitter-rebase->tree-sitter-git-rebase

* get injection working with tree-sitter-git-commit

* set scope under source.gitrebase

* unset include-children on commit message injections

* Revert "unset include-children on commit message injections"

This reverts commit 2ecee15.

* fix generated language docs

* use rebase_command scopes from tree-sitter-git-commit
  • Loading branch information
the-mikedavis authored Dec 30, 2021
1 parent a066f59 commit 8fda87a
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 6 deletions.
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,7 @@
path = helix-syntax/languages/tree-sitter-git-diff
url = https://github.com/the-mikedavis/tree-sitter-git-diff.git
shallow = true
[submodule "helix-syntax/languages/tree-sitter-git-rebase"]
path = helix-syntax/languages/tree-sitter-git-rebase
url = https://github.com/the-mikedavis/tree-sitter-git-rebase.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 @@ -13,6 +13,7 @@
| fish |||| |
| git-commit || | | |
| git-diff || | | |
| git-rebase || | | |
| glsl || || |
| go |||| `gopls` |
| html || | | |
Expand Down
1 change: 1 addition & 0 deletions helix-syntax/languages/tree-sitter-git-rebase
Submodule tree-sitter-git-rebase added at 332dc5
9 changes: 9 additions & 0 deletions languages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -490,3 +490,12 @@ file-types = ["diff"]
injection-regex = "diff"
comment-token = "#"
indent = { tab-width = 2, unit = " " }

[[language]]
name = "git-rebase"
scope = "source.gitrebase"
roots = []
file-types = ["git-rebase-todo"]
injection-regex = "git-rebase"
comment-token = "#"
indent = { tab-width = 2, unit = " " }
1 change: 0 additions & 1 deletion runtime/queries/git-commit/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
(commit) @constant
(item) @markup.link.url
(header) @tag
(rebase_command) @markup.raw

(change kind: "new file" @diff.plus)
(change kind: "deleted" @diff.minus)
Expand Down
8 changes: 3 additions & 5 deletions runtime/queries/git-commit/injections.scm
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
(#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:
;
; ((rebase_command) @injection.content
; (#set! injection.language "git-rebase"))
((rebase_command) @injection.content
(#set! injection.include-children)
(#set! injection.language "git-rebase"))
11 changes: 11 additions & 0 deletions runtime/queries/git-rebase/highlights.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
(operation operator: ["p" "pick" "r" "reword" "e" "edit" "s" "squash" "m" "merge" "d" "drop" "b" "break" "x" "exec"] @keyword)
(operation operator: ["l" "label" "t" "reset"] @function)
(operation operator: ["f" "fixup"] @function.special)

(option) @operator
(label) @string.special.symbol
(commit) @constant
"#" @punctuation.delimiter
(comment) @comment

(ERROR) @error
4 changes: 4 additions & 0 deletions runtime/queries/git-rebase/injections.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
((operation
operator: ["x" "exec"]
(command) @injection.content)
(#set! injection.language "bash"))

0 comments on commit 8fda87a

Please sign in to comment.