R-nvim / R.nvim

Neovim plugin to edit R files
GNU General Public License v3.0
178 stars 18 forks source link

Running R in a ToggleTerm #184

Closed lucasvoirin closed 4 months ago

lucasvoirin commented 4 months ago

Thanks for this great plugin!

I'd like to know if it's possible to run R in a ToggleTerm from akinsho/toggleterm.nvim instead of the default nvim terminal?

jalvesaq commented 4 months ago

I don't have ToggleTerm installed, but you can try to run R in it and check if the functionality that depends on R being running works, such as <LocalLeader>rh and <LocalLeader>ro. Please, report your results.

lucasvoirin commented 4 months ago

It seems that R.nvim does not detect R when it is run in a ToggleTerm. Functionalities like <LocalLeader>rh and <LocalLeader>ro indicate that R is not running (with messages like Did you start R? and The Object Browser can be opened only if R is running.). Maybe because ToggleTerm is opened by a specific :ToggleTerm command ( and not by :term)?

jalvesaq commented 4 months ago

If you look at the function r.run.start_R2() you will see that it saves a file to be sourced by R on startup before calling the function r.term.start_term(). So, to run R in a ToggleTerm or any non-supported terminal emulator, it will be necessary to override at least some of the functions from the Lua module r.term. I'm sorry, but I'm not going to do this. If you convince us of the advantages of ToggleTerm, we could make R.nvim dependent on ToggleTerm, but others might prefer other plugins to manage Neovim's built-in terminal emulator...

My personal preference is to avoid dependencies as much as possible.

lucasvoirin commented 4 months ago

No problem, I completely understand! Thank you for your quick response!