latex-snippets
latex-snippets copied to clipboard
"math()" context doesn't work
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 (https://github.com/lervag/vimtex/issues/1870)
Do you have Treesitter enabled for Latex files? If so, please consider to deactivate TreeSitter for Latex files
nvim-treesitter/nvim-treesitter/issues/1184
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```