diff --git a/rc/extra/editorconfig.kak b/rc/extra/editorconfig.kak index 4e492597..6cc79410 100644 --- a/rc/extra/editorconfig.kak +++ b/rc/extra/editorconfig.kak @@ -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{ - command -v editorconfig >/dev/null 2>&1 || { echo 'echo -color Error The editorconfig tool could not be found'; exit 1; } - editorconfig "${kak_buffile}" | awk -F= -- ' + command -v editorconfig >/dev/null 2>&1 || { echo 'echo -color Error editorconfig could not be found'; exit 1; } + editorconfig "${1:-$kak_buffile}" | awk -F= -- ' /indent_style=/ { indent_style = $2 } /indent_size=/ { indent_size = $2 == "tab" ? 4 : $2 } /tab_width=/ { tab_width = $2 }