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
|
@ -305,6 +305,7 @@ pub trait LspAdapterDelegate: Send + Sync {
|
|||
fn worktree_root_path(&self) -> &Path;
|
||||
fn exists(&self, path: &Path, is_dir: Option<bool>) -> bool;
|
||||
fn update_status(&self, language: LanguageServerName, status: BinaryStatus);
|
||||
fn registered_lsp_adapters(&self) -> Vec<Arc<dyn LspAdapter>>;
|
||||
async fn language_server_download_dir(&self, name: &LanguageServerName) -> Option<Arc<Path>>;
|
||||
|
||||
async fn npm_package_installed_version(
|
||||
|
@ -515,6 +516,26 @@ pub trait LspAdapter: 'static + Send + Sync {
|
|||
Ok(serde_json::json!({}))
|
||||
}
|
||||
|
||||
async fn additional_initialization_options(
|
||||
self: Arc<Self>,
|
||||
_target_language_server_id: LanguageServerName,
|
||||
_: &dyn Fs,
|
||||
_: &Arc<dyn LspAdapterDelegate>,
|
||||
) -> Result<Option<Value>> {
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
async fn additional_workspace_configuration(
|
||||
self: Arc<Self>,
|
||||
_target_language_server_id: LanguageServerName,
|
||||
_: &dyn Fs,
|
||||
_: &Arc<dyn LspAdapterDelegate>,
|
||||
_: Arc<dyn LanguageToolchainStore>,
|
||||
_cx: &mut AsyncApp,
|
||||
) -> Result<Option<Value>> {
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
/// Returns a list of code actions supported by a given LspAdapter
|
||||
fn code_action_kinds(&self) -> Option<Vec<CodeActionKind>> {
|
||||
Some(vec![
|
||||
|
|
|
@ -912,6 +912,15 @@ impl LanguageRegistry {
|
|||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
pub fn all_lsp_adapters(&self) -> Vec<Arc<CachedLspAdapter>> {
|
||||
self.state
|
||||
.read()
|
||||
.all_lsp_adapters
|
||||
.values()
|
||||
.cloned()
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn adapter_for_name(&self, name: &LanguageServerName) -> Option<Arc<CachedLspAdapter>> {
|
||||
self.state.read().all_lsp_adapters.get(name).cloned()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue