r.md

R

R support is available via multiple R Zed extensions:

Installation

  1. Download and Install R.
  2. Install the R packages languageserver and lintr:
install.packages("languageserver")
install.packages("lintr")
  1. Install the ocsmit/zed-r through Zed's extensions manager.

For example on macOS:

brew install --cask r
Rscript --version
Rscript -e 'options(repos = "https://cran.rstudio.com/"); install.packages("languageserver")'
Rscript -e 'options(repos = "https://cran.rstudio.com/"); install.packages("lintr")'
Rscript -e 'packageVersion("languageserver")'
Rscript -e 'packageVersion("lintr")'

Configuration

Linting

REditorSupport/languageserver bundles support for r-lib/lintr as a linter. This can be configured via the use of a .lintr inside your project (or in your home directory for global defaults).

linters: linters_with_defaults(
    line_length_linter(120),
    commented_code_linter = NULL
  )
exclusions: list(
    "inst/doc/creating_linters.R" = 1,
    "inst/example/bad.R",
    "tests/testthat/exclusions-test"
  )

Or exclude it from linting anything,

exclusions: list(".")

See Using lintr for a complete list of options,

Formatting

REditorSupport/languageserver bundles support for r-lib/styler as a formatter. See Customizing Styler for more information on how to customize its behavior.

REditorSupport/languageserver Configuration

You can configure the R languageserver settings via Zed Project Settings .zed/settings.json or Zed User Settings ~/.config/zed/settings.json:

For example to disable Lintr linting and suppress code snippet suggestions (both enabled by default):

{
  "lsp": {
    "r_language_server": {
      "settings": {
        "r": {
          "lsp": {
            "diagnostics": false,
            "snippet_support": false
          }
        }
      }
    }
  }
}