Vimtex only works sporadically when installed with Lazy
Description
Whenever I open a .tex file in neovim, I get the following error with some probability.
(Note that I am running with lazy = false in the Lazy.nvim config)
Steps to reproduce
- Open a tex file (even new/blank one with ending
.tex).
Expected behavior
The file opens and vimtex runs.
Actual behavior
I get the following error some of the time
Error detected while processing BufReadPost Autocommands for "*":
Error executing lua callback: ...cal/Cellar/neovim/0.10.1/share/nvim/runtime/filetype.lua:35: Error executing lua: ...cal/Cellar/neovim/0.10.1/share/nvim/runtim
e/filetype.lua:36: BufReadPost Autocommands for "*"..FileType Autocommands for "*"..function <SNR>1_LoadFTPlugin[20]..script /Users/neil/.local/share/nvim/lazy/
vimtex/ftplugin/tex.vim[25]..function vimtex#init[7]..<SNR>98_init_state[1]..vimtex#state#init[1]..<SNR>101_get_main[8]..<SNR>101_get_main_from_texroot, line 2:
Vim(let):E121: Undefined variable: g:vimtex#re#tex_input_root
stack traceback:
[C]: in function 'nvim_cmd'
...cal/Cellar/neovim/0.10.1/share/nvim/runtime/filetype.lua:36: in function <...cal/Cellar/neovim/0.10.1/share/nvim/runtime/filetype.lua:35>
[C]: in function 'nvim_buf_call'
...cal/Cellar/neovim/0.10.1/share/nvim/runtime/filetype.lua:35: in function <...cal/Cellar/neovim/0.10.1/share/nvim/runtime/filetype.lua:10>
stack traceback:
[C]: in function 'nvim_buf_call'
...cal/Cellar/neovim/0.10.1/share/nvim/runtime/filetype.lua:35: in function <...cal/Cellar/neovim/0.10.1/share/nvim/runtime/filetype.lua:10>
Press ENTER or type command to continue
Do you use a latexmkrc file?
Yes
VimtexInfo
I can't run VimtexInfo, it says `Not an editor command`
You say it sporadically works, but then you say
I can't run VimtexInfo, it says
Not an editor command
Well, can you run :VimtexInfo and show the output when it works?
VimTeX works well for me and most other people, so I am quite sure the problem is on your side. But I need much more information to be able to help you here. I don't know anything about your system or configuration. :VimtexInfo will tell me some of these details, but I also need to see your config.
Fixed by setting priority = 100 i.e., higher than default, in the vimtex config settings