lervag / vimtex

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

WSL2: Viewer cannot find Zathura window ID! #2980

Closed Kaiser-Yang closed 2 months ago

Kaiser-Yang commented 2 months ago

Description

I'm using wsl2 and ubuntu 22.04. When I use :VimtexView to open the viewer, it works well. However, after opening the viewer, when I press j or k to navigate in the neovim. It gives me the information: Viewer cannot find Zathura window ID!

Steps to reproduce

  1. Install vimtex with lazy.nvim
  2. Use the configuration only specifying the viewer

Expected behavior

I can use j and k to scroll up or down.

Actual behavior

Viewer cannot find Zathura window ID!

Do you use a latexmkrc file?

No

VimtexInfo

System info:
  OS: Ubuntu 22.04.4 LTS
  Vim version: NVIM v0.10.0
  Has clientserver: true
  Servername: /run/user/1000//nvim.4380.0

VimTeX project: main
  base: main.tex
  root: /home/kaiser
  tex: /home/kaiser/main.tex
  main parser: current file verified
  document class: article
  packages: amsbsy amsgen amsmath amsopn amstext
  compiler: latexmk
    engine: -pdf
    options:
      -verbose
      -file-line-error
      -synctex=1
      -interaction=nonstopmode
    callback: 1
    continuous: 1
    executable: latexmk
  viewer: Zathura
    xwin id: 0
    cmd_start: zathura  -x "/opt/nvim-linux64/bin/nvim --headless -c \"VimtexInverseSearch %{line} '%{input}'\"" --synctex-forward 30:25:'/home/kaiser/main.tex' 'main.pdf'&
  qf method: LaTeX logfile
Kaiser-Yang commented 2 months ago

I guess it must have something to do with the xdotool: image

Kaiser-Yang commented 2 months ago

BTW, is is possible to toggle the viewer?

Kaiser-Yang commented 2 months ago

lazy.nvim:

'lukas-reineke/cmp-under-comparator',
{
    "micangl/cmp-vimtex",
    config = function() require'plugin_config/cmpvimtex_config' end,
},

cmpvimtex_config.lua:

require('cmp_vimtex').setup({
    -- Eventual options can be specified here.
    -- Check out the tutorial for further details.
})
lervag commented 2 months ago

I'm using wsl2 and ubuntu 22.04. When I use :VimtexView to open the viewer, it works well. However, after opening the viewer, when I press j or k to navigate in the neovim. It gives me the information: Viewer cannot find Zathura window ID!

I guess it must have something to do with the xdotool: …

Yes; that seems right. There's a FAQ entry about this in the docs, see :help vimtex-faq-zathura-windows-wsl.

However, there's also another way to fix this, which is to use the zathura_simple viewer that does not rely on xdotool. This does mean it can spawn multiple windows, but in most cases I don't think that's a big problem.

I can use j and k to scroll up or down.

Well, the message you see should be a "one off" message and it is really unrelated to j and k. The motions should still work as expected, and if not, I believe it must be something else than VimTeX that is causing that particular issue.

lervag commented 2 months ago

BTW, is is possible to toggle the viewer?

What does that mean? You mean open and close from within VimTeX? If so, no.

lazy.nvim: …

cmpvimtex_config.lua: …

I assume this was added to provide info on your configuration. But to be honest, this helps nothing. I think I already provided the necessary info before, but if you should have further or other issues, please provide more detailed info on your config. Most importantly, describe how you install aond configure VimTeX and provide the VimTeX settings you use.

Kaiser-Yang commented 2 months ago

Yes; that seems right. There's a FAQ entry about this in the docs, see :help vimtex-faq-zathura-windows-wsl.

Yes, I've check this part, and I think I've enable the systemd, but it still give me the information, the output of /etc/wsl.conf: image

I can use j and k to scroll up or down.

Well, the message you see should be a "one off" message and it is really unrelated to j and k. The motions should still work as expected, and if not, I believe it must be something else than VimTeX that is causing that particular issue.

The j and k can not make the pdf scroll, but I find that I can use \lv to scroll the pdf to where the cursor in nvim

Kaiser-Yang commented 2 months ago

BTW, is is possible to toggle the viewer?

What does that mean? You mean open and close from within VimTeX? If so, no.

lazy.nvim: …

cmpvimtex_config.lua: …

I assume this was added to provide info on your configuration. But to be honest, this helps nothing. I think I already provided the necessary info before, but if you should have further or other issues, please provide more detailed info on your config. Most importantly, describe how you install aond configure VimTeX and provide the VimTeX settings you use.

Wait a minute, let me make a minimal configurations to reproduce.

Kaiser-Yang commented 2 months ago

I've made a minimal to reproduce my problem, the configurations are available through minimal-vimtex. Just copy the .config directory to reproduce:

image

I use \lv to open the viewer, it is OK, but it will give me the information: Viewer cannot find Zathura window ID!. But I actually can open the viewer.

Kaiser-Yang commented 2 months ago

Well, the message you see should be a "one off" message and it is really unrelated to j and k. The motions should still work as expected, and if not, I believe it must be something else than VimTeX that is causing that particular issue.

It's my bad. What I want to express is to I can make the viewer (the pdf) scroll as I press j or k in nvim? Or is this not suppoted by vimtex naturally, which means I must use \lv to scroll the pdf?

Kaiser-Yang commented 2 months ago

However, there's also another way to fix this, which is to use the zathura_simple viewer that does not rely on xdotool. This does mean it can spawn multiple windows, but in most cases I don't think that's a big problem.

Actually, I've search the information in the issues, and I find the suggestion in some issues, and I've try just update zathura with zathura_simple. But after update, I even cannot use \lv to open the viewer. Here is the information of VimtexInfo:

System info:
  OS: Ubuntu 22.04.4 LTS
  Vim version: NVIM v0.10.0
  Has clientserver: true
  Servername: /run/user/1000//nvim.21514.0

VimTeX project: main
  base: main.tex
  root: /home/kaiser
  tex: /home/kaiser/main.tex
  main parser: current file verified
  document class: article
  packages: amsbsy amsgen amsmath amsopn amstext
  compiler: latexmk
    engine: -pdf
    options:
      -verbose
      -file-line-error
      -synctex=1
      -interaction=nonstopmode
    callback: 1
    continuous: 1
    executable: latexmk
  viewer: Zathura
    cmd_start: zathura  -x "/opt/nvim-linux64/bin/nvim --headless -c \"VimtexInverseSearch %{line} '%{input}'\"" --synctex-forward 2:1:'/home/kaiser/main.tex' 'main.pdf'&
  qf method: LaTeX logfile
lervag commented 2 months ago

Yes, I've check this part, and I think I've enable the systemd, but it still give me the information, the output of /etc/wsl.conf: …

If you've followed that guide and things don't work, then I'm sorry to say I can't really be of much more help on that specific part. I don't use Windows or WSL.

I can use j and k to scroll up or down.

Well, the message you see should be a "one off" message and it is really unrelated to j and k. The motions should still work as expected, and if not, I believe it must be something else than VimTeX that is causing that particular issue.

The j and k can not make the pdf scroll, but I find that I can use \ll to scroll the pdf to where the cursor in nvim

Well, the message you see should be a "one off" message and it is really unrelated to j and k. The motions should still work as expected, and if not, I believe it must be something else than VimTeX that is causing that particular issue.

It's my bad. What I want to express is to I can make the viewer (the pdf) scroll as I press j or k in nvim? Or is this not suppoted by vimtex naturally, which means I must use \lv to scroll the pdf?

Ah; well, if you have neovim focused, you can use \lv to do a forward sync that will scroll the pdf to the location you are inside neovim. But to scroll the pdf, you will need to change focus to Zathura. Within Zathura, I think j and k should scroll, last time I checked.

I've made a minimal configuration to reproduce my problem, the configurations are available through minimal-vimtex. Just copy the .config directory to reproduce:

To be honest, this is really NOT a minimal configuration. A minimal configuration and example looks like this:

-- test.lua
vim.opt.rtp:prepend(vim.fn.stdpath("data") .. "/lazy/vimtex")
vim.opt.rtp:append(vim.fn.stdpath("data") .. "/lazy/vimtex/after")
vim.cmd [[filetype plugin indent on]]

vim.g.vimtex_view_method = "zathura"

-- to use zathura_simple:
vim.g.vimtex_view_method = "zathura_simple"

Now, with this test.lua file, you start neovim with nvim --clean -u test.lua. It will start neovim with pure defaults with VimTeX loaded. Now, it means you don't get your custom mappings and config, but that's the point.

I use \lv to open the viewer, it is OK, but it will give me the information: Viewer cannot find Zathura window ID!. But I actually can open the viewer.

The information you get is a warning due to xdotool not being able to find the Zathura window. It probably means that xdotool does not work properly, which is probably because the dbus thing is not working properly.

However, there's also another way to fix this, which is to use the zathura_simple viewer that does not rely on xdotool. This does mean it can spawn multiple windows, but in most cases I don't think that's a big problem.

Actually, I've search the information in the issues, and I find the suggestion in some issues, and I've try just update zathura with zathura_simple. But after update, I even cannot use \lv to open the viewer. Here is the information of VimtexInfo: …

Strange; zathura_simple is more or less identical to zathura, except it won't use xdotool for checking if there are existing windows. The cmd_start is the same, as you see. So \lv should still work.

Kaiser-Yang commented 2 months ago

I've made a minimal configuration to reproduce my problem, the configurations are available through minimal-vimtex. Just copy the .config directory to reproduce:

To be honest, this is really NOT a minimal configuration. A minimal configuration and example looks like this:

-- test.lua
vim.opt.rtp:prepend(vim.fn.stdpath("data") .. "/lazy/vimtex")
vim.opt.rtp:append(vim.fn.stdpath("data") .. "/lazy/vimtex/after")
vim.cmd [[filetype plugin indent on]]

vim.g.vimtex_view_method = "zathura"

-- to use zathura_simple:
vim.g.vimtex_view_method = "zathura_simple"

Now, with this test.lua file, you start neovim with nvim --clean -u test.lua. It will start neovim with pure defaults with VimTeX loaded. Now, it means you don't get your custom mappings and config, but that's the point.

SORRY for my poor knowledge about nvim and lua.

I use \lv to open the viewer, it is OK, but it will give me the information: Viewer cannot find Zathura window ID!. But I actually can open the viewer.

The information you get is a warning due to xdotool not being able to find the Zathura window. It probably means that xdotool does not work properly, which is probably because the dbus thing is not working properly.

I'll try to Google something about this : ) thanks for your reply.

However, there's also another way to fix this, which is to use the zathura_simple viewer that does not rely on xdotool. This does mean it can spawn multiple windows, but in most cases I don't think that's a big problem.

Actually, I've search the information in the issues, and I find the suggestion in some issues, and I've try just update zathura with zathura_simple. But after update, I even cannot use \lv to open the viewer. Here is the information of VimtexInfo: …

Strange; zathura_simple is more or less identical to zathura, except it won't use xdotool for checking if there are existing windows. The cmd_start is the same, as you see. So \lv should still work.

So do you mean that if zathura can open the viewer, the zathura_simple should work, too, but it is weird this can not work on my environment?

lervag commented 2 months ago

To be honest, this is really NOT a minimal configuration. A minimal configuration and example looks like this: …

SORRY for my poor knowledge about nvim and lua.

No problem, and I'm sorry if my comment was a little bit strong. My intention was only to help educate, not to be rude.

I use \lv to open the viewer, it is OK, but it will give me the information: Viewer cannot find Zathura window ID!. But I actually can open the viewer.

The information you get is a warning due to xdotool not being able to find the Zathura window. It probably means that xdotool does not work properly, which is probably because the dbus thing is not working properly.

I'll try to Google something about this : ) thanks for your reply.

I'm happy to help, but I'm sorry to say that I can't be of much more help on this particular thing since I don't have mucj experience with WSL and can't test things there since I don't use it myself.

Strange; zathura_simple is more or less identical to zathura, except it won't use xdotool for checking if there are existing windows. The cmd_start is the same, as you see. So \lv should still work.

So do you mean that if zathura can open the viewer, the zathura_simple should work, too, but it is weird this can not work on my environment?

Yes, exactly. And yes, it is weird if one of them works and the other do not. On my end, both of these works as expected.

Kaiser-Yang commented 2 months ago

To be honest, this is really NOT a minimal configuration. A minimal configuration and example looks like this: …

SORRY for my poor knowledge about nvim and lua.

No problem, and I'm sorry if my comment was a little bit strong. My intention was only to help educate, not to be rude.

You need not be sorry. I can get what you want to see. Being straightforward is nothing wrong. You are a nice guy. Thank you very much, and I'll try my best to figure this out.

Kaiser-Yang commented 2 months ago

The zathura_simple works. It seems that I forget to close the window opened before, so it seem that the window didn't show up ( because this is actually one), and I'll use this now, and once I find how to fix the problem, I'll share it here.

BTW, a simple way to auto follow in viewer, I use the autocmd:

local autoFollow = false
local function toggleVimtexCursorFollow()
    if autoFollow then
        vim.cmd([[
        augroup VimtexViewOnCursorHold
            autocmd!
        augroup END
        ]])
        autoFollow = false
        vim.cmd('echo "Cursor follow disabled"')
    else
        vim.cmd([[
        augroup VimtexViewOnCursorHold
            autocmd!
            autocmd CursorHold *.tex silent! VimtexView
        augroup END
        ]])
        autoFollow = true
        vim.cmd('echo "Cursor follow enabled"')
    end
end
vim.api.nvim_create_user_command("VimtexToggleCursorFollow", toggleVimtexCursorFollow,
    { range = false, nargs = 0 })
lervag commented 2 months ago

The zathura_simple works. It seems that I forget to close the window opened before, so it seem that the window didn't show up ( because this is actually one), and I'll use this now, and once I find how to fix the problem, I'll share it here.

Great, I'm glad to hear that.

BTW, a simple way to auto follow in viewer, I use the autocmd: …

Yes, this seems like a simple and effective way to "autofollow". Thanks for sharing!

lervag commented 2 months ago

I'll close the issue as it seeme to be nothing more I can do to help here. Feel free to reopen or open new issues if there are other things.