mirror of
https://github.com/zed-industries/zed.git
synced 2026-12-03 05:51:27 +01:00
Make it possible to disable language servers in the extension manifest (#65030)
## Summary This PR enables extension authors to disable language servers from the `extension.toml` as opposed to requiring a change to Zed's default settings. With this in, we no longer need to ship default enabled servers for a given language and can instead resort to extension authors disabling those in their extension. This gives extension authors more control and also finally removes the need to link Zed version releases to extension releases in cases where the extension wants to add a new language server. ## Testing Aside from the added tests, also ran a local build and tested this against the kotlin extension. Worked as I would expect it to. ## Self-review - [X] I've reviewed my diff for quality, security, reliability, and performance. - [-] UI changes follow the [checklist](https://zed.dev/docs/development/ui-checklist). - [X] Tests cover the new or changed behavior. Release Notes: - Added the possibility for language server extensions to configure which language servers are enabled/disabled by default. Visit https://zed.dev/docs/extensions/languages.md#opt-in-language-servers for more information. --------- Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Co-authored-by: zed-zippy[bot] <234243425+zed-zippy[bot]@users.noreply.github.com>
This commit is contained in:
@@ -128,6 +128,8 @@ In this example:
|
||||
|
||||
The `"..."` entry acts as a wildcard that includes any registered language server you haven't explicitly mentioned. Servers you list by name keep their position, and `"..."` fills in the remaining ones at that point in the list. Servers prefixed with `!` are excluded entirely. This means that if a new language server extension is installed or a new server is registered for a language, `"..."` will automatically include it. If you want full control over which servers are enabled, omit `"..."` — only the servers you list by name will be used.
|
||||
|
||||
Extensions can also mark a language server as [disabled by default](./extensions/languages.md#opt-in-language-servers) for some of its languages. Such servers are never included by `"..."`, regardless of your configuration, and only start when you list them by name, e.g. `["my-alternative-server", "..."]`.
|
||||
|
||||
#### Examples
|
||||
|
||||
Suppose you're working with Ruby. The default configuration is:
|
||||
|
||||
@@ -499,6 +499,31 @@ impl zed::Extension for MyExtension {
|
||||
}
|
||||
```
|
||||
|
||||
### Opt-In Language Servers
|
||||
|
||||
If your extension ships a language server that users should only run when they opt in (for example, an alternative to the primary language server), list the languages it should not start for by default in `opt_in_languages`. Every language listed there must also be listed in `languages`:
|
||||
|
||||
```toml
|
||||
[language_servers.my-alternative-server]
|
||||
name = "My Alternative LSP"
|
||||
languages = ["My Language", "My Other Language"]
|
||||
opt_in_languages = ["My Language"]
|
||||
```
|
||||
|
||||
For the languages listed in `opt_in_languages`, the language server is not covered by the `"..."` wildcard in the [`language_servers`](../configuring-languages.md#choosing-language-servers) setting. Users enable it by naming it explicitly:
|
||||
|
||||
```json [settings]
|
||||
{
|
||||
"languages": {
|
||||
"My Language": {
|
||||
"language_servers": ["my-alternative-server", "..."]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
> **Note:** Versions of Zed that do not support `opt_in_languages` ignore it and start the language server for all of its `languages`.
|
||||
|
||||
You can customize the handling of the language server using several optional methods in the `Extension` trait. For example, you can control how completions are styled using the `label_for_completion` method. For a complete list of methods, see the [API docs for the Zed extension API](https://docs.rs/zed_extension_api).
|
||||
|
||||
### Syntax Highlighting with Semantic Tokens
|
||||
|
||||
Reference in New Issue
Block a user