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 } }