# http://haml.info # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*[.](haml) %{ set buffer filetype haml } # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter -group / regions -default code haml \ comment ^\h*/ $ '' \ eval ^\h*%([A-Za-z][A-Za-z0-9_-]*)([#.][A-Za-z][A-Za-z0-9_-]*)?\{\K|#\{\K (?=\}) \{ \ eval ^\h*[=-]\K (? s \h+$ d } } def -hidden haml-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 : haml-filter-around-selections } # indent after lines beginning with : or - try %{ exec -draft k ^\h*[:-] j } } } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook -group haml-highlight global WinSetOption filetype=haml %{ add-highlighter ref haml } hook global WinSetOption filetype=haml %{ hook window InsertEnd .* -group haml-hooks haml-filter-around-selections hook window InsertChar \n -group haml-indent haml-indent-on-new-line } hook -group haml-highlight global WinSetOption filetype=(?!haml).* %{ remove-highlighter haml } hook global WinSetOption filetype=(?!haml).* %{ remove-hooks window haml-indent remove-hooks window haml-hooks }