2012-07-31 14:22:57 +02:00
|
|
|
hook global BufCreate .*\.(diff|patch) %{
|
2017-11-03 08:34:41 +01:00
|
|
|
set-option buffer filetype diff
|
2012-07-31 14:22:57 +02:00
|
|
|
}
|
2012-06-27 14:29:12 +02:00
|
|
|
|
2018-06-28 13:08:58 +02:00
|
|
|
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
|
|
|
|
add-highlighter shared/diff/ regex "^@@[^\n]*@@" 0:cyan,default
|
2012-06-27 14:29:12 +02:00
|
|
|
|
2018-11-28 10:39:07 +01:00
|
|
|
hook -group diff-highlight global WinSetOption filetype=diff %{
|
|
|
|
add-highlighter window/diff ref diff
|
2018-12-11 00:11:35 +01:00
|
|
|
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/diff }
|
2018-11-28 10:39:07 +01:00
|
|
|
}
|
2020-03-22 21:52:40 +01:00
|
|
|
|
|
|
|
define-command \
|
|
|
|
-docstring %{diff-select-file: Select surrounding patch file} \
|
|
|
|
-params 0 \
|
|
|
|
diff-select-file %{
|
|
|
|
evaluate-commands -itersel -save-regs 'ose/' %{
|
|
|
|
try %{
|
|
|
|
execute-keys '"oZgl<a-?>^diff <ret>;"sZ' 'Ge"eZ'
|
|
|
|
try %{ execute-keys '"sz?\n(?=diff )<ret>"e<a-Z><lt>' }
|
|
|
|
execute-keys '"ez'
|
|
|
|
} catch %{
|
|
|
|
execute-keys '"oz'
|
|
|
|
fail 'Not in a diff file'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
define-command \
|
|
|
|
-docstring %{diff-select-hunk: Select surrounding patch hunk} \
|
|
|
|
-params 0 \
|
|
|
|
diff-select-hunk %{
|
|
|
|
evaluate-commands -itersel -save-regs 'ose/' %{
|
|
|
|
try %{
|
|
|
|
execute-keys '"oZgl<a-?>^@@ <ret>;"sZ' 'Ge"eZ'
|
|
|
|
try %{ execute-keys '"sz?\n(?=diff )<ret>"e<a-Z><lt>' }
|
|
|
|
try %{ execute-keys '"sz?\n(?=@@ )<ret>"e<a-Z><lt>' }
|
|
|
|
execute-keys '"ez'
|
|
|
|
} catch %{
|
|
|
|
execute-keys '"oz'
|
|
|
|
fail 'Not in a diff hunk'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|