Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] #5249

Open
ewtoombs opened this issue Oct 23, 2024 · 2 comments
Open

[BUG] #5249

ewtoombs opened this issue Oct 23, 2024 · 2 comments
Labels

Comments

@ewtoombs
Copy link

Version of Kakoune

archlinux 2024.05.18-2

Reproducer

Open a .tex file with this line in it:

$\pi(\hat v)$ is the probability per unit solid angle of the particle escaping with trajectory $\hat v$.

Outcome

This gets highlighted as if it were a formula:

$\pi(\hat v)$ is the probability per unit solid angle of the particle escaping with trajectory $\hat v$.
            ( from here...                                                           to here.  )

Expectations

This should get highlighted instead.

$\pi(\hat v)$ is the probability per unit solid angle of the particle escaping with trajectory $\hat v$.
(  here     )                                                                             and  ( here )

Additional information

It has something to do with the backslash.
If a formula does not start with a backslash, the syntax highlighting works fine.

@ewtoombs ewtoombs added the bug label Oct 23, 2024
@ewtoombs
Copy link
Author

ewtoombs commented Oct 23, 2024

I've been trying to diagnose this madness by directly editing /usr/share/kak/rc/filetype/latex.kak and seeing what happens.
It makes no sense at all.

When I disable all highlighting except

add-highlighter shared/latex regions
add-highlighter shared/latex/content default-region group
add-highlighter shared/latex/content/ regex '(?<!\\)(?:\\\\)*\K\$(\\\$|[^$])+\$|(?<!\\)(?:\\\\)*\K\$\$(\\
»   \$|[^$])+\$\$|(?<!\\)(?:\\\\)*\K\\\[.*?\\\]|\\\(.*?\\\)' 0:meta

the math highlighting works (and all other highlighting is disabled).
Then, when I add just this line:

add-highlighter shared/latex/cs/ regex '(?:\\[a-zA-Z@]+)' 0:keyword

everything breaks!
There is no more highlighting at all.

What the hell is going on with this software?
I give up trying to solve this on my own.

@Screwtapello
Copy link
Contributor

In the snippet you posted, shared/latex is a "regions" highlighter, so everything inside it must be a "region" or "default-region" highlighter.

shared/latex/content is created as a "default-region" highlighter, which is fine. The default region contains a "group" highlighter, and the regex is an anonymous highlighter within that group, so that's fine.

The extra line you add is trying to create an anonymous regex highlighter inside shared/latex/cs, but that highlighter isn't defined anywhere, so Kakoune probably throws an error that prevents the rest of the filetype plugin from running, including the bit that applies the highlighters when you open a LaTeX file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants