From ffc69544db0c883ff1992d7f2825233e6bc7e472 Mon Sep 17 00:00:00 2001 From: Hugo Musso Gualandi Date: Wed, 8 Sep 2021 19:17:17 -0300 Subject: [PATCH] lua.kak: use %[] instead of %{} We will want to use unbalanced "{" and "}" in some of the rules. To support that, let's use "%[]" instead. --- rc/filetype/lua.kak | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/rc/filetype/lua.kak b/rc/filetype/lua.kak index 40d36281..cb0775b5 100644 --- a/rc/filetype/lua.kak +++ b/rc/filetype/lua.kak @@ -33,7 +33,7 @@ hook -group lua-highlight global WinSetOption filetype=lua %{ } -provide-module lua %[ +provide-module lua %§ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ @@ -85,42 +85,42 @@ define-command lua-alternative-file -docstring 'Jump to the alternate file (impl printf %s\\n "edit $altfile" }} -define-command -hidden lua-trim-indent %{ +define-command -hidden lua-trim-indent %[ # remove trailing whitespaces - try %{ execute-keys -draft -itersel s \h+$ d } -} + try %[ execute-keys -draft -itersel s \h+$ d ] +] -define-command -hidden lua-indent-on-char %{ - evaluate-commands -no-hooks -draft -itersel %{ +define-command -hidden lua-indent-on-char %[ + evaluate-commands -no-hooks -draft -itersel %[ # align middle and end structures to start and indent when necessary, elseif is already covered by else - try %{ execute-keys -draft ^\h*(else)$^\h*(if)s\A|.\z) } - try %{ execute-keys -draft ^\h*(end)$^\h*(for|function|if|while)s\A|.\z) } - } -} + try %[ execute-keys -draft ^\h*(else)$^\h*(if)s\A|.\z) ] + try %[ execute-keys -draft ^\h*(end)$^\h*(for|function|if|while)s\A|.\z) ] + ] +] -define-command -hidden lua-indent-on-new-line %{ - evaluate-commands -no-hooks -draft -itersel %{ +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 } + try %[ execute-keys -draft k : lua-trim-indent ] # preserve previous non-empty line indent - try %{ execute-keys -draft ^[^\n]+$s\A|.\z) } + try %[ execute-keys -draft ^[^\n]+$s\A|.\z) ] # indent after start structure - try %{ execute-keys -draft ^[^\n]*\w+[^\n]*$\b(else|elseif|for|function|if|while)\b\bend\b } - } -} + try %[ execute-keys -draft ^[^\n]*\w+[^\n]*$\b(else|elseif|for|function|if|while)\b\bend\b ] + ] +] define-command -hidden lua-insert-on-new-line %[ evaluate-commands -no-hooks -draft -itersel %[ # copy -- comment prefix and following white spaces - try %{ execute-keys -draft ks^\h*\K--\h* y gh j P } + try %[ execute-keys -draft ks^\h*\K--\h* y gh j P ] # wisely add end structure evaluate-commands -save-regs x %[ - try %{ execute-keys -draft ks^\h+"xy } catch %{ reg x '' } # Save previous line indent in register x - try %[ execute-keys -draft k ^x\b[^\n]*(for|function|if|while)\bend\b J}iJ ^x(else|end|elseif)$ # Validate previous line and that it is not closed yet + try %[ execute-keys -draft ks^\h+"xy ] catch %[ reg x '' ] # Save previous line indent in register x + try %[ execute-keys -draft k ^x\b[^\n]*(do|for|function|if|while)\bend\b J}iJ ^x(else|end|elseif)$ # Validate previous line and that it is not closed yet execute-keys -draft oxend # auto insert end execute-keys -draft k\(function\bjjA) ] # auto insert ) for anonymous function ] ] ] -] +§