Closed 777uliahshafar closed 1 year ago
I understand forward search need additional configuration to make it work,
No, not really. On Windows with SumatraPDF, it should "just work"™.
minimal.lua
The supplied minimal.lua
does not make sense. It does not load VimTeX and you don't explain how you load it otherwise...
vim.g.vimtex_compiler_method = "latexmk"
You don't need to set the option if you don't change it from the default.
Expected behavior
Could you please explain the steps you are using to reproduce your issue; in detail? E.g. something like this:
\ll
to start compilation.\lv
to attempt forward search.VimTeX project: simart base: simart.tex root: C:\Users\ul\Documents\simart tex: C:\Users\ul\Documents\simart\simart.tex main parser: current file verified document class: simart packages: arabicnumbers array atbegshi-ltx atveryend-ltx auxhook bigintcalc bitset booktabs calc caption caption3 ctablestack enumitem epstopdf-base etoolbox expl3 fancyhdr fontenc fontspec fontspec-luatex geometry gettitlestring graphics graphicx hijrical hycolor hyperref iftex ifvtex import infwarerr intcalc kvdefinekeys kvoptions kvsetkeys l3keys2e letltxmacro lipsum listings lstmisc ltxcmds luatexbase makecmds nameref natbib paralist pdfescape pdftexcmds polyglossia refcount rerunfilecheck setspace stringenc subfiles tabularx titlesec trig uniquecounter url xkeyval xparse source files: simart.tex subfiles/subfile.tex
Ok, this clearly is not the minimal tex file you supplied above...
compiler: latexmk engine: -lualatex options: -verbose -file-line-error -synctex=1 -interaction=nonstopmode
And this does not contain the -shell-escape
option you say you are using above.
viewer: General job: pid: - cmd: start "" "C:\Users\ul\Documents\simart/simart.pdf"
And this very clearly means you are setting g:vimtex_view_general_viewer
to something.
I'm sorry, but it is very hard to help you if you provide inconsistent data. Can you please:
init.lua
and a minimal LaTeX project. If you find it is hard to design a minimal init.lua
, then at least show the init.lua
and neovim configuration that you are actually using.in order to use VimTex with SumatraPDF on Windows, one possible config (with lazy.nvim as plugin manager):
{
"lervag/vimtex",
-- lazy = false, -- uncomment if you use a neovim config like NvChad which lazy-loads all plugins by default
init = function()
-- Live compilation
vim.g.vimtex_compiler_latexmk = {
out_dir = ".out",
options = {
"-shell-escape",
"-verbose",
"-file-line-error",
"-interaction=nonstopmode",
"-synctex=1",
},
}
vim.g.vimtex_view_general_viewer = "SumatraPDF"
vim.g.vimtex_view_general_options = [[-reuse-instance -forward-search @tex @line @pdf]]
end,
},
Run \ll
to start compilation, then in SumatraPDF:
nvim --headless -c "VimtexInverseSearch %l '%f'"
in the filed for configuring inverse search.Use \lv
on source code and double-click on the PDF to perform forward/inverse search.
If you want, you can use/adapt this config. It should work.
I can agree that lazy.nvim is a good plugin manager. Note though:
vim.g.vimtex_view_general_viewer
and _options
should not really be necessary here.out_dir
; some people like that, others don't :)-- Live compilation
does not seem to add any value to the configuration?Good afternoon all.
Step to Reproduce
cd Documents
then nvim .\minimal\minimal.tex
.I forget to mention that the first time I compile latex documents. It does not directly open SumatraPDF, but it lets me choose software to open the di compilation pdf. Then I choose SumatraPDF as default.
I also put new env. variable C:\Users\ul\AppData\Local\SumatraPDF\SumatraPDF.exe
named SumatraPDF
Now, I have changed to lazy.nvim
plugin manager as suggested. Unfortunetely, it resulted same thing.
Please take a look my configuration on my laptop.
minimal.lua
-- options
local g = vim.g
local o = vim.o
local cmd = vim.cmd
local opt = vim.opt
g.mapleader = " "
g.maplocalleader = " "
cmd('syntax on')
vim.api.nvim_command('filetype plugin indent on')
opt.shortmess:append "c"
o.encoding="utf-8"
-- plugin load
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)
local plugins = {
{"lervag/vimtex",
lazy = false,
},
}
}
local opts = {}
require("lazy").setup(plugins, opts)
-- vimtex
vim.g.vimtex_compiler_latexmk_engines = {
_ = '-lualatex'
}
vim.g.vimtex_compiler_latexmk = {
options = {
"-shell-escape",
"-verbose",
"-file-line-error",
"-interaction=nonstopmode",
"-synctex=1",
},
}
minimal.tex
\documentclass{minimal}
\begin{document}
Hello world!
\pagebreak
Hello world!
\end{document}
vimtex info
System info:
OS: DESKTOP-RMKJQL5 (Microsoft Windows 11 Home Single Language)
Vim version: NVIM v0.9.1
Has clientserver: true
Servername: \\.\pipe\nvim.7120.0
VimTeX project: minimal
base: minimal.tex
root: C:\Users\ul\Documents\minimal
tex: C:\Users\ul\Documents\minimal\minimal.tex
main parser: current file verified
document class: minimal
compiler: latexmk
engine: -lualatex
options:
-shell-escape
-verbose
-file-line-error
-interaction=nonstopmode
-synctex=1
callback: 1
continuous: 1
executable: latexmk
job:
jobid: 6
output: C:\Users\ul\AppData\Local\Temp\nvim.0\AXFCA3\0
cmd: set max_print_line=2000 & latexmk -shell-escape -verbose -file-line-error -interaction=nonstopmode -synctex=1 -lualatex -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'" "minimal.tex"
pid: 8816
viewer: General
job:
pid: -
cmd: start "" "C:\Users\ul\Documents\minimal/minimal.pdf"
qf method: LaTeX logfile
Good afternoon all.
Good morning :)
cd Documents
thennvim .\minimal\minimal.tex
.
Ok; this means you are using your regular init.lua
. Does that mean that the supplied minimal.lua
is the content of your init.lua
?
Do you have any other configuration files?
Now, it seems clear that VimTeX does not properly recognize SumatraPDF on your system. Can you try setting the options explicitly, that is, add
vim.g.vimtex_view_general_viewer = "SumatraPDF"
vim.g.vimtex_view_general_options = "-reuse-instance -forward-search @tex @line @pdf"
I believe it will not work, but that it will give a warning or error message.
In few hours I will be sleep. :)
Ok; this means you are using your regular init.lua. Does that mean that the supplied minimal.lua is the content of your init.lua?
Yes it does. I don't understand which neovim config was minimal.tex loaded. I have the configuration in my nvim
repo.
Do you have any other configuration files?
Yes, should I start neovim with only vimtex?
It really doesn't work, Mr. lervag. The warning message was - Please see :h g:vimtex_view_general_viewer
after I compile \ll.
Ok; this means you are using your regular init.lua. Does that mean that the supplied minimal.lua is the content of your init.lua?
I have the configuration in my
nvim
repo.
Thanks; I've looked at the configuration and it looks good. The problem is very likely not with the config, but with the installation of SumatraPDF.
Do you have any other configuration files?
Yes, should I start neovim with only vimtex?
Let's just use your regular configuration that you host on GitHub.
It really doesn't work, Mr. lervag. The warning message was
- Please see :h g:vimtex_view_general_viewer
after I compile \ll.
Yes; I believe the problem is that SumatraPDF
is not recognized as a valid
program. You can test by trying to run :!SumatraPDF
- if that works, then I'm
wrong.
If it does not work, then try :!SumatraPDF.exe
- does that work?
If that also does not work, then try :!C:\Users\ul\AppData\Local\SumatraPDF\SumatraPDF.exe
- does that work?
You write:
I also put new env. variable
C:\Users\ul\AppData\Local\SumatraPDF\SumatraPDF.exe
namedSumatraPDF
That does not really sound like what you should do here. This is mentioned in :help vimtex-faq-windows
on the second bullet point. What you want to do is to update the PATH
environment variable so that it contains the directory to the executable. I.e., you want to add C:\Users\ul\AppData\Local\SumatraPDF\
to PATH
.
Thank you, I feel relieved for my config. I had installed Sumatra by using .exe file. I guess when I was installing it, I cheked all of the installation options for one user. I could open the sumatra only by run the last command with the path, the first two didn't work. However, the last command showed me some info on nvim command, I showed below in case it helps.
:!C:\Users\ul\AppData\Local\SumatraPDF\SumatraPDF.exe
Starting SumatraPDF, GetCommandLineW():
C:\Users\ul\AppData\Local\SumatraPDF\SumatraPDF.exe
OpenEmbeddedFilesArchive: opened archive
prefs::Load() took 0.52 ms
ParseTranslationTxt: 19181 lines, nStrings: 357
StartMonitoringDirForChangesAPC() C:\Users\ul\AppData\Local\SumatraPDF\SumatraPDF.exe
Forward search still could not work after I changed the Path. (I know it must for sth else)
I'm sorry, but I think you are not really understanding these things. Please, read vimtex-faq-windows
and read the second bullet point:
* Several features rely on having executables like `latexmk` and
`SumatraPDF.exe` "readily available" by adding the parent directories of
the executables to your PATH environment variable. See [1] for more info
on PATH.
The reference [1] is to https://www.rapidee.com/en/path-variable. Please read that link. Or perhaps this is better: https://www.wikihow.com/Change-the-PATH-Environment-Variable-on-Windows.
Alternatively, use this:
vim.g.vimtex_view_general_viewer = [[C:\Users\ul\AppData\Local\SumatraPDF\SumatraPDF.exe]]
vim.g.vimtex_view_general_options = "-reuse-instance -forward-search @tex @line @pdf"
Thank you very much Mr. Lervag, this is not really an issue anyway, it is just my problem and it has fixed now. I really appreciate your help. Thanks.
Great, I'm glad to hear things work now! :)
Description
I understand forward search need additional configuration to make it work, but I have searched through internet its prerequisite and I could not find any configuration worked in windows 11 using neovim. Some of them are old issues, I could not tell which has been implemented on vimtex system related to sumatra pdf on windows 11.
I move to windows from wsl2, after opening issue of the zathura pdf opening yesterday. Now, I have encountered problem of forward search on sumatraPDF in windows 11 using neovim. The compilation of latex documents is working, but it can't highlight the text. I also wanted to point out the inverse search doesn't work with the configuration I set up.
I have set up the vimtex requirement. I have read faq-windows, installingperl strawberry, I use Powershell not built-in windows powershell.
On inverse search I have read this blog but it won't work, only show a glimpse of windows. Thank you very much everyone,
Steps to reproduce
minimal.lua
minimal.tex
Expected behavior
The sumatraPDF can't do forward search on windows 11 using neovim
Actual behavior
The sumatra only open after compilation with the last view page.
Do you use a latexmkrc file?
no
VimtexInfo