diff --git a/rc/extra/coffee.kak b/rc/extra/coffee.kak index b7732592..36171ded 100644 --- a/rc/extra/coffee.kak +++ b/rc/extra/coffee.kak @@ -1,6 +1,8 @@ # http://coffeescript.org # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ +# require commenting.kak + # Detection # ‾‾‾‾‾‾‾‾‾ @@ -50,20 +52,23 @@ addhl -group /coffee/code regex \<(break|case|catch|class|const|continue|debugge # ‾‾‾‾‾‾‾‾ def -hidden _coffee_filter_around_selections %{ - # remove trailing white spaces - try %{ exec -draft -itersel s \h+$ d } + eval -draft -itersel %{ + exec + # remove trailing white spaces + try %{ exec -draft s \h + $ d } + } } def -hidden _coffee_indent_on_new_line %{ eval -draft -itersel %{ # preserve previous line indent - try %{ exec -draft K } + try %{ exec -draft K } # filter previous line try %{ exec -draft k : _coffee_filter_around_selections } # copy '#' comment prefix and following white spaces - try %{ exec -draft k x s ^\h*\K#\h* y j p } - # indent after lines beginning with token and ending with -> - try %_ exec -draft k x ^\h*(case|catch|class|else|finally|for|function|if|switch|try|while|with)|(->)$ j _ + try %{ exec -draft k x s ^ \h * \K \# \h * y j p } + # indent after start structure + try %{ exec -draft k x ^ \h * (case|catch|class|else|finally|for|function|if|switch|try|while|with) \b | (=|->) $ j } } } @@ -75,6 +80,9 @@ hook global WinSetOption filetype=coffee %{ hook window InsertEnd .* -group coffee-hooks _coffee_filter_around_selections hook window InsertChar \n -group coffee-indent _coffee_indent_on_new_line + + set window comment_line_chars '#' + set window comment_selection_chars '###:###' } hook global WinSetOption filetype=(?!coffee).* %{