jalvesaq / Nvim-R

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

Workspace loads from $HOME, but saves in CWD (Mac OS X) #176

Closed qabulin closed 1 year ago

qabulin commented 7 years ago

No matter what directory I'm in, the Nvim-R console loads from the user home ~/.RData workspace. However, the image that is saved when quitting goes to ~//.RData. I'm not sure how this is happening, and tried to remove every .RData file from my system to start fresh just in case. I do not have this problem with just the vanilla R console by itself.

My version outputs: Vim 8.0 & R-3.3.2

Demonstration:

  1. vanilla R console shows correct workspace object before change:

    getwd() [1] "/Users/hito/code/r" ls() [1] "cat"

  2. Nvim-R pop-out console shows wrong workspace object, and overwrites CWD:

    getwd() [1] "/Users/hito/code/r" ls() [1] "dog" rat <- "lester" save.image()

  3. vanilla R console shows same CWD workspace, now modified:

    getwd() [1] "/Users/hito/code/r" ls() [1] "dog" "rat"

  4. vanilla R console shows home directory workspace, actually loaded above by Nvim-R:

    getwd() [1] "/Users/hito" ls() [1] "dog"

jalvesaq commented 7 years ago

What is your operating system? I can't reproduce the bug on Linux (Ubuntu 16.10).

jalvesaq commented 7 years ago

Please, see:

:h R_nvim_wd
qabulin commented 7 years ago

Thanks for the quick follow up!

My operating system: OS X 10.10.5 (14F2109)

Unfortunately, R_vim_wd = 1 does not give me Vim's working directory. When R_vim_wd = -1, getwd() returns user home as expected, which is more accurate to the workspace behavior I'm experiencing.

After further digging and trying different options, it seems that this may be just be related to the Mac Terminal app I'm using for the R console. There is a setting "New windows open with: Same Working Directory" that is not getting the working directory Vim is in, even when tweaking the R_vim_wd setting.

HOWEVER, if I use a Tmux window for my R console, the workspace current working directory does load and I DO get the correct image.

So for some reason, this appears to be limited only to using Terminal app for R console.

jalvesaq commented 7 years ago

Thanks for the feedback! I don't have any Mac to make tests, but we may let issue open because perhaps someone might know how to fix it.