-
Notifications
You must be signed in to change notification settings - Fork 1
Installation
The installation process is described in four sections:
Before installing the plugin, you should install its dependencies:
Main dependencies:
-
Vim >=
8.2.84
: Vim must be compiled with+channel
,+job
and+conceal
features. In Normal mode, do:version
to check if your Vim has these features. -
Neovim >=
0.6.0
See also: https://github.com/neovim/neovim/wiki/Installing-Neovim Also cmp-nvim-r if you want auto omni completion from Nvim-R: https://github.com/jalvesaq/cmp-nvim-r -
R >=
4.0.0
:
Notes about the R package nvimcom
:
-
The R package
nvimcom
is included in Nvim-R and is automatically installed and updated whenever necessary. The package requires compilation by a C compiler (e.g.gcc
orclang
). -
You do not need to load
nvimcom
in your.Rprofile
because the Nvim-R plugin sets the environment variableR_DEFAULT_PACKAGES
, includingnvimcom
in the list of packages to be loaded on R startup. However, if you set the optiondefaultPackages
in a.Rprofile
, you should include "nvimcom" among the packages to be loaded (see nvimcom-not-loaded). -
On Windows, you have to install Rtools to be able to build the package: https://cran.r-project.org/bin/windows/Rtools/
Additional dependencies for editing Rnoweb documents:
-
latexmk: Automate the compilation of LaTeX documents. See examples in
R_latexcmd
. -
PDF viewer with SyncTeX support and capable of automatically reloading documents. This is required only if you edit Rnoweb files.
- On Linux and other Unix systems: Zathura (recommended), Evince or Okular.
- On OS X: Skim.
- On Windows: SumatraPDF.
Suggestions for Unix (Linux, OS X, Cygwin, etc.):
-
Tmux >= 3.0: Tmux is required only if you want to run R in an external terminal emulator (see
R_external_term
). -
colorout: Colorizes the R output in terminal emulators. (Mostly useful if running R in an external terminal emulator. See
R_external_term
). You should put in yourRprofile
:library(colorout)
If running Gnome Shell on Wayland, you may also want to install the extension "Activate Window By Title" which will be used to raise Zathura window displaying the PDF file generated from Rnoweb, Rmd or Quarto documents.
Suggestions for bibliographic completion from Zotero:
For RMarkdown (.Rmd
) and Quarto (.qmd
) documents:
If you have a previous Vimball installation, you should uninstall it first:
:packadd vimball
:RmVimball Nvim-R
Either use a plugin manager to install Nvim-R or follow the instructions
on Vim |packages|
to install the Nvim-R package (either the zip or the tar.gz
file) released at https://github.com/jalvesaq/Nvim-R/releases.
Note: The <LocalLeader>
is \
by default.
The plugin is a file-type
plugin. It will be active only if you are editing a
.R, .Rnw, .Rd, .Rmd, .Rrst or .qmd file. The key bindings will not be active
while editing either unnamed files or files with name extensions other than the
mentioned above: However, see:
https://github.com/jalvesaq/Nvim-R/wiki/Enable-Nvim-R-for-any-file-type
If the plugin is active, pressing <LocalLeader>rf
should start R.
Did you see warning messages but they disappeared before you have had time to
read them? Type the command :messages
in Normal mode to see them again.
Run the command :RDebugInfo
which will show information useful to fix some
common issues.
To see messages received by nvimcom
, put in your ~/.Rprofile
:
options(nvimcom.verbose = 5)
To see messages received by Vim, uncomment the first line of the function
ROnJobStdout()
at R/nvimrcom.vim
and delete the string "DEBUG:". It will
become:
call writefile(a:data, "/dev/shm/nvimrserver_stdout", "a")
Then, in another terminal or in another Tmux pane, you would have to use tail to follow the output:
tail -f /dev/shm/nvimrserver_stdout
If R does not start with the <LocalLeader>rf
command and you get an error
message instead, you may want to set the path to the R executable (see
R_path
).
If you see the following message in the R console:
During startup - Warning messages:
1: In library(package, lib.loc = lib.loc, character.only = TRUE,
logical.return = TRUE, : there is no package called ‘nvimcom’
2: package ‘nvimcom’ in options("defaultPackages") was not found
Try quitting both R and Vim and starting them again.
If you still see the message "The package nvimcom wasn't loaded yet" after
starting R, then Nvim-R could not induce R to load nvimcom. Nvim-R sets the
environment variable R_DEFAULT_PACKAGES
before starting R. If the variable
already exists, the string ,nvimcom
is appended to it.
However, if you set the option defaultPackages
in your .Rprofile
or in a
.Rprofile
in the current directory, the environment variable will be
overridden. Thus, if you have to set the option defaultPackages
, you should
include "nvimcom" among the packages to be loaded. You might want to include
"nvimcom" only if R was started by Nvim-R, as in the example below:
if(Sys.getenv("NVIMR_TMPDIR") == ""){
options(defaultPackages = c("utils", "grDevices", "graphics", "stats", "methods"))
} else {
options(defaultPackages = c("utils", "grDevices", "graphics", "stats", "methods", "nvimcom"))
}
Finally, run the command :RDebugInfo
after <LocalLeader>rf
and check the
path where nvimcom was installed.
On Windows, nvimcom compilation will fail if your .Rprofile
outputs anything
during R Startup. It will also fail with a message about --slave
not being a
gcc
option if either make.exe
or gcc.exe
from RTools are not the first
ones found in your systems' PATH
(see
R_path
and
Rtools-path
).
The plugin should work without the need of any configuration right after installation, but if you do not like how the plugin works, you could look at the section Nvim-R-options to see if there is an option that could make you happier.
You can also install additional plugins to get more useful functionality to edit R code. Please, access Nvim-R's wiki: https://github.com/jalvesaq/Nvim-R/wiki