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

Support distinguishing different cases of math environment using different group #2467

Closed
pilgrimlyieu opened this issue Aug 21, 2022 · 7 comments

Comments

@pilgrimlyieu
Copy link

pilgrimlyieu commented Aug 21, 2022

Use different groups for texMathZones to make it possible to distinguish them. See also #2397.

Here are currently supported cases (see :help vimtex-syntax-reference, table 3):

  GROUP                    DEFAULT        EXAMPLE
  ----------------------------------------------------------------------------
  texMathZone              Special        \( HERE \); \[ HERE \]
  texMathZoneX             texMathZone    $ HERE $
  texMathZoneXX            texMathZone    $$ HERE $$

Notice that we can't distinguish \( Inline Math \) and \[ Display Math \] through, since they are both texMathZone.

@lervag
Copy link
Owner

lervag commented Aug 21, 2022

Perhaps we could use something like this:

GROUP DEFAULT EXAMPLE
texMathZoneLI Special \( here \)
texMathZoneLD Special \[ here \]
texMathZoneTI texMathZone $ here $
texMathZoneTD texMathZone $$ here $$

The idea behind these names is that the L implies the LaTeX shorthand, whereas the T implies the TeX shorthand. Further, the I is for "inline" and D is for "display". This is consistent with how these forms are explain in e.g. the wiki LaTeX book.

@clason do you have any thoughts on this? Ideas for more consistent naming, perhaps?

@clason
Copy link
Contributor

clason commented Aug 21, 2022

Hmm, I'd prefer if the current behaviour wouldn't change (all math zones link to texMathZone, which links to Special).

Otherwise the naming is sound (and better than X, XX); I just worry a bit about compatibility with the builtin tex syntax file -- will this lead to a huge regression with common colorschemes? (But are there even any with specific tex highlight groups?)

Will you use special groups for the delimiters themselves then?

@lervag
Copy link
Owner

lervag commented Aug 21, 2022

Hmm, I'd prefer if the current behaviour wouldn't change (all math zones link to texMathZone, which links to Special).

Sorry, here's an adjusted suggestion that should make more sense:

GROUP DEFAULT EXAMPLE
texMathZone Special N/A
texMathZoneLI texMathZone \( here \)
texMathZoneLD texMathZone \[ here \]
texMathZoneTI texMathZone $ here $
texMathZoneTD texMathZone $$ here $$

Will you use special groups for the delimiters themselves then?

The delimiters will still all link to texMathDelimZone, of course.

Otherwise the naming is sound (and better than X, XX); I just worry a bit about compatibility with the builtin tex syntax file -- will this lead to a huge regression with common colorschemes? (But are there even any with specific tex highlight groups?)

I don't think so, but I have to admit I don't know. But then, this change should make it really easy for colorscheme creators to adjust their rules, right?

@clason
Copy link
Contributor

clason commented Aug 21, 2022

The delimiters will still all link to texMathDelimZone, of course.

I meant, will you add texMathDelimZoneTD and friends? (I assume yes, but just to make it explicit.)

I don't think so, but I have to admit I don't know. But then, this change should make it really easy for colorscheme creators to adjust their rules, right?

Yes, it's not hard to adapt at all; just trying to come up with possible complaints about this change.

@lervag
Copy link
Owner

lervag commented Aug 21, 2022

The delimiters will still all link to texMathDelimZone, of course.

I meant, will you add texMathDelimZoneTD and friends? (I assume yes, but just to make it explicit.)

I don't see why not. If we link them to a common one, things will not change for anyone, except it allows more flexibility for people who might want it.

Updated suggestion:

GROUP DEFAULT EXAMPLE
texMathZone Special N/A
texMathZoneLI texMathZone \( here \)
texMathZoneLD texMathZone \[ here \]
texMathZoneTI texMathZone $ here $
texMathZoneTD texMathZone $$ here $$
texMathDelimZone texDelim N/A
texMathDelimZoneLI texMathDelimZone \( and \)
texMathDelimZoneLD texMathDelimZone \[ and \]
texMathDelimZoneTI texMathDelimZone $ and $
texMathDelimZoneTD texMathDelimZone $$ and $$

@lervag
Copy link
Owner

lervag commented Aug 21, 2022

Notice, with these suggestions, it would be easy to check if one is inside an inline environment with vimtex#syntax#in('texMathZone[LT]I'), or inside any of the math zones with vimtex#syntax#in('texMathZone').

lervag added a commit that referenced this issue Aug 21, 2022
@lervag
Copy link
Owner

lervag commented Aug 21, 2022

Done; I've updated the code and the docs, as well as the related wiki entry. Let me know if there is something that is not working as expected!

(I will make sure this gets some attention in the next release notes.)

@lervag lervag closed this as completed Aug 21, 2022
pilgrimlyieu added a commit to pilgrimlyieu/Snippets-Dependencies that referenced this issue Aug 27, 2022
1. `md`   : Update punctuation support list
2. `mdtex`: Update specific math environment distinguishing(related to lervag/vimtex#2467)
tomtomjhj added a commit to tomtomjhj/init.vim that referenced this issue Aug 28, 2022
* adapt to lervag/vimtex#2467
* remove broken stuff
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