summaryrefslogtreecommitdiffstats
path: root/genvim.txr
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-07-02 05:44:49 -0700
committerKaz Kylheku <kaz@kylheku.com>2015-07-02 05:44:49 -0700
commit2652ea85266677746b34eb6e0721f3a806feadb2 (patch)
treeea8e2c7988ed1baec2e3894eb0f3de3836f52bca /genvim.txr
parent62d1ded8ee9e5be68c7c2545b047c929e9ff63fd (diff)
downloadtxr-2652ea85266677746b34eb6e0721f3a806feadb2.tar.gz
txr-2652ea85266677746b34eb6e0721f3a806feadb2.tar.bz2
txr-2652ea85266677746b34eb6e0721f3a806feadb2.zip
Handle escapes accurately in Vim syntax highlighting.
* genvim.txr (txr_badesc, txr_stresc, txr_numesc, txr_regesc): New match categories. (txr_string, txr_quasilit, txr_regex, txl_regex): No longer use skip= argument, but rather contain escape categories. All escapes are colored as Special rather than String, and unknown or malformed escapes are colored as errors.
Diffstat (limited to 'genvim.txr')
-rw-r--r--genvim.txr19
1 files changed, 14 insertions, 5 deletions
diff --git a/genvim.txr b/genvim.txr
index 652e5f9c..e74ed9c2 100644
--- a/genvim.txr
+++ b/genvim.txr
@@ -88,7 +88,12 @@ syn match txr_hashbang "^#!.*"
@ (end)
@ (output :continue out)
syn match txr_metanum "@@[0-9]\+"
+syn match txr_badesc "\\." contained
syn match txr_escat "\\@@" contained
+syn match txr_stresc "\\[abtnvfre \n"`'\\]" contained
+syn match txr_numesc "\\x[0-9A-Fa-f]\+;\?" contained
+syn match txr_numesc "\\[0-7]\+;\?" contained
+syn match txr_regesc "\\[abtnvfre\\ \n/sSdDwW()\|.*?+~&%\[\]\-]" contained
syn match txr_nested_error "[^\t `]\+" contained
syn match txr_chr "#\\x[A-Fa-f0-9]\+"@(if txr-p " contained")
@@ -131,10 +136,10 @@ syn region txr_list @(if txr-p "contained ")matchgroup=Delimiter start="#\?H\?("
syn region txr_bracket @(if txr-p "contained ")matchgroup=Delimiter start="\[" matchgroup=Delimiter end="\]" contains=txl_keyword,txr_string,txl_regex,txr_num,txr_badnum,txl_ident,txr_metanum,txr_list,txr_bracket,txr_mlist,txr_mbracket,txr_quasilit,txr_chr,txr_quote,txr_unquote,txr_splice,txr_dot,txr_dotdot,txr_metaat,txr_ncomment,txr_nested_error
syn region txr_mlist @(if txr-p "contained ")matchgroup=Delimiter start="@@[ \t]*(" matchgroup=Delimiter end=")" contains=txl_keyword,txr_string,txl_regex,txr_num,txr_badnum,txl_ident,txr_metanum,txr_list,txr_bracket,txr_mlist,txr_mbracket,txr_quasilit,txr_chr,txr_quote,txr_unquote,txr_splice,txr_dot,txr_dotdot,txr_metaat,txr_ncomment,txr_nested_error
syn region txr_mbracket matchgroup=Delimiter start="@@[ \t]*\[" matchgroup=Delimiter end="\]" contains=txl_keyword,txr_string,txl_regex,txr_num,txr_badnum,txl_ident,txr_metanum,txr_list,txr_bracket,txr_mlist,txr_mbracket,txr_quasilit,txr_chr,txr_quote,txr_unquote,txr_splice,txr_dot,txr_dotdot,txr_metaat,txr_ncomment,txr_nested_error
-syn region txr_string @(if txr-p "contained ")start=+#\?\*\?"+ skip=+\\\\\|\\"\|\\\n+ end=+"\|\n+
-syn region txr_quasilit @(if txr-p "contained ")start=+#\?\*\?`+ skip=+\\\\\|\\`\|\\\n+ end=+`\|\n+ contains=txr_splicevar,txr_metanum,txr_bracevar,txr_mlist,txr_mbracket,txr_escat
-syn region txr_regex @(if txr-p "contained ")start="/" skip="\\\\\|\\/\|\\\n" end="/\|\n"
-syn region txl_regex @(if txr-p "contained ")start="#/" skip="\\\\\|\\/\|\\\n" end="/\|\n"
+syn region txr_string @(if txr-p "contained ")start=+#\?\*\?"+ end=+["\n]+ contains=txr_stresc,txr_numesc,txr_badesc
+syn region txr_quasilit @(if txr-p "contained ")start=+#\?\*\?`+ end=+[`\n]+ contains=txr_splicevar,txr_metanum,txr_bracevar,txr_mlist,txr_mbracket,txr_escat,txr_stresc,txr_numesc,txr_badesc
+syn region txr_regex @(if txr-p "contained ")start="/" end="[/\n]" contains=txr_regesc,txr_numesc,txr_badesc
+syn region txl_regex @(if txr-p "contained ")start="#/" end="[/\n]" contains=txr_regesc,txr_numesc,txr_badesc
hi def link txr_at Special
hi def link txr_atstar Special
@@ -155,7 +160,11 @@ hi def link txr_regdir String
hi def link txr_variable Identifier
hi def link txr_splicevar Identifier
hi def link txr_metanum Identifier
-hi def link txr_escat String
+hi def link txr_escat Special
+hi def link txr_stresc Special
+hi def link txr_numesc Special
+hi def link txr_regesc Special
+hi def link txr_badesc Error
hi def link txr_ident Identifier
hi def link txl_ident Identifier
hi def link txr_num Number