From a602b4b305a374ead16afca51278f35e9ac152af Mon Sep 17 00:00:00 2001 From: Peter Tripp Date: Sun, 29 Jun 2025 12:21:10 -0400 Subject: [PATCH] Improve R documentation (#33594) Release Notes: - N/A --- docs/src/languages/r.md | 75 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 68 insertions(+), 7 deletions(-) diff --git a/docs/src/languages/r.md b/docs/src/languages/r.md index ce123d4606..6b40f6970d 100644 --- a/docs/src/languages/r.md +++ b/docs/src/languages/r.md @@ -1,9 +1,14 @@ # R -R support is available through the [R extension](https://github.com/ocsmit/zed-r). +R support is available via multiple R Zed extensions: -- Tree-sitter: [r-lib/tree-sitter-r](https://github.com/r-lib/tree-sitter-r) -- Language-Server: [REditorSupport/languageserver](https://github.com/REditorSupport/languageserver) +- [ocsmit/zed-r](https://github.com/ocsmit/zed-r) + + - Tree-sitter: [r-lib/tree-sitter-r](https://github.com/r-lib/tree-sitter-r) + - Language-Server: [REditorSupport/languageserver](https://github.com/REditorSupport/languageserver) + +- [posit-dev/air](https://github.com/posit-dev/air/tree/main/editors/zed) + - Language-Server: [posit-dev/air](https://github.com/posit-dev/air) ## Installation @@ -15,7 +20,7 @@ install.packages("languageserver") install.packages("lintr") ``` -3. Install the [R Zed extension](https://github.com/ocsmit/zed-r) through Zed's extensions manager. +3. Install the [ocsmit/zed-r](https://github.com/ocsmit/zed-r) through Zed's extensions manager. For example on macOS: @@ -28,7 +33,65 @@ Rscript -e 'packageVersion("languageserver")' Rscript -e 'packageVersion("lintr")' ``` -## Ark Installation +## Configuration + +### Linting + +`REditorSupport/languageserver` bundles support for [r-lib/lintr](https://github.com/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). + +```r +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, + +```r +exclusions: list(".") +``` + +See [Using lintr](https://lintr.r-lib.org/articles/lintr.html) for a complete list of options, + +### Formatting + +`REditorSupport/languageserver` bundles support for [r-lib/styler](https://github.com/r-lib/styler) as a formatter. See [Customizing Styler](https://cran.r-project.org/web/packages/styler/vignettes/customizing_styler.html) for more information on how to customize its behavior. + +### REditorSupport/languageserver Configuration + +You can configure the [R languageserver settings](https://github.com/REditorSupport/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): + +```json +{ + "lsp": { + "r_language_server": { + "settings": { + "r": { + "lsp": { + "diagnostics": false, + "snippet_support": false + } + } + } + } + } +} +``` + +