allow to override filename + remove existing hooks

This commit is contained in:
Martin Chaine 2016-12-28 20:18:31 +01:00
parent 292d9c9f01
commit 45fb4b6bac

View File

@ -18,10 +18,11 @@ def -hidden _editorconfig-bufwritepre-hook %{
} } } }
} }
def editorconfig-load -docstring "Set indentation options and whitespace behavior according to editorconfig" %{ def editorconfig-load -params ..1 -docstring "editorconfig-load [file]: set formatting behavior according to editorconfig" %{
remove-hooks buffer editorconfig-hooks
%sh{ %sh{
command -v editorconfig >/dev/null 2>&1 || { echo 'echo -color Error The editorconfig tool could not be found'; exit 1; } command -v editorconfig >/dev/null 2>&1 || { echo 'echo -color Error editorconfig could not be found'; exit 1; }
editorconfig "${kak_buffile}" | awk -F= -- ' editorconfig "${1:-$kak_buffile}" | awk -F= -- '
/indent_style=/ { indent_style = $2 } /indent_style=/ { indent_style = $2 }
/indent_size=/ { indent_size = $2 == "tab" ? 4 : $2 } /indent_size=/ { indent_size = $2 == "tab" ? 4 : $2 }
/tab_width=/ { tab_width = $2 } /tab_width=/ { tab_width = $2 }