dotfiles/.config/kak/autoload/hop.kak

79 lines
3 KiB
Text

# https://git.sr.ht/~hadronized/hop.kak
# evaluate-commands %sh{ hop-kak --init }
provide-module hop-kak %~
declare-option range-specs hop_ranges
set-face global hop_label_head %exp{%opt{background},%opt{orange_golden}+Fbua}
set-face global hop_label_tail %exp{%opt{background},%opt{orange_golden}+Fbua}
# needed so the cursor face doesn't override what hop sets
# but only temporary because otherwise we want cursor face to
# override others
define-command -hidden hop-set-cursor %{
set-face window PrimaryCursorNormal "%opt{background},%opt{orange_blaze}+b"
set-face window SecondaryCursorNormal "%opt{background},%opt{orange_muted}"
set-face window PrimaryCursorInsert "%opt{background},%opt{g_3}+b"
set-face window SecondaryCursorInsert "%opt{background},%opt{g_7}"
set-face window PrimaryCursorNormalEol "%opt{background},%opt{orange_smolder}+b"
set-face window SecondaryCursorNormalEol "%opt{background},%opt{golden_muted}"
set-face window PrimaryCursorInsertEol "%opt{background},%opt{g_1}+b"
set-face window SecondaryCursorInsertEol "%opt{background},%opt{g_5}"
set-face window PrimarySelection ",%opt{brown_dark}"
set-face window SecondarySelection ",%opt{brown_darker}"
}
define-command -hidden hop-clear-cursor %{
set-face window PrimaryCursorNormal "%opt{background},%opt{orange_blaze}+gfb"
set-face window SecondaryCursorNormal "%opt{background},%opt{orange_muted}+gf"
set-face window PrimaryCursorInsert "%opt{background},%opt{g_3}+gfb"
set-face window SecondaryCursorInsert "%opt{background},%opt{g_7}+gf"
set-face window PrimaryCursorNormalEol "%opt{background},%opt{orange_smolder}+gfb"
set-face window SecondaryCursorNormalEol "%opt{background},%opt{golden_muted}+gf"
set-face window PrimaryCursorInsertEol "%opt{background},%opt{g_1}+gfb"
set-face window SecondaryCursorInsertEol "%opt{background},%opt{g_5}+gf"
set-face window PrimarySelection ",%opt{brown_dark}+g"
set-face window SecondarySelection ",%opt{brown_darker}+g"
}
declare-option str hop_kak_keyset 'tnserigmaodhcxplfuwyqz'
# select visible buffer
map global normal <a-%> ':execute-keys gtGbx<ret>'
define-command hop-kak %{
evaluate-commands -no-hooks -- %sh{
hop-kak --keyset "$kak_opt_hop_kak_keyset" --sels "$kak_selections_desc"
}
}
define-command -override hop-kak-words %{
hop-set-cursor
eval "ui-scrolloff-disable"
try %{ ui-wrap-disable }
map window normal <esc> ': trigger-user-hook donehop<ret><esc>'
map window normal , ': trigger-user-hook donehop<ret>,'
hook -once window User donehop %{
hop-clear-cursor
eval "ui-scrolloff-enable"
try %{ ui-wrap-enable }
unmap window normal <esc>
unmap window normal ,
}
execute-keys 'gtGbxs\w+<ret>: hop-kak<ret>'
}
declare-user-mode hop
map -docstring %{
Filter visible words
} global hop w ': hop-kak-words<ret>'
map -docstring %{
Filter selection
} global hop s ': hop-kak<ret>'
map -docstring %{
Hop mode
} global user h ': enter-user-mode hop<ret>'
~