Take the formatting function out of the hook

This commit is contained in:
Frank LENORMAND 2015-09-06 18:05:33 +03:00
parent b1598f9542
commit 88775a91b3

View File

@ -71,11 +71,13 @@ def -hidden _dlang-indent-on-closing-curly-brace %[
]
decl str dlang_dfmt_options ""
def dlang-enable-dfmt -docstring "Format the code using the dfmt utility upon saving" %{
hook buffer -group dlang-formatter BufWritePre .* %{
def dlang-format-dfmt -docstring "Format the code using the dfmt utility" %{
%sh{
readonly x=$((kak_cursor_column - 1))
readonly y="${kak_cursor_line}"
echo "exec -draft %{%|dfmt<space>${kak_opt_dlang_dfmt_options// /<space>}<ret>}"
}
echo "exec gg ${y}g ${x}l"
}
}
@ -94,10 +96,15 @@ hook global WinSetOption filetype=dlang %{
hook window InsertChar \n -group dlang-indent _dlang-indent-on-new-line
hook window InsertChar \{ -group dlang-indent _dlang-indent-on-opening-curly-brace
hook window InsertChar \} -group dlang-indent _dlang-indent-on-closing-curly-brace
alias global format-code dlang-format-dfmt
}
hook global WinSetOption filetype=(?!dlang).* %{
rmhl dlang
rmhooks window dlang-hooks
rmhooks window dlang-indent
unalias global format-code
}