aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_lsp_server/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_lsp_server/src/main.rs')
-rw-r--r--crates/ra_lsp_server/src/main.rs17
1 files changed, 7 insertions, 10 deletions
diff --git a/crates/ra_lsp_server/src/main.rs b/crates/ra_lsp_server/src/main.rs
index 3879eeff2..c8a017c5c 100644
--- a/crates/ra_lsp_server/src/main.rs
+++ b/crates/ra_lsp_server/src/main.rs
@@ -1,7 +1,7 @@
1//! `ra_lsp_server` binary 1//! `ra_lsp_server` binary
2 2
3use lsp_server::Connection; 3use lsp_server::Connection;
4use ra_lsp_server::{show_message, Result, ServerConfig}; 4use ra_lsp_server::{from_json, show_message, Result, ServerConfig};
5use ra_prof; 5use ra_prof;
6 6
7fn main() -> Result<()> { 7fn main() -> Result<()> {
@@ -45,7 +45,8 @@ fn run_server() -> Result<()> {
45 let server_capabilities = serde_json::to_value(ra_lsp_server::server_capabilities()).unwrap(); 45 let server_capabilities = serde_json::to_value(ra_lsp_server::server_capabilities()).unwrap();
46 46
47 let initialize_params = connection.initialize(server_capabilities)?; 47 let initialize_params = connection.initialize(server_capabilities)?;
48 let initialize_params: lsp_types::InitializeParams = serde_json::from_value(initialize_params)?; 48 let initialize_params =
49 from_json::<lsp_types::InitializeParams>("InitializeParams", initialize_params)?;
49 50
50 if let Some(client_info) = initialize_params.client_info { 51 if let Some(client_info) = initialize_params.client_info {
51 log::info!("Client '{}' {}", client_info.name, client_info.version.unwrap_or_default()); 52 log::info!("Client '{}' {}", client_info.name, client_info.version.unwrap_or_default());
@@ -62,17 +63,13 @@ fn run_server() -> Result<()> {
62 .filter(|workspaces| !workspaces.is_empty()) 63 .filter(|workspaces| !workspaces.is_empty())
63 .unwrap_or_else(|| vec![root]); 64 .unwrap_or_else(|| vec![root]);
64 65
65 let server_config: ServerConfig = initialize_params 66 let server_config = initialize_params
66 .initialization_options 67 .initialization_options
67 .and_then(|v| { 68 .and_then(|v| {
68 serde_json::from_value(v) 69 from_json::<ServerConfig>("config", v)
69 .map_err(|e| { 70 .map_err(|e| {
70 log::error!("failed to deserialize config: {}", e); 71 log::error!("{}", e);
71 show_message( 72 show_message(lsp_types::MessageType::Error, e.to_string(), &connection.sender);
72 lsp_types::MessageType::Error,
73 format!("failed to deserialize config: {}", e),
74 &connection.sender,
75 );
76 }) 73 })
77 .ok() 74 .ok()
78 }) 75 })