diff options
Diffstat (limited to 'helix-lsp/src')
-rw-r--r-- | helix-lsp/src/lib.rs | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/helix-lsp/src/lib.rs b/helix-lsp/src/lib.rs index ba0c3fee..6b4bb430 100644 --- a/helix-lsp/src/lib.rs +++ b/helix-lsp/src/lib.rs @@ -12,7 +12,7 @@ pub use lsp_types as lsp; use futures_util::stream::select_all::SelectAll; use helix_core::{ path, - syntax::{LanguageConfiguration, LanguageServerConfiguration}, + syntax::{LanguageConfiguration, LanguageServerConfiguration, LanguageServerFeatures}, }; use tokio::sync::mpsc::UnboundedReceiver; @@ -26,7 +26,7 @@ use thiserror::Error; use tokio_stream::wrappers::UnboundedReceiverStream; pub type Result<T> = core::result::Result<T, Error>; -type LanguageServerName = String; +pub type LanguageServerName = String; #[derive(Error, Debug)] pub enum Error { @@ -689,9 +689,9 @@ impl Registry { ) -> Result<Vec<Arc<Client>>> { language_config .language_servers - .keys() - .filter_map(|name| { - #[allow(clippy::map_entry)] + .iter() + .filter_map(|LanguageServerFeatures { name, .. }| { + // #[allow(clippy::map_entry)] if self.inner.contains_key(name) { let client = match self.start_client( name.clone(), @@ -740,17 +740,20 @@ impl Registry { doc_path: Option<&std::path::PathBuf>, root_dirs: &[PathBuf], enable_snippets: bool, - ) -> Result<Vec<Arc<Client>>> { + ) -> Result<HashMap<LanguageServerName, Arc<Client>>> { language_config .language_servers - .keys() - .map(|name| { + .iter() + .map(|LanguageServerFeatures { name, .. }| { if let Some(clients) = self.inner.get_mut(name) { + // clients.find( + if let Some((_, client)) = clients.iter_mut().enumerate().find(|(i, client)| { client.try_add_doc(&language_config.roots, root_dirs, doc_path, *i == 0) }) { - return Ok(client.clone()); + return Ok((name.to_owned(), client.clone())); } + // return Ok((name.clone(), clients.clone())); } let client = self.start_client( name.clone(), @@ -761,7 +764,7 @@ impl Registry { )?; let clients = self.inner.entry(name.clone()).or_default(); clients.push(client.clone()); - Ok(client) + Ok((name.clone(), client)) }) .collect() } |