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

Vimtex 2.0 Math Zone #1870

Closed
yushangakki opened this issue Nov 28, 2020 · 4 comments
Closed

Vimtex 2.0 Math Zone #1870

yushangakki opened this issue Nov 28, 2020 · 4 comments

Comments

@yushangakki
Copy link

Hi Thanks for the big update! However, my old configuration on MathZone broke:

.config/nvim/after/tex.vim

syn clear texMathZoneW
syn region texMathZoneW	matchgroup=Delimiter start="\\\["			matchgroup=Delimiter	end="\\]\|%stopzone\>"			keepend contains=@texMathZoneGroup
call TexNewMathZone("E","align",1)
call TexNewMathZone("F","alignat",1)
call TexNewMathZone("G","equation",1)
call TexNewMathZone("H","flalign",1)
call TexNewMathZone("I","gather",1)
call TexNewMathZone("J","multline",1)
call TexNewMathZone("K","xalignat",1)
call TexNewMathZone("L","dmath",1)

minimal.tex

\documentclass{minimal}
\begin{document}
Hello world!
\end{document}

Observed Behaviour
No such highlight group name: texMathZoneW.

Unknown function: TexNewMathZone

Expected Behaviour
Make the align environment also be treated as the math zone.

Thanks! Happy Thanksgiving!

@lervag
Copy link
Owner

lervag commented Nov 28, 2020

Your configuration is not necessary, because Vimtex already has good suppor for the amsmath package.:)

Happy thanksgiving!

@lervag
Copy link
Owner

lervag commented Nov 28, 2020

Note that the texMathZone* groups do not exist, so no need for the syn clear. If you want to make new math zones, the method is called vimtex#syntax#core#new_region_math. An example:

call vimtex#syntax#core#new_region_math('gather')

Note, though, as said before: You don't need to do this, because Vimtex already adds these groups when you use the amsmath package.

@lervag lervag closed this as completed Nov 28, 2020
@yushangakki
Copy link
Author

Hi Dr. Lervag thanks for the quick reply, this question is actually about Ultisnips, where the context(math) breaks on Vimtex2.0

tex.snippets

global !p
texMathZones = ['texMathZone'+x for x in ['A', 'AS', 'B', 'BS', 'C', 'CS', 'D', 'DS', 'E', 'ES', 'F', 'FS', 'G', 'GS', 'H', 'HS', 'I', 'IS', 'J', 'JS', 'K', 'KS', 'L', 'LS', 'DS', 'V', 'W', 'X', 'Y', 'Z']]
texIgnoreMathZones = ['texMathText']
texMathZoneIds = vim.eval('map('+str(texMathZones)+", 'hlID(v:val)')")
texIgnoreMathZoneIds = vim.eval('map('+str(texIgnoreMathZones)+", 'hlID(v:val)')")
ignore = texIgnoreMathZoneIds[0]
def math():
	synstackids = vim.eval("synstack(line('.'), col('.') - (col('.')>=2 ? 1 : 0))")
	try:
		first = next(i for i in reversed(synstackids) if i in texIgnoreMathZoneIds or i in texMathZoneIds)
		return first != ignore
	except StopIteration:
		return False
endglobal

context "math()"
snippet ,ff "Fraction" iA
\frac{${1:numer}}{${2:denom}}${0}
endsnippet

After upgrading to vimtex 2.0, the snippets with trigger ,ff doesn't work anymore.

May I get some insights on how I could resolve the issues here?

@lervag
Copy link
Owner

lervag commented Dec 1, 2020

Yes, this was already reported and resolved some days ago, see #1863. Specifically, see my comment. :

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

No branches or pull requests

2 participants