From b84abd57de39facb8159b6a0f6f6390268ff54d0 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Mon, 24 Jan 2022 17:09:44 +0100 Subject: [PATCH] rc diff: make it a module We want to move git-diff-goto-source from rc/tools/git.kak to rc/filetype/diff.kak (or should we could create rc/tools/diff.kak?). Either way, create the diff module so we can formalize this dependency. Currently this module only provides highlighters, so require it wherever we reference them. Keep the diff-select-{file,hunk} commands outside the module because people might already use them in git buffers. --- rc/filetype/diff.kak | 8 ++++++++ rc/filetype/git.kak | 1 + rc/tools/git.kak | 2 ++ 3 files changed, 11 insertions(+) diff --git a/rc/filetype/diff.kak b/rc/filetype/diff.kak index d904ce5a..c0cb4523 100644 --- a/rc/filetype/diff.kak +++ b/rc/filetype/diff.kak @@ -2,6 +2,12 @@ hook global BufCreate .*\.(diff|patch) %{ set-option buffer filetype diff } +hook global WinSetOption filetype=diff %{ + require-module diff +} + +provide-module diff %§ + add-highlighter shared/diff group add-highlighter shared/diff/ regex "^\+[^\n]*\n" 0:green,default add-highlighter shared/diff/ regex "^-[^\n]*\n" 0:red,default @@ -12,6 +18,8 @@ hook -group diff-highlight global WinSetOption filetype=diff %{ hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/diff } } +§ + define-command \ -docstring %{diff-select-file: Select surrounding patch file} \ -params 0 \ diff --git a/rc/filetype/git.kak b/rc/filetype/git.kak index aa53de2d..52304582 100644 --- a/rc/filetype/git.kak +++ b/rc/filetype/git.kak @@ -35,6 +35,7 @@ hook -group git-rebase-highlight global WinSetOption filetype=git-rebase %{ provide-module git-commit %{ +require-module diff add-highlighter shared/git-commit regions add-highlighter shared/git-commit/diff region '^diff --git' '^(?=diff --git)' ref diff # highlight potential diffs from the -v option add-highlighter shared/git-commit/comments region ^# $ group diff --git a/rc/tools/git.kak b/rc/tools/git.kak index 0cd505d0..c79b620f 100644 --- a/rc/tools/git.kak +++ b/rc/tools/git.kak @@ -2,6 +2,7 @@ declare-option -docstring "name of the client in which documentation is to be di str docsclient hook -group git-log-highlight global WinSetOption filetype=git-log %{ + require-module diff add-highlighter window/git-log group add-highlighter window/git-log/ regex '^([*|\\ /_.-])*' 0:keyword add-highlighter window/git-log/ regex '^( ?[*|\\ /_.-])*\h{,3}(commit )?(\b[0-9a-f]{4,40}\b)' 2:keyword 3:comment @@ -12,6 +13,7 @@ hook -group git-log-highlight global WinSetOption filetype=git-log %{ } hook -group git-status-highlight global WinSetOption filetype=git-status %{ + require-module diff add-highlighter window/git-status group add-highlighter window/git-status/ regex '^## ' 0:comment add-highlighter window/git-status/ regex '^## (\S*[^\s\.@])' 1:green