Cannot reopen R session after it is closed
Recently I started having an issue where after opening a R session (\rf), and closing it with :q in neovim, it cannot be reopened in the same neovim instance. That neovim instance must be closed out completely and restarted. But, if instead I use ^d in R, and answer n (or y) to the prompt about saving r data, it can be reopened. Luckily this is a minor inconvenience and not a major issue.
I did not explore why this might be the case but am happy to look more closely with your guidance. This my favorite package and am happy to contribute if need be.
R version 4.1.2 arm based Mac OS Monterey 12.1 on an M1 chip NVIM v0.6.1 compiled by homebrew nvim-r 0.9.16
I can replicate the issue. With :q it seems that we simply detach R, but it keeps running. I can find its PID with:
ps -Af | grep R
I can start R again with <LocalLeader>rf if I kill R:
kill 123456
where 123456 is the R PID.
Note: you can also kill R with the :RKill command. I could add an autocmd to the R Console buffer to kill R when its window is closed, but users can use :q on purpose to hide R and :b2 to open it again... So, I'm not sure if not killing R automatically is a bug or a feature.
The :RKill command works exactly how I would need it to and is sufficient, thank you!
As for :b2 this opens my nerdtree file browser and not R. Although, I won't use that feature. Just letting you know it is not working on my device potentially because of the nerdtree plugin.
The command will be :b3 if the R Console is the third buffer to be opened.
Now, <LocalLeader>rf reopens the R buffer if it was manually closed.