Skip to content

Instantly share code, notes, and snippets.

@brownag

brownag/nvim-r-setup.md

Last active Dec 23, 2020
Embed
What would you like to do?
My setup for Nvim-R on *nix using vim-plug

Setting up Nvim-R on *nix

Install nvim by preferred method

apt

sudo apt install neovim

pacman

sudo pacman -S neovim

Install vim-plug - an alternative vim plugin manager

 sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs \
        https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'

Add to local nvim config file ~/.config/nvim/init.vim:

set nowrap                            

vmap <Space> <Plug>RDSendSelection
nmap <Space> <Plug>RDSendLine   

inoremap <C-Space> <C-x><C-o> 
let R_assign = 2 

call plug#begin()
 Plug 'jalvesaq/Nvim-R', {'branch': 'stable'} 
 Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
 Plug 'junegunn/vim-github-dashboard'                      
 " any additional plugins go here
call plug#end()                                                                 

Optional: radian setup

radian - A 21st century R console - https://github.com/randy3k/radian

Add to init.vim:

let R_app = "radian"                                                                          
let R_cmd = "R"                                                                               
let R_hl_term = 0                                                                             
let R_args = []
let R_bracketed_paste = 1

Install radian using Python 3 pip

apt

sudo apt install python3-pip 
sudo pip3 install radian

pacman

sudo pacman install -S base-devel python python-pip
sudo pip install radian

Optional: vim-github-dashboard setup

Install the json_pure and neovim Ruby Gems.

apt

sudo apt install ruby rubygems ruby-dev 

pacman

sudo pacman -S ruby rubygems
gem install json_pure neovim

Open nvim and install/update plugins

:PlugInstall

Open an R file

Keyboard shortcuts:

  • \rf to start R session

  • Ctrl+W to switch view ports

  • Ctrl+Space for omni-complete in nvim;

  • Tab for auto-complete (radian)

  • :NERDTreeToggle (NERDTree)

  • :GHDashboard and :GHActivity (vim-github-dashboard)

  • vim Cheat Cheat: https://vim.rtorr.com/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment