Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Back and forward search is working under wayland without xdotool, but vimtex still complains #2026

Closed
jbuencuerpo opened this issue Apr 7, 2021 · 15 comments

Comments

@jbuencuerpo
Copy link

Issue

The plugin use to fail doing back/forward search in wayland. Now it works (thanks!) However, the plugin complains in wayland about needing xdotool?

VimTeX: Zathura requires xdotool for forward search!

But, surprisingly back and forward search is working. The issue is that it shouldn't complain?

I am happy I can use it in wayland! but also I am confused as it is not mentioned in the README or issues

minimal.vim

set nocompatible
let &runtimepath  = '~/.vim/plugged/vimtex,' . &runtimepath
let &runtimepath .= ',~/.vim/plugged/vimtex/after'
filetype plugin indent on
syntax enable

let g:tex_flavor = 'pdflatex'
let g:vimtex_view_method = 'zathura'

minimal.tex

\documentclass{minimal}
\begin{document}
Hello world!
\newpage
Bye Github!
\end{document}

Commands/Input /
Observed Behaviour
Open the file, vimtex complains about xdotool. Compile it and \lv green region, ctrl+click to reverse search.

Expected Behaviour
Forward/backward search works on wayland (leader v or ctr+click on zathura)

Output from VimtexInfo

System info
  OS: Pop!_OS 20.10
  Vim version: VIM 8.2 (1-716)
  Has clientserver: true
  Servername: VIM1

VimTeX project: minimal
  base: minimal.tex
  root: /home/jero/Documents/Writing/test
  tex: /home/jero/Documents/Writing/test/minimal.tex
  out: /home/jero/Documents/Writing/test/minimal.pdf
  log: /home/jero/Documents/Writing/test/minimal.log
  aux: /home/jero/Documents/Writing/test/minimal.aux
  fls: /home/jero/Documents/Writing/test/minimal.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
    job: process 24557 run
    pid: 24557
    cmd: max_print_line=2000 latexmk -verbose -file-line-error -synctex=1 -interaction=nonstopmode -pdf -pvc -e '$new_viewer_always = "0"' -e '$pdf_previe
  viewer: Zathura
    xwin id: 0
    process: 
      pid: -
      cmd: zathura -x "/usr/bin/vim.gtk3 --servername VIM1 --remote-expr \"vimtex#view#reverse_goto(%{line}, '%{input}')\"" --synctex-forward 1:4:'/home/j
  qf: LaTeX logfile
    root: /home/jero/Documents/Writing/test
    addqflist: 62
    errorformat_saved: 
    fix_paths: 63
    main: /home/jero/Documents/Writing/test/minimal.tex
    set_errorformat: 61
  document class: minimal

Included patches: 1-716

@lervag
Copy link
Owner

lervag commented Apr 8, 2021

The plugin use to fail doing back/forward search in wayland. Now it works (thanks!)

Good to hear it. I don't think this is because of something I did, though.

However, the plugin complains in wayland about needing xdotool?

Yes: xdotool is not used for forward or backward search. It is used to avoid creating unnecessary windows. From :VimtexInfo, you can notice the xwin id property of the viewer. xdotool is used to get this ID and to possibly attach to any existing windows.

For example: If you open a LaTeX file, then do \ll to compile it - latexmk will no automatically open Zathura. When you do \lv, it will typically create a new window. And, at least, backward search will not work in the first window.

minimal.vim

Notice that g:tex_flavor i) is no longer relevant to VimTeX, and ii) that 'pdflatex' is not a valid choice (see :help g:tex_flavor). I recommend to simply delete that line in your config.

@jbuencuerpo
Copy link
Author

For example: If you open a LaTeX file, then do \ll to compile it - latexmk will no automatically open Zathura. When you do \lv, it will typically create a new window. And, at least, backward search will not work in the first window.

No, it creates a window when doing \ll and then \lv highlight/focus (same window). If I press ctrl-click on Zathura's window I do backward search.

I have tested with gnome-terminal and kitty. When using the gnome-terminal I even have the notification that the Zathura window is ready (not-steal focus behavior of gnome), but I don't see new windows.

Maybe is an update on Zathura?

zathura 0.4.7
girara 0.3.5 (runtime: 0.3.5)
(plugin) pdf-poppler (0.3.0) (/usr/lib/x86_64-linux-gnu/zathura/libpdf-poppler.so)

I am not sure if zathura is working through wayland or X11 backend as it complains:

(org.pwmt.zathura:7577): Gdk-CRITICAL **: 08:50:27.005: gdk_wayland_window_set_dbus_properties_libgtk_only: assertion 'GDK_IS_WAYLAND_WINDOW (window)' failed

Do you want me to run another test?

I removed the extra pdflatex line, thanks!

@lervag
Copy link
Owner

lervag commented Apr 8, 2021

So, what you are saying is that: VimTeX + Zathura + Wayland just works on Wayland. I.e., \lv does forward search as expected and backward search (ctrl+click in Zathura) works as expected. And that this holds even if the PDF was opened by latexmk after \ll. Further, there is no "duplicate window" issues?

After looking into the code, I notice a couple of things that will probably be noticable:

  • After doing \ll, I expect you should notice a glitch caused by this code:

    for l:dummy in range(30)
    let l:xwin_exists = self.xwin_exists()
    if l:xwin_exists | break | endif
    sleep 50m
    endfor

    The for loop will execute the sleep statement 30 times, leading to a 1.5 second glitch. The loop is there to detect if Zathura was started by latexmk after \ll and it requires xdotool to work. This glitch should appear everytime the document is finished compiling (from the callback). However, this may be solved by adding let g:vimtex_view_automatic = 0 to your vimrc file. Notice, though, that this will also specify for latexmk to not open the viewer on \ll.

  • If you add let g:vimtex_view_forward_search_on_start = 0 to your vimrc file, then I expect that \ll will create a duplicate window, because this removes the --synctex-forward option for Zathura which I think prevents it from opening a new window. I think it should also make \lv stop working as expected.

So, regarding the issue: It seems it is safe to remove the warning message. I think the message might not be so helpful, and in this case it is clearly just annoying. I've tried to slightly improve the docs instead.

@lervag lervag closed this as completed Apr 8, 2021
lervag added a commit that referenced this issue Apr 8, 2021
@jbuencuerpo
Copy link
Author

jbuencuerpo commented Apr 8, 2021

If I add:

let g:vimtex_view_automatic = 0

backward search (from Zathura to vim) stops working, not what you expected I guess. Without it, it may need 1.5s before highlight the text in Zathura.

If I add

let g:vimtex_view_forward_search_on_start = 0

It opens a new window each time.

@lervag
Copy link
Owner

lervag commented Apr 8, 2021

If I add let g:vimtex_view_forward_search_on_start = 0 It opens a new window each time.

As expected.

If I add: let g:vimtex_view_automatic = 0 backward search (from Zathura to vim) stops working, not what you expected I guess.

Can you explain the steps you perform? Can you also show the viewer section of the :VimtexInfo output? It should show the full zathura command used to open the viewer.

Without it, it may need 1.5s before highlight the text in Zathura.

Yes, so: in a sense, you can say that Zathura works almost as expected as is. But, as I said, if you are working on a document, then saving :w, then the callback may interrupt your workflow due to this 1.5s "glitch".

@jbuencuerpo
Copy link
Author

jbuencuerpo commented Apr 8, 2021

I guess I am not so sensitive of that 1.5s, so if i can be faster, the better.
In the terminal:

vim --servername VIM -u minimal.vim minimal.tex

Then in vim \ll

Then it opens zathura, 1.5 s appears the green line on the line started on vim. Then I ctrl-click on the next page, in zathura. It goes to the next line in vim. Also, the other way.

Trying also \lv highlight in green, without opening other window, if it is behind, gnome gives the window is ready notification (kitty or gnome-terminal).

:VimtexInfo

System info
  OS: Pop!_OS 20.10
  Vim version: VIM 8.2 (1-716)
  Has clientserver: true
  Servername: VIM

VimTeX project: minimal
  base: minimal.tex
  root: /home/jero/Documents/Writing/test
  tex: /home/jero/Documents/Writing/test/minimal.tex
  out: /home/jero/Documents/Writing/test/minimal.pdf
  log: /home/jero/Documents/Writing/test/minimal.log
  aux: /home/jero/Documents/Writing/test/minimal.aux
  fls: /home/jero/Documents/Writing/test/minimal.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
    job: process 28419 run
    pid: 28419
    cmd: max_print_line=2000 latexmk -verbose -file-line-error -synctex=1 -interaction=nonstopmode -pdf -pvc -e '$new_viewer_always = "0"' -e '$pdf_previewer = "zathura  -x \"/usr/bin/vim.gtk3 --servername VIM --remote +\%{line} \%{input}\" \%S"' -e '$success_cmd = "echo vimtex_compiler_callback_success"' -e '$failure_cmd = "echo vimtex_compiler_callback_failure"' 'minimal.tex'
  viewer: Zathura
    xwin id: 0
    process: 
      pid: -
      cmd: zathura -x "/usr/bin/vim.gtk3 --servername VIM --remote-expr \"vimtex#view#reverse_goto(%{line}, '%{input}')\"" --synctex-forward 1:1:'/home/jero/Documents/Writing/test/minimal.tex'  '/home/jero/Documents/Writing/test/minimal.pdf' >/dev/null 2>&1 &
  qf: LaTeX logfile
    root: /home/jero/Documents/Writing/test
    addqflist: 62
    errorformat_saved: 
    fix_paths: 63
    main: /home/jero/Documents/Writing/test/minimal.tex
    set_errorformat: 61
  document class: minimal

@lervag
Copy link
Owner

lervag commented Apr 9, 2021

Ok, thanks. Is there anything more to do or discuss here?

@jbuencuerpo
Copy link
Author

jbuencuerpo commented Apr 9, 2021

I have updated to the latest version, no warning from xdotool, everything is working (only that 1.5s I can live with). So thanks!

lervag added a commit that referenced this issue Apr 9, 2021
@lervag
Copy link
Owner

lervag commented Apr 9, 2021

I've done some refactoring and clean up of the code, and I now also added the option g:vimtex_view_automatic_xwin - if you disable it, the delay should be resolved.

@jbuencuerpo
Copy link
Author

I have tested, and it works, thanks! (awesome plugin by the way)

@lervag
Copy link
Owner

lervag commented Apr 10, 2021

Great, and thanks! :)

@YanniPapandreou
Copy link

Hi, sorry to comment here after this is closed but I have been struggling a lot to get forward and reverse search working on wayland with zathura. I am very new to this so I am probably doing something wrong. I have looked at a lot of the issues mentioning wayland but cannot seem to figure this out. Are there any good guides anywhere?

@lervag
Copy link
Owner

lervag commented Sep 13, 2022

Are there any good guides anywhere?

The documentation is the main guide. Anything else is prone to become outdated. However, there is no content currently specific for Wayland. Still, Zathura should work even without things like xdotool.

Please open a new issue if you want more help. Having more details makes it easier to help you.

@YanniPapandreou
Copy link

Thanks for getting back to me, I will try again and if I still have problems I will open an issue (great plugin btw!)

@lervag
Copy link
Owner

lervag commented Sep 14, 2022

No problem; thanks for the kind words :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants