summaryrefslogtreecommitdiff
path: root/rc
diff options
context:
space:
mode:
authorEric <ericv8v9s@outlook.com>2025-04-09 03:16:55 -0400
committerEric <ericv8v9s@outlook.com>2025-04-09 03:16:55 -0400
commit761ac45e61531a8aa5fb0536d692959ee23c0c12 (patch)
treee4b59a1bed8a6cb232c8f5e45f02e87c6884e609 /rc
parent922607221b8e5b2683babb9ebeba9372e97b836c (diff)
Fixed latex highlighter escaping math mode
Previously, using any macro in math mode (e.g. `$x \in X$`) causes the whole thing to fail to be recognized as math because the macro (`\in`) would be captured by the "cs" region.
Diffstat (limited to 'rc')
-rw-r--r--rc/filetype/latex.kak8
1 files changed, 5 insertions, 3 deletions
diff --git a/rc/filetype/latex.kak b/rc/filetype/latex.kak
index 70c37674..d2bf0e74 100644
--- a/rc/filetype/latex.kak
+++ b/rc/filetype/latex.kak
@@ -42,6 +42,11 @@ add-highlighter shared/latex/content default-region group
add-highlighter shared/latex/cs region '(?<!\\)(?:\\\\)*\K\\[@\w]' '/\n|(?<![@:\\{}\[\]*])(?![@:\\{}\[\]*])\b|(?<!\\)(?:\\\\)*\K\}\K' group
add-highlighter shared/latex/comment region '(?<!\\)(?:\\\\)*\K%' '\n' fill comment
+# Math mode between dollar signs/pairs
+add-highlighter shared/latex/dollar-math region -match-capture '(?<!\\)(?:\\\\)*\K(\$\$?)' '(?<!\\)(?:\\\\)*(\$\$?)' fill meta
+add-highlighter shared/latex/paren-math region '(?<!\\)(?:\\\\)*\K\\\(' '(?<!\\)(?:\\\\)*\\\)' fill meta
+add-highlighter shared/latex/bracket-math region '(?<!\\)(?:\\\\)*\K\\\[' '(?<!\\)(?:\\\\)*\\\]' fill meta
+
# Document and LaTeX2e control sequence
add-highlighter shared/latex/cs/ regex '(?:\\[a-zA-Z@]+)' 0:keyword
## Options passed to LaTeX2e control sequences, between brackets
@@ -73,9 +78,6 @@ add-highlighter shared/latex/content/ regex '(?<!\\)(?:\\\\)*\K#+[1-9]' 0:string
## group containing words and numbers (list separated by ; , / or spaces)
add-highlighter shared/latex/content/ regex '(?<!\\)(?:\\\\)*\K\{([\s/;,.\w\d]+)\}' 1:string
-# Math mode between dollar signs/pairs
-add-highlighter shared/latex/content/ regex '((?<!\\)(?:\\\\)*\K\$(\\\$|[^$])+\$)|((?<!\\)(?:\\\\)*\K\$\$(\\\$|[^$])+\$\$)|((?<!\\)(?:\\\\)*\K\\\[.*?\\\])|(\\\(.*?\\\))' 0:meta
-
# Indent
# ------