diff --git a/crates/ra_lsp_server/src/lib.rs b/crates/ra_lsp_server/src/lib.rs index ca388e4722..2c5d7c72d9 100644 --- a/crates/ra_lsp_server/src/lib.rs +++ b/crates/ra_lsp_server/src/lib.rs @@ -11,5 +11,8 @@ mod world; pub type Result = std::result::Result>; pub use crate::{ - caps::server_capabilities, config::ServerConfig, main_loop::main_loop, main_loop::LspError, + caps::server_capabilities, + config::ServerConfig, + main_loop::LspError, + main_loop::{main_loop, show_message}, }; diff --git a/crates/ra_lsp_server/src/main.rs b/crates/ra_lsp_server/src/main.rs index 36d4898bd9..ae1392cb5d 100644 --- a/crates/ra_lsp_server/src/main.rs +++ b/crates/ra_lsp_server/src/main.rs @@ -1,8 +1,7 @@ use flexi_logger::{Duplicate, Logger}; use gen_lsp_server::{run_server, stdio_transport}; -use serde::Deserialize; -use ra_lsp_server::{Result, ServerConfig}; +use ra_lsp_server::{show_message, Result, ServerConfig}; use ra_prof; fn main() -> Result<()> { @@ -46,15 +45,23 @@ fn main_inner() -> Result<()> { .filter(|workspaces| !workspaces.is_empty()) .unwrap_or_else(|| vec![root]); - let opts = params + let server_config: ServerConfig = params .initialization_options .and_then(|v| { - ServerConfig::deserialize(v) - .map_err(|e| log::error!("failed to deserialize config: {}", e)) + serde_json::from_value(v) + .map_err(|e| { + log::error!("failed to deserialize config: {}", e); + show_message( + lsp_types::MessageType::Error, + format!("failed to deserialize config: {}", e), + s, + ); + }) .ok() }) .unwrap_or_default(); - ra_lsp_server::main_loop(workspace_roots, params.capabilities, opts, r, s) + + ra_lsp_server::main_loop(workspace_roots, params.capabilities, server_config, r, s) })?; log::info!("shutting down IO..."); threads.join()?; diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs index fcb7823861..c0395c6d82 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( }); } -fn show_message(typ: req::MessageType, message: impl Into, sender: &Sender) { +pub fn show_message( + typ: req::MessageType, + message: impl Into, + sender: &Sender, +) { let message = message.into(); let params = req::ShowMessageParams { typ, message }; let not = RawNotification::new::(¶ms);