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

Add simple Zathura viewer alternative #2639

Closed
wants to merge 3 commits into from
Closed

Conversation

lervag
Copy link
Owner

@lervag lervag commented Feb 19, 2023

This PR adds a zathura_simple viewer variant that does not depend on xdotool. This means it should work well on e.g. Wayland (see e.g. #2046).

This is a simpler version of the Zathura viewer that does not depend on
xdotool. It should work better on systems that do not use Xorg, e.g. on
Wayland.

refer: #2046
@lervag lervag mentioned this pull request Feb 19, 2023
@lervag
Copy link
Owner Author

lervag commented Feb 19, 2023

I would be glad to have some users test this on e.g. Wayland. To test:

  • Checkout the fest/zathura-wayland branch of VimTeX.

  • Use the zathura_simple viewer, i.e.:

    let g:vimtex_view_method = 'zathura_simple'

Things to test:

  • Does it generally work?
  • Does synctex work (forward and backward search)?
  • Do you experience interference if you open multiple vim/neovim + VimTeX sessions with multiple Zathura instances?
    • If so, do you experience this even if you have different file names for the source files (e.g. main.tex vs test.tex)?

@gssfaw
Copy link

gssfaw commented Feb 21, 2023

Hello, I want to mention that the default version of plugin was already just working on wayland in my case, i.e. I haven't encountered multiple zathura windows.

I've tried this branch, it also works well: It opens one window after compilation, after recompiling that one window updates. If I close neovim and keep zathura window, then open neovim and compile it again - it will update that zathura window. Synctex is working on the one file projects and on the multiple file projects.

I've also opened two nvim instances with different project compiled and they seem to work fine. Tried with two same test.tex names and with different - works in both cases.

Here is my vimtex config:

local g = vim.g
g.vimtex_view_method = 'zathura_simple'
g.maplocalleader = ","
g.vimtex_syntax_enabled = 0
g.vimtex_syntax_conceal_disable = 1

@lervag
Copy link
Owner Author

lervag commented Feb 21, 2023

Hello, I want to mention that the default version of plugin was already just working on wayland in my case, i.e. I haven't encountered multiple zathura windows.

Ok! Still, the xdotool stuff will make the standard Zathura version less than optimal when xdotool is not available, and I think this simple variant should work better in these cases.

I've tried this branch, it also works well: …

Thanks for testing! I'll wait some more time before I merge this to see if more people will test and provide feedback.

@rrueger
Copy link

rrueger commented Feb 25, 2023

Thank you for continuing to work on this (especially since you don't use Wayland yourself!)

Unfortunately, this doesn't work for me. I am having multiple viewers being opened and search doesn't work (new viewers are opened in the wrong place).

I don't want to speculate too much on why this is the case, but I found that appending

function! s:viewer._exists() dict abort " {{{1
  return v:true
endfunction

" }}}1
function! s:viewer._forward_search(outfile) dict abort " {{{1
  if !self.has_synctex | return | endif

  let l:synctex_file = fnamemodify(a:outfile, ':r') . '.synctex.gz'
  if !filereadable(l:synctex_file) | return | endif

  let self.cmd_forward_search
        \ = vimtex#view#zathura#cmdline(a:outfile, self.has_synctex, 0)

  call vimtex#jobs#run(self.cmd_forward_search)
endfunction

" }}}1

to zathura_simple.vim fixes both issues. It looks to be that s:viewer_exists() is not defined in zathura_simple and therefore a new viewer is opened every time. @lervag even mentioned this in a comment.

When I changed the zathura._exists() function to always return false, then the above will open multiple viewers.

Surprisingly (to me), telling VimTex that a viewer is always open (return v:true) yields the correct behaviour.

This has been tested like my last comment. Opening windows, opening different pdfs etc.

@lervag
Copy link
Owner Author

lervag commented Feb 25, 2023

Unfortunately, this doesn't work for me. I am having multiple viewers being opened and search doesn't work (new viewers are opened in the wrong place).

Strange.

I don't want to speculate too much on why this is the case, but I found that appending …

That shouldn't be necessary. The idea is to never use the forward_search method. But I notice I made a mistake, so I'm pushing a new version that I believe should work. Please update and test again.

It looks to be that s:viewer_exists() is not defined in zathura_simple

Yes, the idea is to always include the forward and inverse search command-line options. Then we don't need anything except the _start() method.

@rrueger
Copy link

rrueger commented Feb 25, 2023

Brilliant, now it works perfectly for me!

Thank you so much for your fast work!

@lervag
Copy link
Owner Author

lervag commented Feb 25, 2023

Cool, thanks for testing and for the useful feedback!

I'll wait for a few more days before I merge this; and I'll add proper documentation of course.

lervag added a commit that referenced this pull request Feb 28, 2023
@lervag lervag closed this Feb 28, 2023
@lervag lervag deleted the feat/zathura-wayland branch February 28, 2023 21:02
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

Successfully merging this pull request may close these issues.

3 participants