Git Product home page Git Product logo

nvim-r's Introduction

Nvim-R

This is the development code of Nvim-R which improves Vim's support to edit R code.

Installation

If you use a plugin manager, such as vim-plug, follow its instructions on how to install plugins from github.

To install the stable version of the plugin, if using vim-plug, put this in your vimrc/init.vim:

Plug 'jalvesaq/Nvim-R', {'branch': 'stable'}

The stable branch is a copy of the last released version plus minor bug fixes eventually found after the release. I plan to keep the stable branch compatible with Ubuntu LTS releases, and the master branch compatible with Ubuntu normal releases.

Please, read the section Installation from the plugin's documentation for details.

Usage

Please, read the plugin's documentation for instructions on usage.

Screenshots

The animated GIF below shows R running in a Neovim terminal buffer. We can note:

  1. The editor has some code to load Afrobarometer data on Mozambique, R is running below the editor and the Object Browser is on the right side. On the R Console, we can see messages inform some packages were loaded. The messages are in magenta because they were colorized by the package colorout.

  2. When the command library("foreign") is sent to R, the string read.spss turns blue because it is immediately recognized as a loaded function (the Vim color scheme used is southernlights).

  3. When Mozambique's data.frame is created, it is automatically displayed in the Object Browser. Messages about unrecognized types are in magenta because they were sent to stderr, and the line Warning messages is in red because colorout recognized it as a warning.

  4. When the "label" attributes are applied to the data.frame elements, the labels show up in the Object Browser.

  5. The next images show results of omni completion.

  6. The last slide shows the output of summary.

Nvim-R screenshots

The communication between R and either Vim or Neovim

In addition to sending lines of code to R Console, Nvim-R and R communicate with each other through TCP connections. The R package nvimcom runs a TCP server that receives messages from Vim/Neovim, and it also sends messages through a TCP connection to Vim/Neovim. Moreover, nvimcom includes the application nclientserver which is never used by R itself, but is run by Vim/Neovim, providing both a TCP client and a TCP server. The Diagram below shows the three paths of communication between Vim/Neovim and R:

  • The black path is followed by all commands that you trigger in the editor and that you can see being pasted into R Console. There are three different ways of sending the commands to R Console:

    • When running R in a Neovim built-in terminal, the function chansend() is used to send code to R Console.

    • When running R in an external terminal emulator, Tmux is used to send commands to R Console.

    • On Windows operating system, Nvim-R can send a message to R (nvimcom) which forwards the command to R Console.

  • The blue path is followed by the few commands that you trigger, but that are not pasted into R Console and do not output anything in R Console; their results are seen in the editor itself. These are the commands to do omnicompletion (of names of objects and function arguments), start and manipulate the Object Browser (\ro, \r= and \r-), call R help (\rh or :Rhelp), insert the output of an R command (:Rinsert) and format selected text (:Rformat).

  • The red path is followed by R messages that tell the editor to update the Object Browser, update the syntax highlight to include newly loaded libraries and open the PDF output after knitting an Rnoweb file and compiling the LaTeX result.

Neovim-R communication

nvim-r's People

Contributors

jalvesaq avatar mdlerch avatar fvd avatar ashiklom avatar mllg avatar klmr avatar zeloff avatar kprimice avatar randy3k avatar nacnudus avatar petobens avatar sjewo avatar thomasteoh avatar norival avatar y9c avatar zkamvar avatar matsburg avatar statquant avatar m576f167 avatar mschilli87 avatar khughitt avatar coachshea avatar jimhester avatar hongyuanjia avatar wilkox avatar bamonroe avatar

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.