Add more documentation about ways to configure language servers and rust-analyzer (#29932)
Release Notes: - N/A
This commit is contained in:
parent
c56a1cf2b1
commit
76c0eded0d
3 changed files with 91 additions and 1 deletions
|
@ -182,6 +182,63 @@ Here's how you would structure these settings in Zed's `settings.json`:
|
|||
}
|
||||
```
|
||||
|
||||
#### Possible configuration options
|
||||
|
||||
Depending on how a particular language server is implemented, they may depend on different configuration options, both specified in the LSP.
|
||||
|
||||
- [initializationOptions](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#version_3_17_0)
|
||||
|
||||
Sent once during language server startup, requires server's restart to reapply changes.
|
||||
|
||||
For example, rust-analyzer and clangd rely on this way of configuring only.
|
||||
|
||||
```json
|
||||
"lsp": {
|
||||
"rust-analyzer": {
|
||||
"initialization_options": {
|
||||
"checkOnSave": false
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
- [Configuration Request](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#workspace_configuration)
|
||||
|
||||
May be queried by the server multiple times.
|
||||
Most of the servers would rely on this way of configuring only.
|
||||
|
||||
```json
|
||||
"lsp": {
|
||||
"tailwindcss-language-server": {
|
||||
"settings": {
|
||||
"tailwindCSS": {
|
||||
"emmetCompletions": true,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Apart of the LSP-related server configuration options, certain servers in Zed allow configuring the way binary is launched by Zed.
|
||||
|
||||
Languages mention in the documentation, whether they support it or not and their defaults for the configuration values:
|
||||
|
||||
```json
|
||||
"languages": {
|
||||
"Markdown": {
|
||||
"binary": {
|
||||
// Whether to fetch the binary from the internet, or attempt to find locally.
|
||||
"ignore_system_version": false,
|
||||
"path": "/path/to/langserver/bin",
|
||||
"arguments": ["--option", "value"],
|
||||
"env": {
|
||||
"FOO": "BAR"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Enabling or Disabling Language Servers
|
||||
|
||||
You can toggle language server support globally or per-language:
|
||||
|
|
|
@ -119,6 +119,39 @@ If you are using `rustup` and you can find a list of available target triples (`
|
|||
rustup target list --installed
|
||||
```
|
||||
|
||||
## LSP tasks
|
||||
|
||||
Zed provides tasks using tree-sitter, but rust-analyzer has an LSP extension method for querying file-related tasks via LSP.
|
||||
This is enabled by default and can be configured as
|
||||
|
||||
```json
|
||||
"lsp": {
|
||||
"rust-analyzer": {
|
||||
enable_lsp_tasks": true,
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Manual Cargo Diagnostics fetch
|
||||
|
||||
By default, rust-analyzer has `checkOnSave: true` enabled, which causes every buffer save to trigger a `cargo check --workspace --all-targets` command.
|
||||
For lager projects this might introduce excessive wait times, so a more fine-grained triggering could be enabled by altering the
|
||||
|
||||
```json
|
||||
"diagnostics": {
|
||||
"cargo": {
|
||||
// When enabled, Zed disables rust-analyzer's check on save and starts to query
|
||||
// Cargo diagnostics separately.
|
||||
"fetch_cargo_diagnostics": false
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
default settings.
|
||||
|
||||
This will stop rust-analyzer from running `cargo check ...` on save, yet still allow to run
|
||||
`editor: run/clear/cancel flycheck` commands in Rust files to refresh cargo diagnostics; the project diagnostics editor will also refresh cargo diagnostics with `editor: run flycheck` command when the setting is enabled.
|
||||
|
||||
## More server configuration
|
||||
|
||||
<!--
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue