-
Notifications
You must be signed in to change notification settings - Fork 407
[Question] Detecting VimTeX Environment with Lua #2501
Description
Description
More of a question than an issue, but I couldn't really find a clear answer through other searches previously and I don't really know where else I can ask. I moved to LuaSnip a while earlier and I want to be able to create environment-dependent snippets. There's a way to do this on Python, but the Lua "translation" doesn't seem to work - snippets just activate regardless of environment.
Original Python:
def env(name):
[x,y] = vim.eval("vimtex#env#is_inside('" + name + "')")
return x != '0' and y != '0'Rough Lua Translation:
local function env(name)
if vim.api.nvim_eval("vimtex#env#is_inside('" .. name .. "')") ~= nil then
return 1
end
return 0
end
local function tikz()
return env("tikzpicture")
endIf someone has more information on the syntax command (if I'm using the right one - I did look at the API reference and it seemed to be outdated but still worked on UltiSnips last I checked) and figuring out what it returns so this can be manipulated for Lua, it would be helpful for things like bullet points in enumerate/itemize or TikZ specific snippets in, that would be really helpful. Thanks!
VimtexInfo
System info:
OS: Linux 5.19.11-arch1-1
Vim version: NVIM v0.7.2
Has clientserver: true
Servername: /tmp/nvimGtE41c/0
VimTeX project: test
base: test.tex
root: /home/revise/Documents/test
tex: /home/revise/Documents/test/test.tex
main parser: current file verified
document class: article
compiler: latexmk
engine: -pdf
options:
-verbose
-file-line-error
-synctex=1
-interaction=nonstopmode
build_dir: out
callback: 1
continuous: 1
executable: latexmk
viewer: General
qf method: LaTeX logfile