diff options
| author | Eric Toombs <not@public.tld> | 2025-05-16 12:55:00 +0300 |
|---|---|---|
| committer | Eric Toombs <not@public.tld> | 2025-05-16 12:58:14 +0300 |
| commit | 73f11ba2f54bfb19eb001fc4832cd3e7f862e10f (patch) | |
| tree | d8213063d7996816f2fa458d8162d6cbdab7b20b /rc | |
| parent | 2d8c0b8bf0d7d18218d4c939003da39a018361e7 (diff) | |
latex: highlight $ $$ \[ and \( math modes properly.
These math modes were being split apart by control sequence regions.
To avoid this, they must be their own regions.
Fixes https://github.com/mawww/kakoune/issues/5249 .
Also, I got rid of an errant / in the control sequence ending regex that couldn't be right.
Diffstat (limited to 'rc')
| -rw-r--r-- | rc/filetype/latex.kak | 16 |
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 |
