From c4a6f5fa966b45ae88d314886b5fa4fe5333aeaf Mon Sep 17 00:00:00 2001 From: Alex Leferry 2 Date: Wed, 16 Jul 2014 13:59:51 +0200 Subject: [PATCH] ruby.kak: indent on opener / closer tokens --- rc/ruby.kak | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/rc/ruby.kak b/rc/ruby.kak index bb3a26e6..99fecc19 100644 --- a/rc/ruby.kak +++ b/rc/ruby.kak @@ -67,27 +67,29 @@ def -hidden _ruby_filter_around_selections %{ } } -def -hidden _ruby_indent_on_char %{ - eval -draft -itersel %{ +def -hidden _ruby_indent_on_char " + eval -draft -itersel %_ # deindent on (else|elsif|end|rescue|when) keyword insertion try %{ exec -draft w (else|elsif|end|rescue|when) } - } -} + # align closer token to its opener when alone on a line + try %/ exec -draft ^\h+[]}]$ m s \`|.\' 1 / + _ +" -def -hidden _ruby_indent_on_new_line %{ - eval -draft -itersel %{ +def -hidden _ruby_indent_on_new_line " + eval -draft -itersel ' # preserve previous line indent try %{ exec -draft K } # filter previous line try %{ exec -draft k : _ruby_filter_around_selections } - # copy '#' comment prefix and following white spaces + # copy _#_ comment prefix and following white spaces try %{ exec -draft k x s ^\h*\K#\h* y j p } - # indent after (else|elsif|rescue|when) keywords - try %_ exec -draft k x (else|elsif|rescue|when) j _ - # indent after (begin|case|class|def|do|if|loop|module|unless|until|while) keywords and add 'end' keyword + # indent after (else|elsif|rescue|when) keywords and lines beginning / ending with opener token + try %_ exec -draft k x (else|elsif|rescue|when)|^\h*[[{]|[[{]$ j _ + # indent after (begin|case|class|def|do|if|loop|module|unless|until|while) keywords and add _end_ keyword try %{ exec -draft k x (begin|case|class|def|do|(? x y p j a end k } - } -} + ' +" # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾