languageserver

An implementation of the Language Server Protocol for R

Github stars Tracking Chart

languageserver: An implementation of the Language Server Protocol for R

Build Status
Github Action
codecov
CRAN\_Status\_Badge

languageserver is an implement of the Microsoft's Language Server Protocol for the language of R.

It is released on CRAN and can be easily installed by

install.packages("languageserver")

The development version of languageserver could be installed by running the following in R

source("https://install-github.me/REditorSupport/languageserver")

Language Clients

These editors are supported by installing the corresponding package.

Services Implemented

languageserver is still under active development, the following services have been implemented:

  • textDocumentSync (diagnostics)
  • hoverProvider
  • completionProvider
  • signatureHelpProvider
  • definitionProvider
  • referencesProvider
  • documentHighlightProvider
  • documentSymbolProvider
  • workspaceSymbolProvider
  • codeActionProvider
  • codeLensProvider
  • documentFormattingProvider
  • documentRangeFormattingProvider
  • documentOnTypeFormattingProvider
  • renameProvider
  • documentLinkProvider
  • colorProvider
  • executeCommandProvider

Settings

languageserver exposes the following settings via workspace/didChangeConfiguration

{
    "r.lsp.debug": {
      "type": "boolean",
      "default": false,
      "description": "Debug R Language Server"
    },
    "r.lsp.diagnostics": {
      "type": "boolean",
      "default": true,
      "description": "Enable Diagnostics"
    }
}

FAQ

Linters

With lintr v2.0.0, the linters can be specified by creating the .lintr file at the project or home directory. Details can be found at lintr documentation. The option languageserver.default_linters is now deprecated in favor of the .lintr approach.

Customizing server capbabilities

Server capabilities are defined in capabilities.R. Users could override the settings by specifiying languageserver.server_capabilities option in .Rprofile. For example,
the following code will turn off definitionProvider,

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

Please only use this option to disable providers and do not enable any providers that have not been implemented. Changing any other entries may cause unexpected behaviors on the server.

Customizing formatting style

The language server uses styler to perform code formatting. It uses styler::tidyverse_style(indent_by = options$tabSize) as the default style where options is the formatting
options
.

The formatting style can be customized by specifying languageserver.formatting_style option which
is supposed to be a function that accepts an options argument mentioned above. You could consider to put the code in .Rprofile.

styler::tidyverse_style provides numerous arguments to customize the formatting behavior. For example, to make it only work at indention scope:

options(languageserver.formatting_style = function(options) {
    styler::tidyverse_style(scope = "indention", indent_by = options$tabSize)
})

To disable assignment operator fix (replacing = with <-):

options(languageserver.formatting_style = function(options) {
    style <- styler::tidyverse_style(indent_by = options$tabSize)
    style$token$force_assignment_op <- NULL
    style
})

To further customize the formatting style, please refer to Customizing styler.

Main metrics

Overview
Name With OwnerREditorSupport/languageserver
Primary LanguageR
Program languageR (Language Count: 3)
Platform
License:Other
所有者活动
Created At2017-09-11 03:31:07
Pushed At2025-04-10 04:52:39
Last Commit At2025-04-09 21:52:30
Release Count16
Last Release Namev0.3.16 (Posted on )
First Release Namev0.3.1 (Posted on 2019-10-25 13:44:09)
用户参与
Stargazers Count620
Watchers Count16
Fork Count99
Commits Count1.6k
Has Issues Enabled
Issues Count384
Issue Open Count124
Pull Requests Count272
Pull Requests Open Count2
Pull Requests Close Count12
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private