diff options
Diffstat (limited to 'crates/ra_lsp_server')
-rw-r--r-- | crates/ra_lsp_server/src/lib.rs | 5 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/main.rs | 19 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/main_loop.rs | 6 |
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 | ||
12 | pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>; | 12 | pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>; |
13 | pub use crate::{ | 13 | pub 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 @@ | |||
1 | use flexi_logger::{Duplicate, Logger}; | 1 | use flexi_logger::{Duplicate, Logger}; |
2 | use gen_lsp_server::{run_server, stdio_transport}; | 2 | use gen_lsp_server::{run_server, stdio_transport}; |
3 | use serde::Deserialize; | ||
4 | 3 | ||
5 | use ra_lsp_server::{Result, ServerConfig}; | 4 | use ra_lsp_server::{show_message, Result, ServerConfig}; |
6 | use ra_prof; | 5 | use ra_prof; |
7 | 6 | ||
8 | fn main() -> Result<()> { | 7 | fn 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 | ||
620 | fn show_message(typ: req::MessageType, message: impl Into<String>, sender: &Sender<RawMessage>) { | 620 | pub 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>(¶ms); | 627 | let not = RawNotification::new::<req::ShowMessage>(¶ms); |