lervag / vimtex

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

Can't set page SumatraPDF after continuous compilation, despite return focus works #2762

Closed 777uliahshafar closed 11 months ago

777uliahshafar commented 11 months ago

I am using Windows 11, neovim and SumatraPDF. After continuous compilation, the SumatraPDF can't set the page for the new added line.

See comment by @lervag in https://github.com/lervag/vimtex/issues/117#issuecomment-74546114

Steps to reproduce

  1. Continuous Compile minimal.tex

Actual behaviour The PDF viewer (SumatraPDF) still on the same page after continuous compilation success.

Expected behaviour I'd like to SumatraPDf go to the page where I have added new text. but will return focus on neovim.

Do you use a latexmkrc file? No

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.2176.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: paper
  packages: expl3 fontenc fontspec fontspec-luatex xparse
  compiler: latexmk
    engine: -lualatex
    options:
      -shell-escape
      -verbose
      -file-line-error
      -synctex=1
      -interaction=nonstopmode
    callback: 1
    continuous: 1
    executable: latexmk
    job: 
      jobid: 10
      output: C:\Users\ul\AppData\Local\Temp\nvim.0\PPeby5\0
      cmd: set max_print_line=2000 & latexmk -shell-escape -verbose -file-line-error -synctex=1 -interaction=nonstopmode -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: 8892
  viewer: General
    job: 
      pid: 3688
      cmd: SumatraPDF -reuse-instance -forward-search "C:\Users\ul\Documents\minimal\minimal.tex" 14 "C:\Users\ul\Documents\minimal/minimal.pdf"
  qf method: LaTeX logfile
lervag commented 11 months ago

See comment by @lervag in #117 (comment)

You first opened the issue by copying my comment, then later added the description. I've moved your issue description to your original post, removed the copy of my comment and instead just left the reference. However, it is VERY unclear what the point of that reference is - could you explain?

I am using Windows 11, neovim and SumatraPDF. After continuous compilation, the SumatraPDF can't set the page for the new added line.

Does regular forward search work? I.e., if you do \lv, does it make SumatraPDF move to the current line?

777uliahshafar commented 11 months ago

Sorry, my bad, Mr. Lervag, I am always in rush when I faced the issue, :D. Alright, I referenced your comment in that issue for acknowledging what is supposed to happen after continuous compilation. 1. return focus to vim, 2. Set page in viewer to the current page. For the second, I think it means the viewer would forward search. In case of my system, the viewer would not set page where new text was added before I can edited back in my vim. Though, the viewer was still updated without clear sign.

Does regular forward search work? I.e., if you do \lv, does it make SumatraPDF move to the current line?

The Vimtex-View is works as it supposed to. The SumatraPDF did a great job highlighting the text and focus on its window. I wanted that highlight also happen when I did continuous compilation or at least the page could move then directly move to vim. I am still wonder if that can happen.

Before read your comment on the issue I referenced, I planned to use vimtex event compile to vimtex event view. But I could not find those resource (configuration on the internet). I am happy to explain bit more if my language bit complex. Thank you.

lervag commented 11 months ago

Sorry, my bad, Mr. Lervag,

Ok, no problem :)

I am always in rush when I faced the issue, :D.

Notice, though, that by being "in rush" you are most likely causing both me and you to spend more time communicating before actually getting to a solution. Thus, if you slow down, then you may experience that you actually speed up by avoiding unnecessary "double work". :)

Slow is smooth, smooth is fast!

Before read your comment on the issue I referenced, I planned to use vimtex event compile to vimtex event view. But I could not find those resource (configuration on the internet). I am happy to explain bit more if my language bit complex. Thank you.

I think this may be your best solution here. You can use something like this:

augroup vimtex_events
  autocmd!
  autocmd User VimtexEventCompileSuccess VimtexView
augroup END

You can place it more or less whereever you want. I would suggest putting it near where you are configuring VimTeX generally.

777uliahshafar commented 11 months ago

I am back from refreshers and slow and smooth, The solution by using vimtex event is good Mr. Lervag, However, Just like what I thought the focus is not comeback to the neovim. I'd like to watch the change on viewer (either change the page or using highlight) and still maintain my cursor on neovim. Could this be happen Sir? Thank you very much.

lervag commented 11 months ago

The solution by using vimtex event is good Mr. Lervag, However, Just like what I thought the focus is not comeback to the neovim.

Ah. Ok, that's harder.

I'd like to watch the change on viewer (either change the page or using highlight) and still maintain my cursor on neovim. Could this be happen Sir? Thank you very much.

I'm not sure, to be honest. I assume SumatraPDF will refresh, right, so it does update automatically after compilation. But you want it to also highlight the position of the cursor similar to what happens when you do \lv, but without it getting focus?

I checked the SumatraPDF manual, and I don't find any related command-line options. I'm not sure if this is possible, and if it is, I don't know how. Sorry!

777uliahshafar commented 11 months ago

Thank you Mr. lervag for the responses. I feel very good for my configuration now. I will leave this for further exploration for me. Cheers.

lervag commented 11 months ago

Glad to hear it! :)

xarthurx commented 8 months ago

Facing exactly the same issue. If I check the actual compiled PDF, the change has been made. But SumatraPDF is not updating the change.

xarthurx commented 8 months ago

Facing exactly the same issue. If I check the actual compiled PDF, the change has been made. But SumatraPDF is not updating the change.

A temporary work-around is to press r in SumatraPDF, which manually refresh the PDF file...

lervag commented 8 months ago

Facing exactly the same issue. If I check the actual compiled PDF, the change has been made. But SumatraPDF is not updating the change.

I'm not sure if that is the same issue. Also, as this issue was resolved, it seems better if you open a new issue with a full and detailed description that follows the issue template.

As far as I know, things should work well with VimTeX and SumatraPDF. There have not been any significant changes recently that should have changed anything either. Thus, if you have a problem, I believe it may be caused by some configuration issue or similar. To help, I would have to know more, most of which is asked in the regular issue template.