Skip to contents

Choose an editor action below to see an R example. The workspace server started by run() uses the capabilities negotiated with your editor. For open documents in an embedded host, see the features of run_embedded() below. To check a different package version, compare feature availability.

Which editor features can I use?

For features built on these providers, see the guides to data frames and Polars, classes and methods, roxygen type hints, and R Markdown and Quarto.

Write and read R

Explore a file or project

Change code

Diagnose and format

Which features can an embedded host use?

A host such as a dedicated webR worker starts run_embedded() and exchanges JSON-RPC strings with its editor. The host reads the response to initialize to discover which capabilities this server advertises.

  • Reading and writing. Completion and item resolution, hover, Signature Help, document symbols and highlights, folding, and full-document semantic tokens are available. Embedded hosts use full token requests for semantic highlighting.

  • Navigation and editing. Go to Definition, Find References, and Rename use open documents in the same workspace folder. A client can negotiate generated read-only package definitions and Prepare Rename. A rename that could affect closed files needs client support for confirming an annotated open-document edit.

  • Diagnostics. The client requests syntax diagnostics with textDocument/diagnostic. When lintr is available and selected, the server also checks infix spacing. Following a change to the effective diagnostics configuration, a client that supports refresh can receive workspace/diagnostic/refresh.

  • Formatting. With styler installed, the host can request whole-document formatting. For workspace indexing, call or type hierarchy, code actions, and additional formatting modes, use the workspace server.

Embedded hosts and webR shows a complete exchange and how to share a separate R session's package search order.

How does the editor keep results up to date?

  • Open buffers. The editor sends textDocument/didOpen, incremental textDocument/didChange, textDocument/didSave, and textDocument/didClose. Positions use UTF-16. The server reads unsaved text for completion and navigation and drops superseded work after edits.

  • Projects. Adding or removing a workspace folder sends workspace/didChangeWorkspaceFolders. Changes to watched files arrive through workspace/didChangeWatchedFiles. The server uses these to update project information and lint or formatter configuration. Clients supporting work-done progress can display indexing updates through window/workDoneProgress/create and $/progress. Workspace indexing

  • Settings. The editor sends workspace/didChangeConfiguration when its settings change. For clients supporting dynamic registration, the server uses client/registerCapability and client/unregisterCapability to update the available formatting commands. If a selected backend is unavailable, window/showMessage can display the reason. Server settings

  • Session. The editor and server negotiate capabilities with initialize and initialized. Clients can cancel a pending request with $/cancelRequest, change protocol tracing with $/setTrace, and end a session with shutdown and exit. Collect a server log

Why can two editors show different results?

  • Installed package source. Go to Definition can show a generated function body when a definition has no source location. An editor supporting LSP text document content can open it as a read-only virtual document and refresh it. Other clients receive a generated temporary file. Editing that copy has no effect on the installed function.

  • Formatting commands. With dynamic registration the editor can update its formatting commands when the backend changes. A client with static capabilities learns the available modes when it starts. For that client, set the formatting backend in the server's R profile and restart it. Available formatting modes

  • Refactoring help. Editors supporting both code-action documentation and opening a URL can show a documentation link in the refactoring menu. Navigation and refactoring

  • Glue highlighting. An editor that supports workspace/semanticTokens/refresh can recolor already-open documents when you change glue highlighting settings. Glue templates

Override an advertised capability

If another tool already supplies a feature, set the corresponding capability in the R profile read at server startup. For example, to leave Go to Definition to another provider, add this to .Rprofile and restart the server.

options(languageserver.server_capabilities = list(
    definitionProvider = FALSE
))

The server's response to initialize shows the capabilities enabled for that client.