Fix auto indentation for if/case and else
This commit is contained in:
parent
e858df3ca2
commit
6cf39a5f4f
|
@ -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-&> }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user