diff --git a/rc/base/javascript.kak b/rc/base/javascript.kak index 30f0bbf3..59f1f746 100644 --- a/rc/base/javascript.kak +++ b/rc/base/javascript.kak @@ -1,40 +1,13 @@ # Detection # ‾‾‾‾‾‾‾‾‾ -hook global BufCreate .*[.](js) %{ +hook global BufCreate .*[.](js)x? %{ set-option buffer filetype javascript } -# Highlighters -# ‾‾‾‾‾‾‾‾‾‾‾‾ - -add-highlighter shared/ regions -default code javascript \ - double_string '"' (? > -# Initialization -# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ +# Highlighting and hooks bulder for JavaScript and TypeScript +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ +define-command -hidden init-javascript-filetype -params 1 %~ + # Highlighters + # ‾‾‾‾‾‾‾‾‾‾‾‾ -hook -group javascript-highlight global WinSetOption filetype=javascript %{ add-highlighter window ref javascript } + 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" (?