diff options
Diffstat (limited to 'crates/rust-analyzer/src/bin/main.rs')
-rw-r--r-- | crates/rust-analyzer/src/bin/main.rs | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/crates/rust-analyzer/src/bin/main.rs b/crates/rust-analyzer/src/bin/main.rs index a744a6695..483f50ce6 100644 --- a/crates/rust-analyzer/src/bin/main.rs +++ b/crates/rust-analyzer/src/bin/main.rs | |||
@@ -5,7 +5,7 @@ mod args; | |||
5 | 5 | ||
6 | use lsp_server::Connection; | 6 | use lsp_server::Connection; |
7 | 7 | ||
8 | use rust_analyzer::{cli, from_json, show_message, Result, ServerConfig}; | 8 | use rust_analyzer::{cli, from_json, Config, Result}; |
9 | 9 | ||
10 | use crate::args::HelpPrinted; | 10 | use crate::args::HelpPrinted; |
11 | 11 | ||
@@ -78,24 +78,18 @@ fn run_server() -> Result<()> { | |||
78 | .filter(|workspaces| !workspaces.is_empty()) | 78 | .filter(|workspaces| !workspaces.is_empty()) |
79 | .unwrap_or_else(|| vec![root]); | 79 | .unwrap_or_else(|| vec![root]); |
80 | 80 | ||
81 | let server_config = initialize_params | 81 | let config = { |
82 | .initialization_options | 82 | let mut config = Config::default(); |
83 | .and_then(|v| { | 83 | if let Some(value) = &initialize_params.initialization_options { |
84 | from_json::<ServerConfig>("config", v) | 84 | config.update(value); |
85 | .map_err(|e| { | 85 | } |
86 | log::error!("{}", e); | 86 | if let Some(caps) = &initialize_params.capabilities.text_document { |
87 | show_message(lsp_types::MessageType::Error, e.to_string(), &connection.sender); | 87 | config.update_caps(caps); |
88 | }) | 88 | } |
89 | .ok() | 89 | config |
90 | }) | 90 | }; |
91 | .unwrap_or_default(); | 91 | |
92 | 92 | rust_analyzer::main_loop(workspace_roots, config, connection)?; | |
93 | rust_analyzer::main_loop( | ||
94 | workspace_roots, | ||
95 | initialize_params.capabilities, | ||
96 | server_config, | ||
97 | connection, | ||
98 | )?; | ||
99 | 93 | ||
100 | log::info!("shutting down IO..."); | 94 | log::info!("shutting down IO..."); |
101 | io_threads.join()?; | 95 | io_threads.join()?; |