diff --git a/crates/project/src/project_settings.rs b/crates/project/src/project_settings.rs index 21cdb25e7e..7b43e166d0 100644 --- a/crates/project/src/project_settings.rs +++ b/crates/project/src/project_settings.rs @@ -297,7 +297,7 @@ pub struct BinarySettings { pub path: Option, pub arguments: Option>, // this can't be an FxHashMap because the extension APIs require the default SipHash - pub env: Option>, + pub env: Option>, pub ignore_system_version: Option, } diff --git a/docs/src/configuring-languages.md b/docs/src/configuring-languages.md index e4eb53d497..facd2df036 100644 --- a/docs/src/configuring-languages.md +++ b/docs/src/configuring-languages.md @@ -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: diff --git a/docs/src/languages/rust.md b/docs/src/languages/rust.md index 752567b787..aa4e801fcd 100644 --- a/docs/src/languages/rust.md +++ b/docs/src/languages/rust.md @@ -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