Closed MrRedCrack closed 3 months ago
Based on a fresh kickstart.nvim configuration, I added a vimtex.lua to the plugins folder to load vimtex with its settings: …
You have clearly just copied the contents from the README. Here's an updated version that should work better:
return {
{
'lervag/vimtex',
lazy = false,
init = function()
vim.g.vimtex_quickfix_open_on_warning = false
vim.g.vimtex_compiler_latexmk = {
aux_dir = "latexmk_aux",
options = [
"-verbose",
"-file-line-error",
"-synctex=1",
"-interaction=nonstopmode",
"-shell-escape",
],
}
vim.g.vimtex_compiler_latexmk_engines = { ["_"] = "-lualatex" }
end,
},
}
I've successfully compiled an existing latex project and able to forward search just fine even from sub .tex files using SumatraPDF as the viewer, but I cannot perform any inverse search by double clicking the document, after adding the option in Sumatra as instructed:
cmd /c start /min "" nvim --headless -c "VimtexInverseSearch %l '%f'"
whenever I double click the document a cmd window briefly pops up and disappears.Then I tried to manually run the VimtexInverseSearch command from powershell, and then from within nvim. Both instantly quits nvim no matter what options i pass to the command. I don't know how to continue troubleshooting from this point.
That is as expected. The nvim --headless -c ...
command is meant to start a new neovim instance which communicates the inverse search to the "real" neovim instance and then quits.
Out of curiosity, how did you try to run the command from powershell? I.e., which command did you run?
I've looked this up and found a lot of people fixed the issue by adding the lazy = false option to not lazy load the plugin, but that is not the case for me.
The point here is simply that you should not lazy load VimTeX. If you do, then you will break the VimtexInverseSearch
command.
Out of curiosity, how did you try to run the command from powershell? I.e., which command did you run?
I left the nvim instance that compiled the latex project running,
then from the latex project folder, I opened a new powershell instance and entered this command, where dsd.tex is the main project file
nvim --headless -c "VimtexInverseSearch 1 dsd.tex"
The point here is simply that you should not lazy load VimTeX. If you do, then you will break the
VimtexInverseSearch
command.
yep, I got that. But I'm confused what else has gone wrong as SumatraPDF inverse search is not working still.
You have clearly just copied the contents from the README. Here's an updated version that should work better:
I have pasted the entire thing but not sure what's the issue here:
Sorry, my mistake: Change [
to {
and ]
to }
.
Out of curiosity, how did you try to run the command from powershell? I.e., which command did you run?
I left the nvim instance that compiled the latex project running, then from the latex project folder, I opened a new powershell instance and entered this command, where dsd.tex is the main project file
nvim --headless -c "VimtexInverseSearch 1 dsd.tex"
Ok; and what is the result when you do that? Also, can you try this: nvim --headless -c "VimtexInverseSearch 1 'dsd.tex'"
- what is the result now?
Sorry, my mistake: Change
[
to{
and]
to}
.
works now, thanks for the cleaner code. I'm using this configuration for the test results below:
Ok; and what is the result when you do that? Also, can you try this:
nvim --headless -c "VimtexInverseSearch 1 'dsd.tex'"
- what is the result now?
It seems to be doing something, but there is error, both with and without the single quotes:
So I tried to run the command again but replaced dsd.tex with its full path, then it worked and the cursor jumped to the intended line.
However, when double clicking in Sumatra there is no response in the nvim instance, nor does the cursor move anywhere. Already tried changing the options, no change in result:
nvim --headless -c "VimtexInverseSearch %l '%f'"
cmd /c start /min "" nvim --headless -c "VimtexInverseSearch %l '%f'"
The nvim window sometimes gets brought into focus when I double click in Sumatra, but no change can be found anywhere.
I think you are on to something here. I think it would be useful to temporarily change the inverse view command in SumatraPDF to something that logs the %l
and %f
to a file. In bash on Linux, this would be echo %l %f >> out.log
; but I don't know what to use on CMD/Powershell.
According to ChatGPT, you could try this:
cmd /c echo %l %f >> C:\path\to\your\log\file.txt
But I'm not sure if that will work. The point of this is to check if the %f
filename is interpolated correctly.
But I'm not sure if that will work. The point of this is to check if the
%f
filename is interpolated correctly.
It works, here is the output:
It looked normal, so I changed it back to the VimtexInverseSearch command. I don't know why, it magically started working. Tried changing the config back to the old messy one, still no issues. I'm confident I had restarted my computer several times when trying to troubleshoot this. Not sure what changed for it to start working. I will close this issue.
My guess is that you had a slight typo in your original command, but of course, we'll never know. And it doesn't matter; I'm glad to hear it works now!
Description
Hi, I'm new to nvim, just trying to transition from VSCode to nvim for latex writing.
Based on a fresh kickstart.nvim configuration, I added a vimtex.lua to the plugins folder to load vimtex with its settings:
I've successfully compiled an existing latex project and able to forward search just fine even from sub .tex files using SumatraPDF as the viewer, but I cannot perform any inverse search by double clicking the document, after adding the option in Sumatra as instructed:
cmd /c start /min "" nvim --headless -c "VimtexInverseSearch %l '%f'"
whenever I double click the document a cmd window briefly pops up and disappears.Then I tried to manually run the VimtexInverseSearch command from powershell, and then from within nvim. Both instantly quits nvim no matter what options i pass to the command. I don't know how to continue troubleshooting from this point.
I've looked this up and found a lot of people fixed the issue by adding the lazy = false option to not lazy load the plugin, but that is not the case for me.
Inverse search has always worked just fine in VSCode, so I don't think it should be a problem with the .tex project, so I haven't tried with a minimal test file.
Steps to reproduce
<leader>ll
Expected behavior
No response
Actual behavior
No response
Do you use a latexmkrc file?
No
VimtexInfo