# http://w3.org/Style/CSS # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*[.](css) %{ set-option buffer filetype css } # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/ regions -default selector css \ declaration [{] [}] '' \ comment /[*] [*]/ '' add-highlighter shared/css/comment fill comment add-highlighter shared/css/declaration regions content \ string '"' (? s \h+$ d } } define-command -hidden css-indent-on-new-line %[ eval -draft -itersel %[ # preserve previous line indent try %[ exec -draft \; K ] # filter previous line try %[ exec -draft k : css-filter-around-selections ] # indent after lines ending with with { try %[ exec -draft k \{$ j ] ] ] define-command -hidden css-indent-on-closing-curly-brace %[ eval -draft -itersel %[ # align to opening curly brace when alone on a line try %[ exec -draft ^\h+\}$ m s \A|.\z 1 ] ] ] # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook -group css-highlight global WinSetOption filetype=css %{ add-highlighter window ref css } hook global WinSetOption filetype=css %[ hook window InsertEnd .* -group css-hooks css-filter-around-selections hook window InsertChar \n -group css-indent css-indent-on-new-line hook window InsertChar \} -group css-indent css-indent-on-closing-curly-brace ] hook -group css-highlight global WinSetOption filetype=(?!css).* %{ remove-highlighter window/css } hook global WinSetOption filetype=(?!css).* %{ remove-hooks window css-indent remove-hooks window css-hooks }