# http://w3.org/html # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*\.html %{ set-option buffer filetype html } hook global BufCreate .*\.xml %{ set-option buffer filetype xml } # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/html regions add-highlighter shared/html/comment region '' fill comment add-highlighter shared/html/tag region < > '' regions add-highlighter shared/html/style region \K (?=) '' ref css add-highlighter shared/html/script region \K (?=) '' ref javascript add-highlighter shared/html/tag/base default-region group add-highlighter shared/html/tag/ region '"' (? s \h+$ d } } define-command -hidden html-indent-on-greater-than %[ evaluate-commands -draft -itersel %[ # align closing tag to opening when alone on a line try %[ execute-keys -draft s ^\h+/(\w+)$ {c1,/1 s \A|.\z 1 ] ] ] define-command -hidden html-indent-on-new-line %{ evaluate-commands -draft -itersel %{ # preserve previous line indent try %{ execute-keys -draft \; K } # filter previous line try %{ execute-keys -draft k : html-filter-around-selections } # indent after lines ending with opening tag try %{ execute-keys -draft k <[^/][^>]+>$ j } } } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook -group html-highlight global WinSetOption filetype=(?:html|xml) %{ add-highlighter window/html ref html } hook global WinSetOption filetype=(?:html|xml) %{ hook window ModeChange insert:.* -group html-hooks html-filter-around-selections hook window InsertChar '>' -group html-indent html-indent-on-greater-than hook window InsertChar \n -group html-indent html-indent-on-new-line } hook -group html-highlight global WinSetOption filetype=(?!html)(?!xml).* %{ remove-highlighter window/html } hook global WinSetOption filetype=(?!html)(?!xml).* %{ remove-hooks window html-indent remove-hooks window html-hooks }