diff --git a/crates/language/src/language.rs b/crates/language/src/language.rs index beec63dfd2..4f03da1afe 100644 --- a/crates/language/src/language.rs +++ b/crates/language/src/language.rs @@ -583,7 +583,7 @@ struct LanguageRegistryState { pub struct PendingLanguageServer { pub server_id: LanguageServerId, - pub task: Task>, + pub task: Task>>, pub container_dir: Option>, } @@ -896,7 +896,8 @@ impl LanguageRegistry { } }) .detach(); - Ok(server) + + Ok(Some(server)) }); return Some(PendingLanguageServer { @@ -944,19 +945,24 @@ impl LanguageRegistry { .clone(); drop(lock); - let binaries = entry.clone().map_err(|e| anyhow!(e)).await?; + let binary = match entry.clone().await.log_err() { + Some(binary) => binary, + None => return Ok(None), + }; if let Some(task) = adapter.will_start_server(&delegate, &mut cx) { - task.await?; + if task.await.log_err().is_none() { + return Ok(None); + } } - lsp::LanguageServer::new( + Ok(Some(lsp::LanguageServer::new( server_id, - binaries, + binary, &root_path, adapter.code_action_kinds(), cx, - ) + )?)) }) }; diff --git a/crates/project/src/project.rs b/crates/project/src/project.rs index 4c6b25b0e9..7be57e921d 100644 --- a/crates/project/src/project.rs +++ b/crates/project/src/project.rs @@ -2471,7 +2471,7 @@ impl Project { .await; match result { - Ok(server) => Some(server), + Ok(server) => server, Err(err) => { log::error!("failed to start language server {:?}: {}", server_name, err); @@ -2571,8 +2571,8 @@ impl Project { server_id: LanguageServerId, key: (WorktreeId, LanguageServerName), cx: &mut AsyncAppContext, - ) -> Result> { - let language_server = Self::setup_pending_language_server( + ) -> Result>> { + let setup = Self::setup_pending_language_server( this, initialization_options, pending_server, @@ -2580,8 +2580,12 @@ impl Project { languages, server_id, cx, - ) - .await?; + ); + + let language_server = match setup.await? { + Some(language_server) => language_server, + None => return Ok(None), + }; let this = match this.upgrade(cx) { Some(this) => this, @@ -2599,7 +2603,7 @@ impl Project { ) })?; - Ok(language_server) + Ok(Some(language_server)) } async fn setup_pending_language_server( @@ -2610,11 +2614,13 @@ impl Project { languages: Arc, server_id: LanguageServerId, cx: &mut AsyncAppContext, - ) -> Result> { + ) -> Result>> { let workspace_config = cx.update(|cx| languages.workspace_configuration(cx)).await; - let language_server = pending_server.task.await?; - let language_server = language_server.initialize(initialization_options).await?; + let language_server = match pending_server.task.await? { + Some(server) => server.initialize(initialization_options).await?, + None => return Ok(None), + }; language_server .on_notification::({ @@ -2756,7 +2762,7 @@ impl Project { ) .ok(); - Ok(language_server) + Ok(Some(language_server)) } fn insert_newly_running_language_server(