|
| 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 --> |
0 commit comments