From d6bde05d27d8f969f20e5509e85bc71c4f2f5fe2 Mon Sep 17 00:00:00 2001 From: Martin Chaine Date: Sun, 1 Jan 2017 19:19:40 +0100 Subject: [PATCH] don't handle trailing newline option kakoune handles files as a list of lines with a newline ending --- rc/extra/editorconfig.kak | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/rc/extra/editorconfig.kak b/rc/extra/editorconfig.kak index 6cc79410..a6f43461 100644 --- a/rc/extra/editorconfig.kak +++ b/rc/extra/editorconfig.kak @@ -2,21 +2,6 @@ # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ decl -hidden bool editorconfig_trim_trailing_whitespace false -decl -hidden int editorconfig_insert_final_newline 0 - -def -hidden _editorconfig-bufwritepre-hook %{ - hook buffer BufWritePre %val{buffile} -group editorconfig-hooks %{ %sh{ - if [ ${kak_opt_editorconfig_trim_trailing_whitespace} = "true" ]; then - printf %s\\n "try %{ exec -draft %{ %s\h+$d } }" - fi - if [ ${kak_opt_editorconfig_insert_final_newline} -gt 0 ]; then - printf %s\\n "try %{ exec -draft %{ %s\v+\Zd } }" - fi - if [ ${kak_opt_editorconfig_insert_final_newline} -gt 1 ]; then - printf %s\\n "try %{ exec -draft %{ geo } }" - fi - } } -} def editorconfig-load -params ..1 -docstring "editorconfig-load [file]: set formatting behavior according to editorconfig" %{ remove-hooks buffer editorconfig-hooks @@ -29,7 +14,6 @@ def editorconfig-load -params ..1 -docstring "editorconfig-load [file]: set form /end_of_line=/ { end_of_line = $2 } /charset=/ { charset = $2 } /trim_trailing_whitespace/ { trim_trailing_whitespace = $2 } - /insert_final_newline/ { insert_final_newline = $2 } END { if (indent_style == "tab") { @@ -52,11 +36,12 @@ def editorconfig-load -params ..1 -docstring "editorconfig-load [file]: set form if (trim_trailing_whitespace == "true") { print "set buffer editorconfig_trim_trailing_whitespace true" } - if (insert_final_newline) { - print "set buffer editorconfig_insert_final_newline " (insert_final_newline == "true" ? 2 : 1) - } } ' } - _editorconfig-bufwritepre-hook + hook buffer BufWritePre %val{buffile} -group editorconfig-hooks %{ %sh{ + if [ ${kak_opt_editorconfig_trim_trailing_whitespace} = "true" ]; then + printf %s\\n "try %{ exec -draft %{ %s\h+$d } }" + fi + } } }