From 3ac328c1f7bff97df573fd16b454137e69c0b4d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=20Ros=C3=A9n?= Date: Sun, 7 Jan 2018 23:17:37 +0100 Subject: [PATCH] Highlight JSX Additionally merges the javascript and typescript highlighters. Fixes #1700 --- rc/base/javascript.kak | 133 +++++++++++++++++++++++++++------------- rc/extra/typescript.kak | 54 ---------------- 2 files changed, 89 insertions(+), 98 deletions(-) delete mode 100644 rc/extra/typescript.kak diff --git a/rc/base/javascript.kak b/rc/base/javascript.kak index 30f0bbf33..59f1f7463 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" (?