Skip to content

Commit f74c5c3

Browse files
Add documentation on how to use Air in Zed (#332)
* Add documentation on how to use Air in Zed * Update docs/editor-zed.qmd Co-authored-by: Lionel Henry <lionel.hry@proton.me> --------- Co-authored-by: Lionel Henry <lionel.hry@proton.me>
1 parent df9fea0 commit f74c5c3

4 files changed

Lines changed: 87 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
# Development version
44

5+
- Added documentation on using Air in [Zed](https://github.com/zed-industries/zed).
6+
57

68
# 0.5.0
79

docs/_quarto.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ website:
2525
- section: "Editors"
2626
href: editors.qmd
2727
contents:
28-
- editor-rstudio.qmd
2928
- editor-vscode.qmd
29+
- editor-rstudio.qmd
30+
- editor-zed.qmd
3031
- editor-neovim.qmd
3132
- editor-helix.qmd
3233

docs/editor-zed.qmd

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
---
2+
title: "Zed"
3+
editor:
4+
markdown:
5+
wrap: sentence
6+
canonical: true
7+
---
8+
9+
[Zed](https://github.com/zed-industries/zed) is a collaborative editor with an extension system and builtin support for the [Language Server Protocol](https://microsoft.github.io/language-server-protocol/).
10+
11+
# Installation
12+
13+
To use Air in Zed, you currently need to install the following two Zed extensions by running the command `zed: extensions`:
14+
15+
- `R`
16+
17+
- Adds *language* support for R, teaching Zed about R file types, syntax highlighting, and other basic editor capabilities.
18+
This is required for Zed to detect R files and call Air on them.
19+
20+
- Adds *language server* support for R, backed by the [`languageserver`](https://github.com/REditorSupport/languageserver) R package.
21+
This is turned on by default, but is optional if you just want to use Air.
22+
The languageserver package provides a more comprehensive language server than Air.
23+
While Air's language server is currently focused only on formatting, languageserver also provides help, go to definition, and other nice features.
24+
25+
- `Air`
26+
27+
- Adds *language server* support for R, backed by Air.
28+
The Air language server is primarily used for document formatting.
29+
30+
You won't need to install the Air command line tool - the Zed extension will download it for you as needed.
31+
32+
To configure Zed to use the Air language server to format R files, add the following to your Zed `settings.json`:
33+
34+
``` json
35+
{
36+
"languages": {
37+
"R": {
38+
"language_servers": ["air"]
39+
}
40+
}
41+
}
42+
```
43+
44+
If you'd like to also use [`languageserver`](https://github.com/REditorSupport/languageserver) through the Zed R extension, use the following configuration:
45+
46+
``` json
47+
{
48+
"languages": {
49+
"R": {
50+
"language_servers": ["air", "r_language_server"]
51+
}
52+
}
53+
}
54+
```
55+
56+
::: callout-caution
57+
## It's important that `"air"` is provided before `"r_language_server"`, otherwise Air won't get formatting requests!
58+
:::
59+
60+
If you use `"r_language_server"`, note that languageserver provides on-type formatting support.
61+
Notably, it will automatically break pipe chains of \>1 pipe over multiple lines when you type a closing `)`.
62+
If you don't want this and would like Air to be fully in charge of formatting, then use this configuration:
63+
64+
``` json
65+
{
66+
"languages": {
67+
"R": {
68+
"language_servers": ["air", "r_language_server"],
69+
"use_on_type_format": false
70+
}
71+
}
72+
}
73+
```
74+
75+
# Features
76+
77+
## Format on save
78+
79+
The Zed setting `format_on_save` is `"on"` by default, so there is no additional configuration required to get Zed to format your R files on save using Air.
80+
81+
<!--# Come back and add video -->

docs/editors.qmd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ Follow one of our editor specific guides to get set up with Air in your preferre
1717

1818
- [RStudio](editor-rstudio.qmd)
1919

20+
- [Zed](editor-zed.qmd)
21+
2022
- [Neovim](editor-neovim.qmd)
2123

2224
- [Helix](editor-helix.qmd)

0 commit comments

Comments
 (0)