rc diff: evaluate diff-highlight hook before loading module

A recent commit wrapped diff.kak into a module. The module includes the
hook that adds diff highlighting to filetype=diff buffers.  This means
that the hook is only loaded after opening the first diff buffer in a
Kakoune session, so it only actually fires for the second diff buffer.
Fix this by moving the hook out of the module.

Fixes #4525
This commit is contained in:
Johannes Altmanninger 2022-02-01 20:09:48 +01:00 committed by Maxime Coste
parent 4bd34caf4f
commit 0b29fcf32a

View File

@ -7,6 +7,11 @@ hook global WinSetOption filetype=diff %{
require-module diff
}
hook -group diff-highlight global WinSetOption filetype=diff %{
add-highlighter window/diff ref diff
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/diff }
}
provide-module diff %§
add-highlighter shared/diff group
@ -14,11 +19,6 @@ add-highlighter shared/diff/ regex "^\+[^\n]*\n" 0:green,default
add-highlighter shared/diff/ regex "^-[^\n]*\n" 0:red,default
add-highlighter shared/diff/ regex "^@@[^\n]*@@" 0:cyan,default
hook -group diff-highlight global WinSetOption filetype=diff %{
add-highlighter window/diff ref diff
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/diff }
}
define-command diff-jump \
-docstring %{diff-jump [<switches>] [<directory>]: edit the diff's source file at the cursor position.
Paths are resolved relative to <directory>, or the current working directory if unspecified.