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
|
@ -267,6 +267,58 @@ impl LspAdapter for ExtensionLspAdapter {
|
|||
})
|
||||
}
|
||||
|
||||
async fn additional_initialization_options(
|
||||
self: Arc<Self>,
|
||||
target_language_server_id: LanguageServerName,
|
||||
_: &dyn Fs,
|
||||
delegate: &Arc<dyn LspAdapterDelegate>,
|
||||
) -> Result<Option<serde_json::Value>> {
|
||||
let delegate = Arc::new(WorktreeDelegateAdapter(delegate.clone())) as _;
|
||||
let json_options: Option<String> = self
|
||||
.extension
|
||||
.language_server_additional_initialization_options(
|
||||
self.language_server_id.clone(),
|
||||
target_language_server_id.clone(),
|
||||
delegate,
|
||||
)
|
||||
.await?;
|
||||
Ok(if let Some(json_options) = json_options {
|
||||
serde_json::from_str(&json_options).with_context(|| {
|
||||
format!(
|
||||
"failed to parse additional_initialization_options from extension: {json_options}"
|
||||
)
|
||||
})?
|
||||
} else {
|
||||
None
|
||||
})
|
||||
}
|
||||
|
||||
async fn additional_workspace_configuration(
|
||||
self: Arc<Self>,
|
||||
target_language_server_id: LanguageServerName,
|
||||
_: &dyn Fs,
|
||||
delegate: &Arc<dyn LspAdapterDelegate>,
|
||||
_: Arc<dyn LanguageToolchainStore>,
|
||||
_cx: &mut AsyncApp,
|
||||
) -> Result<Option<serde_json::Value>> {
|
||||
let delegate = Arc::new(WorktreeDelegateAdapter(delegate.clone())) as _;
|
||||
let json_options: Option<String> = self
|
||||
.extension
|
||||
.language_server_additional_workspace_configuration(
|
||||
self.language_server_id.clone(),
|
||||
target_language_server_id.clone(),
|
||||
delegate,
|
||||
)
|
||||
.await?;
|
||||
Ok(if let Some(json_options) = json_options {
|
||||
serde_json::from_str(&json_options).with_context(|| {
|
||||
format!("failed to parse additional_workspace_configuration from extension: {json_options}")
|
||||
})?
|
||||
} else {
|
||||
None
|
||||
})
|
||||
}
|
||||
|
||||
async fn labels_for_completions(
|
||||
self: Arc<Self>,
|
||||
completions: &[lsp::CompletionItem],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue