diff --git a/.config/kak/autoload/filetype/kdl.kak b/.config/kak/autoload/filetype/kdl.kak index b898d624..140df29d 100644 --- a/.config/kak/autoload/filetype/kdl.kak +++ b/.config/kak/autoload/filetype/kdl.kak @@ -2,5 +2,23 @@ hook global BufCreate .*[.](kdl) %{ set-option buffer filetype kdl set-option buffer comment_line "//" set-option buffer comment_block_begin "/*" - set-option buffer comment_block_ "*/" + set-option buffer comment_block_end "*/" + set-option window formatcmd "kdlfmt format -" +} + +hook global WinSetOption filetype=kdl %{ + require-module kdl + + hook window InsertChar \n -group kdl-indent %{ kdl-indent-newline } + hook window InsertChar \} -group kdl-indent %{ kdl-indent-closing-brace } + + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window kdl-indent } + + hook -group kdl-auto-format window BufWritePre .* format + hook -once -always WinSetOption filetype=.* %sh{ + if [ "$kak_opt_filetype" != "kdl" ]; then + echo "unset-option window formatcmd" + echo "remove-hooks window kdl-auto-format" + fi + } }