From 45fb4b6bac0307babf295ec4307647fd4820a427 Mon Sep 17 00:00:00 2001 From: Martin Chaine Date: Wed, 28 Dec 2016 20:18:31 +0100 Subject: [PATCH] allow to override filename + remove existing hooks --- rc/extra/editorconfig.kak | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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 }