This took me some time to figure out. Works like a charm, VimtexInverseSearch as well as texlab did not work for me.
I use Lunarvim so I haven't try it on vanilla Neovim.
You first need to install the package neovim-remote on your platform.
Then, use the following configuration in your Packer declaration where vimtex is declared:
{
'lervag/vimtex',
ft = { 'tex', 'bib' }, -- for lazy loading
config = function()
vim.cmd("syntax enable")
vim.cmd("let g:vimtex_view_general_viewer='sioyek'")
-- %1: file, %2: line number
local options =
string.format(
'--reuse-window --inverse-search="nvr --servername %s +%%2 %%1" --forward-search-file @tex --forward-search-line @line @pdf',
vim.v.servername)
local command = string.format(
"let g:vimtex_view_general_options='%s'",
options)
vim.cmd(command)
vim.cmd("let g:vimtex_compiler_progname='nvr'")
end,
},You can bind vimtex command VimtexView to a key for forward search. It should jump to the line location in the pdf document.
For backward search, you need to turn on Synctex in Sioyek (I haven't found a way to enable it automatically), e.g., running turn_on_synctex.
After, just right clicking the document will jumps to its source code location.
thanks!