lervag / vimtex

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

Error: Viewer cannot find Zathura window ID! #1806

Closed Char-Aznable closed 3 years ago

Char-Aznable commented 3 years ago

Issue This error show up in vim when doing a forward search:

vimtex: Viewer cannot find Zathura window ID!

minimal.vim

call plug#begin('~/.vim/plugged')
Plug 'lervag/vimtex'
call plug#end()

let g:tex_flavor = 'latex'
let g:vimtex_view_method = 'zathura'
function! ZathuraHook() abort
  if exists('b:vimtex.viewer.xwin_id') && b:vimtex.viewer.xwin_id <= 0
    silent call system('xdotool windowactivate ' . b:vimtex.viewer.xwin_id . ' --sync')
    silent call system('xdotool windowraise ' . b:vimtex.viewer.xwin_id)
  endif
endfunction

augroup vimrc_vimtex
  autocmd!
  autocmd User VimtexEventView call ZathuraHook()
augroup END

minimal.tex

\documentclass{minimal}
\begin{document}
Hello world!
\end{document}

Commands/Input

  1. vim -u minimal.vim minimal.tex
  2. \ll -- zathura window shows up
  3. \lv -- error shows up (see below) and zathura window is not brought to front

Observed Behaviour This error show up in vim when doing a forward search:

vimtex: Viewer cannot find Zathura window ID!

Expected Behaviour No error shows up.

Output from VimtexInfo

System info
  OS: Ubuntu 18.04.4 LTS
  Vim version: VIM 8.2 (1-1718)
  Has clientserver: true
  Servername: GVIM2

vimtex project: test
  base: test.tex
  root: /home/aznb/papers
  tex: /home/aznb/papers/test.tex
  out: /home/aznb/papers/test.pdf
  log: /home/aznb/papers/test.log
  aux: /home/aznb/papers/test.aux
  fls: /home/aznb/papers/test.fls
  main parser: current file verified
  compiler: latexmk
    configuration: 
      continuous: 1
      callback: 1
      latexmk options:
        -verbose
        -file-line-error
        -synctex=1
        -interaction=nonstopmode
      latexmk engine: -pdf
  viewer: Zathura
    xwin id: 0
  qf: LaTeX logfile
    addqflist: 61
    fix_paths: 62
    set_errorformat: 60
  document class: minimal
lervag commented 3 years ago

I've updated your minimal vimrc: no reason to use the if g:plug... thing.

However: Your specification is incomplete. gvim test.tex is not enough to reproduce. Can you please update your issue with a full specification of the steps required to reproduce? For reference, see #1808 - only in the last post does the reporter specify the required steps, and when they are clear, I can fix or respond properly much faster. This part is important, and I've tried to make this clear in the issue template.

Also, note: this does work as expected for me. I do this:

  1. Create the files specified by you (minimal.vim and mwe.tex).

  2. Open Vim with nvim -u minimal.vim mwe.tex.

  3. Type \ll to compile the document. The viewer is opened.

  4. Type \lv, the forward search is performed as expected.

  5. I close the viewer.

  6. I repeat \lv: the viewer is opened again and forward search is performed as expected.

Char-Aznable commented 3 years ago

Your modified version of minimal.vim gives error:

vimtex: g:tex_flavor not specified
        Please read :help vimtex-tex-flavor!
Char-Aznable commented 3 years ago

I updated the required steps in the OP

Char-Aznable commented 3 years ago

I finally noticed that this bug has something to do with Ubuntu's Wayland window manager. Disabling Wayland makes the error goes away. But I have to use Wayland for a dual monitor setup.

lervag commented 3 years ago

Your modified version of minimal.vim gives error:

vimtex: g:tex_flavor not specified
        Please read :help vimtex-tex-flavor!

Sorry, I forgot to add that option. I've updated the minimal.vim now.

I updated the required steps in the OP

Great, thanks.

I finally noticed that this bug has something to do with Ubuntu's Wayland window manager. Disabling Wayland makes the error goes away. But I have to use Wayland for a dual monitor setup.

Ah, yes. Wayland is not supported for the Zathura compatibility. Sorry! It may be possible to achieve this, but I don't use Wayland and I have too much to do. I'll gladly review and accept a good PR for this. An idea for how to do it was proposed in #1775 (see the linked comment and the following comments).

So, I'm sorry to say I'll close this issue as "won't fix" for now.

lervag commented 3 years ago

There's also ydotool. It might be a way to solve this.

tunahankaratay commented 2 years ago

Any updates on the topic after 1.5 years? Wayland is becoming increasingly popular and most major distributions use it. I like it a lot more as well.

lervag commented 2 years ago

Any updates on the topic after 1.5 years? Wayland is becoming increasingly popular and most major distributions use it. I like it a lot more as well.

As I wrote above:

Ah, yes. Wayland is not supported for the Zathura compatibility. Sorry! It may be possible to achieve this, but I don't use Wayland and I have too much to do. I'll gladly review and accept a good PR for this...

Nothing has changed from my side, sorry. If I were to convert to Wayland myself I would probably fix this. I use Xorg with Fluxbox and don't see any reasons to change. Sorry. So, this means someone else will need to submit a PR. I'll be more than happy to assist.

rafisics commented 3 months ago

I am having the same kind of issue on Ubuntu. The PDF file is not opening after VimTeX compilation.

Using the command xprop and selecting Zathura window, gives me:

_NET_WM_STATE(ATOM) = _NET_WM_STATE_FOCUSED
WM_STATE(WM_STATE):
        window state: Normal
        icon window: 0x0
_NET_WM_DESKTOP(CARDINAL) = 0
_GTK_EDGE_CONSTRAINTS(CARDINAL) = 170
_NET_FRAME_EXTENTS(CARDINAL) = 0, 0, 37, 0
WM_HINTS(WM_HINTS):
        Client accepts input or input focus: True
        Initial state is Normal State.
        bitmap id # to use for icon: 0x4200013
        bitmap id # of mask for icon: 0x420001e
        window id # of group leader: 0x4200001
_GTK_THEME_VARIANT(UTF8_STRING) = 
XdndAware(ATOM) = BITMAP
_NET_WM_OPAQUE_REGION(CARDINAL) = 0, 0, 683, 704
_NET_WM_WINDOW_TYPE(ATOM) = _NET_WM_WINDOW_TYPE_NORMAL
_NET_WM_SYNC_REQUEST_COUNTER(CARDINAL) = 69206021, 69206022
_NET_WM_USER_TIME_WINDOW(WINDOW): window id # 0x4200004
WM_CLIENT_LEADER(WINDOW): window id # 0x4200001
_NET_WM_PID(CARDINAL) = 50002
WM_LOCALE_NAME(STRING) = "en_US.UTF-8"
WM_CLIENT_MACHINE(STRING) = "ubuntu"
WM_NORMAL_HINTS(WM_SIZE_HINTS):
        program specified minimum size: 0 by 0
        program specified base size: 0 by 0
        window gravity: NorthWest
WM_PROTOCOLS(ATOM): protocols  WM_DELETE_WINDOW, WM_TAKE_FOCUS, _NET_WM_PING, _NET_WM_SYNC_REQUEST
WM_CLASS(STRING) = "org.pwmt.zathura", "Zathura"
WM_ICON_NAME(STRING) = "org.pwmt.zathura"
_NET_WM_ICON_NAME(UTF8_STRING) = "org.pwmt.zathura"
WM_NAME(STRING) = "org.pwmt.zathura"
_NET_WM_NAME(UTF8_STRING) = "org.pwmt.zathura"

I am using https://github.com/benbrastmckie/.config and my vimtex.lua file in the directory ~/.config/nvim/lua/neotex/plugins contains:

return {
  "lervag/vimtex",
  init = function()
    vim.g['vimtex_view_method'] = 'zathura'        -- main variant with xdotool (requires X11; not compatible with wayland)
    -- vim.g['vimtex_view_method'] = 'zathura_simple' -- for variant without xdotool to avoid errors in wayland
    vim.g['vimtex_quickfix_mode'] = 0              -- suppress error reporting on save and build
    vim.g['vimtex_mappings_enabled'] = 0           -- Ignore mappings
    vim.g['vimtex_indent_enabled'] = 0             -- Auto Indent
    vim.g['tex_flavor'] = 'latex'                  -- how to read tex files
    vim.g['tex_indent_items'] = 0                  -- turn off enumerate indent
    vim.g['tex_indent_brace'] = 0                  -- turn off brace indent
    vim.g['vimtex_context_pdf_viewer'] = 'okular'  -- external PDF viewer run from vimtex menu command
    vim.g['vimtex_log_ignore'] = ({                -- Error suppression:
      'Underfull',
      'Overfull',
      'specifier changed to',
      'Token not allowed in a PDF string',
    })
  end,
}
lervag commented 3 months ago

@rafisics This issue thread is very old and in my last reply I explained that I won't work on Wayland support for Zathura.

Further, since you are using xprop it seems you are using Xorg and not Wayland, thus this issue is not relevant and it is not the same as your problem. Thus, I strongly advice to open new issues instead of adding a comment to old threads.

I am using https://github.com/benbrastmckie/.config and my vimtex.lua file in the directory ~/.config/nvim/lua/neotex/plugins contains:

You are using someone elses config; that's OK, but you really should read the docs for all the options you use. Some of these options are not relevant and can be removed. I would simplify that config to this:

return {
  "lervag/vimtex",
  init = function()
    vim.g.vimtex_view_method = 'zathura'
    -- vim.g.vimtex_quickfix_mode = 0
    -- vim.g.vimtex_mappings_enabled = 0
    -- vim.g.vimtex_indent_enabled = 0
    -- vim.g.vimtex_context_pdf_viewer = 'okular'
    vim.g.vimtex_log_ignore = ({
      'Underfull',
      'Overfull',
      'specifier changed to',
      'Token not allowed in a PDF string',
    })
  end,
}

I've commented out a few of the options since I believe you might not really want to set them. If you really did, just uncomment them. I've also removed the explanation comments; instead, learn to use the docs: :help vimtex_OPTION-NAME.

Now, for your actual issue, please open a new issue and follow the issue template.