From 443df231951c5fe7fefd77d26945e532ed343e65 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Sun, 6 Mar 2022 14:47:50 -0600 Subject: [PATCH] update tree-sitter-git-rebase 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 --- languages.toml | 2 +- runtime/queries/git-rebase/highlights.scm | 41 ++++++++++++++++++----- runtime/queries/git-rebase/injections.scm | 6 ++-- 3 files changed, 37 insertions(+), 12 deletions(-) diff --git a/languages.toml b/languages.toml index 6287123e42a6a..c0a1f52c72c45 100644 --- a/languages.toml +++ b/languages.toml @@ -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" diff --git a/runtime/queries/git-rebase/highlights.scm b/runtime/queries/git-rebase/highlights.scm index 4f007037d4b7c..23ed7ef96a077 100644 --- a/runtime/queries/git-rebase/highlights.scm +++ b/runtime/queries/git-rebase/highlights.scm @@ -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 diff --git a/runtime/queries/git-rebase/injections.scm b/runtime/queries/git-rebase/injections.scm index 070129b63d887..e3b4aec01b81d 100644 --- a/runtime/queries/git-rebase/injections.scm +++ b/runtime/queries/git-rebase/injections.scm @@ -1,4 +1,4 @@ -((operation - operator: ["x" "exec"] - (command) @injection.content) +(((command) @__command__ + (message) @injection.content) + (#match? @__command__ "^(x|exec)$") (#set! injection.language "bash"))