Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

An implementation of the Language Server Protocol for R

License

NotificationsYou must be signed in to change notification settings

REditorSupport/languageserver

Repository files navigation

R-CMD-checkcodecovCRAN_Status_BadgeCRAN Downloadsr-universe

languageserver is an implementation of the Microsoft'sLanguage Server Protocol for the language of R.

Installation

A few dependencies are required beforehand:

# On Debian, Ubuntu, etc.apt install --assume-yes --no-install-recommends build-essential libcurl4-openssl-dev libssl-dev libxml2-dev r-base# On Fedora, Centos, etc.dnf install --assumeyes --setopt=install_weak_deps=False @development-tools libcurl-devel libxml2-devel openssl-devel R# On Alpineapk add --no-cache curl-dev g++ gcc libxml2-dev linux-headers make R R-dev

languageserver is released on CRAN and can be easily installed by

install.packages("languageserver")

To try the latest features, install the daily development build from ourr-universe repository:

install.packages("languageserver",repos= c(reditorsupport="https://reditorsupport.r-universe.dev",    getOption("repos")))

Or install the latest development version from our GitHub repository:

# install.packages("remotes")remotes::install_github("REditorSupport/languageserver")

Language Clients

The following editors are supported by installing the corresponding extensions:

  • VS Code:vscode-R

  • Atom:atom-ide-r

  • Sublime Text:R-IDE

  • Vim/NeoVim:LanguageClient-neovim with settings

    letg:LanguageClient_serverCommands= {\'r': ['R','--no-echo','-e','languageserver::run()'],\}

    or, if you usecoc.nvim, you can do one of two things:

    • Installcoc-r-lsp with:

      :CocInstall coc-r-lsp
    • or install the languageserver package in R

      install.packages("languageserver")# or install the developement version# remotes::install_github("REditorSupport/languageserver")

      Then add the following to your Coc config:

      "languageserver": {"R": {"command":"/usr/bin/R","args" : ["--no-echo","-e","languageserver::run()"],"filetypes" : ["r"]    }}
  • Emacs:lsp-mode

  • JupyterLab:jupyterlab-lsp

  • BBEdit: preconfigured in version 14.0 and later; see theBBEdit LSP support page for complete details.

  • Nova:R-Nova

Services Implemented

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

Settings

languageserver exposes the following settings via LSP configuration.

settingsdefaultdescription
r.lsp.debugfalseincrease verbosity for debug purpose
r.lsp.log_filenullfile to log debug messages, fallback to stderr if empty
r.lsp.diagnosticstrueenable file diagnostics vialintr
r.lsp.rich_documentationtruerich documentation with enhanced markdown features
r.lsp.snippet_supporttrueenable snippets in auto completion
r.lsp.max_completions200maximum number of completion items
r.lsp.lint_cachefalsetoggle caching of lint results
r.lsp.server_capabilities{}override server capabilities defined incapabilities.R. See FAQ below.
r.lsp.link_file_size_limit16384maximum file size (in bytes) that supports document links

These settings could also specified in.Rprofile file viaoptions(languageserver.<SETTING_NAME> = <VALUE>). For example,

options(languageserver.snippet_support=FALSE)

will turn off snippet support globally. LSP configuration settings are always overriden byoptions().

FAQ

Linters

Withlintr v2.0.0, the linters can be specified by creating the.lintr file at the project or home directory. Details can be found at lintrdocumentation.

Customizing server capabilities

Server capabilities are defined incapabilities.R.Users could override the capabilities by specifying the LSP configuration settingserver_capabilities oroptions(languageserver.server_capabilities) in.Rprofile. For example, to turn offdefinitionProvider, one could either use LSP configuration

"r": {"lsp": {"server_capabilities": {"definitionProvider":false        }    }}

or R options

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

Customizing formatting style

The language server usesstyler to perform code formatting. It usesstyler::tidyverse_style(indent_by = options$tabSize) as the default style whereoptions is theformattingoptions.

The formatting style can be customized by specifyinglanguageserver.formatting_style option whichis supposed to be a function that accepts anoptions 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<-NULLstyle})

To further customize the formatting style, please refer toCustomizing styler.

About

An implementation of the Language Server Protocol for R

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp