summaryrefslogtreecommitdiff
path: root/rc
diff options
context:
space:
mode:
Diffstat (limited to 'rc')
-rw-r--r--rc/filetype/latex.kak16
1 files changed, 10 insertions, 6 deletions
diff --git a/rc/filetype/latex.kak b/rc/filetype/latex.kak
index d2bf0e74..8c9a7561 100644
--- a/rc/filetype/latex.kak
+++ b/rc/filetype/latex.kak
@@ -34,19 +34,23 @@ provide-module latex %~
add-highlighter shared/latex regions
add-highlighter shared/latex/content default-region group
+
+# Math modes
+# $math$ must have at least one non-$ character inside.
+# This is so that $$math$$ get matched properly.
+add-highlighter shared/latex/dollar-math region '(?<!\\)(?:\\\\)*\K\$[^$]' '(?<!\\)(\\\\)*\$' fill meta
+add-highlighter shared/latex/ddollar-math region '(?<!\\)(?:\\\\)*\K\$\$' '(?<!\\)(\\\\)*\$\$' fill meta
+add-highlighter shared/latex/bracket-math region '(?<!\\)(?:\\\\)*\K\\\[' '\\\]' fill meta
+add-highlighter shared/latex/paren-math region '(?<!\\)(?:\\\\)*\K\\\(' '\\\)' fill meta
+
# Region for control sequence (includes latex2e arguments and options)
# starting with unescaped \ and ending :
# - at eol, or
# - at word boundaries not preceded nor followed by @ : \ { } [ ] *, or
# - after an unescaped }
-add-highlighter shared/latex/cs region '(?<!\\)(?:\\\\)*\K\\[@\w]' '/\n|(?<![@:\\{}\[\]*])(?![@:\\{}\[\]*])\b|(?<!\\)(?:\\\\)*\K\}\K' 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