From 3c3a4ec98559f0341e88f20e94b4de3e54be8626 Mon Sep 17 00:00:00 2001 From: SeerLite Date: Fri, 2 Oct 2020 19:32:09 -0300 Subject: [PATCH 2/2] lua.kak: Correct -trim-indent hook and fix indent --- rc/filetype/lua.kak | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rc/filetype/lua.kak b/rc/filetype/lua.kak index 9328bc02..82dc51cc 100644 --- a/rc/filetype/lua.kak +++ b/rc/filetype/lua.kak @@ -14,7 +14,7 @@ hook global BufCreate .*[.](lua) %{ hook global WinSetOption filetype=lua %{ require-module lua - hook window ModeChange pop:insert:.* -group lua-indent lua-trim-indent + hook window ModeChange pop:insert:.* -group lua-trim-indent lua-trim-indent hook window InsertChar .* -group lua-indent lua-indent-on-char hook window InsertChar \n -group lua-indent lua-indent-on-new-line hook window InsertChar \n -group lua-insert lua-insert-on-new-line @@ -100,10 +100,10 @@ define-command -hidden lua-indent-on-char %{ define-command -hidden lua-indent-on-new-line %{ evaluate-commands -no-hooks -draft -itersel %{ + # remove trailing white spaces from previous line + try %{ execute-keys -draft k : lua-trim-indent } # preserve previous non-empty line indent try %{ execute-keys -draft ^[^\n]+$s\A|.\z) } - # remove trailing white spaces from previous line - try %{ execute-keys -draft ks\h+$d } # indent after start structure try %{ execute-keys -draft ^[^\n]*\w+[^\n]*$^\h*(else|elseif|for|function|if|while)\b } }