-
Notifications
You must be signed in to change notification settings - Fork 391
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
Weird cmd prompt pop up when compiling #2706
Comments
I believe it is really only one problem. And I'm sorry to say I don't I'll first comment the "non-problem":
When you do
You can simplify this. On Windows, SumatraPDF should be automatically used as the viewer. And call plug#begin()
Plug 'lervag/vimtex'
Plug 'SirVer/ultisnips'
call plug#end()
let g:vimtex_quickfix_mode=0
I know that VimTeX with SumatraPDF should work well for most people on Windows. However, I do not use it myself and I don't even have a windows machine. Thus, it is hard for me to debug this type of issue. Sorry! Let's start with the simple question: is there any change after simplifying your config as explained above? Also, did you read the docs, i.e.:
Finally, as a potential solution, you could look into using WSL to use neovim and VimTeX in a simple Linux system on Windows. In that case, |
Thank you for explaining that!
Also thank you for suggesting doing this, however, the problem is still there. But I find if my PDFreader has been opened before compilation, the cmd will not pop out (the cmd window flashes but not stay). I guess this "probelm" has something to do with the PDF reader. Since this does not really affect me writing and editing, I will let it be there before I find the solution. I will try to reproduce this problem and make some tests using other's PC. Something setting relates to PDFreader probably was accidentally changed, I assume. |
No problem :)
That was not really unexpected.
No, the problem has to do with how VimTeX opens SumatraPDF. And to improve it I would really like to have someone who is able to also work with the VimTeX code to help me figure out a better solution. Unfortunately, I do not know of/remember any active VimTeX users that uses Windows that is also comfortable with experimenting with the code and code changes.
I'm sorry to say that I can't think of anything better as a workaround than opening the PDF viewer manually. |
Please don't say that! I really appreciate for your help and constructive advice!
I just tried Vimtex+Latex+SumatraPDF on another PC that has never been used for that, and the same problem showed up. I think you are right and the problem is a general one. Also, I just find the same problem in the pull request #2627. Thanks again for your prompt response and help! |
I am fairly new to texing in nvim and the cmd prompt pop up bothers me too. Here is my attempt at a workaround. It seems that Vimtex utilizing So I wrote an autocmd calling this command every time I start editing a function open_sumatra_pdf()
local pdf_file = vim.fn.expand('%:r') .. '.pdf'
if vim.fn.filereadable(pdf_file) == 0 then
pdf_file = ""
end
local cmd = 'cmd /c start /b "" SumatraPDF -reuse-instance ' .. pdf_file
os.execute(cmd)
end
vim.api.nvim_create_autocmd({"BufReadPost"}, {
pattern = {"*.tex", "*.latex"},
callback = open_sumatra_pdf,
}) Every time a tex file is open, SumatraPDF will start and open the corresponding pdf file if exist, similar to TeXworks. Compiling will not cause a pop up again as Vimtex is using the same instance of SumatraPDF. Hope this help. |
<3
Ok, so, it seems there is some form of regression then.
@nitxy Great, I'm glad you are pitching in! Perhaps we can solve this
By default, VimTeX will use the following command: cmd /s /c "SumatraPDF -reuse-instance -forward-search "C:\path\to\text.tex" 123 "C:\path\to\text.pdf"" If you want to test with some minimal implementation, then the following should be more or less the same as what VimTeX is doing now: local cmd = [[cmd /s /c "SumatraPDF -reuse-instance -forward-search "C:\path\to\text.tex" 123 "C:\path\to\text.pdf""]]
jobstart(cmd, { detach = true }) You could also directly use the API from VimTeX: local cmd = [[SumatraPDF -reuse-instance -forward-search "C:\path\to\text.tex" 123 "C:\path\to\text.pdf"]]
local job = vim.fn["vimtex#jobs#start"](cmd, { detached = true })
-- now you can inspect the "job" object, which has some relevant properties
print(vim.inspect(job)) Perhaps you could look into which of |
It seems I made an important change all the way back in 2021 when I changed to newer apis: 7d8d92a#diff-5dfc6e98658ea0afff17d250db4ad5f3a92a7abcb65a4242ee88432803852f7fL158-L166 I believe there was a discussion about this, but I don't remember it. |
It seems the most relevant discussion was #2195, which is the PR that introduced these changes. But there is no talk about this particular thing. Perhaps it is really a regression? |
Sorry for all the comments - should have finished my investigations before replying. But, it seems we need to determine the best command string on Windows. I believe the alternatives are:
The code that needs to be changed is here: vimtex/autoload/vimtex/jobs/neovim.vim Lines 9 to 11 in e9ad2be
|
I tried running local cmd = [[cmd /s /c "SumatraPDF -reuse-instance -forward-search "C:\path\to\text.tex" 123 "C:\path\to\text.pdf""]]
vim.fn.jobstart(cmd, { detach = true }) with But actually, if I just remove the vimtex/autoload/vimtex/jobs/neovim.vim Lines 57 to 58 in e9ad2be
To begin with, I arrive at |
Ok, thanks for checking!
Very interesting! Then this may be the a solution, actually. The reason for adding the |
Thanks @georgejean for testing! I believe the change is more or less harmless and leads to a more desired behaviour. I've therefore merged #2717. |
In fact, using |
Description
Hi everyone, I am a beginner of Nvim and GitHub. I know almost nothing about the cool techy knowledge (programming, operation system, etc.). However, as my study gets more math-intense, I was trying to use latex to document lecture notes and all kinds of writings. And I finally found the combination of Nvim+Vimtex has been proved to be a feasible solution.
After days' struggling, I finally made my Nvim and Vimtex work. It could compile and produce pdfs. However, two problems showed.
Cmd.mp4
.tex
again, compiler stopped. And it won't compile until I\ll
orVimtexCompile
at the second time.stopped.mp4
And the closest case I found is #2601, however, my problem didn't get fixed when I run Nvim as Administrator.
I really appreciate any comments and/or advice! Also, I am quite new to GitHub, please let me know if I missed any information or failed to follow GitHub rules! Thank you!
Steps to reproduce
init.vim
file as below..tex
file as below.\ll
, the Problem 1 showed.\\
, then it suggest compiler stopped.\ll
again, worked.Expected behavior
Actual behavior
\ll
the second time to make it work.Do you use a latexmkrc file?
No
VimtexInfo
The text was updated successfully, but these errors were encountered: