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

:VimtexInfo fails on first attempt to run #2671

Closed
henriqpsantos opened this issue Mar 22, 2023 · 10 comments
Closed

:VimtexInfo fails on first attempt to run #2671

henriqpsantos opened this issue Mar 22, 2023 · 10 comments
Labels

Comments

@henriqpsantos
Copy link

henriqpsantos commented Mar 22, 2023

Description

With the specified minimal config, :VimtexInfo fails on the first attempt to run it. Full error is in #2664.

Steps to reproduce

vim.cmd ('filetype plugin indent on')
vim.cmd ('syntax enable')
vim.opt.runtimepath:prepend "C:/Users/-----/Documents/.data/nvim-data/lazy/vimtex"
vim.opt.runtimepath:append "C:/Users/-----/Documents/.data/nvim-data/lazy/vimtex/after"

Expected behavior

VimTeX information to be displayed.

Actual behavior

Error: string "<ff>091 MB" contains byte that does not start any UTF-8 character.

Do you use a latexmkrc file?

No

VimtexInfo

System info:
  OS: LAPTOP-QDMBVVL7 (Microsoft Windows 10 Home)
  Vim version: NVIM v0.9.0-dev-1028+gd422fc827
  Has clientserver: true
  Servername: \\.\pipe\nvim-nvr

VimTeX project: minimal
  base: minimal.tex
  root: C:\Users\----\Internxt\Development\.config\minimal with spaces
  tex: C:\Users\----\Internxt\Development\.config\minimal with spaces\minimal.tex
  main parser: current file verified
  document class: minimal
  compiler: tectonic
    options:
      --keep-logs
      --synctex
    job: 
      jobid: 5
      output: C:\Users\----\AppData\Local\Temp\nvim.0\wt0xJ8\0
      cmd: tectonic --keep-logs --synctex --outdir=C:\Users\----\Internxt\Development\.config\minimal\ with\ spaces "minimal.tex"
  viewer: sioyek
    job: 
      pid: -
      cmd: sioyek  --inverse-search "C:\Program Files\Neovim\bin\nvim.exe --headless -c \"VimtexInverseSearch %2 '%1'\"" --forward-search-file "C:\\Users\\----\\Internxt\\Development\\.config\\minimal with spaces\\minimal.tex" --forward-search-line 1 "C:\\Users\\----\\Internxt\\Development\\.config\\minimal with spaces/minimal.pdf"
    cmd_start: sioyek  --inverse-search "C:\Program Files\Neovim\bin\nvim.exe --headless -c \"VimtexInverseSearch %2 '%1'\"" --forward-search-file "C:\\Users\\----\\Internxt\\Development\\.config\\minimal with spaces\\minimal.tex" --forward-search-line 1 "C:\\Users\\----\\Internxt\\Development\\.config\\minimal with spaces/minimal.pdf"
  qf method: LaTeX logfile
@lervag
Copy link
Owner

lervag commented Mar 25, 2023

With the specified minimal config, :VimtexInfo fails on the first attempt to run it.

Ok, but it works on every subsequent attempt?

Steps to reproduce

vim.cmd ('filetype plugin indent on')
vim.cmd ('syntax enable')
vim.opt.runtimepath:prepend "C:/Users/-----/Documents/.data/nvim-data/lazy/vimtex"
vim.opt.runtimepath:append "C:/Users/-----/Documents/.data/nvim-data/lazy/vimtex/after"

Can you be even more explicit about the steps? E.g., do you do this?

  1. Save the above minimal config to test.lua.
  2. Run nvim --clean -u test.lua test.tex (test.tex does not need to exist).
  3. Now in neovim run :VimtexInfo - the error appears.
  4. On subsequent :VimtexInfo, the following information is displayed: ...

After explaining your steps above; can you explain if there is any different after you do :VimtexClearCache ALL and you repeat the steps?

@georgejean
Copy link

georgejean commented Jun 6, 2023

I have the same problem (see the gif below) :
vimtex
We see that it works only on the second run but I have to escape to make the buffer reappear.

But the gif above shows another issue that bothers me more :
I've tested two PDF viewer (SumatraPDF and Okular) but neither of the two are recognized when I compile (should I open a new issue ?).
I had put the two binaries in the PATH and they had worked well on the prompt. I had also tried to give their full path to vimtex_view_general_viewer.

Here is my config :

local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "https://github.com/folke/lazy.nvim.git",
    "--branch=stable", -- latest stable release
    lazypath,
  })
end
vim.opt.rtp:prepend(lazypath)

vim.g.mapleader = " " 
vim.g.maplocalleader = " "
require("lazy").setup({{
    "lervag/vimtex",
    ft = { "tex", "bib" },   -- I've also tried to remove this line
    init = function()
      -- Live compilation
      vim.g.vimtex_compiler_latexmk = {
        build_dir = ".out",
        options = {
          "-shell-escape",
          "-verbose",
          "-file-line-error",
          "-interaction=nonstopmode",
          "-synctex=1",
        },
      }
      vim.g.vimtex_view_general_viewer = "okular"
      vim.g.vimtex_view_general_options = [[--unique file:@pdf\#src:@line@tex]]
    end,
  },
})

(I've got no more success if I don't use lazy.nvim's lazy-loading mechanism for the plugin (line ft = { "tex", "bib"} removed))
and here is what :VimtexInfo shows after compile (by the way, compilation works fine):

System info:
  OS: DESKTOP-M1LKF1M (Microsoft Windows 11 Famille)
  Vim version: NVIM v0.9.1
  Has clientserver: true
  Servername: \\.\pipe\nvim-bare.8884.0

VimTeX project: essai
  base: essai.tex
  root: C:\Users\blanc
  tex: C:\Users\blanc\essai.tex
  main parser: current file verified
  document class: minimal
  compiler: latexmk
    engine: -pdf
    options:
      -shell-escape
      -verbose
      -file-line-error
      -interaction=nonstopmode
      -synctex=1
    build_dir: .out
    callback: 1
    continuous: 1
    executable: latexmk
    job: 
      jobid: 6
      output: C:\Users\blanc\AppData\Local\Temp\nvim-bare.0\36OlAA\0
      cmd: set max_print_line=2000 & latexmk -shell-escape -verbose -file-line-error -interaction=nonstopmode -synctex=1 -pdf -outdir=.out -pvc -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'" "essai.tex"
      pid: 2176
  viewer: General
  qf method: LaTeX logfile

I'm sorry but I really don't know how to enable PDF viewing and any help would be very welcome !

@lervag
Copy link
Owner

lervag commented Jun 7, 2023

I have the same problem (see the gif below) …

My first impression is that this is due to lazy loading.

But the gif above shows another issue that bothers me more : I've tested two PDF viewer (SumatraPDF and Okular) but neither of the two are recognized when I compile (should I open a new issue ?).

Let's solve the first problem first. It may be related.

Here is my config : …

Is this the only configuration? I suspect you are not doing nvim --clean -u init.lua with an init.lua that contains the supplied config? Notice that Neovim will imlicitly load plugins and files under your config directory (that's why --clean is important).

(I've got no more success if I don't use lazy.nvim's lazy-loading mechanism for the plugin (line ft = { "tex", "bib"} removed)) and here is what :VimtexInfo shows after compile (by the way, compilation works fine):

Don't use lazy.nvim's lazy-loading mechanism for VimTeX. It is not relevant if that is the problem here or not: you just should not force lazy loading of VimTeX, because it breaks things. VimTeX is lazy by design anyways.

You probably read my last comment to @henriqpsantos, where I ask for more explicit steps. It would be much easier to help if I get more information, such as a proper minimal (or evne full) configuration and the exact steps to reproduce.

@georgejean
Copy link

georgejean commented Jun 7, 2023

@lervag Thanks for your feedback !

The problem seems to be Windows' related because I have tested the same config in WSL2 and VimtexInfo runs normally.
Here is the result I've got on Windows with a clean config (I've followed the steps you explained before and disable the useless here lazy-loading performed by lazy.nvim. I've just added filetype plugin indent on and syntax enable in init.lua):
vimtex
It's not a big issue for users because VimtexInfo will work from the second run.
I've got no more success with ocular : It seems I can't set the PDF viewer on Windows.
Nevertheless, I've switched back to SumatraPDF and ... it works (I don't know why it didn't before).
I've managed to use forward and backward synctex search but there are still some caveats for which documentation suggests fixes and I think I will share my experience as a beginner in a more related issue, for example #2706, since here, it is off topic.
On WSL2, I've managed to use Vimtex with Sioyek but synctex backward search doesn't work for now. I've also tried Zathura on WSL2 but PDF doesn't open and the error is the same as in #2577, #2391 and #2329 (according to the error message given by testing cmd_start on the shell). I don't go on here because it's again off topic (I will deep in later).

If I can afford it, I would be interested to know your choice for the PDF viewer (if you accept to answer) and why it could be a good choice.
EDIT : I finally use Zathura on WSL2 because I can now open it and make forward/backward search and because I'm stuck with backward search with Sioyek even when synctex is activated by F4...

@lervag
Copy link
Owner

lervag commented Jun 8, 2023

Here is the result I've got on Windows with a clean config (I've followed the steps you explained before and disable the useless here lazy-loading performed by lazy.nvim. I've just added filetype plugin indent on and syntax enable in init.lua):

Ok; I've inspected the error message you get:

screenshot_2023-06-08_17-06-39

It has to do with the encoding, I think. Let's test some more; could you

  1. open the test file with nvim --clean ... as before, then
  2. run echo vimtex#jobs#capture('systeminfo') - does it return the same error message (more or less) as before?

It's not a big issue for users because VimtexInfo will work from the second run.

I agree, but it means something is wrong already at the start, and I always like to fix the first issues first. This part should work, and if it doesn't we want to figure out what's wrong.

I notice you are using Windows with French as the UI language. I believe the problem is related to language and encodings - it seems you are also not using UTF-8 encoding. I'm not really sure how to configure this type of thing in Windows. Could you check regional settings and see if there may be some relevant config?

Also, could you try to refresh the cache with :VimtexClearCache ALL?

I've got no more success with ocular : It seems I can't set the PDF viewer on Windows. Nevertheless, I've switched back to SumatraPDF and ... it works (I don't know why it didn't before).

I would be surprised if SumatraPDF did not work. Okular may be more experimental, but it should also work.

I've managed to use forward and backward synctex search but there are still some caveats for which documentation suggests fixes and I think I will share my experience as a beginner in a more related issue, for example #2706, since here, it is off topic.

No, please! Don't update old issues, create a new one instead! I really don't like spamming threads with digressions. E.g., this particular thread is about VimtexInfo failing, and the discussion about PDF viewers is not relevant. Also, I much prefer users opening new issues rather than commenting on old issues, especially if they are closed.

If I can afford it, I would be interested to know your choice for the PDF viewer (if you accept to answer) and why it could be a good choice.

I use Sioyek today. I like it, but I'm not sure if I like it more than Zathura. It has many more interesting features, but I don't know if I need them yet. Zathura is simple, fast and has nice keybindings that I like.


Let's continue the discussion on the original issue, but please open a new issue if you want to discuss the PDF viewers. :)

@georgejean
Copy link

georgejean commented Jun 8, 2023

Thanks for all your answers !
When I run vimtex#jobs#capture('systeminfo'), I don't get an error but rather text with accented characters not rendered correctly:
capture2

I notice you are using Windows with French as the UI language. I believe the problem is related to language and encodings - it seems you are also not using UTF-8 encoding. I'm not really sure how to configure this type of thing in Windows. Could you check regional settings and see if there may be some relevant config?

As a workaround, I use:
intl.cpl
then
Administrative -> Change system locale -> BETA: Use Unicode UTF-8 for worldwide language.
vimtex4
It needs a reboot and then it works (VimtexInfo gives output on first run and the output of
echo vimtex#jobs#capture('systeminfo') is correct).

No, please! Don't update old issues, create a new one instead! I really don't like spamming threads with digressions. E.g., this particular thread is about VimtexInfo failing, and the discussion about PDF viewers is not relevant. Also, I much prefer users opening new issues rather than commenting on old issues, especially if they are closed.

Ok ! I completely understand.

@lervag
Copy link
Owner

lervag commented Jun 8, 2023

Thanks for checking these things. It seems enabling the beta feature solves the issue? Perhaps we could add a section to the faq about this in e.g. :help vimtex-faq-windows (or add a more specific entry linked to from there)?

@georgejean
Copy link

That sounds good to me. For the faq, should I make a PR or do you take care of it?

@lervag
Copy link
Owner

lervag commented Jun 9, 2023

I'd be very happy to consider a PR. :)

@lervag
Copy link
Owner

lervag commented Jun 13, 2023

I assume that this means we can close the issue?

@lervag lervag closed this as completed Jun 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants