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

"math()" context doesn't work #23

Open
tarsiec opened this issue Jul 18, 2022 · 2 comments
Open

"math()" context doesn't work #23

tarsiec opened this issue Jul 18, 2022 · 2 comments

Comments

@tarsiec
Copy link

tarsiec commented Jul 18, 2022

Snippets with "math()" contexts don't work in any math environment.
Math context currently defined as

def math():
	return vim.eval('vimtex#syntax#in_mathzone()') == '1'

Nor does it work for me when changed to

texMathZones = ['texMathZone' + x for x in ['', 'X', 'XX', 'Env', 'EnvStarred', 'Ensured']]
texIgnoreMathZones = ['texMathTextArg']

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

As suggested by an issue on vimtex (lervag/vimtex#1870)

@JirR02
Copy link

JirR02 commented Aug 29, 2022

Do you have Treesitter enabled for Latex files? If so, please consider to deactivate TreeSitter for Latex files

nvim-treesitter/nvim-treesitter/issues/1184

@AlfredLouis00
Copy link

mine doesn't work neither.
I'm new to vim and work on Windows. I just put the tex.snippets file under the path AppDate\Local\nvim\plugged\ultisnips\. and i found i can't transfer the snippet, say // or / fraction with <Tab>.
as you can see that here I can't even call a common snippet not requiring context "math()"

snippet // "Fraction" iA
\\frac{$1}{$2}$0
endsnippet

snippet / "Fraction" i
\\frac{${VISUAL}}{$1}$0
endsnippet```

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

3 participants