I have been using vimtex
with UltiSnips
for a while on Linux platform and it has been working just fine.
Recently, I switched to MacBook Air M1 for the same and installed the above mentioned plugins to work with MacVim
using vim-plug
. All UltiSnips
snippets are working (expanding) except for those which use a context
by which I mean that regular snippets expand as expected whereas the snippets involving a context do not expand. Also, I found out that if I comment out the context "math()" from snippets then they do expand. So basically the problem now is that the context
environment is causing problems with snippet expansion. A sample for my snippets is provided below.
I suspect this is due to MacVim
running on top of Rosetta 2
but cannot be sure as nothing else has changed (maybe someone using same setup as me but on regular Intel chips can pitch in for more data).
Can someone help me figure out this thing?
Snippets :-
- Regular snippets which do work :-
snippet pack "creates a usepackage command" bAm
\usepackage{${1:package_name}}
endsnippet
- Context snippets which do not work (here the context is
math()
) :-
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', 'AmsA', 'AmsB', 'AmsC',
'AmsD', 'AmsE', 'AmsF', 'AmsG', 'AmsAS', 'AmsBS', 'AmsCS', 'AmsDS', 'AmsES',
'AmsFS', 'AmsGS' ]]
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
keywords1 = { 'a' : '\\alpha', 'b' : '\\beta', 'g' : '\\gamma', 'd' : '\\delta', 'e' : '\\epsilon', 'z' : '\\zeta', 't' : '\\theta', 'i' : '\\iota', 'k' : '\\kappa', 'l' : '\\lambda', 's' : '\\sigma', 'o' : '\\omega', 'p' : '\\psi', 'A' : '\\Alpha', 'B' : '\\Beta', 'G' : '\\Gamma', 'D' : '\\Delta', 'E' : '\\Epsilon', 'Z' : '\\Zeta', 'T' : '\\Theta', 'I' : '\\Iota', 'K' : '\\Kappa', 'L' : '\\Lambda', 'S' : '\\Sigma', 'O' : '\\Omega', 'P' : '\\Psi' }
keywords2 = { 't' : '\\tau', 'p' : '\\pi', 'f' : '\\phi' , 'm' : '\\mu', 'n' : '\\nu', 'e' : '\\eta', 'T' : '\\Tau', 'P' : '\\Pi', 'F' : '\\Phi', 'M' : '\\Mu', 'N' : '\\Nu', 'E' : '\\Eta'}
endglobal
######################################################################
context "math()"
snippet ";([a,b,g,d,e,z,t,i,k,l,s,o,p,A,B,G,D,E,Z,T,I,K,L,S,O,P])" "Greek Letters 1" rAm
`!p snip.rv = keywords1[match.group(1)]`
endsnippet
######################################################################
context "math()"
snippet "'([t,p,f,m,n,e,T,P,F,M,N,E])" "Greek Letters 2" rAm
`!p snip.rv = keywords2[match.group(1)]`
endsnippet
######################################################################
context
environment (or whatever it is called) but wasn't able to isolate the issue any further.vim.eval(...)
which only works for regular vim and I am using MacVim?