jalvesaq / nvim-r Goto Github PK
View Code? Open in Web Editor NEWVim plugin to work with R
License: GNU General Public License v2.0
Vim plugin to work with R
License: GNU General Public License v2.0
I am using the Nvim-R on Mac OS X El Capitan (10.11.3). It works perfectly if I use Neovim or terminal MacVim to open a .R script and send commands to R from there. However, Neovim does not work with the gui version of MaVim. The problem is described as follows:
After openning a .R file from gui MacVim, I used ",rf" to call R console. R was then opened in a separate terminal window. Now the problem started. When I tried to use any command to send code, eg, ",aa", ",rq", etc, nothing was happening in R and I cannot see any command being sent.
Not sure if this is also happening in other operating systems.
If I start R (\rf) and eventually close R (\rq) but then start R again (\rf) having never exited my nvim session, then the neovim server port is not passed to R. I tried to find the bug myself, but did not have any luck.
Here's some relevant output
nvim:
\rf (start R the first time)
R:
nvimcom: NVIMR_SVRNM=Neovim_0
nvimcom 0.9.1 loaded
NVIMR_TMPDIR = /dev/shm/R_tmp_dir
NVIMR_ID = LaIj8ZY9E43Rx1lBKedjTw
nvimcom port: 10003
nvimcom Received: [1] 1902
nvim:
:echo $NVIMR_SVRNM
Neovim_0
nvim:
:Rhelp lm (help pops up in nvim)
R:
nvimcom_nvimclient(ShowRDoc('lm')): '1902' (1902)
nvim:
\rq (quit R)
\rf (start R again)
R:
nvimcom: NVIMR_SVRNM=Neovim_1902
nvimcom 0.9.1 loaded
NVIMR_TMPDIR = /dev/shm/R_tmp_dir
NVIMR_ID = LaIj8ZY9E43Rx1lBKedjTw
nvimcom port: 10003
(((SVRNM is different and nvimcom Received: [1] 1902 does not show up)))
nvim:
:echo $NVIMR_SVRNM
Neovim_1902
nvim:
:Rhelp lm (help does not pop up)
R:
nvimcom_nvimclient(ShowRDoc('lm')): '' (0)
nvimcom_nvimclient() called although Neovim server port is undefined
Let me know if there is any more information that would be helpful.
Hello and thank you for this brilliant plugin!
For the life of me, I can't get it load the right version of R. The first R executable in my PATH is the one I want, but the plugin keeps running a version under /usr/lib64/R (which doesn't have the right libraries installed). I've set let R_path = "/path/to/preferred/R/R-3.1.2/bin"
in my .nvimrc
, but that doesn't seem to change anything.
Thank you for your help.
Is there option to force r console open in a tmux windows instead of external console with vim rather than nvim?
I'm not ready to work with neovim
It's Solved. Thanks for your great plugin
I have to read the doc of Nvim-R in these days.
Load nested functions dosn't include the outer function.
Cheers
getInParentsFrame <- function(name){
# recursing through parent frames looking for name
sysf <- rev(sys.parents())
ff <- function(sysf){
n <- head(sysf,1)
if (length(sysf) == 0)
{
return ("")
}
env <- sys.frame(n)
if (identical(env, emptyenv()))
{
return ("")
}
else if (exists(name, envir = env, inherits = FALSE))
{
get(name,envir=env)
}
else
{
ff(tail(sysf,-1))
}}
ff(sysf)
}
results in the tmp file :
cat /tmp/Nvim-R-te/Rsource-11287
ff <- function(sysf){
n <- head(sysf,1)
if (length(sysf) == 0)
{
return ("")
}
env <- sys.frame(n)
if (identical(env, emptyenv()))
{
return ("")
}
else if (exists(name, envir = env, inherits = FALSE))
{
get(name,envir=env)
}
else
{
ff(tail(sysf,-1))
}}
When a user wants to install vim-r-plugin they google and go to:
http://www.vim.org/scripts/script.php?script_id=2628
These instructions point to the install instructions:
https://raw.githubusercontent.com/jcfaria/Vim-R-plugin/master/doc/r-plugin.txt
When I go through the install instructions it says
Ok I go to the link and it directs me to the release page which is a repo that is marked deprecated:
https://github.com/jalvesaq/VimCom/releases
which in turn diects me to this repo
So is installing github Nvim-R all that is needed now?
No need to install Rtools? No need to use devtools and install vimcom (the old webpage which had these instructions has vanished).
The info on this repo says we can install Nvim-R via Vundle. But if I do that, I take it that vim-r-plugin is not installed? But it also says that Nvim-R is an offshoot of vim-r-plugin. So it DOES include the vim-r-plugin? If so if I install Nvim-R it WILL include vim-r-plugin and I WON'T have to install via downloading the vmb file from vim.org and installing with so %? So I don't need to do anything from the R console then?
Sorry if the above is confusing, but the instructions on this repo, githubuserconent.com and vim.org are confusing so I don't know how to understand it.
Thanks
I've just installed nvim-r. To check if it's working fine, i created an example script file with a simple R command. I then started R (\rc
) and ran the line. The command was executed fine, but some seconds after I received the message:
Vim: Caught deadly signal SEGV
Vim: preserving files...
Vim: Finished.
Segmentation fault (core dumped)
Tried with some other scripts i have, happened the same.
My first guess was to come here and check the closed and opened issues, found nothing. Over the web ti says it can be caused by a number of reasons, including hardware, which i doubt, or vim itself. But since it doesn't happen with other plugins or vim alone, I thought I should come here and see if you guys can help me.
I am running vim with Nvim-R and I have encountered a problem with the vertical split option. When I initiate R and then switch to the R pane (i.e. with -o), the lines in R seem to bleed over into my vim Rscript pane. It is purely an aesthetic thing, and when I switch back to the vim Rscript pane and move the cursor over those lines, they clear up. When I switch back, however, the bleedover reoccurs. The following screenshot should illustrate the issue. This does not happen when the panes are split horizontally.
Hi,
in the previous vim-r pluging I had a hotkey to start R, but also restart R if it was already running.
I used let g:vimrplugin_restart = 1
I saw in your news that you apparently had a restart option for the rewrite of the new plugin, but removed this.
a) Why did you remove this?
b) Is there still a way to emulate the restarting?
I think the problem is that in the RComment function, cmt variable is defined as '#', instead of using g:R_rcomment_string like in the RSimpleCommentLine. I am not sure if you intentionally prevent customization of RComment function or there is another way to make the customized comment string working with that setting. In my case, after I change the code to
let cmt = g:R_rcomment_string
my customized comment string shows up instead of the original #.
I’m running NVIM 0.1.3-dev with Nvim 0.9.1 inside iTerm 2 Build 1.0.0.20130319. I’d like to use tmux instead running R inside an Nvim buffer for various reasons (1). In Vim/Vim-R I could simply launch Vim inside tmux and then, when launching R using rf, I got a nice vertically split screen with Vim and the R console.
I’ve tried achieving the same in Nvim-R using the following configuration:
let R_term = "xterm"
let R_silent_term = 1
let R_vsplit = 1
However, when launching R via rf, R is instead launches inside a separate xterm.app window. How can I disable this and instead launch R inside the tmux split screen?
(1) The main reason is that the input mode in the R console works very weirdy; it doesn’t respect inputrc (duh), but nor does it accept proper vim movement commands; for instance, Esc, 0 does not go to the beginning of the command line (well; it does, but once I go back into insert mode I’m back at the end of the line). It also seems inconvenient that I cannot change focus back to the editor buffer without first leaving insert mode; but maybe I’m overlooking something.
I'm currently using Vim on ubuntu 14.04. I also compile Vim from source to satisfy the dependencies. But when I started R by using \rf the following errors shown on
Error detected while processing function StartR[88]..StartR_Neovim: line 28: E117: Unknown function: termopen E15: Invalid expression: termopen(g:rplugin_R . " " . join(g:rplugin_r_args), {'on_exit': function('ROnJobExit')}) line 43: E492: Not an editor command: tnoremap <buffer> <Esc> <C-\><C-n> line 45: E216: No such group or event: TermClose <buffer> call OnTermClose() The package nvimcom wasn't loaded yet.
I'm trying to create an Arch Linux PKGBUILD
for nvim-r
. I'm not sure if you are familiar with Arch packaging, but the pertinent lines are as follows.
vim -c "UseVimball ${pkgdir}/usr/share/vim/vimfiles" -c q \
"${srcdir}/Nvim-R.vmb"
rm "${pkgdir}/usr/share/vim/vimfiles/.VimballRecord"
rm "${pkgdir}/usr/share/vim/vimfiles/doc/tags"
Basically, this installs the vimball (downloaded from the Github Releases
page) into /usr/share/vim/vimfiles/
(with root permissions). However, when I open a *.Rmd
file in vim
, then start R
with <leader>rf
, I get the following error.
* installing to library ‘/home/protist/R/x86_64-pc-linux-gnu-library/3.2’
* installing *source* package ‘nvimcom’ ...
** libs
gcc -I/usr/include/R/ -DNDEBUG -D_FORTIFY_SOURCE=2 -fpic -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -c nvimcom.c -o nvimcom.o
Assembler messages:
Fatal error: can't create nvimcom.o: Permission denied
/usr/lib64/R/etc/Makeconf:134: recipe for target 'nvimcom.o' failed
make: *** [nvimcom.o] Error 2
ERROR: compilation failed for package ‘nvimcom’
* removing ‘/home/protist/R/x86_64-pc-linux-gnu-library/3.2/nvimcom’
I don't quite understand how nvimcom
is being installed, but is the error due to the original vimball being installed with root permissions? If so, would you suggest I fix the PKGBUILD
to install nvimcom
during the package installation, i.e. with root permissions and out of vim/R?
I'm not sure if this is an issue that relates more to Nvim-R or Neovim itself, but I thought I would describe here first in case you have some insights.
The problem occurs whenever open a new file after opening an R console is already open. When I then close the buffer associated with the new file, the terminal which was previously split screen becomes a separate buffer and the split goes away altogether.
To reproduce:
,rf
:e test2.R
:bd
Neovim version: NVIM v0.1.3-350-gc94575f
With any command in the form of:
:Rhelp item
the response is:
Error detected while processing function ROnJobStdout..ShowRDoc:
line 40:
E121: Undefined variable: b:objbrtitle
Press ENTER or type command to continue
This happens on Ubuntu 14.04 with an up to date version of neovim. I have installed w3m and use the .Rprofile settings as they are suggested in the documentation.
I am getting these error messages when I open R or Rmd files. Do I have a missing package?
"test.R" 3L, 24C
Error detected while processing ~/.config/nvim/ftplugin/r.vim:
line 97:
E117: Unknown function: RCreateStartMaps
line 98:
E117: Unknown function: RCreateEditMaps
line 101:
E117: Unknown function: RCreateMaps
line 102:
E117: Unknown function: RCreateMaps
line 103:
E117: Unknown function: RCreateMaps
line 107:
E117: Unknown function: RCreateMaps
line 109:
E117: Unknown function: RCreateSendMaps
line 110:
E117: Unknown function: RControlMaps
line 111:
E117: Unknown function: RCreateMaps
A chunk that has a variable or function name with a back-tick will not be sent correctly to the R session. For example:
```{r}
`%notin%` <- function(x,y) !(x %in% y)
```
resulting in an unexpected SPECIAL
error
```{r}
`Binomial nomenclature` <- 3
```
resulting in an unexpected INCOMPLETE_STRING
error
Perhaps the definition of the chunk could look at consecutive back-ticks. It seems as if it only looks at the first.
I have just set up the Nvim-R plugin for Neovim
to send lines of code from an .R
-file opened with Neovim
to a terminal inside a tmux
session.
Previously, I have worked with its predecessor Vim-R, which is no longer being maintained.
In the old Vim-R
, it was easy to send a visually selected block of code to the terminal by pressing the r
key while in visual mode after adding the following line to my .vimrc
:
let g:vimrplugin_map_r = 1
However, this feature seems to be deprecated in the new Nvim-R
-plugin. As a workaround I have tried to add the following line to my .vimrc
:
vmap <Space> <Plug>RDSendSelection
This actually allows me to send a visually selected section to the terminal, however, it always includes the next non-empty line after the selection, which is irritating. This is especially so, because it even ignores multiple blank lines.
How can I modify this behavior?
Hi, the syntax highlighting for R markdown is not working.
and i can send code from outside the triple backtick braces. any idea how can i fix this?
I'm trying to migrate to Nvim-R from Vim-R-Plugin.
Unfortunately neovim won't install on my system so I have to use vim.
How can I enable the channel, conceal and job features in vim at compilation time? Google is failing me.
Thanks,
Enrico
Have tried setting it inside and out of .vimrc, have tried changing R_assign_map as well. Mvim and I'm loading plugin with Vundle as Plugin 'vim-scripts/Vim-R-plugin'
Hi jalvesaq, first of all let me say that I am huge fan of this plugin and also vimcmdline. There is one thing I noticed when using this plugin: when knitting an Rmd file to a beamer presentation, for example, the resulting pdf is opened in a new window every time. It would be better if the pdf was only opened after the first time the file is knit. I realize I can set R_openpdf = 0 in my vimrc file, but then it won't open automatically when I first knit.
Thanks!
First off, great plugin! I use it religiously!
One minor issue: As part of the "Learn Vimscript the Hard Way" series, I remapped my <ESC>
key to <nop>
to train my fingers to the (much better, in my opinion) jk
for getting out of insert more. However, this change breaks the very useful Shift -
key for creating R's assignment operator. From looking at your code, this is because the function ReplaceUnderS()
calls the <ESC>
key explicitly.
I feel like there's a relatively simple way to fix this. Maybe by using the normal!
command instead of calling the <ESC>
key? Or just using inoremap
in the binding?
Removing my own maps on <ESC>
fixed the problem, but I think this is worth fixing for people who might have <ESC>
bound to other things.
Just a friendly advanced warning. Changes mainly affect jobstart invocation & handler function.
See neovim/neovim#2247.
I tried to set this option to 5 but the height on startup was still half of my window. When I set it to a large value, for example 30, it actually worked. The startup window height increased. At first I thought it might because of the startup messages. I tried to use Rstart custom and type --quiet, but nothing changed. So I am asking, whether it is possible to set this option to a small value? I set R_vsplit = 0
Hi Jalvesaq,
I could not find any Nvim-R.vmb release as mentionned at https://github.com/jalvesaq/Nvim-R for instsalling Nvim-R.vmb ? COuld you please help for installing it?
Thank you anyway so much for the work so far!
Manuel
To repeat in on Ubuntu 14.04 tmux 1.8:
Error detected while processing function ROnJobActivity..ShowRDoc:
Line 17
E121: Undefined variable: g:rplugin_R_bufname
OS: GNU/Linux Debian Jessie - Nvim-R.0.9.3
The installation of nvimcom failed because rewritable directory (/usr/...). I solved it by a build of the nvimcom package using the sources (R CMD BUILD nvimcom) and installed it from the R (install.packages(...)).
PS: Nvim-R plugin is really a good job, bravo!
For example, I set R_rconsole_height=3. After I opened neovim terminal in horizontal split window and closed it, the R console height would increase. But this situation won't happen when I use Unite, which also opens a buffer in split window. After I closed Unite, the R console height kept unchanged. Is it a problem from neovim? or is it a problem from Nvim-R?
Hi,
I see a lot of (functional!, not source) overlap between this project and slimv
. Both make it possible to run another REPL process, and to exchange information between them. (In fact, I'm currently using vim
, slimv
, and swank-r
for my R needs.)
Because of this overlap it would be great if both projects could be using the same keybindings; what is called "Send file" (\aa
) here is "Evaluate buffer" (,eb
) in slimv
, and so on.
On opening a .Rmd file, I get the following error:
Error detected while processing ~/.nvim/bundle/Nvim-R/ftplugin/rmd_nvimr.vim.
line 158:
Undefined variable: b:undo_ftplugin
As far as I can tell, all the features of the plugin work fine, but this error pops up every time a .Rmd file is opened, and occasionally while editing the file as well.
From poking around GitHub issues with other plugins (example), I think this can easily be fixed by checking if b:undo_ftplugin
is set before appending to it with .=
.
This may also be a problem on my end, via a conflict with a different package. But regardless, I feel like a check on the existence of a variable can't hurt.
Otherwise, great plugin! I use it religiously.
Dear Nvim-R.
I am a vim-r-plugin user and thought I would check out the Nvim-R.
I am unfortunately somewhat stuck, after having installed neovim (easy), and vimballed
the nvim-r ? It would extremely helpful with some more installation details on how to
do the next couple of steps.
best
Can this plugin also set the (local) commentstring
?
I use @tpope's vim-commentary and I have to set thecommentstring
for R files like this:
autocmd FileType r setlocal commentstring=#\ %s
Anyway, is it this plugin's responsibility to set filetype-specific variables (like indentation, makeprg
, equalprg
, ... and commentstring
)? If yes, I would love to see commentstring
supported.
I has used neobundle to install Nvim-R and install RTools
version of R is 3.2.4, RTools is RTools33
but when i push C-X C-O will appear " List is empty, Did you load nvimcom package? "
Is nvimcom automatically loaded ?
When using Nvim-R, if type in a vi
command in the R terminal to check the definition of a function, like
vi(ls)
then we can exit it by pressing ZZ. But if it is launched from the R code window, then basically I found we would be stuck. If pressing ZZ in the so-called terminal window now, it would close the whole terminal rather than the interior vi.
It might not be a bug. Understand it is a nasty thing: a vi inside vi. Any suggestions? Thanks!
As a RStudio user I kind of got used to sending R-code with <Control-Enter>
to the REPL. However this was tricky to configure in neovim and I didn't find anything in the documentation of Nvim-R. So here is one solution working in Ubuntu 14.04 with gnome-terminal. The tricky part is to find out what the terminal actually sees when <Control-Enter>
is hit; this I found out using this stackoverflow question. And here is the solutions:
nnoremap <C-J> :call SendLineToR("stay")<CR><Down>
inoremap <C-J> <Esc>:call SendLineToR("stay")<CR><Down><Home>i
vnoremap <C-J> :call SendSelectionToR("echo", "stay")<CR><Esc>
<C-J>
is interpreted as nil: <NL>
which is apparently what gnome-terminal detects as input. Since there is already an example for <Space>
in the documentation I thought it might be an interesting addition.
Thanks for Nvim-R!
-s
Hope this is the right channel for issue like this: When I open a help in R and close it, the object window holding the R console all of a sudden is taking half of the window size in comparison to the 1/3 set up. I was wondering if there's a way to restore the windows to the initial sizes before the opening of the help file. This occurs on linux running nvim in terminal.
Since new iTerm2 supports in-line images, I am wondering whether it is possible to output R graphs directly into iTerm so I don't have to use X11 anymore. iTerm image viewer is imgcat and there is an external matplotlib backend for iterm too. In addition, iTerm can also view pdfs (termpdf), although it is really beta for now.
OS: Windows 7x64, R-3.1x64
After installing Nvim-R, I am not able to load packages (via library) installed in the user directory R_LIBS_USER, although the corresponding environment variable has been set. Installing the packages as admin into R_HOME solves the problem, but requires admin rights all the time when installing new packages.
If invoking R in a separate terminal window, the focus is given to the newly called terminal window that runs R. Is it possible to keep the focus on the nvim/vim terminal window?
Thanks.
Using Skim on OSX, with let R_openpdf = 1
, every time I recompile, it spawns a new instance of Skim. Changing this value to 0 prevents Skim from being opened at all, so it works as expected in that regard.
I need to launch a wrapper script instead of R itself. Consequently, my R_path used to be configured (in Vim-R-plugin) as follows:
let vimrplugin_r_path = "~/.R/launcher.sh"
This launcher.sh
is just starting R on my local computer, but on the cluster on which I’m working it’s a more complex command that submits an interactive job to a cluster:
bsub -Is -XF -M 16000 -R 'rusage[mem=16000]' R
Alas, this no longer works because R_path
now expects only a directory. As a workaround I can rename launcher.sh
to R
but this isn’t really desirable because it creates confusion with executable names. Was there a good reason for changing this setting to expect a directory rather than a path to the executable?
I have been using the Vim-R-Plugin with homebrew vim within a tmux session on OS X and wanted to preserve the existing behavior. Namely the R session starts within the tmux session rather than in a new window.
After combing through the docs I eventually found setting let g:R_tmux_split = 1
in my .vimrc
did what I wanted.
I am not sure if this setup is common enough to document, but I wanted to document the problem and solution in case others have the same issue.
If you don't feel any further documentation is needed this can be closed as I have a resolution.
versions: nvim-r--0.9.0, neovim--v0.1.0-45-gbb43d9b
After compiling pdf using \kp
for a .rmd file, I get the error message:
Error detected while processing function ROnJobStdout:
line 7:
E117: Unknown function: ROpenPDF
Press ENTER or type command to continue
This appears to be a new issue; I haven't had this problem before.
Attempted to update nvim-r and neovim.
Relevant lines in init.vim:
let R_pdfviewer = "zathura"
let R_openpdf = 1
Edit: I should add that I can open the pdf manually just fine from outside nvim, so it is compiling correctly, however \op seems not to work because it simply calls \o and then pastes from the first register.
I am confused that I am now using traditional vim 7.4, but this plugin says it is compatible with neovim. Can I use this plugin with vim? Thank you!
In nvim 0.1 there is no longer an .nvimrc file, but things have moved to ~/.config/nvim/init.vim. So the instruction for the runtimepath in the readme.md
file would read:
set runtimepath+=~/NVim-R, ~/.config/nvim, $VIMRUNTIME, ~/.config/nvim/after
However, I checked, and i have never set the runtimepath and worked with Nvim-R without issue. There is no mention in the documentation of what runtimepath would actually do, and what would go in the ~/NVim-R folder once set.
Could you explain the need to set runtimepath a little bit further?
Trying to run Nvim-R on Windows 10 (starting with \rf
) yields the error message:
* installing to library 'C:/Users/frans/Documents/R/win-library/3.2'
* installing *source* package 'nvimcom' ...
** libs
*** arch - i386
Warning: running command 'make -f "Makevars.win" -f "C:/PROGRA~1/R/R-32~1.4RE/etc/i386/Makeconf" -f "C:/PROGRA~1/R/R-32~1.4RE/share/make/winshlib.mk" SHLIB="nvimcom.dll" OBJECTS="nvimcom.o"' had status 127
ERROR: compilation failed for package 'nvimcom'
* removing 'C:/Users/frans/Documents/R/win-library/3.2/nvimcom
I installed this package but when I start my R session, I get this error
The package nvimcom wasn't loaded yet
Any ideas on how to resolve it. The package says that nvimcom is bundled with this plugin. What setup config am I missing.
Thank you.
This option is not working after I updated Nvim-R.
Neovim version 0.1.2
R version 3.2.3
nvimcom version 0.9-8.4
I tried to install the released version of nvimcom and problem solved. But when I open r from neovim, it shows warning message: Your version of Nvim-R requires nvimcom-0.9-8.4. I don't know whether it is because of nvimcom or Nvim-R that Rout_more_colors not woking.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.