diff options
author | Blaž Hrastnik | 2021-05-06 04:56:34 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2021-05-06 04:56:34 +0000 |
commit | 355ad3cb8289611b06cd42fa62ddfe0a5c716e83 (patch) | |
tree | 7c94da6e122a9ecf542103b46a3ca9e80654a52e /helix-lsp/src/lib.rs | |
parent | 0e5308bce1a6e7d7d00854ae50902546cea9578d (diff) |
Tokio migration.
Diffstat (limited to 'helix-lsp/src/lib.rs')
-rw-r--r-- | helix-lsp/src/lib.rs | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/helix-lsp/src/lib.rs b/helix-lsp/src/lib.rs index 6dcc6605..fd7e6fd3 100644 --- a/helix-lsp/src/lib.rs +++ b/helix-lsp/src/lib.rs @@ -18,6 +18,8 @@ use std::{collections::HashMap, sync::Arc}; use serde::{Deserialize, Serialize}; +use tokio_stream::wrappers::UnboundedReceiverStream; + #[derive(Error, Debug)] pub enum Error { #[error("protocol error: {0}")] @@ -163,12 +165,11 @@ pub use jsonrpc::Call; type LanguageId = String; use crate::select_all::SelectAll; -use smol::channel::Receiver; pub struct Registry { inner: HashMap<LanguageId, Option<Arc<Client>>>, - pub incoming: SelectAll<Receiver<Call>>, + pub incoming: SelectAll<UnboundedReceiverStream<Call>>, } impl Default for Registry { @@ -185,11 +186,7 @@ impl Registry { } } - pub fn get( - &mut self, - language_config: &LanguageConfiguration, - ex: &smol::Executor, - ) -> Option<Arc<Client>> { + pub fn get(&mut self, language_config: &LanguageConfiguration) -> Option<Arc<Client>> { // TODO: propagate the error if let Some(config) = &language_config.language_server { // avoid borrow issues @@ -203,12 +200,13 @@ impl Registry { // initialize a new client let (mut client, incoming) = - Client::start(&ex, &config.command, &config.args).ok()?; + Client::start(&config.command, &config.args).ok()?; // TODO: run this async without blocking - smol::block_on(client.initialize()).unwrap(); + let rt = tokio::runtime::Handle::current(); + rt.block_on(client.initialize()).unwrap(); - s_incoming.push(incoming); + s_incoming.push(UnboundedReceiverStream::new(incoming)); Some(Arc::new(client)) }) |