diff --git a/rc/javascript.kak b/rc/javascript.kak index 4592d4db..6ace8dad 100644 --- a/rc/javascript.kak +++ b/rc/javascript.kak @@ -47,10 +47,10 @@ def -hidden _javascript_filter_around_selections %{ } def -hidden _javascript_indent_on_char " - eval -draft -itersel ' - # indent closer token to its opener - try %_ exec -draft gh ^\h*[]}] m _ - ' + eval -draft -itersel %_ + # align closer token to its opener when alone on a line + try %/ exec -draft ^\h+[]}]$ m s \`|.\' 1 / + _ " def -hidden _javascript_indent_on_new_line " diff --git a/rc/json.kak b/rc/json.kak index f1a32f3b..dcc18db3 100644 --- a/rc/json.kak +++ b/rc/json.kak @@ -34,10 +34,10 @@ def -hidden _json_filter_around_selections %{ } def -hidden _json_indent_on_char " - eval -draft -itersel ' - # indent closer token to its opener - try %_ exec -draft gh ^\h*[]}] m _ - ' + eval -draft -itersel %_ + # align closer token to its opener when alone on a line + try %/ exec -draft ^\h+[]}]$ m s \`|.\' 1 / + _ " def -hidden _json_indent_on_new_line " diff --git a/rc/ruby.kak b/rc/ruby.kak index bb3a26e6..2871de4b 100644 --- a/rc/ruby.kak +++ b/rc/ruby.kak @@ -48,7 +48,7 @@ addhl -group /ruby/comment fill comment addhl -group /ruby/literal fill meta -addhl -group /ruby/code regex \<([a-z]\w+:)|([$@][a-z]\w+)|(\W\K:[a-z]\w+[=?!]?) 0:identifier +addhl -group /ruby/code regex \<([A-Za-z]\w+:)|([$@][A-Za-z]\w+)|(\W\K:[A-Za-z]\w+[=?!]?) 0:identifier addhl -group /ruby/code regex \<(require|include)\> 0:meta addhl -group /ruby/code regex \<(attr_(reader|writer|accessor))\> 0:attribute @@ -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 # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾