Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'src/lsp.rs')
| -rw-r--r-- | src/lsp.rs | 24 |
1 files changed, 13 insertions, 11 deletions
@@ -12,14 +12,12 @@ use helix_core::syntax::config::{ use json_value_merge::Merge; use log::info; use lsp_server::Message; -use lsp_types::notification::*; -use lsp_types::request::*; use lsp_types::*; use rootcause::report; use tokio::sync::oneshot; use winit::window::Window; mod client; -mod communication; +pub(crate) mod communication; pub use client::*; mod init_opts; mod rq; @@ -45,12 +43,14 @@ pub fn run( let (not_tx, not_rx) = unbounded(); let (_req_tx, _req_rx) = unbounded(); let (window_tx, window_rx) = oneshot::channel::<Arc<dyn Window>>(); + let mut rt = tokio::runtime::Builder::new_multi_thread(); + #[cfg(target_family = "unix")] + rt.enable_io(); let mut c = Client { tx: Tx(tx), progress: Box::leak(Box::new(papaya::HashMap::new())), - runtime: tokio::runtime::Builder::new_multi_thread() + runtime: rt .enable_time() - // .enable_io() .worker_threads(3) .thread_name("lsp runtime") .build()?, @@ -76,12 +76,16 @@ pub fn run( } }; info!("spawned {}", serde_json::to_string_pretty(&opts).unwrap()); - _ = c.request::<Initialize>(&opts)?; + _ = c.request::<InitializeRequest>(&opts)?; let x = rx .iter() .find_map(|x| { serde_json::from_value::<InitializeResult>( - x.response()?.result?, + match x { + Message::Notification(_) | Message::Request(_) => None, + Message::Response(response) => Some(response), + }? + .result?, ) .ok() }) @@ -92,10 +96,8 @@ pub fn run( // Some(PositionEncodingKind::UTF8) // ); c.initialized = Some(x); - c.notify::<lsp_types::notification::Initialized>( - &InitializedParams {}, - )?; - c.notify::<SetTrace>(&SetTraceParams { + c.notify::<lsp_types::InitializedNotification>(&InitializedParams {})?; + c.notify::<SetTraceNotification>(&SetTraceParams { value: lsp_types::TraceValue::Verbose, })?; let progress = c.progress; |