Skip to content

Commit

Permalink
update tree-sitter-git-rebase
Browse files Browse the repository at this point in the history
changes:

* the grammar has been completely rewritten in a way that removes
  some of the "jumpiness" of the highlights
    * when changing a command (for example from 'pick' to 'drop'),
      highlighting would treat parts of the commit hash as a command
  • Loading branch information
the-mikedavis committed Mar 11, 2022
1 parent 830585e commit 443df23
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 12 deletions.
2 changes: 1 addition & 1 deletion languages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,7 @@ indent = { tab-width = 2, unit = " " }

[[grammar]]
name = "git-rebase"
source = { git = "https://github.com/the-mikedavis/tree-sitter-git-rebase", rev = "332dc528f27044bc4427024dbb33e6941fc131f2" }
source = { git = "https://github.com/the-mikedavis/tree-sitter-git-rebase", rev = "8ea81bbf4c92f95b33cf3aeaa9bd348f07d4b6ab" }

[[language]]
name = "regex"
Expand Down
41 changes: 33 additions & 8 deletions runtime/queries/git-rebase/highlights.scm
Original file line number Diff line number Diff line change
@@ -1,11 +1,36 @@
(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)
; a rough translation:
; * constant.builtin - git hash
; * constant - a git label
; * keyword - command that acts on commits commits
; * function - command that acts only on labels
; * comment - discarded commentary on a command, has no effect on the rebase
; * string - text used in the rebase operation
; * operator - a 'switch' (used in fixup and merge), either -c or -C at time of writing

(((command) @keyword
(label) @constant.builtin
(message)? @comment)
(#match? @keyword "^(p|pick|r|reword|e|edit|s|squash|d|drop)$"))

(((command) @function
(label) @constant
(message)? @comment)
(#match? @function "^(l|label|t|reset)$"))

((command) @keyword
(#match? @keyword "^(x|exec|b|break)$"))

(((command) @function.special
(label) @constant.builtin
(message)? @comment)
(#match? @function.special "^(f|fixup)$"))

(((command) @keyword
(label) @constant.builtin
(label) @constant
(message) @string)
(#match? @keyword "^(m|merge)$"))

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

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

0 comments on commit 443df23

Please sign in to comment.