Closed The-Cyber-Thinkerer closed 2 years ago
Yes, for example, add the following to the top of your snippets file:
global !p
def math():
return vim.eval('vimtex#syntax#in_mathzone()') == '1'
def comment():
return vim.eval('vimtex#syntax#in_comment()') == '1'
def env(name):
[x,y] = vim.eval("vimtex#env#is_inside('" + name + "')")
return x != '0' and x != '0'
endglobal
And then you can use it as follows:
context "env('itemize')"
snippet ...
...
endsnippet
You can also do stuff like this:
context "env('itemize') or env('enumerate')"
etc.
Thank you so much, I was able to incorporate two environments at once ! PS: Such an amazing piece of code !
I am new to vim and all it’s plugins, I have been reading your code. I see you have used vimtex#syntax#in_mathzone() to use it specifically to creat snippets for math environment. I want to ask is there a way to make snippets specific to the “enumerate” environment or”list” since I want to define specific snippets for that particular environment in a similar fashion. Thank you