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

Better delimiter highlighting #2776

Closed
tinyCatzilla opened this issue Aug 23, 2023 · 6 comments
Closed

Better delimiter highlighting #2776

tinyCatzilla opened this issue Aug 23, 2023 · 6 comments

Comments

@tinyCatzilla
Copy link

tinyCatzilla commented Aug 23, 2023

As of right now, texMathDelim has some strange properties that I can't seem to wrangle.

  • within any texMathZone, inequalities are recognized as delimiters and not math operators.
  • For commands that are seen "under-the-hood" without delimiters, the delimiters and arguments are not recognized. For example, using \frac{1}{2} instead of the shortcut \frac12 will color the delimiters and numbers as part of the command. This sharply contrasts a similar fraction without a shortcut, like \frac{12}{2}.
  • Paired delimiters are recognized, such as \lvert and \rvert. The unpaired delimiter '|' is also recognized. But the synonymous command for the unpaired delimiter \vert is only seen as a command.

Below is a screenshot demonstrating these properties, where texMathDelim is pink, texDelim is dark blue, and texCmd and texCmdEnv are yellow.

SCR-20230823-ngrr

In regards to inequalities being delimiters, this is something particularly strange to me. I haven't heard of <> being delimiters in LaTeX, but I could just be uninformed. Also, If any of these are fixable or problems on my end, I would appreciate support getting it working :).

Edit: fuck, sorry about closing and reopening. was trying to edit to show this other strange thing i realized with regards to math operators not being recognized when superscripted.
SCR-20230823-nlqm

@lervag
Copy link
Owner

lervag commented Aug 24, 2023

Are you sure you are not using Treesitter for highlighting? I believe things look different with VimTeX. See :help vimtex-faq-treesitter.

@tinyCatzilla
Copy link
Author

tinyCatzilla commented Aug 24, 2023

I believe I disabled it with the following configuration. I also remember that I saw a VimTeX notification that treesitter was controlling highlighting before changing these options.

Is there a way to make sure that this is disabling treesitter as intended?

SCR-20230824-pmmt

If so, yes, treesitter was disabled.

@lervag
Copy link
Owner

lervag commented Aug 26, 2023

Ok, sorry; I see that with default settings I can get the same result as you. So, there are several things going on here:

  1. \frac{1}{2} is captured as a concealable symbol ½. You can see it if you do :set conceallevel=2. You can disable conceals if you want with let g:vimtex_syntax_conceal_disable = 1.

  2. > and < are both delimiters and operators. For no particular reason, I chose to highlight as delimiters. I guess it does make sense to highlight them as operators instead?

  3. VimTeX does not support highlighting things like \vert ... \vert as delimiters, because they are not really that. If you use them as delimiters, you should always use \lvert .. rvert. Similar for things like \bigl .. \bigr and stuff. However, perhaps I'm being to strict here...

@Rmano
Copy link

Rmano commented Aug 26, 2023

My opinion:

  1. I never use conceal, so I abstain here
  2. I think < and > are more often used as operators than delimiters
  3. I think you're right --- considering by default delimiter the ones with "direction"

@tinyCatzilla
Copy link
Author

tinyCatzilla commented Aug 26, 2023

Thanks for the great support and confirmation that this is intended behavior. To respond with my opinion:

  1. I also do not use conceal and thus abstain. However, I was a bit confused that I had to disable conceals manually, despite it never being shown. But once I changed the global setting, highlighting does work as expected.
  2. Yes, < and > not prioritized as operators is really my only major gripe. The rest is more-so to spark discussion.
  3. I also think you're right; \vert should not be used as a delimiter (even if it is all-too-common). But then for consistency, neither should it's synonym|.

By the way, love the plugin -- keep up the great work.

@lervag
Copy link
Owner

lervag commented Sep 19, 2023

Sorry for the long silence! I've had a lot of stuff going on, including silly stuff such as playing a computer game. It's a phase, it'll pass!

In any case:

  1. conceallevel is not a global option, it is windows local. I believe using it to set the default value of g:vimtex_syntax_conceal_disable may yield an unexpected behaviour, and so I will keep these things as they are now. The conceal feature is the first section in :help vimtex-syntax and the current behaviour is explained at the top.

  2. I agree and I've updated accordingly.

  3. Good point about |. I've fixed that. I made some additional changes: / should also not be a delimiter, same for ..

This are minor things, but at the same time, I think they do make a noticable improvement. Thanks!

By the way, love the plugin -- keep up the great work.

Thank you, I'm glad to hear it!

@lervag lervag closed this as completed Sep 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants