jalvesaq / Nvim-R

Vim plugin to work with R
GNU General Public License v2.0
968 stars 126 forks source link

RMarkdown to PDF opens a new window every time. #783

Closed Unaimend closed 11 months ago

Unaimend commented 11 months ago

First of all, thank you for this great plugin,

I just have a small question/suggestion currently when executing RMakeRmd("pdf_document") a new window of my pdf-viewer application is created every time. Is there some way of making this more ergonomic by replacing the already open window with a new instance?

Thanks for your time Thomas

jalvesaq commented 11 months ago

It depends on the operating system and pdf viewer. What are yours?

Unaimend commented 11 months ago

OS: Ubuntu 22.04.2 LTS PDF viewer: zathura 0.4.9

jalvesaq commented 11 months ago

It used to work on the X Server: the Zathura window was raised to the top by wmctrl. But on Wayland it is necessary a different method of raising the window for each desktop environment (Gnome, KDE, XFCE, Sway, etc). I have tried the Gnome Shell Extension "Activate Window By Title", but it seems that it no longer works. I'm currently using the Sway window manager, and I can't develop and maintain a different system of raising windows for desktop environments that I don't use. So, pull requests for each desktop environment are welcome. The function to be patched is RRaiseWindow() (at R/pdf_init.vim).

Note: on Sway, I would have to use the command swaymsg, but it doesn't make sense to be worried about raising windows on Sway because by default all windows are visible, and float windows are always on top of normal windows.

jalvesaq commented 11 months ago

While we wait for the pull requests, I changed the default value of R_openpdf to 1 on Wayland...

Unaimend commented 11 months ago

Sorry. I still use X with i3. I should have specified that but I will look into the function you mentioned. Maybe I can figure out what is going on.

jalvesaq commented 11 months ago

And, what is your pdf viewer?

Unaimend commented 11 months ago

PDF viewer: zathura 0.4.9

jalvesaq commented 11 months ago

The function RStart_Zathura() (at R/pdf_zathura.vim) should kill the running instance of Zathura and start a new one. But it relies on the name of the pdf being in the window title. Anyway, whether the function still works properly or not, I guess that, as in my case, R_openpdf=1 is what you need.

Unaimend commented 11 months ago

Thank you very much. This worked. I cannot express in words how thankful I am for this plugin