# http://coffeescript.org # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*[.](coffee) %{ set-option buffer filetype coffee } # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/ regions -default code coffee \ double_string '"""' '"""' '' \ single_string "'''" "'''" '' \ comment '###' '###' '' \ regex '///' ///[gimy]* '' \ double_string '"' (? # remove trailing white spaces try %{ exec -draft s \h + $ d } } } define-command -hidden coffee-indent-on-new-line %{ eval -draft -itersel %{ # copy '#' comment prefix and following white spaces try %{ exec -draft k s '^\h*\K#\h*' y gh j P } # preserve previous line indent try %{ exec -draft \; K } # filter previous line try %{ exec -draft k : coffee-filter-around-selections } # indent after start structure try %{ exec -draft k ^ \h * (case|catch|class|else|finally|for|function|if|switch|try|while|with) \b | (=|->) $ j } } } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook -group coffee-highlight global WinSetOption filetype=coffee %{ add-highlighter window 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).* %{ remove-highlighter window/coffee } hook global WinSetOption filetype=(?!coffee).* %{ remove-hooks window coffee-indent remove-hooks window coffee-hooks }