Zathura synctex inverse search not working
Description
Basically, I don't have inverse search working in Zathura (version 0.5.2 with mupdf backend).
I am honestly quite stumped, and I swear this feature used to work, and broke down somewhere along the many updates etc. I also have coc-vimtex installed but don't think it has anything to do with this.
Here is the relevant config in my vimrc:
let g:tex_flavor = "latex"
let g:vimtex_view_method = 'zathura'
let g:vimtex_view_forward_search_on_start = 0
let g:vimtex_compiler_method = 'latexmk'
let g:vimtex_quickfix_open_on_warning = 0
let g:vimtex_imaps_enabled = 1
let g:vimtex_imaps_leader = ';'
let g:vimtex_compiler_latexmk = {
\ 'backend' : 'nvim',
\ 'background' : 1,
\ 'build_dir' : '',
\ 'callback' : 1,
\ 'continuous' : 1,
\ 'executable' : 'latexmk',
\ 'hooks' : [],
\ 'options' : [
\ '-verbose',
\ '-emulate-aux-dir',
\ '-f',
\ '-file-line-error',
\ '-synctex=1',
\ '-interaction=nonstopmode',
\ ],
\}
My latexmkrc contains the following:
$pdf_mode = 1;
$clean_ext = 'bbl synctex.gz';
I also tried looking through similar issues, but didn't find anything that worked.
Am I missing a setting or a very silly thing somewhere in my config? I suppose I am under the impression that synctex should just work out of the box. I have also checked that Zathura is installed (and linked) to libsynctex which is responsible for synctex integration, and of course, forward search works without any issues.
I haven't uploaded the minimal vimrc yet, but I will gladly do if nothing seems immediately off with my current setup.
Steps to reproduce
No response
Expected behavior
No response
Actual behavior
No response
Do you use a latexmkrc file?
Yes
VimtexInfo
System info:
OS: Ubuntu 22.04.2 LTS
LaTeX version: pdfTeX 3.141592653-2.6-1.40.22 (TeX Live 2022/dev/Debian)
Vim version: NVIM v0.11.0
Has clientserver: true
Servername: /run/user/1000/nvim.150458.0
$PATH:
- /bin
- /home/amanjitsk/.local/bin
- /home/amanjitsk/.local/bin/i3ipc
- /home/amanjitsk/.local/bin/i3ipc/i3-focus
- /home/amanjitsk/.local/bin/i3ipc/i3-focus/tools
- /home/amanjitsk/.local/bin/rofi-menus
- /home/amanjitsk/.local/bin/utils
- /home/amanjitsk/.local/bin/xutils
- /home/amanjitsk/.local/cargo/bin
- /home/amanjitsk/.local/go/bin
- /home/amanjitsk/.local/pyenv/bin
- /sbin
- /snap/bin
- /usr/bin
- /usr/games
- /usr/local/bin
- /usr/local/games
- /usr/local/sbin
- /usr/sbin
VimTeX project: bw
base: bw.tex
root: /home/amanjitsk/Projects/applications
tex: /home/amanjitsk/Projects/applications/bw.tex
main parser: current file verified
document class: article
packages: afterpage algorithm2e algorithmic amsbsy amscd amsfonts amsgen amsmath amsopn amssymb amstext amsthm appendix array arxiv atbegshi atbegshi-ltx atveryend atveryend-ltx auxhook babel bbm bigintcalc bitset bm bookmark booktabs calc cancel caption caption3 cleveref color datatool-base datatool-fp defpattern derivative dsfont empheq enumitem environ epsfig epstopdf epstopdf-base esdiff etexcmds etoolbox expl3 fancyvrb floatrow fontenc fp fp-addons fp-basic fp-eqn fp-eval fp-exp fp-pas fp-random fp-snap fp-trigo fp-upn fr-longtable framed geometry gettitlestring glossaries glossaries-compatible-307 glossary-hypernav glossary-list glossary-long glossary-super glossary-tree graphics graphicx grfext hycolor hyperref hyphenat ifoddpage iftex ifthen ifvtex infwarerr inputenc intcalc keyval kvdefinekeys kvoptions kvsetkeys l3keys2e letltxmacro lineno listings longtable lstmisc ltcaption ltxcmds makecell mathbbol mathrsfs mathtools mdframed mfirstuc mhsetup microtype minted nameref natbib needspace nicefrac parskip pdfescape pdftexcmds pgf pgfcalendar pgfcomp-version-0-65 pgfcomp-version-1-18 pgfcore pgffor pgfkeys pgfmath pgfplots pgfrcs pgfsys psfrag pythontex ragged2e refcount relsize rerunfilecheck rotating scalefnt scalerel siunitx subcaption substr supertabular tensor textcase tikz tikz-dependency tracklang translations translator trig trimspaces ulem uniquecounter url wrapfig xcolor xfor xkeyval xparse xspace zref-abspage zref-base
source files:
bw.tex
preamble.tex
compiler: latexmk
engine: -pdf
options:
-verbose
-emulate-aux-dir
-f
-file-line-error
-synctex=1
-interaction=nonstopmode
callback: 1
continuous: 1
executable: latexmk
job:
jobid: 55
output: /tmp/nvim.amanjitsk/5tYUaV/6
cmd: max_print_line=2000 latexmk -verbose -emulate-aux-dir -f -file-line-error -synctex=1 -interaction=nonstopmode -pdf -pvc -pvctimeout- -view=none -e '$compiling_cmd = ($compiling_cmd ? $compiling_cmd . " ; " : "") . "echo vimtex_compiler_callback_compiling"' -e '$success_cmd = ($success_cmd ? $success_cmd . " ; " : "") . "echo vimtex_compiler_callback_success"' -e '$failure_cmd = ($failure_cmd ? $failure_cmd . " ; " : "") . "echo vimtex_compiler_callback_failure"' 'bw.tex'
pid: 154737
viewer: Zathura
xwin id: 65011715
cmd_forward_search: zathura --synctex-forward 1058:8:'/home/amanjitsk/Projects/IEEE/applications/bw.tex' 'bw.pdf'&
cmd_start: zathura -x "/tmp/.mount_nvimEfNFjD/usr/bin/nvim --headless -c \"VimtexInverseSearch %{line}:%{column} '%{input}'\"" 'bw.pdf'&
qf method: LaTeX logfile
Basically, I don't have inverse search working in Zathura (version
0.5.2withmupdfbackend).
I am honestly quite stumped, and I swear this feature used to work, and broke down somewhere along the many updates etc.
That's strange. There's no change in VimTeX that should break this, unless you update so rarely that there were breaking changes that you didn't notice.
Here is the relevant config in my vimrc: …
Here's a cleaned up version. Notice that g:tex_flavor is not necessary. Also, I don't understand why you would want to add the -f option. The interaction=nonstopmode should suffice. If you have a lot of errors in your document you really should fix them.
let g:vimtex_view_method = 'zathura'
let g:vimtex_view_forward_search_on_start = 0
let g:vimtex_quickfix_open_on_warning = 0
let g:vimtex_imaps_leader = ';'
let g:vimtex_compiler_latexmk = {
\ 'options' : [
\ '-verbose',
\ '-emulate-aux-dir',
\ '-file-line-error',
\ '-synctex=1',
\ '-interaction=nonstopmode',
\ ],
\}
My
latexmkrccontains the following: …
Seems fine!
But ok, from :VimtexInfo I notice this:
cmd_start: zathura -x "/tmp/.mount_nvimEfNFjD/usr/bin/nvim --headless -c \"VimtexInverseSearch %{line}:%{column} '%{input}'\"" 'bw.pdf'&
Specifically, the path to the neovim executable seems somewhat strange. Perhaps it is not a problem, but I would definitely try running that specific command in your terminal at /home/amanjitsk/Projects/applications. Ensure you also have a neovim open with bw.tex in a buffer and then try the inverse search. Does the terminal started Zathura give any useful output/errors/warnings?
Finally, a common gotcha: Ensure that your neovim config does not lazy load VimTeX!
AHHH so when I run the command as above
zathura -x "/tmp/.mount_nvimEfNFjD/usr/bin/nvim --headless -c \"VimtexInverseSearch %{line}:%{column} '%{input}'\"" 'bw.pdf'&
the inverse synctex does work! But it just does not work when it is launched by vimtex (or using :VimtexView) - what do you think could be causing this pathology ? Is there a way to check the program (zathura in this case) launch logs from within vimtex?
I also noticed the weird path to the neovim binary, but my neovim is at $HOME/.local/bin/nvim - could this potentially be an appimage thing (I use the appimage binary from the github-releases)? And it generates a new location/path for each new neovim instance I open.
AHHH so when I run the command as above
zathura -x "/tmp/.mount_nvimEfNFjD/usr/bin/nvim --headless -c \"VimtexInverseSearch %{line}:%{column} '%{input}'\"" 'bw.pdf'&the inverse synctex does work! …
I also noticed the weird path to the neovim binary, but my neovim is at
$HOME/.local/bin/nvim
But why is neovim both at this location and at the /tmp/.mount... location? In any case, perhaps it helps if you specify the g:vimtex_callback_progpath variable, e.g.
let g:vimtex_callback_progpath = "$HOME/.local/bin/nvim"
Even with this setting, it doesn't work: I added
let g:vimtex_callback_progpath = "$HOME/.local/bin/nvim"
and now :VimtexInfo reads
System info:
OS: Ubuntu 22.04.3 LTS
LaTeX version: pdfTeX 3.141592653-2.6-1.40.22 (TeX Live 2022/dev/Debian)
Vim version: NVIM v0.11.1
Has clientserver: true
Servername: /run/user/10246/nvim.223571.0
$PATH:
- /bin
- /h/amanjitsk/.local/bin
- /h/amanjitsk/.local/bin/cpdfd_bin
- /h/amanjitsk/.local/bin/i3ipc
- /h/amanjitsk/.local/bin/rofi-menus
- /h/amanjitsk/.local/bin/utils
- /h/amanjitsk/.local/bin/utils/OneDrive
- /h/amanjitsk/.local/bin/utils/OneDrive/Share
- /h/amanjitsk/.local/bin/utils/OneDrive/Share/papis-cache
- /h/amanjitsk/.local/bin/utils/OneDrive/Share/papis-cache/database
- /h/amanjitsk/.local/bin/xutils
- /h/amanjitsk/.local/cargo/bin
- /h/amanjitsk/.local/go/bin
- /h/amanjitsk/.local/pyenv/bin
- /sbin
- /snap/bin
- /usr/bin
- /usr/games
- /usr/local/bin
- /usr/local/games
- /usr/local/sbin
- /usr/sbin
VimTeX project: bw
base: bw.tex
root: /fs1/home/amanjitsk/Projects/applications
tex: /fs1/home/amanjitsk/Projects/applications/bw.tex
main parser: current file verified
document class: article
packages: afterpage algorithm2e algorithmic amsbsy amscd amsfonts amsgen amsmath amsopn amssymb amstext amsthm appendix array arxiv atbegshi atbegshi-ltx atveryend atveryend-ltx auxhook babel bbm bigintcalc bitset bm bookmark booktabs calc cancel caption caption3 cleveref color datatool-base datatool-fp defpattern derivative dsfont empheq enumitem environ epsfig epstopdf epstopdf-base esdiff etexcmds etoolbox expl3 fancyvrb floatrow fontenc fp fp-addons fp-basic fp-eqn fp-eval fp-exp fp-pas fp-random fp-snap fp-trigo fp-upn fr-longtable framed geometry gettitlestring glossaries glossaries-compatible-307 glossary-hypernav glossary-list glossary-long glossary-super glossary-tree graphics graphicx grfext hycolor hyperref hyphenat ifoddpage iftex ifthen ifvtex infwarerr inputenc intcalc keyval kvdefinekeys kvoptions kvsetkeys l3keys2e letltxmacro lineno listings longtable lstmisc ltcaption ltxcmds makecell mathbbol mathrsfs mathtools mdframed mfirstuc mhsetup microtype minted nameref natbib needspace nicefrac parskip pdfescape pdftexcmds pgf pgfcalendar pgfcomp-version-0-65 pgfcomp-version-1-18 pgfcore pgffor pgfkeys pgfmath pgfplots pgfrcs pgfsys psfrag pythontex ragged2e refcount relsize rerunfilecheck rotating scalefnt scalerel siunitx subcaption substr supertabular tensor textcase tikz tikz-dependency tracklang translations translator trig trimspaces ulem uniquecounter url wrapfig xcolor xfor xkeyval xparse xspace zref-abspage zref-base
source files:
bw.tex
preamble.tex
compiler: latexmk
engine: -pdf
options:
-verbose
-emulate-aux-dir
-file-line-error
-synctex=1
-interaction=nonstopmode
callback: 1
continuous: 1
executable: latexmk
job:
jobid: 30
output: /tmp/nvim.amanjitsk/72qk86/6
cmd: max_print_line=2000 latexmk -verbose -emulate-aux-dir -file-line-error -synctex=1 -interaction=nonstopmode -pdf -pvc -pvctimeout- -view=none -e '$compiling_cmd = ($compiling_cmd ? $compiling_cmd . " ; " : "") . "echo vimtex_compiler_callback_compiling"' -e '$success_cmd = ($success_cmd ? $success_cmd . " ; " : "") . "echo vimtex_compiler_callback_success"' -e '$failure_cmd = ($failure_cmd ? $failure_cmd . " ; " : "") . "echo vimtex_compiler_callback_failure"' 'bw.tex'
pid: 224205
viewer: Zathura
xwin id: 71303171
cmd_start: zathura -x "$HOME/.local/bin/nvim --headless -c \"VimtexInverseSearch %{line}:%{column} '%{input}'\"" 'bw.pdf'&
qf method: LaTeX logfile
And it literally again works if I run this command in a terminal, just does not work "automatically" with vimtex (When first compiling, or using :VimtexView). Again, it would help if I could access vimtex logs to see what happens when I try to ctrl+left_click on the zathura instance. But this is honestly quite surprising ...
I agree it is very surprising. And sorry, no, there is no log for the zathura output when it is started by VimTeX.
Can you confirm that, when you are testing now, you do not have any existing Zathura windows open first?
It seems like we should go for the minimal example here. On my end, everything works as expected. Thus, please provide a test.vim file and a test.tex file, as well as the steps to reproduce the problem. It would make it easier to rule out things and possibly to find the problem here.
Can you confirm that, when you are testing now, you do not have any existing Zathura windows open first?
I do in fact have zathura windows open, but they don't contain instances of the file I am trying to work synctex with.
Thanks for the help! What goes in the test.vim file? Is it just a bare-bones vimrc?
You can use test files like this:
" test.vim
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'
let g:vimtex_view_forward_search_on_start = 0
let g:vimtex_quickfix_open_on_warning = 0
let g:vimtex_imaps_leader = ';'
let g:vimtex_compiler_latexmk = {
\ 'options' : [
\ '-verbose',
\ '-emulate-aux-dir',
\ '-file-line-error',
\ '-synctex=1',
\ '-interaction=nonstopmode',
\ ],
\}
and
% test.tex
\documentclass{minimal}
\begin{document}
Hello World!
\end{document}
Ensure that the runtimepath has the correct path to VimTeX (it is probably not the right one in my example).
Create a temporary folder for these files, then run nvim --clean -u test.vim test.tex to start Vim and VimTeX with the minimal config and example.
Welp, the minimal config does work as expected! Which means this is probably to do with my config somewhere, just don't know where possibly it could be coming from.
I'm glad to hear that!
A common issue with configs: are you lazy loading VimTeX somehow?
I am just using vim-plug and have it setup as
Plug 'lervag/vimtex'
Is that lazy-loading?
Nope, that looks fine.