# http://haml.info # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*[.](haml) %{ set-option buffer filetype haml } # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/haml regions add-highlighter shared/haml/code default-region group add-highlighter shared/haml/comment region ^\h*/ $ fill comment # Filters # http://haml.info/docs/yardoc/file.REFERENCE.html#filters add-highlighter shared/haml/eval1 region -recurse \{ ^\h*%([A-Za-z][A-Za-z0-9_-]*)([#.][A-Za-z][A-Za-z0-9_-]*)?\{\K|#\{\K (?=\}) ref ruby add-highlighter shared/haml/eval2 region ^\h*[=-]\K (? s \h+$ d } } define-command -hidden haml-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 : haml-filter-around-selections } # indent after lines beginning with : or - try %{ execute-keys -draft k ^\h*[:-] j } } } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook -group haml-highlight global WinSetOption filetype=haml %{ add-highlighter window/haml ref haml hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/haml } } hook global WinSetOption filetype=haml %{ hook window ModeChange insert:.* -group haml-hooks haml-filter-around-selections hook window InsertChar \n -group haml-indent haml-indent-on-new-line hook -once -always window WinSetOption filetype=.* %{ remove-hooks window haml-.+ } }