lervag / vimtex

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

Neovim and Zathura: no inverse search #2876

Closed Tyrn closed 9 months ago

Tyrn commented 9 months ago

Description

With Neovim (AstroNvim) I have forward search, but not the inverse one. My ~/.latexmkrc:

$pdf_mode = 1;
$pdflatex = 'xelatex -interaction=nonstopmode -synctex=1';

~/.config/nvim/lua/user/plugins/vimtex.lua:

return {
  -- VImTex configuration
  {
    "lervag/vimtex",
    init = function()
      vim.g.tex_flavor = "latex"
      vim.g.vimtex_view_method = "zathura"
      -- :wvim.g.vimtex_view_general_viewer = "zathura"
      -- vim.g.vimtex_view_general_options = "--unique file:@pdf#src:@line@tex"
      -- vim.g.vimtex_view_general_options_latexmk = '--unique'
      -- vim.g.vimtex_compiler_progname = "nvr"
      vim.g.vimtex_compiler_method = "latexmk"
      vim.g.vimtex_compiler_latexmk = {
        background = 1,
        continuous = 1,
      }
    end,
    event = "BufRead",
    keys = { ... }
  },
}

~/.config/zathura/zathurarc is empty now; I tried to put a lot of things from somebody's else configs, but to no effect whatever.

What I can tell:

  1. Okular solution works, including the inverse search.
  2. With Zathura forward search works, whatever changes I try.
  3. :VimtexInfo shows exactly what one should expect, I suppose.
  4. For unsuccessful inverse search with Zathura I use Ctrl+Left Click.

What else should I check?

Steps to reproduce

No response

Expected behavior

No response

Actual behavior

No response

Do you use a latexmkrc file?

Yes

VimtexInfo

compiler: latexmk
    engine: -pdf
    options:
      -verbose
      -file-line-error
      -synctex=1
      -interaction=nonstopmode
    callback: 1
    continuous: 1
    executable: latexmk
    job: 
      jobid: 5
      output: /tmp/nvim.alexey/8GLyzq/0
      cmd: max_print_line=2000 latexmk -verbose -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"' 'main-keenan-breaking-out.tex'
      pid: 371638
  viewer: Zathura
    xwin id: 10485763
    cmd_forward_search: zathura --synctex-forward 70:25:'/home/alexey/spaces/text/spanish-notes/09-snappy-answers.tex' 'main-keenan-breaking-out.pdf'&
    cmd_start: zathura  -x "/usr/bin/nvim --headless -c \"VimtexInverseSearch %{line} '%{input}'\"" --synctex-forward 10:22:'/home/alexey/spaces/text/spanish-notes/main-keenan-breaking-out.tex' 'main-keenan-breaking-out.pdf'&
  qf method: LaTeX logfile
lervag commented 9 months ago

Please remove this line:

    event = "BufRead",
lervag commented 9 months ago

You should not lazy load VimTeX (or any plugin, really, if you don't know what you are doing!). I've tried to make it clear in the README, here: https://github.com/lervag/vimtex/blob/fe20ab1bd82a23441ac55054afefcd60001947a2/README.md?plain=1#L64-L69.

Tyrn commented 9 months ago

Yes, it occurred to me. I tried to remove event = "BufRead", it just disconnected everything. Seconds ago, I added lazy=false, and it helped.

return {
  -- VImTex configuration
  {
    "lervag/vimtex",
    lazy = false,
    init = function()
      vim.g.tex_flavor = "latex"
      vim.g.vimtex_view_method = "zathura"
...

Is it good and proper?

lervag commented 9 months ago

Ah, yes, that looks good. lazy.nvim does not have lazy = true by default, though, so either this is set to default by your distro or you did so yourself. So, again, be warned that you should know what you are doing when you lazy load plugins. ;)