Closed mizhozan closed 1 year ago
I think, before we discuss the solution, it is very useful to properly understand which problem you are trying to solve. I'm not quite sure here. From what I understand, you are trying to achieve the following workflow:
zathura file.pdf
<c+shift-click>
to open a new terminal and open Vim with VimTeX in that terminal on file.tex
Workflows that start from opening some pdf in Zathura from VimTeX should already work perfectly fine without configuring Zathura at all.
The workflow is correct. The so-called 'forward search' is perfect; it had no issues. For the backward search, though, I had to configure zathura. Previously, I could have only done it with gVim. Now, with the command above, I can also do the same for vim. I've only noticed a bit of lag in the opening (about 2sec).
This is not an issue with vimtex, it's zathura's, and I've opened an issue in their repo. I couldn't figure out how to make it treat the whole vim command and its options as a command option, but due to whatever reason, it only takes the first two as command and option and pass others as file paths to vim. That was the problem, and I was searching for a better approach while documenting the current working config (for Zathura). As I have seen, people need to script it with something like vimura script.
The workflow is correct. The so-called 'forward search' is perfect; it had no issues. For the backward search, though, I had to configure zathura.
Sorry, but this has me confused. So, to clarify: Does the following work for you?
cd
to some LaTeX project.nvim main.tex
.\lv
).This is not an issue with vimtex, it's zathura's, and I've opened an issue in their repo. I couldn't figure out how to make it treat the whole vim command and its options as a command option, but due to whatever reason, it only takes the first two as command and option and pass others as file paths to vim.
For the workflow I mentioned in the last comment, I would think you will either need to 1) use a gui version of Vim (like gVim), or 2) use a terminal as the main entry point. But you can't use :VimtexInverseSearch
in this case! That command requires there to be an existing Vim or neovim instance with VimTeX open already. If you want Zathura to start a new instance of Vim + VimTeX, then you need a different command. And if you want this to work transparently and equally well in all cases, then you need more work. It is not impossible, but IMHO, it is much easier to be pragmatic and allow the slightly less perfect solution:
If you open Zathura for some LaTeX project and there is no Vim/neovim instance, then the inverse command will open a terminal with Vim or gVim with the file. However, the next time you do reverse search you will open another new terminal/gVim instance.
If you open Zathura from VimTeX, the reverse search will work well as long as there is a VimTeX instance alive. This should generally work as expected at most times.
If you move from 1 to 2, then you could simply kill Zathura after opening Vim then restart it immediately from within VimTeX with \lv
. Now things work as expected from here.
- Open a terminal and cd to some LaTeX project.
- Start Vim/neovim, e.g. nvim main.tex.
- Compile project if necessary.
- Open viewer (e.g. \lv).
- Does backward search work as expected now?
Short: Yes, it works. Even if I close zathura and open pdf independently (not lv
) it still open new buffer for the backward search.
forward search (from vim/vimtex to zathura) is out of concern as it works as expected.
If I close the vim and open the .tex file again with it while the zathura kept open, the backward search no longer works in most cases (not always). I need to lv
again and do the same.
I had this issue with a project with subfile
package. Neither forward nor backward worked. But this may be another problem.
If you open Zathura for some LaTeX project and there is no Vim/neovim instance, then the inverse command will open a terminal with Vim or gVim with the file. However, the next time you do reverse search you will open another new terminal/gVim instance.
I had no intention for this case, though having it is good scenario but as you mentioned it might not worth the hassle.
If you open Zathura from VimTeX, the reverse search will work well as long as there is a VimTeX instance alive. This should generally work as expected at most times.
yes, this works in most of the time. This might be some problem with the server or zathura sometimes in opening closing vim/zathura it doesn't work anymore and I need to lv
again which is not a big deal. (NOTE: there is always one vim instance on the file open when perform backward search, so we're always talking about scenario 2 you mentioned.)
My initial concern with this issue was how to configure zathura such that it send the vim with all those extra options (-v --not-a-term -T dumb
). I have removed them in current zathura configuration as said and just not sure if it has some consequences. For example less robust backward search or causing the problem with projects that rely on subfile
package.
Short: Yes, it works. Even if I close zathura and open pdf independently (not
lv
) it still open new buffer for the backward search.I had this issue with a project with
subfile
package. Neither forward nor backward worked. But this may be another problem.
Yes, that may be another problem. Feel free to open a new issue. Please follow the issue template if you do.
If you open Zathura for some LaTeX project and there is no Vim/neovim instance, then the inverse command will open a terminal with Vim or gVim with the file. However, the next time you do reverse search you will open another new terminal/gVim instance.
I had no intention for this case, though having it is good scenario but as you mentioned it might not worth the hassle.
Well, if that is true, then you should not need to add any zathura configuration. Please do this:
Remove any set synctex-editor
line from your ~/.config/zathura/zathurarc
file.
Open some LaTeX project with Vim+VimTeX.
Compile, if necessary.
Open pdf with Zathura with \lv
.
Test reverse search, notice that it should work as expected automatically.
The only reason to add set synctex-editor
in your config file is to allow the workflow I specified, i.e. where you open a pdf with Zathura from your terminal without having any VimTeX sessions.
My initial concern with this issue was how to configure zathura such that it send the vim with all those extra options (
-v --not-a-term -T dumb
).
You should not need to configure Zathura at all. It should "just work"™.
Well, if that is true, then you should not need to add any zathura configuration. Please do this:
- Remove any
set synctex-editor
line from your~/.config/zathura/zathurarc
file.- Open some LaTeX project with Vim+VimTeX.
- Compile, if necessary.
- Open pdf with Zathura with
\lv
.- Test reverse search, notice that it should work as expected automatically.
The only reason to add
set synctex-editor
in your config file is to allow the workflow I specified, i.e. where you open a pdf with Zathura from your terminal without having any VimTeX sessions.My initial concern with this issue was how to configure zathura such that it send the vim with all those extra options (
-v --not-a-term -T dumb
).You should not need to configure Zathura at all. It should "just work"™.
That's amazing, I tested it and it worked. I don't know how zathura handles it but only with set synctex true
it worked.
That's amazing, I tested it and it worked.
Glad to hear it!
I don't know how zathura handles it but only with
set synctex true
it worked.
You don't even need set synctex true
. Things should work even without a zathurarc
file.
Things should work even without a
zathurarc
file.
I had some vim like shortcut for doing stuff in zathura like pdf-page-extract or launching other app or even compile which is the basis of my affection for that pdf app as well, so let's keep that at least after all this :smiley:
Yes, of course; I should have been more clear. My point was only that I don't think you even need to have set synctex true
. :)
I also encountered the reverse search issues using zathura
.
I followed the instruction, and the workflow works:
.tex
file using nvim<leader>ll
<leader>lv
In the PDF opened via zathura
, I tried reverse search by holding <ctrl>
and clicking the text, but it did not go to the line in .tex
file.
The viminfo
:
System info:
OS: Manjaro Linux
Vim version: NVIM v0.9.0
Has clientserver: true
Servername: /run/user/1000/nvim.4035481.0
VimTeX project: week1-intro
base: week1-intro.tex
root: /home/zhongpu/github/python-swufe/slides
tex: /home/zhongpu/github/python-swufe/slides/week1-intro.tex
main parser: current file verified
document class: beamer
packages: CJKfntef algorithm2e amsbsy amsfonts amsgen amsmath amsopn amssymb amstext amsthm atbegshi atbegshi-ltx atveryend atveryend-ltx auxhook beamerbaseauxtemplates beamerbaseboxes beamerbasecolor beamerbasecompatibility beamerbasedecode beamerbasefont beamerbaseframe beamerbaseframecomponents beamerbaseframesize beamerbaselocalstructure beamerbasemisc beamerbasemodes beamerbasenavigation beamerbasenotes beamerbaseoptions beamerbaseoverlay beamerbaserequires beamerbasesection beamerbasetemplates beamerbasethemes beamerbasetheorems beamerbasetitle beamerbasetoc beamerbasetranslator beamerbasetwoscreens beamerbaseverbatim beamercolorthemedefault beamercolorthememetropolis beamerfontthemedefault beamerfontthememetropolis beamerinnerthemedefault beamerinnerthememetropolis beamerouterthemedefault beamerouterthememetropolis beamerthemedefault beamerthememetropolis bigintcalc bitset booktabs calc caption caption3 catchfile color ctexhook enumerate etexcmds etoolbox expl3 fancyvrb float fontawesome5 fontawesome5-utex-helper fontenc fontspec fontspec-xetex framed fvextra geometry gettitlestring graphics graphicx hycolor hyperref ifluatex ifoddpage ifplatform iftex ifthen ifvtex ifxetex infwarerr intcalc keyval kvdefinekeys kvoptions kvsetkeys l3keys2e letltxmacro lineno ltxcmds minted nameref pdfescape pdftexcmds pgf pgfcomp-version-0-65 pgfcomp-version-1-18 pgfcore pgffor pgfkeys pgfmath pgfopts pgfplots pgfplotsthemetol pgfrcs pgfsys refcount relsize rerunfilecheck sansmathaccent scrlfile scrlfile-hook scrlogo shellesc stringenc textcomp tikz translator trig uniquecounter upquote url xcolor xeCJK xeCJKfntef xparse xspace xstring xtemplate xxcolor
compiler: latexmk
engine: -xelatex
options:
-verbose
-file-line-error
-synctex=1
-interaction=nonstopmode
callback: 1
continuous: 1
executable: latexmk
job:
jobid: 17
output: /tmp/nvim.zhongpu/MxB31z/0
cmd: max_print_line=2000 latexmk -verbose -file-line-error -synctex=1 -interaction=nonstopmode -xelatex -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"' 'week1-intro.tex'
pid: 4040525
viewer: Zathura
xwin id: 157286403
cmd_start: zathura -x "/usr/bin/nvim --headless -c \"VimtexInverseSearch %{line} '%{input}'\"" --synctex-forward 554:11:'/home/zhongpu/github/python-swufe/slides/week1-intro.tex' 'week1-intro.pdf'&
qf method: LaTeX logfile
I also encountered the reverse search issues using
zathura
.
This discussion was closed as resolved. I would much prefer you open a new issue. And if/when you do, please use a minimal example as explained in the issue template. Or, at the very least, provide your neovim config.
I am trying to exploit this latest vimtex functionality
VimtexInverseSearch
for Zathura to instead of gvim, open current vim in terminal. This has been a long issue and this new command can solve it. However, I have tried various format of recommend vimtex command from the help like this:This opens following buffers:
-v
--not-a-term
-T
dumb
-c
VimtexInverseSearch 68 /run/media/path/to/file.tex
it clearly do not parse after
vim --remote-silent
as vim options, however this works:I haven't seen a problem when removing those options
remote-silent -v --not-a-term -T dumb
, not sure about implications, but is there a workaround this?p.s. Zathura inverse search works with
CTRL-SHIFT-Click
and it should be re-launch after each config. p.s. I created a issue in upstream as well p.s. This gist also tries to solve this, but beforeVimtexInverseSearch()
era.