Skip to content
Kun Ren edited this page Sep 19, 2021 · 7 revisions

The R language service implements the Language Server Protocol and provides a set of language analysis features such as completion, signature, hover, definition, references, diagnostics, etc.

The language service is provided by the R language server (implemented by languageserver) which performs static code analysis with the latest user documents in R and Rmd languages. Therefore, it does not rely on an active R session and thus does not require the code to be executed.

To install the package from CRAN:

install.packages("languageserver")

To experience the latest features, install the package from GitHub:

remotes::install_github("REditorSupport/languageserver")

Settings

The following settings could be set up to deviate from the default behavior:

  • r.lsp.enabled: Enable the R language service (default).
  • r.rpath.windows, r.rpath.mac, r.rpath.linux: Path to R binary for launching the R Language Server package (see below). Examples: /usr/bin/R (Linux/macOS), C:\\Program Files\\R\\R-4.1.0\\bin\\x64\\R.exe (Windows). If the settings are left blank (default), then the R path will be detected from the PATH environment variable and Windows registry. It should be vanilla R rather than radian console.
  • r.lsp.args: The command line arguments to use when launching R Language Server. Example: --vanilla to disable loading startup scripts such as .Rprofile and Rprofile.site.
  • r.lsp.debug: Enable debugging traces. Defaults to false. Set this to true if you are having trouble getting the Language Server working.
  • r.lsp.diagnostics: Enable linting of R code, using the lintr package. Defaults to true. To disable this, you must have at least version 0.2.7 of the R Language Server installed.

Completion

Completion

Scope completion

Signature

Package function signature

User function signature

Hover

Hover

Document highlight

Document highlight

Document and workspace symbol

Document outline

Document symbol

Document/workspace symbols

Code sections

Code section symbols

Diagnostics

Diagnostics

Formatting

Formatting

On-type-formatting

Code actions

Go to definition

Definition

Find references

Find references

Rename symbol

Rename symbol

Call hierarchy

Call Hierarchy

Code folding

Code section and function folding ranges

Document link

Link

Color picker

Document color

Document selection

Selection range

Clone this wiki locally