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