Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'src/lsp.rs')
-rw-r--r--src/lsp.rs30
1 files changed, 18 insertions, 12 deletions
diff --git a/src/lsp.rs b/src/lsp.rs
index 9628740..4312cf8 100644
--- a/src/lsp.rs
+++ b/src/lsp.rs
@@ -10,15 +10,14 @@ use helix_core::syntax::config::{
LanguageServerConfiguration, LanguageServerFeatures,
};
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;
@@ -44,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(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()?,
@@ -60,24 +61,31 @@ pub fn run(
req_rx: _req_rx,
not_rx,
lsp_data: data,
+ workspace: workspace.clone(),
};
let mut opts = init_opts::get(
workspace,
&data.0.config,
data.1.name == "rust-analyzer",
);
+
if let Some(v) = vscode_conf {
match opts.initialization_options {
Some(ref mut x) => x.merge(&v),
None => opts.initialization_options = Some(v),
}
};
- _ = c.request::<Initialize>(&opts)?;
+ info!("spawned {}", serde_json::to_string_pretty(&opts).unwrap());
+ _ = 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()
})
@@ -88,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;