Skip to content

About

An implementation of the Language Server Protocol for R

Topics

Resources

Stars

679 stars

Watchers

13 watching

Forks

Repository files navigation

languageserver: An implementation of the Language Server Protocol for R

R-CMD-check codecov CRAN_Status_Badge CRAN Downloads r-universe

languageserver brings completion, hover help, navigation, refactoring, diagnostics, and formatting to R editors through the Language Server Protocol.

Documentation · Five-minute walkthrough · Guide sources

Installation

Install the CRAN release in the R library your editor uses.

install.packages("languageserver")

For the default diagnostics and formatting tools, also install lintr and styler. Linux users building from source may need system libraries. The guides describe the source version they accompany. If you installed an earlier release, compare its features or try a development build from r-universe. Release compatibility · Linux build prerequisites · Development installation

Language Clients

Open an R file in VS Code, Neovim, Emacs, or another LSP client. The setup guide shows how to connect the editor and check the connection by jumping to a local function. Set up your editor

Embedded hosts and webR

A notebook or browser editor can use run_embedded() in a dedicated R worker and exchange JSON-RPC messages directly. Navigation uses open buffers in the same workspace folder. Hosts can supply their session's package search order. Embed the server · R API

Services Implemented

The server uses incremental tree-sitter parsing for responsive completion, selections, outlines, and folding while you type. The server uses its usual analysis when a syntax tree cannot answer reliably. Read code while you type

Documenting argument, return, and member types

The server can use explicit roxygen type annotations for member completion, signature help, navigation, and S3 dispatch. A parameter or return value can name a source class, and @inheritParams can share parameter descriptions across functions. Try roxygen type hints

S3 method information

Signature Help can show method-specific arguments when the server can infer the input class. Try an S3 generic

Refactoring

Select an expression to extract a variable, select statements to extract a function, or inline a local value when its evaluation is preserved. Try an extraction

Go to Definition for S4 methods

Use Go to Definition on an S4 generic to open its source declaration and registered methods. Explore S4 declarations

Go to Definition for project helpers

Map a test file to its project helpers so Go to Definition can find them while they are closed. Configure project helpers

Generated package definitions

Inspect the generated body of an installed function when its original source file is unavailable. Open a package definition

Settings

Configure the server through the editor or the R profile that its R process reads. Packages that include these guides provide the settings reference through help("languageserver-settings", package = "languageserver") and the walkthrough through vignette("quick-start", package = "languageserver") in R. Server settings · Server launch options

FAQ

For missing completions, definitions, or formatting commands, work through the checks for your symptom. Troubleshooting

Linters

Configure lintr in the project and inspect diagnostics in the editor. Read a lint finding

Selecting diagnostics and formatting backends

Choose lintr or Jarl for diagnostics, and styler or Air for formatting. Choose a backend

Custom R adapters

Supply a custom diagnostics or formatting function through an R option. Custom adapters

Customizing server capabilities

Override the capabilities the server advertises at startup. Capability overrides

Customizing formatting style

Give styler a formatting style function in the server's R profile. Custom styles

About

An implementation of the Language Server Protocol for R

Topics

Resources

Stars

679 stars

Watchers

13 watching

Forks

Releases

Packages

Used by

Contributors

Languages