# http://kakoune.org # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate (.*/)?(kakrc|.*.kak) %{ set buffer filetype kak } # Highlighters & Completion # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter -group / regions -default code kakrc \ comment (^|\h)\K\# $ '' \ double_string %{(^|\h)"} %{(? y jgh P } # preserve previous line indent try %{ exec -draft K } # cleanup trailing whitespaces from previous line try %{ exec -draft k s \h+$ d } # indent after line ending with %[[:punct:]] try %{ exec -draft k \%[[:punct:]]$ j } } } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook -group kak-highlight global WinSetOption filetype=kak %{ add-highlighter 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).* %{ remove-highlighter kakrc } hook global WinSetOption filetype=(?!kak).* %{ remove-hooks window kak-indent }