Closed firubat closed 1 week ago
If I open a neovim session, load a .tex file and compile it, (with default
<localleader>ll
) it gets compiled and viewed, but synctex doesn't work (no backward or forward search).
Ok, that's strange.
I use the LazyVim distro, a minimal configuration for vimtex is with the following lua: …
Well, this feels like a bad suggested configuration. And I believe it may be the reason things don't work well for you.
First, why did you add the FileType
autocommand? It is not suggested in the LazyVim config and it does not make sense. I also notice that LazyVim suggests the config
function, but you should use the init
function.
So, please try the following config instead:
return {
{
"lervag/vimtex",
lazy = false,
init = function()
vim.g.vimtex_view_method = "zathura"
end,
},
}
Well seems I was basing my config on an old version of the LazyVim config, which have since then changed without me noticing.
Anyway your config works as expected, thanks!
Great; glad to hear it works now! I made a PR to the LazyVim docs to fix the config
vs init
thing as well. Let's hope that helps other people avoid issues like this in the future.
Actually it works with either config
or init
, but with init
some commands didn't take effect. For example I have this command:
vim.cmd([[highlight Conceal guifg=#9ccfd8]])
which doesn't work with init
but does work with config
. Don't ask me why.
my hypothesis is that with the filetype autocommand, there was some delay in loading the viewer configuration for the first time, so it didn't work.
I can tell you why: With init
, the command will run very early and the highlight will likely be overwritten by your colorscheme. But: You should not add custom highlights like this. I've written about this stuff in :help vimtex-syntax-core
, so I recommend your read that and one or more of the links provided there.
Thanks for the tip, seems I have a lot to read :)
No problem, and yes, unfortunately, there's a lot to read. But I think you can get far by skimming much of it. 😅
Description
If I open a neovim session, load a .tex file and compile it, (with default
<localleader>ll
) it gets compiled and viewed, but synctex doesn't work (no backward or forward search).If I run
VimtexView
another instance of the viewer (zathura) will open (still with no synctex). I tried closing the viewer and usingVimtexView
, tried stopping and resuming compilation, tried closing the buffer and reopening it - all won't get synctex to work, until I reload vimtex (VimtexReload
), after which things start working as expected.If I open a second file (before reloading vimtex) and compile it, synctex will work for that file.
Steps to reproduce
I use the LazyVim distro, a minimal configuration for vimtex is with the following lua:
(I don't use the lang.tex LazyVim Extra)
Expected behavior
No response
Actual behavior
No response
Do you use a latexmkrc file?
No
VimtexInfo