An implementation of the Language Server Protocol for R
Switch branches/tags
Nothing to show
Clone or download
Latest commit 470cf17 Sep 15, 2018

languageserver: An implementation of the Language Server Protocol for R


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


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



The R package knitr is required to enable languageserver for Rmarkdown files. languageserver doesn't specify knitr as a dependency however, users may need to install it manually.

Language Clients

These editors are supported by installing the corresponding package.

let g:LanguageClient_serverCommands = {
    \ 'r': ['R', '--slave', '-e', 'languageserver::run()'],
    \ }
(lsp-define-stdio-client lsp-R "R"
                         (lambda () default-directory)
			 '("R" "--slave" "-e" "languageserver::run()"))
(add-hook 'R-mode-hook #'lsp-R-enable)

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
  • executeCommandProvider

Diagnostics settings

User can specify the default linters in .Rprofile. For example,

    packageEvent("languageserver", "onLoad"),
    function(...) {
        options(languageserver.default_linters = lintr::with_defaults(
            line_length_linter = lintr::line_length_linter(100),
            object_usage_linter = NULL,
            object_length_linter = NULL,
            object_name_linter = NULL,
            commented_code_linter = NULL

Please note that this setting is ignored if a .lintr file is found.