diff --git a/crates/copilot/src/copilot.rs b/crates/copilot/src/copilot.rs index 866bb8d7f5..4c45bf823b 100644 --- a/crates/copilot/src/copilot.rs +++ b/crates/copilot/src/copilot.rs @@ -15,7 +15,7 @@ use language::{ ToPointUtf16, }; use log::{debug, error}; -use lsp::{LanguageServer, LanguageServerBinaries, LanguageServerBinary, LanguageServerId}; +use lsp::{LanguageServer, LanguageServerBinary, LanguageServerId}; use node_runtime::NodeRuntime; use request::{LogMessage, StatusNotification}; use settings::SettingsStore; @@ -366,13 +366,9 @@ impl Copilot { path: node_path, arguments, }; - let binaries = LanguageServerBinaries { - binary: binary.clone(), - installation_test_binary: Some(binary), - }; let server = LanguageServer::new( LanguageServerId(0), - binaries, + binary, Path::new("/"), None, cx.clone(), diff --git a/crates/language/src/language.rs b/crates/language/src/language.rs index 9e3d3708ba..beec63dfd2 100644 --- a/crates/language/src/language.rs +++ b/crates/language/src/language.rs @@ -20,7 +20,7 @@ use futures::{ use gpui::{executor::Background, AppContext, AsyncAppContext, Task}; use highlight_map::HighlightMap; use lazy_static::lazy_static; -use lsp::{CodeActionKind, LanguageServerBinaries, LanguageServerBinary}; +use lsp::{CodeActionKind, LanguageServerBinary}; use parking_lot::{Mutex, RwLock}; use postage::watch; use regex::Regex; @@ -564,10 +564,7 @@ pub struct LanguageRegistry { login_shell_env_loaded: Shared>, #[allow(clippy::type_complexity)] lsp_binary_paths: Mutex< - HashMap< - LanguageServerName, - Shared>>>, - >, + HashMap>>>>, >, executor: Option>, } @@ -859,7 +856,7 @@ impl LanguageRegistry { self.state.read().languages.iter().cloned().collect() } - pub fn start_pending_language_server( + pub fn create_pending_language_server( self: &Arc, language: Arc, adapter: Arc, @@ -932,7 +929,7 @@ impl LanguageRegistry { .entry(adapter.name.clone()) .or_insert_with(|| { cx.spawn(|cx| { - get_binaries( + get_binary( adapter.clone(), language.clone(), delegate.clone(), @@ -953,15 +950,13 @@ impl LanguageRegistry { task.await?; } - let server = lsp::LanguageServer::new( + lsp::LanguageServer::new( server_id, binaries, &root_path, adapter.code_action_kinds(), cx, - )?; - - Ok(server) + ) }) }; @@ -1047,14 +1042,14 @@ impl Default for LanguageRegistry { } } -async fn get_binaries( +async fn get_binary( adapter: Arc, language: Arc, delegate: Arc, container_dir: Arc, statuses: async_broadcast::Sender<(Arc, LanguageServerBinaryStatus)>, mut cx: AsyncAppContext, -) -> Result { +) -> Result { if !container_dir.exists() { smol::fs::create_dir_all(&container_dir) .await @@ -1082,13 +1077,7 @@ async fn get_binaries( statuses .broadcast((language.clone(), LanguageServerBinaryStatus::Cached)) .await?; - let installation_test_binary = adapter - .installation_test_binary(container_dir.to_path_buf()) - .await; - return Ok(LanguageServerBinaries { - binary, - installation_test_binary, - }); + return Ok(binary); } else { statuses .broadcast(( @@ -1110,7 +1099,7 @@ async fn fetch_latest_binary( delegate: &dyn LspAdapterDelegate, container_dir: &Path, lsp_binary_statuses_tx: async_broadcast::Sender<(Arc, LanguageServerBinaryStatus)>, -) -> Result { +) -> Result { let container_dir: Arc = container_dir.into(); lsp_binary_statuses_tx .broadcast(( @@ -1127,17 +1116,11 @@ async fn fetch_latest_binary( let binary = adapter .fetch_server_binary(version_info, container_dir.to_path_buf(), delegate) .await?; - let installation_test_binary = adapter - .installation_test_binary(container_dir.to_path_buf()) - .await; lsp_binary_statuses_tx .broadcast((language.clone(), LanguageServerBinaryStatus::Downloaded)) .await?; - Ok(LanguageServerBinaries { - binary, - installation_test_binary, - }) + Ok(binary) } impl Language { diff --git a/crates/lsp/src/lsp.rs b/crates/lsp/src/lsp.rs index deab1d9cc0..ffca2f24ab 100644 --- a/crates/lsp/src/lsp.rs +++ b/crates/lsp/src/lsp.rs @@ -43,12 +43,6 @@ pub struct LanguageServerBinary { pub arguments: Vec, } -#[derive(Debug, Clone, Deserialize)] -pub struct LanguageServerBinaries { - pub binary: LanguageServerBinary, - pub installation_test_binary: Option, -} - pub struct LanguageServer { server_id: LanguageServerId, next_id: AtomicUsize, @@ -65,7 +59,6 @@ pub struct LanguageServer { output_done_rx: Mutex>, root_path: PathBuf, _server: Option>, - installation_test_binary: Option, } #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] @@ -135,7 +128,7 @@ struct Error { impl LanguageServer { pub fn new( server_id: LanguageServerId, - binaries: LanguageServerBinaries, + binary: LanguageServerBinary, root_path: &Path, code_action_kinds: Option>, cx: AsyncAppContext, @@ -146,9 +139,9 @@ impl LanguageServer { root_path.parent().unwrap_or_else(|| Path::new("/")) }; - let mut server = process::Command::new(&binaries.binary.path) + let mut server = process::Command::new(&binary.path) .current_dir(working_dir) - .args(binaries.binary.arguments) + .args(binary.arguments) .stdin(Stdio::piped()) .stdout(Stdio::piped()) .stderr(Stdio::inherit()) @@ -162,7 +155,6 @@ impl LanguageServer { stdin, stout, Some(server), - binaries.installation_test_binary, root_path, code_action_kinds, cx, @@ -181,7 +173,7 @@ impl LanguageServer { }, ); - if let Some(name) = binaries.binary.path.file_name() { + if let Some(name) = binary.path.file_name() { server.name = name.to_string_lossy().to_string(); } @@ -193,7 +185,6 @@ impl LanguageServer { stdin: Stdin, stdout: Stdout, server: Option, - installation_test_binary: Option, root_path: &Path, code_action_kinds: Option>, cx: AsyncAppContext, @@ -248,14 +239,9 @@ impl LanguageServer { output_done_rx: Mutex::new(Some(output_done_rx)), root_path: root_path.to_path_buf(), _server: server.map(|server| Mutex::new(server)), - installation_test_binary, } } - pub fn installation_test_binary(&self) -> &Option { - &self.installation_test_binary - } - pub fn code_action_kinds(&self) -> Option> { self.code_action_kinds.clone() } @@ -840,7 +826,6 @@ impl LanguageServer { stdin_writer, stdout_reader, None, - None, Path::new("/"), None, cx.clone(), @@ -852,7 +837,6 @@ impl LanguageServer { stdout_writer, stdin_reader, None, - None, Path::new("/"), None, cx, diff --git a/crates/project/src/project.rs b/crates/project/src/project.rs index a33a47779c..4c6b25b0e9 100644 --- a/crates/project/src/project.rs +++ b/crates/project/src/project.rs @@ -2423,7 +2423,7 @@ impl Project { return; } - let pending_server = match self.languages.start_pending_language_server( + let pending_server = match self.languages.create_pending_language_server( language.clone(), adapter.clone(), worktree_path,