- In a script called 'vimura':
#!/bin/sh
echo $1
zathura -s -x "gvim --servername $1 -c \"let g:syncpdf='$1'\" --remote +%{line} %{input}" $*
For zathura >= 0.3.2 remove -s
.
- In your vimrc:
function! Synctex()
" remove 'silent' for debugging
execute "silent !zathura --synctex-forward " . line('.') . ":" . col('.') . ":" . bufname('%') . " " . g:syncpdf
endfunction
map <C-enter> :call Synctex()<cr>
- Build your latex doc with synctex enabled
pdflatex -synctex=1 ...
-
Open PDF with vimura script.
-
CTRL+Click
in Zathura jumps to source in vim. -
CTRL+Enter
in vim jumps to corresponding position in PDF.
The answer by @perelo led me to the following
latex.vim
snippet for my nvim configuration:I would love to hook in any motion to automatically call the function (which by some miracle doesn't reopen a new process, unless it's not open yet), but only if I already opened Zathura manually. Any ideas on how to do this? Having one function to only open Zathura (which I thought I had), and one to re-sync the position sounds like the ideal solution.
As a note, I had misconfigured texlab (getting
cmd ["texlab"] is not executable
errors), causing me to have to press enter after pressing Ctrl+Click in Zathura. I disabled the LSP server for texlab, and synctex works without any problem. I still need to clean up the LSP. Regardless, is there some way of "ignoring" this error message, or appending a<cr>
keypress throughnvr
?