From f25e8640b8a5194d155675d9f31f71b4a35f283d Mon Sep 17 00:00:00 2001 From: Frank LENORMAND Date: Sat, 17 Feb 2018 11:53:56 +0300 Subject: [PATCH] base javascript: Tweak variable highlighting This commit avoids false positives when highlighting literals such as `$window`, which is a regular variable but still highlighted as a special value. Special highlighting of variables that start with a dollar sign `$` was also removed, as not all variables start with a dollar sign, and we don't have a reliable way yet to detect variables. --- rc/base/javascript.kak | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rc/base/javascript.kak b/rc/base/javascript.kak index 59f1f746..bda5396b 100644 --- a/rc/base/javascript.kak +++ b/rc/base/javascript.kak @@ -64,8 +64,7 @@ define-command -hidden init-javascript-filetype -params 1 %~ add-highlighter "shared/%arg{1}/literal" fill string add-highlighter "shared/%arg{1}/literal" regex \$\{.*?\} 0:value - add-highlighter "shared/%arg{1}/code" regex \$\w* 0:variable - add-highlighter "shared/%arg{1}/code" regex \b(document|false|null|parent|self|this|true|undefined|window)\b 0:value + add-highlighter "shared/%arg{1}/code" regex [^$_]\b(document|false|null|parent|self|this|true|undefined|window)\b 1:value add-highlighter "shared/%arg{1}/code" regex "-?\b[0-9]*\.?[0-9]+" 0:value add-highlighter "shared/%arg{1}/code" regex \b(Array|Boolean|Date|Function|Number|Object|RegExp|String|Symbol)\b 0:type