lervag / vimtex

VimTeX: A modern Vim and neovim filetype plugin for LaTeX files.
MIT License
5.45k stars 388 forks source link

Cannot call zathura from vimtex #2955

Closed CCandle closed 4 months ago

CCandle commented 4 months ago

Description

I use zathura as vimtex viewer, but zathura won't open while press '\lv'.

Steps to reproduce

According to other issues, I'd tried to run

zathura  -x "/opt/homebrew/Cellar/neovim/0.9.0/bin/nvim --headless -c \"VimtexInverseSearch %{line} '%{input}'\"" --synctex-forward 4:14:'/Users/ccandle/Coding/LaTeX/minimal/minimal.tex' 'build/minimal.pdf'&

and it returned

error: Could not connect to session bus: Could not connect: No such file or directory
error: Got no usable data from SyncTeX or D-Bus failed in some way.

[1]  + 19760 exit 255   zathura -x  --synctex-forward  'build/main.pdf'

But if I remove the '--synctex-forward' option, run

zathura  -x "/opt/homebrew/Cellar/neovim/0.9.0/bin/nvim --headless -c \"VimtexInverseSearch %{line} '%{input}'\"" 'build/minimal.pdf'&

the zathura will open, and obviously the sync function can't work.

nvim calls 'plugins.vim' and the vimtex part is

let g:tex_flavor = 'latex'
let g:vimtex_view_method = 'zathura'
let g:vimtex_quickfix_mode = 0
let g:vimtex_quickfix_ignore_filters = [
      \ 'Underfull',
      \ 'Overfull'
      \ ]
let g:vimtex_compiler_latexmk_engines = {'_' : '-xelatex'}
let g:vimtex_compiler_latexmk = {
      \ 'build_dir': 'build',
      \ 'callback' : 1,
      \ 'continuous' : 1,
      \ 'executable' : 'latexmk',
      \ 'hooks' : [],
      \ 'options' : [
      \   '-verbose',
      \   '-file-line-error',
      \   '-shell-escape',
      \   '-synctex=1',
      \   '-interaction=nonstopmode',
      \ ],
      \}
let g:maplocalleader=' '
let g:view_enable=1
let g:view_automatic=1
let g:vimtex_texcount_custom_arg = '-ch -total'

Expected behavior

zathura open with sync function.

Actual behavior

zathura cannot open from vimtex.

Do you use a latexmkrc file?

No

VimtexInfo

System info:
  OS: macOS 13.4 (22F66)
  Vim version: NVIM v0.9.0
  Has clientserver: true
  Servername: /var/folders/b6/m07vnt4d0mz87_00d_h5k_4c0000gn/T/nvim.ccandle/xklptI/nvim.20181.0

VimTeX project: minimal
  base: minimal.tex
  root: /Users/ccandle/Coding/LaTeX/minimal
  tex: /Users/ccandle/Coding/LaTeX/minimal/minimal.tex
  main parser: fallback current file
  document class: 
  compiler: latexmk
    engine: -xelatex
    options:
      -verbose
      -file-line-error
      -shell-escape
      -synctex=1
      -interaction=nonstopmode
    build_dir: build
    callback: 1
    continuous: 1
    executable: latexmk
    job: 
      jobid: 10
      output: /var/folders/b6/m07vnt4d0mz87_00d_h5k_4c0000gn/T/nvim.ccandle/xklptI/0
      cmd: max_print_line=2000 latexmk -verbose -file-line-error -shell-escape -synctex=1 -interaction=nonstopmode -xelatex -outdir=build -pvc -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"' 'minimal.tex'
      pid: 20200
  viewer: Zathura
    xwin id: 0
    cmd_start: zathura  -x "/opt/homebrew/Cellar/neovim/0.9.0/bin/nvim --headless -c \"VimtexInverseSearch %{line} '%{input}'\"" --synctex-forward 4:14:'/Users/ccandle/Coding/LaTeX/minimal/minimal.tex' 'build/minimal.pdf'&
  qf method: LaTeX logfile
CCandle commented 4 months ago

By the way, it's nothing todo with the build_dir. Things will go the same if I set 'build_dir': ''.

lervag commented 4 months ago

I use zathura as vimtex viewer, but zathura won't open while press '\lv'.

Since you are on MacOS, you could also use Skim. It is known to work well.

According to other issues, I'd tried to run

zathura  -x "/opt/homebrew/Cellar/neovim/0.9.0/bin/nvim --headless -c \"VimtexInverseSearch %{line} '%{input}'\"" --synctex-forward 4:14:'/Users/ccandle/Coding/LaTeX/minimal/minimal.tex' 'build/minimal.pdf'&

and it returned

error: Could not connect to session bus: Could not connect: No such file or directory
error: Got no usable data from SyncTeX or D-Bus failed in some way.

[1]  + 19760 exit 255   zathura -x  --synctex-forward  'build/main.pdf'

Please read :help vimtex-view-zathura, then :help vimtex-faq-zathura-macos. If that section can not help you, then I don't have any further ideas. Sorry!

nvim calls 'plugins.vim' and the vimtex part is …

let g:tex_flavor = 'latex'
let g:vimtex_view_method = 'zathura'
let g:vimtex_quickfix_mode = 0
let g:vimtex_quickfix_ignore_filters = [
      \ 'Underfull',
      \ 'Overfull'
      \ ]
let g:vimtex_compiler_latexmk_engines = {'_' : '-xelatex'}
let g:vimtex_compiler_latexmk = {
      \ 'build_dir': 'build',
      \ 'callback' : 1,
      \ 'continuous' : 1,
      \ 'executable' : 'latexmk',
      \ 'hooks' : [],
      \ 'options' : [
      \   '-verbose',
      \   '-file-line-error',
      \   '-shell-escape',
      \   '-synctex=1',
      \   '-interaction=nonstopmode',
      \ ],
      \}
let g:maplocalleader=' '
let g:view_enable=1
let g:view_automatic=1
let g:vimtex_texcount_custom_arg = '-ch -total'

Comments:

Here's a simplified version:

let g:maplocalleader=' '

let g:vimtex_view_method = 'zathura'
let g:vimtex_quickfix_mode = 0
let g:vimtex_quickfix_ignore_filters = [
      \ 'Underfull',
      \ 'Overfull'
      \ ]
let g:vimtex_compiler_latexmk_engines = {'_' : '-xelatex'}
let g:vimtex_compiler_latexmk = {
      \ 'build_dir': 'build',
      \ 'options' : [
      \   '-verbose',
      \   '-file-line-error',
      \   '-shell-escape',
      \   '-synctex=1',
      \   '-interaction=nonstopmode',
      \ ],
      \}
let g:vimtex_texcount_custom_arg = '-ch -total'
CCandle commented 4 months ago

Since you are on MacOS, you could also use Skim. It is known to work well.

Skim works well, but I prefer zathura. Luckily zathura works again after reinstalling the nvim, vimtex and zathura, using the exact same configuration. I guess it's something about file permissions and zathura settings.

Comments:

  • You don't need let g:tex_flavor - remove it.
  • VimTeX options all start with g:vimtex_.
  • maplocalleader is not really a VimTeX option, it is a Vim/Neovim specific thing. You should not have that as part of the VimTeX config.
  • You can simplify things.

Here's a simplified version:

...

Thanks for your guiding, it's really helpful for me as a beginner. I tried modifying other people's tutorials online, which maybe messed up vimtex.

lervag commented 4 months ago

Great, glad to hear it works now! I'll close the issue then.