Giter VIP home page Giter VIP logo

Comments (8)

jalvesaq avatar jalvesaq commented on July 22, 2024

It's not that easy. StartR() and RQuit() do more than start and quit R. The functions also set environment variables, create and close Tmux panes etc. I added the option "restart" to the "how" argument of RQuit(). I didn't test it carefully, but it should work with GVim and with Vim if Tmux is started before Vim (please, see the tip about tvim in the plugin's documentation). To restart R, do the following in Vim:

:call RQuit("restart")

We still have to create a user interface to this command. One option is to create yet another shortcut, but I don't know what it could be because <LocalLeader>rr and <LocalLeader>re are already in use. Other option is to create a vimrplugin_ option to turn <LocalLeader>rm into “restart R” instead of just “remove all objects from workspace”. Another option is to create a command, like :RestartR

from vim-r-plugin.

jalvesaq avatar jalvesaq commented on July 22, 2024

Did you test the RQuit("restart")?

from vim-r-plugin.

mllg avatar mllg commented on July 22, 2024

Just now.

Works if vim is started inside a tmux session. Otherwise strange behavior: First only the error message "Cannot restart R" popped up, then (after one successful try inside tmux) a new console window is opened instead of vim restarting (?) in a tmux split. And this is permanent across sessions: now even a normal R start (\rf) is opening a new window. Restarting works though. Haven't tested it with gvim.

I'm using vim-7.4.5, tmux-1.8 and KDE's konsole as terminal emulator on Gentoo.

Maybe some other plugins are conflicting. If you cannot reproduce, i'll try it with a clean vimrc.

from vim-r-plugin.

jalvesaq avatar jalvesaq commented on July 22, 2024

In my last commit I removed the integration with screen plugin. Now, it's necessary to be in a Tmux session to split the terminal in two regions: 4226112

Please, look for the "tvim" tip on the plugin's documentation.

from vim-r-plugin.

mllg avatar mllg commented on July 22, 2024

Missed that. Than the restart works as intended. But I think RQuit("restart") should start a new R session if none is running. I think I would then remap \rf to start/restart then, although it is a little risky.

Also, with the last commit you can start multiple R sessions (unsure if bug or feature) but only quit the last one started.

from vim-r-plugin.

jalvesaq avatar jalvesaq commented on July 22, 2024

I will create the option vimrplugin_restart. When vimrplugin_restart = 1, \rf and \rv will mean "Restart R if it's already running and start it if not running yet".

Vim can only quit the last R session: The plugin creates the variable $VIMINSTANCEID whose value is the name of the first buffer opened + local time at startup. This prevents Vim sending code to the wrong R Console in circumstances like the following:

  1. Start Vim as: vim script_1.R
  2. Open script_2.R
  3. Start R.
  4. Close the first tab (script_1.R)
  5. Start a new instance of Vim as: vim script_1.R

If you close Vim without quitting R with \rq the R session gets "abandoned".

from vim-r-plugin.

jalvesaq avatar jalvesaq commented on July 22, 2024

I added the option vimrplugin_restart for Linux/Unix only. If its value is 1, \rf, \rv or \rc will restart R if it's already running.

The function RQuit() no longer deals with the argument "restart".

from vim-r-plugin.

mllg avatar mllg commented on July 22, 2024

Thanks!

from vim-r-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.