# http://coffeescript.org # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*[.](coffee) %{ set-option buffer filetype coffee } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=coffee %{ require-module coffee hook window ModeChange insert:.* -group coffee-trim-indent coffee-trim-indent hook window InsertChar \n -group coffee-indent coffee-indent-on-new-line hook -once -always window WinSetOption filetype=.* %{ remove-hooks window coffee-.+ } } hook -group coffee-highlight global WinSetOption filetype=coffee %{ add-highlighter window/coffee ref coffee hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/coffee } } provide-module coffee %[ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/coffee regions add-highlighter shared/coffee/code default-region group add-highlighter shared/coffee/single_string region "'" "'" fill string add-highlighter shared/coffee/single_string_alt region "'''" "'''" fill string add-highlighter shared/coffee/double_string region '"' (? # remove trailing white spaces try %{ execute-keys -draft s \h + $ d } } } define-command -hidden coffee-indent-on-new-line %{ evaluate-commands -draft -itersel %{ # copy '#' comment prefix and following white spaces try %{ execute-keys -draft k s '^\h*\K#\h*' y gh j P } # preserve previous line indent try %{ execute-keys -draft \; K } # filter previous line try %{ execute-keys -draft k : coffee-trim-indent } # indent after start structure try %{ execute-keys -draft k ^ \h * (case|catch|class|else|finally|for|function|if|switch|try|while|with) \b | (=|->) $ j } } } ]