extension: Add support for additional_workspace_configuration
and additional_initialization_options
(#27407)
Closes #22410 With this PR extensions can provide additional workspace configuration for other LSP Adapters. This allows extensions like Astro, Svelte, Vue, etc to provide plugins for vtsls typescript server, fixing issues like: https://github.com/zed-industries/zed/issues/4577, https://github.com/zed-industries/zed/issues/21697, https://github.com/zed-industries/zed/issues/26901#issuecomment-2737485096 Todo: - [x] Test case when extension is installed, does vtsls workspace config refreshes? Before: <img width="450" alt="image" src="https://github.com/user-attachments/assets/f242167c-5264-44ab-b5a7-8c90eb75c6a1" /> After: <img width="450" alt="image" src="https://github.com/user-attachments/assets/6a5f1afe-a0e1-4f64-8a95-919b0bf97614" /> Release Notes: - N/A
This commit is contained in:
parent
9468b9699e
commit
8f1023360d
9 changed files with 360 additions and 19 deletions
|
@ -93,6 +93,26 @@ pub trait Extension: Send + Sync {
|
|||
Ok(None)
|
||||
}
|
||||
|
||||
/// Returns the initialization options to pass to the other language server.
|
||||
fn language_server_additional_initialization_options(
|
||||
&mut self,
|
||||
_language_server_id: &LanguageServerId,
|
||||
_target_language_server_id: &LanguageServerId,
|
||||
_worktree: &Worktree,
|
||||
) -> Result<Option<serde_json::Value>> {
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
/// Returns the workspace configuration options to pass to the other language server.
|
||||
fn language_server_additional_workspace_configuration(
|
||||
&mut self,
|
||||
_language_server_id: &LanguageServerId,
|
||||
_target_language_server_id: &LanguageServerId,
|
||||
_worktree: &Worktree,
|
||||
) -> Result<Option<serde_json::Value>> {
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
/// Returns the label for the given completion.
|
||||
fn label_for_completion(
|
||||
&self,
|
||||
|
@ -235,6 +255,38 @@ impl wit::Guest for Component {
|
|||
.and_then(|value| serde_json::to_string(&value).ok()))
|
||||
}
|
||||
|
||||
fn language_server_additional_initialization_options(
|
||||
language_server_id: String,
|
||||
target_language_server_id: String,
|
||||
worktree: &Worktree,
|
||||
) -> Result<Option<String>, String> {
|
||||
let language_server_id = LanguageServerId(language_server_id);
|
||||
let target_language_server_id = LanguageServerId(target_language_server_id);
|
||||
Ok(extension()
|
||||
.language_server_additional_initialization_options(
|
||||
&language_server_id,
|
||||
&target_language_server_id,
|
||||
worktree,
|
||||
)?
|
||||
.and_then(|value| serde_json::to_string(&value).ok()))
|
||||
}
|
||||
|
||||
fn language_server_additional_workspace_configuration(
|
||||
language_server_id: String,
|
||||
target_language_server_id: String,
|
||||
worktree: &Worktree,
|
||||
) -> Result<Option<String>, String> {
|
||||
let language_server_id = LanguageServerId(language_server_id);
|
||||
let target_language_server_id = LanguageServerId(target_language_server_id);
|
||||
Ok(extension()
|
||||
.language_server_additional_workspace_configuration(
|
||||
&language_server_id,
|
||||
&target_language_server_id,
|
||||
worktree,
|
||||
)?
|
||||
.and_then(|value| serde_json::to_string(&value).ok()))
|
||||
}
|
||||
|
||||
fn labels_for_completions(
|
||||
language_server_id: String,
|
||||
completions: Vec<Completion>,
|
||||
|
|
|
@ -95,6 +95,12 @@ world extension {
|
|||
/// Returns the workspace configuration options to pass to the language server.
|
||||
export language-server-workspace-configuration: func(language-server-id: string, worktree: borrow<worktree>) -> result<option<string>, string>;
|
||||
|
||||
/// Returns the initialization options to pass to the other language server.
|
||||
export language-server-additional-initialization-options: func(language-server-id: string, target-language-server-id: string, worktree: borrow<worktree>) -> result<option<string>, string>;
|
||||
|
||||
/// Returns the workspace configuration options to pass to the other language server.
|
||||
export language-server-additional-workspace-configuration: func(language-server-id: string, target-language-server-id: string, worktree: borrow<worktree>) -> result<option<string>, string>;
|
||||
|
||||
/// A label containing some code.
|
||||
record code-label {
|
||||
/// The source code to parse with Tree-sitter.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue