`syntax on` in neovim causes zathura to open multiple windows
Description
I know syntax on is redundant in neovim. But when I have it on and I hit \lv to view a document in zathura, it causes a new window to open each time. When I remove syntax on the problem goes away.
Steps to reproduce
minimal init.vim
syntax on
lua require('plugins') -- ~/.config/nvim/lua/plugins.lua
corresponding ~/.config/nvim/lua/plugins.lua:
return require('packer').startup(function(use)
use {'lervag/vimtex',
config = function()
vim.cmd([[
let g:vimtex_view_method = 'zathura'
let g:vimtex_view_general_viewer = 'zathura'
let g:vimtex_view_enabled=1
]])
end
}
end)
minimal tex file compiled with synctex:
\documentclass{article}
\begin{document}
This is our first document here we go!
\end{document}
Expected behavior
syntax on makes plus \lv should just update position in current document.
Actual behavior
syntax on causes a problem, new window is opened with each \lv.
Do you use a latexmkrc file?
No
VimtexInfo
System info:
OS: Linux 5.18.14-arch1-1
Vim version: NVIM v0.7.2
Has clientserver: true
Servername: /tmp/nvimsocket
VimTeX project: example1
base: example1.tex
root: /home/jordan/Documents/latex_learning/latex_beginners_guide
tex: /home/jordan/Documents/latex_learning/latex_beginners_guide/example1.tex
main parser: current file verified
document class: article
compiler: latexmk
engine: -pdf
options:
-verbose
-file-line-error
-synctex=1
-interaction=nonstopmode
callback: 1
continuous: 1
executable: latexmk
viewer: General
job:
pid: -
cmd: zathura '/home/jordan/Documents/latex_learning/latex_beginners_guide/example1.pdf'
qf method: LaTeX logfile
I know
syntax onis redundant in neovim. But when I have it on and I hit\lvto view a document in zathura, it causes a new window to open each time. When I removesyntax onthe problem goes away.
I don't believe syntax on has relevance here.
You use these options:
let g:vimtex_view_method = 'zathura'
let g:vimtex_view_general_viewer = 'zathura'
let g:vimtex_view_enabled=1
However, you should change it to simply this:
let g:vimtex_view_method = 'zathura'
After you do, and after you open a TeX file and do \lv (compile if necessary), can you show me the output of \li again? I'm specifically interested in the viewer: part.
ok I made the changes you requested and the the issue persists.
it seems that it only matters if syntax on is put in the vimrc. typing :syntax on or :syntax off from the command line doesn't change anything. I determined this by deleting all output files (pdf, aux, synctex.gzl, etc), and using \ll and \lv each time to view it several times, but typing :syntax on or :syntax off before and after compiling/ viewing. Maybe I didn't try each order but everything points to the issue being whether syntax on is in the init.vim or not, not fixable by changing the setting while running vim.
worth mentioning that syntax on also turns off the green highlighting at the targeted position in the pdf.
to be explicit here are the files now:
init.vim:
syntax on "adding and removing this line
lua require('plugins') -- ~/.config/nvim/lua/plugins.lua
plugins.lua
return require('packer').startup(function(use)
use {'lervag/vimtex',
config = function()
vim.cmd([[
let g:vimtex_view_method = 'zathura'
]])
end
}
end)
minimal tex file
\documentclass{article}
\begin{document}
This is our first document here we go!
\end{document}
vimtexinfo
System info:
OS: Linux 5.18.14-arch1-1
Vim version: NVIM v0.7.2
Has clientserver: true
Servername: /tmp/nvimsocket
VimTeX project: example1
base: example1.tex
root: /home/jordan/Documents/latex_learning/latex_beginners_guide
tex: /home/jordan/Documents/latex_learning/latex_beginners_guide/example1.tex
main parser: current file verified
document class: article
compiler: latexmk
engine: -pdf
options:
-verbose
-file-line-error
-synctex=1
-interaction=nonstopmode
callback: 1
continuous: 1
executable: latexmk
viewer: General
qf method: LaTeX logfile
I believe the problem is in the configuration. Try and move the VimTeX config out of the packer init, e.g. into your init.vim or init.lua or similar. You could even do it as simple as this:
return require('packer').startup(function(use)
use 'lervag/vimtex'
end)
-- VimTeX config
vim.g.vimtex_view_method = 'zathura'
To be more explicit; I believe the config function from packer executes too late. Options for VimTeX must be specified before VimTeX is initialized in a buffer. For some reason, it seems the config function executes at the wrong time.
Made the above change. Including/excluding syntax on still causes/solves the problem respectively, but for some reason it's worse now; the toggling makes vimtex ignore the choice of viewer and use the firefox pdf viewer (both for the minimal config you suggest and my previous minimal configs). This is not a huge issue for me because I have the solution. Just thought you should know about this behavior!
Also thanks for making a great package!
Ok. Then we have to take a full step back. Instead of using your current configuration, we now use an actual minimal configuration (as specified in the issue template).
Create a file init.vim with the following content in the same directory as the minimal test.tex:
set nocompatible
set runtimepath^=~/.local/plugged/vimtex
set runtimepath+=~/.local/plugged/vimtex/after
filetype plugin indent on
syntax enable
let g:vimtex_view_method = 'zathura'
Change the runtimepath paths to the one on your system. I.e., the path where vimtex is downloaded by packer.
Now do nvim --clean -u init.vim test.tex. Let me know if this works as expected (I believe it should).
Also thanks for making a great package!
My pleasure; I'm glad you like it!
ok it works now with your suggestion. good to know about the option --clean
If I modify your suggested vimrc so that there is no filetype plugin indent on but syntax enable is there, the problems I describe start again, but if I delete both lines, things work as expected. if only filetype plugin indent on is there , things work fine too. if the order of syntax on and filetype plugin indent on is reversed, the problems also start again, which was the problem in my main setup. reversing this order also in my main config also affects whether my mapping for localleader space used by vimtex; it is still set by neovim ;:let maplocalleader outputs it to the command line; vimtex just doesn't use it. but the localleader thing merits opening a second issue if I want to pursue it.
I might be missing something here because I am still beginner/intermediate at neovim.
ok it works now with your suggestion. good to know about the option
--clean
In case you didn't notice (you probably did): the --clean option is (more or less) only useful for debugging and testing.
If I modify your suggested vimrc so that there is no
filetype plugin indent onbutsyntax enableis there, the problems I describe start again,
If I do that, on my end, things still work exactly as expected.
but if I delete both lines, things work as expected.
If you delete both lines, then, on neovim nightly, VimTeX will not be loaded at all. You need one of these lines. I'm not really sure exactly what is happening, but I regard these things as not really a problem, because most people/everyone wants these lines. Most plugin managers add them for you automatically, so you may see a lot of config examples where people don't have them explicitly.
if only
filetype plugin indent onis there , things work fine too.
For me as well.
if the order of
syntax onandfiletype plugin indent onis reversed, the problems also start again, which was the problem in my main setup.
For me, it works as expected.
reversing this order also in my main config also affects whether my mapping for localleader space used by vimtex; it is still set by neovim ;
:let maplocalleaderoutputs it to the command line; vimtex just doesn't use it. but the localleader thing merits opening a second issue if I want to pursue it.
Yes, feel free to open an issue. Notice, though, that I can't reproduce this problem either! Reversing the filetype and syntax lines do not change anything on my side.
I might be missing something here because I am still beginner/intermediate at neovim.
I believe the issues you are describing are all mostly with your configuration. I don't mind looking into them, but it is hard without a reproducible example. :\
If you have your config on github, feel free to share the full repo with me. I could try and understand what is happening...