0

I have the following line in my nvim configuration file:

map <leader>c :w! \| !compiler <c-r>%<CR>\| !zathura $(echo %:r".pdf") && disown<CR><CR>

The first part (or 2/3 of the line) works to compile the file I'm working, but I want to bring up zathura when this happens. Can I modify the last bit? It's my best guess but it doesn't work right now. Also, I don't want multiple instances of zathura to be open (If I say, compile and then recompile).

I should add that the compiler command automatically runs pdflatex.

1

2 Answers 2

1

I recommend using the vimtex plugin.

It allows opening zathura as a PDF viewer after compiling in one step. Also it has continuous mode, meaning that you will be able to see automatically compiled changes immediately in the running zathura instance.

0

If the currently active file is your main file (which the !compiler invocation already assumes), you can open the corresponding pdf with

!zathura '%<'.pdf&;disown<cr>:redraw!<cr>

The :redraw! part is not strictly necessary.

This doesn't solve the "don't open another instance" part of your question. This could be done with a boolean indicating that zathura was already called...

6
  • This doesn't work for me, when I try to use the command on it's own, the bottom of the vim terminal flashes for a second and nothing changes. Aug 16, 2020 at 17:08
  • I have the vim file open as blah.tex , this may be why. How do I change this in vim cmd line? Aug 16, 2020 at 17:12
  • :! zathura $(echo "%" | cut -f 1 -d '.').pdf opens the file , but I wan't to open in a new dwm window. How do I do this? Aug 16, 2020 at 17:28
  • Im thinking something like zathur --fork foo.pdf, but this doesn't work on the command line Aug 16, 2020 at 17:39
  • @mtheorylord the & does fork it into the background. And I use the above command for productive use since years ago (without the ;disown part)... And it should open blah.pdf if your currently active buffer's name is blah.tex.
    – Skillmon
    Aug 16, 2020 at 20:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.