From dbfed1306f3a7a93cd0b65dca5476ca41dd9419d Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sun, 23 Sep 2018 18:00:51 +1000 Subject: [PATCH] git.kak: Refactor commit message highlighting Use regions to avoid highlighting the commit message as a diff. The new method will fail if one line of the commit message matches '^diff --git' but that is fairly unlikely. Fixes #2371 --- rc/base/git.kak | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/rc/base/git.kak b/rc/base/git.kak index 3ae831e8..1e5b4297 100644 --- a/rc/base/git.kak +++ b/rc/base/git.kak @@ -7,10 +7,11 @@ hook global BufCreate .*(\.gitconfig|git/config) %{ } hook -group git-commit-highlight global WinSetOption filetype=git-commit %{ - add-highlighter window/git-commit-highlight group - add-highlighter window/git-commit-highlight/ regex "^\h*#[^\n]*\n" 0:cyan,default - add-highlighter window/git-commit-highlight/ regex "\b(?:(modified)|(deleted)|(new file)|(renamed|copied)):([^\n]*)\n" 1:yellow 2:red 3:green 4:blue 5:magenta - add-highlighter window/git-commit-highlight/ ref diff # highlight potential diffs from the -v option + add-highlighter window/git-commit-highlight regions + add-highlighter window/git-commit-highlight/diff region '^diff --git' '^(?=diff --git)' ref diff # highlight potential diffs from the -v option + add-highlighter window/git-commit-highlight/comments region '^\h*#' '$' group + add-highlighter window/git-commit-highlight/comments/ fill cyan,default + add-highlighter window/git-commit-highlight/comments/ regex "\b(?:(modified)|(deleted)|(new file)|(renamed|copied)):([^\n]*)$" 1:yellow 2:red 3:green 4:blue 5:magenta } hook -group git-commit-highlight global WinSetOption filetype=(?!git-commit).* %{ remove-highlighter window/git-commit-highlight }