Reorder definition of 3 indent/insert commands

This commit is contained in:
John Isom 2020-08-01 11:32:16 -06:00
parent 0d4dfbc349
commit c36583524c

View File

@ -186,6 +186,19 @@ define-command -hidden crystal-trim-indent %{
}
}
define-command -hidden crystal-indent-on-char %{
evaluate-commands -no-hooks -draft -itersel %{
# align 'else/elsif' to 'if'
try %{ execute-keys -draft <a-x> <a-k> ^\h*(?:else|elsif)$ <ret> <a-a>i <a-semicolon> <a-?> ^\h*(?:if) <ret> <a-S> 1<a-&> }
# align 'when' to 'case'
try %{ execute-keys -draft <a-x> <a-k> ^\h*(?:when)$ <ret> <a-a>i <a-semicolon> <a-?> ^\h*(?:case) <ret> <a-S> 1<a-&> }
# align 'rescue' to 'begin/def'
try %{ execute-keys -draft <a-x> <a-k> ^\h*(?:rescue)$ <ret> <a-a>i <a-semicolon> <a-?> ^\h*(?:begin|def) <ret> <a-S> 1<a-&> }
# align 'end' to opening structure
try %{ execute-keys -draft <a-x> <a-k> ^\h*(?:end)$ <ret> <a-a>i <a-semicolon> <a-?> ^\h*(?:begin|case|class|def|for|if|module|unless|until|while) <ret> <a-S> 1<a-&> }
}
}
define-command -hidden crystal-indent-on-new-line %{
evaluate-commands -no-hooks -draft -itersel %{
# Copy previous line indent
@ -204,19 +217,6 @@ define-command -hidden crystal-insert-on-new-line %{
}
}
define-command -hidden crystal-indent-on-char %{
evaluate-commands -no-hooks -draft -itersel %{
# align 'else/elsif' to 'if'
try %{ execute-keys -draft <a-x> <a-k> ^\h*(?:else|elsif)$ <ret> <a-a>i <a-semicolon> <a-?> ^\h*(?:if) <ret> <a-S> 1<a-&> }
# align 'when' to 'case'
try %{ execute-keys -draft <a-x> <a-k> ^\h*(?:when)$ <ret> <a-a>i <a-semicolon> <a-?> ^\h*(?:case) <ret> <a-S> 1<a-&> }
# align 'rescue' to 'begin/def'
try %{ execute-keys -draft <a-x> <a-k> ^\h*(?:rescue)$ <ret> <a-a>i <a-semicolon> <a-?> ^\h*(?:begin|def) <ret> <a-S> 1<a-&> }
# align 'end' to opening structure
try %{ execute-keys -draft <a-x> <a-k> ^\h*(?:end)$ <ret> <a-a>i <a-semicolon> <a-?> ^\h*(?:begin|case|class|def|for|if|module|unless|until|while) <ret> <a-S> 1<a-&> }
}
}
define-command -hidden crystal-fetch-keywords %{
set-register dquote %sh{
curl --location https://github.com/crystal-lang/crystal/raw/master/src/compiler/crystal/syntax/lexer.cr |