aboutsummaryrefslogtreecommitdiff
path: root/helix-lsp
diff options
context:
space:
mode:
authorPhilipp Mildenberger2023-03-19 22:37:41 +0000
committerPhilipp Mildenberger2023-05-18 19:48:32 +0000
commit2eeac10755e6b88e3d5861dee7e2016a10c01c9f (patch)
tree81d338cb10f0718e3bbf280015ecf4a96dc460c7 /helix-lsp
parentb1199c552be39eec8cb428310c8bb2a952454b04 (diff)
Refactor doc language servers to a HashMap, and the config to use a Vec to retain order
Diffstat (limited to 'helix-lsp')
-rw-r--r--helix-lsp/src/lib.rs23
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()
}