aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_lsp_server
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-08-22 09:08:22 +0100
committerAleksey Kladov <[email protected]>2019-08-22 09:08:22 +0100
commit4dd5afb7fe2eb20748ade9141e74b04f5dd2f922 (patch)
tree5addeedbb0d01fe1a0385aedb7d16ac700a1d1b7 /crates/ra_lsp_server
parent5fd9a5be0984faa138281e46dd4b73cfdad073b1 (diff)
show error to the user when deserializing config
Diffstat (limited to 'crates/ra_lsp_server')
-rw-r--r--crates/ra_lsp_server/src/lib.rs5
-rw-r--r--crates/ra_lsp_server/src/main.rs19
-rw-r--r--crates/ra_lsp_server/src/main_loop.rs6
3 files changed, 22 insertions, 8 deletions
diff --git a/crates/ra_lsp_server/src/lib.rs b/crates/ra_lsp_server/src/lib.rs
index ca388e472..2c5d7c72d 100644
--- a/crates/ra_lsp_server/src/lib.rs
+++ b/crates/ra_lsp_server/src/lib.rs
@@ -11,5 +11,8 @@ mod world;
11 11
12pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>; 12pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>;
13pub use crate::{ 13pub use crate::{
14 caps::server_capabilities, config::ServerConfig, main_loop::main_loop, main_loop::LspError, 14 caps::server_capabilities,
15 config::ServerConfig,
16 main_loop::LspError,
17 main_loop::{main_loop, show_message},
15}; 18};
diff --git a/crates/ra_lsp_server/src/main.rs b/crates/ra_lsp_server/src/main.rs
index 36d4898bd..ae1392cb5 100644
--- a/crates/ra_lsp_server/src/main.rs
+++ b/crates/ra_lsp_server/src/main.rs
@@ -1,8 +1,7 @@
1use flexi_logger::{Duplicate, Logger}; 1use flexi_logger::{Duplicate, Logger};
2use gen_lsp_server::{run_server, stdio_transport}; 2use gen_lsp_server::{run_server, stdio_transport};
3use serde::Deserialize;
4 3
5use ra_lsp_server::{Result, ServerConfig}; 4use ra_lsp_server::{show_message, Result, ServerConfig};
6use ra_prof; 5use ra_prof;
7 6
8fn main() -> Result<()> { 7fn main() -> Result<()> {
@@ -46,15 +45,23 @@ fn main_inner() -> Result<()> {
46 .filter(|workspaces| !workspaces.is_empty()) 45 .filter(|workspaces| !workspaces.is_empty())
47 .unwrap_or_else(|| vec![root]); 46 .unwrap_or_else(|| vec![root]);
48 47
49 let opts = params 48 let server_config: ServerConfig = params
50 .initialization_options 49 .initialization_options
51 .and_then(|v| { 50 .and_then(|v| {
52 ServerConfig::deserialize(v) 51 serde_json::from_value(v)
53 .map_err(|e| log::error!("failed to deserialize config: {}", e)) 52 .map_err(|e| {
53 log::error!("failed to deserialize config: {}", e);
54 show_message(
55 lsp_types::MessageType::Error,
56 format!("failed to deserialize config: {}", e),
57 s,
58 );
59 })
54 .ok() 60 .ok()
55 }) 61 })
56 .unwrap_or_default(); 62 .unwrap_or_default();
57 ra_lsp_server::main_loop(workspace_roots, params.capabilities, opts, r, s) 63
64 ra_lsp_server::main_loop(workspace_roots, params.capabilities, server_config, r, s)
58 })?; 65 })?;
59 log::info!("shutting down IO..."); 66 log::info!("shutting down IO...");
60 threads.join()?; 67 threads.join()?;
diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs
index fcb782386..c0395c6d8 100644
--- a/crates/ra_lsp_server/src/main_loop.rs
+++ b/crates/ra_lsp_server/src/main_loop.rs
@@ -617,7 +617,11 @@ fn update_file_notifications_on_threadpool(
617 }); 617 });
618} 618}
619 619
620fn show_message(typ: req::MessageType, message: impl Into<String>, sender: &Sender<RawMessage>) { 620pub fn show_message(
621 typ: req::MessageType,
622 message: impl Into<String>,
623 sender: &Sender<RawMessage>,
624) {
621 let message = message.into(); 625 let message = message.into();
622 let params = req::ShowMessageParams { typ, message }; 626 let params = req::ShowMessageParams { typ, message };
623 let not = RawNotification::new::<req::ShowMessage>(&params); 627 let not = RawNotification::new::<req::ShowMessage>(&params);