From bcf3808e9763bfe1bbf70f6053f890c80639d7c9 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Wed, 29 Dec 2021 09:31:23 -0600 Subject: Add tree-sitter-git-diff (#1373) * add submodule on tree-sitter-git-diff * add git-diff highlights * inject git-diff into git-commit * update tree-sitter-git-commit with fix for bad diff case * add git-diff to language support docs * include-children in diff injections This ensures that children nodes of $.message are included in the injection, such as $.user or issue/pr numbers. Without this change, diffs containing '#' or '@' characters can trip up the injection and be parsed separately. See https://github.com/helix-editor/helix/pull/1373#issuecomment-1001215629 * set diff language's scope as source.diff--- runtime/queries/git-commit/highlights.scm | 4 ---- runtime/queries/git-commit/injections.scm | 13 ++++--------- runtime/queries/git-diff/highlights.scm | 6 ++++++ 3 files changed, 10 insertions(+), 13 deletions(-) create mode 100644 runtime/queries/git-diff/highlights.scm (limited to 'runtime') 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 -- cgit v1.2.3-70-g09d2