# Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*[.](js)x? %{ set-option buffer filetype javascript } hook global BufCreate .*[.](ts)x? %{ set-option buffer filetype typescript } # Commands # ‾‾‾‾‾‾‾‾ define-command -hidden javascript-filter-around-selections %{ # remove trailing white spaces try %{ execute-keys -draft -itersel s \h+$ d } } define-command -hidden javascript-indent-on-char %< evaluate-commands -draft -itersel %< # align closer token to its opener when alone on a line try %/ execute-keys -draft ^\h+[]}]$ m s \A|.\z 1 / > > define-command -hidden javascript-indent-on-new-line %< evaluate-commands -draft -itersel %< # copy // comments 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 : javascript-filter-around-selections } # indent after lines beginning / ending with opener token try %_ execute-keys -draft k ^\h*[[{]|[[{]$ j _ > > # Highlighting and hooks bulder for JavaScript and TypeScript # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ define-command -hidden init-javascript-filetype -params 1 %~ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/ regions -default code %arg{1} \ double_string '"' (?])(?!>\()) (|/>) (? < \ expr \{ \} \{ add-highlighter "shared/%arg{1}/jsx/content/expr" ref %arg{1} add-highlighter "shared/%arg{1}/jsx/content/tag" regex (\w+) 1:attribute add-highlighter "shared/%arg{1}/jsx/content/tag" regex ) 0:meta add-highlighter "shared/%arg{1}/jsx/content/tag" regions content \ string =\K" (?