ruby.kak: indent on opener / closer tokens

This commit is contained in:
Alex Leferry 2 2014-07-16 13:59:51 +02:00
parent cd656ae4eb
commit c4a6f5fa96

View File

@ -67,27 +67,29 @@ def -hidden _ruby_filter_around_selections %{
} }
} }
def -hidden _ruby_indent_on_char %{ def -hidden _ruby_indent_on_char "
eval -draft -itersel %{ eval -draft -itersel %_
# deindent on (else|elsif|end|rescue|when) keyword insertion # deindent on (else|elsif|end|rescue|when) keyword insertion
try %{ exec -draft <space> <a-i>w <a-k> (else|elsif|end|rescue|when) <ret> <a-lt> } try %{ exec -draft <space> <a-i>w <a-k> (else|elsif|end|rescue|when) <ret> <a-lt> }
} # align closer token to its opener when alone on a line
} try %/ exec -draft <a-h> <a-k> ^\h+[]}]$ <ret> m s \`|.\' <ret> 1<a-&> /
_
"
def -hidden _ruby_indent_on_new_line %{ def -hidden _ruby_indent_on_new_line "
eval -draft -itersel %{ eval -draft -itersel '
# preserve previous line indent # preserve previous line indent
try %{ exec -draft <space> K <a-&> } try %{ exec -draft <space> K <a-&> }
# filter previous line # filter previous line
try %{ exec -draft k : _ruby_filter_around_selections <ret> } try %{ exec -draft k : _ruby_filter_around_selections <ret> }
# copy '#' comment prefix and following white spaces # copy _#_ comment prefix and following white spaces
try %{ exec -draft k x s ^\h*\K#\h* <ret> y j p } try %{ exec -draft k x s ^\h*\K#\h* <ret> y j p }
# indent after (else|elsif|rescue|when) keywords # indent after (else|elsif|rescue|when) keywords and lines beginning / ending with opener token
try %_ exec -draft <space> k x <a-k> (else|elsif|rescue|when) <ret> j <a-gt> _ try %_ exec -draft <space> k x <a-k> (else|elsif|rescue|when)|^\h*[[{]|[[{]$ <ret> j <a-gt> _
# indent after (begin|case|class|def|do|if|loop|module|unless|until|while) keywords and add 'end' keyword # indent after (begin|case|class|def|do|if|loop|module|unless|until|while) keywords and add _end_ keyword
try %{ exec -draft <space> k x <a-k> (begin|case|class|def|do|(?<!els)if|loop|module|unless|until|while) <ret> x y p j a end <esc> k <a-gt> } try %{ exec -draft <space> k x <a-k> (begin|case|class|def|do|(?<!els)if|loop|module|unless|until|while) <ret> x y p j a end <esc> k <a-gt> }
} '
} "
# Initialization # Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾