diff --git a/rc/core/kakrc.kak b/rc/core/kakrc.kak index 92d7f68c..780e4f5b 100644 --- a/rc/core/kakrc.kak +++ b/rc/core/kakrc.kak @@ -1,7 +1,16 @@ +# http://kakoune.org +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +# Detection +# ‾‾‾‾‾‾‾‾‾ + hook global BufCreate (.*/)?(kakrc|.*.kak) %{ set buffer filetype kak } +# Highlighters & Completion +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + addhl -group / regions -default code kakrc \ comment (^|\h)\K\# $ '' \ double_string %{(^|\h)"} %{(? K } + # cleanup trailing whitespaces from previous line + try %{ exec -draft k s \h+$ d } + # copy '#' comment prefix and following white spaces + try %{ exec -draft k x s ^\h*#\h* y jgh P } + # indent after line ending with %[[:punct:]] + try %{ exec -draft k \%[[:punct:]]$ j } + } +} + +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + hook -group kak-highlight global WinSetOption filetype=kak %{ addhl ref kakrc } + +hook global WinSetOption filetype=kak %{ + hook window InsertChar \n -group kak-indent kak-indent-on-new-line + # cleanup trailing whitespaces on current line insert end + hook window InsertEnd .* -group kak-indent %{ try %{ exec -draft \; s ^\h+$ d } } +} + hook -group kak-highlight global WinSetOption filetype=(?!kak).* %{ rmhl kakrc } +hook global WinSetOption filetype=(?!kak).* %{ rmhooks window kak-indent }