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")
These editors are supported by installing the corresponding package.
-
VSCode: vscode-r-lsp
-
Atom: atom-ide-r
-
Sublime Text: LSP
-
Vim/NeoVim: LanguageClient-neovim with settings
let g:LanguageClient_serverCommands = {
\ 'r': ['R', '--quiet', '--slave', '-e', 'languageserver::run()'],
\ }
- EMacs: lsp-mode with settings
(lsp-define-stdio-client lsp-R "R"
(lambda () default-directory)
'("R" "--quiet" "--slave" "-e" "languageserver::run()"))
(add-hook 'R-mode-hook #'lsp-R-enable)
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
User can specify the default linters in .Rprofile
. Please note that this setting
is ignored if a .lintr
file is found.
options(languageserver.default_linters = lintr::with_defaults(
line_length_linter = lintr::line_length_linter(100),
object_length_linter = NULL,
object_name_linter = NULL,
commented_code_linter = NULL
))