# http://coffeescript.org # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*[.](coffee) %{ set buffer filetype coffee } # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ addhl -group / regions -default code coffee \ double_string '"""' '"""' '' \ single_string "'''" "'''" '' \ comment '###' '###' '' \ regex '///' ///[gimy]* '' \ double_string '"' (? # 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 } # 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 gh 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 } } } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook -group coffee-highlight global WinSetOption filetype=coffee %{ addhl ref coffee } 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 } hook -group coffee-highlight global WinSetOption filetype=(?!coffee).* %{ rmhl coffee } hook global WinSetOption filetype=(?!coffee).* %{ rmhooks window coffee-indent rmhooks window coffee-hooks }