Fix auto indentation for if/case and else

This commit is contained in:
John Isom 2020-08-02 11:22:28 -06:00
parent e858df3ca2
commit 6cf39a5f4f

View File

@ -188,14 +188,16 @@ define-command -hidden crystal-trim-indent %{
define-command -hidden crystal-indent-on-char %{ define-command -hidden crystal-indent-on-char %{
evaluate-commands -no-hooks -draft -itersel %{ evaluate-commands -no-hooks -draft -itersel %{
# align 'else/elsif' to 'if' # align 'else' to 'if/case'
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-&> } try %{ execute-keys -draft <a-x> <a-k> ^\h*else$ <ret> <a-a>i <a-semicolon> <a-?> ^\h*(?:if|case) <ret> <a-S> 1<a-&> }
# align 'else/when' to 'case' # align 'elsif' to 'if'
try %{ execute-keys -draft <a-x> <a-k> ^\h*(?:else|when)$ <ret> <a-a>i <a-semicolon> <a-?> ^\h*(?:case) <ret> <a-S> 1<a-&> } try %{ execute-keys -draft <a-x> <a-k> ^\h*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' # 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-&> } 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 # 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-&> } 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-&> }
} }
} }