aboutsummaryrefslogtreecommitdiff
path: root/crates/rust-analyzer/src/main_loop.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2021-01-06 10:54:28 +0000
committerAleksey Kladov <[email protected]>2021-01-06 12:39:28 +0000
commitf7a15b5cd1df58e46066bbd27c90cb1ad7f9c316 (patch)
treedf2caa99c4558b9f2550420896ec9998566e1d5d /crates/rust-analyzer/src/main_loop.rs
parentc3104466596e85d7fa43b8e3ac015bcabd08fcce (diff)
More maintainable config
Rather than eagerly converting JSON, we losslessly keep it as is, and change the shape of user-submitted data at the last moment. This also allows us to remove a bunch of wrong Defaults
Diffstat (limited to 'crates/rust-analyzer/src/main_loop.rs')
-rw-r--r--crates/rust-analyzer/src/main_loop.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs
index 8eca79f7e..53f9546b8 100644
--- a/crates/rust-analyzer/src/main_loop.rs
+++ b/crates/rust-analyzer/src/main_loop.rs
@@ -99,7 +99,8 @@ impl fmt::Debug for Event {
99 99
100impl GlobalState { 100impl GlobalState {
101 fn run(mut self, inbox: Receiver<lsp_server::Message>) -> Result<()> { 101 fn run(mut self, inbox: Receiver<lsp_server::Message>) -> Result<()> {
102 if self.config.linked_projects.is_empty() && self.config.notifications.cargo_toml_not_found 102 if self.config.linked_projects().is_empty()
103 && self.config.notifications().cargo_toml_not_found
103 { 104 {
104 self.show_message( 105 self.show_message(
105 lsp_types::MessageType::Error, 106 lsp_types::MessageType::Error,
@@ -296,7 +297,7 @@ impl GlobalState {
296 flycheck::Message::AddDiagnostic { workspace_root, diagnostic } => { 297 flycheck::Message::AddDiagnostic { workspace_root, diagnostic } => {
297 let diagnostics = 298 let diagnostics =
298 crate::diagnostics::to_proto::map_rust_diagnostic_to_lsp( 299 crate::diagnostics::to_proto::map_rust_diagnostic_to_lsp(
299 &self.config.diagnostics_map, 300 &self.config.diagnostics_map(),
300 &diagnostic, 301 &diagnostic,
301 &workspace_root, 302 &workspace_root,
302 ); 303 );
@@ -365,13 +366,13 @@ impl GlobalState {
365 self.update_file_notifications_on_threadpool(); 366 self.update_file_notifications_on_threadpool();
366 367
367 // Refresh semantic tokens if the client supports it. 368 // Refresh semantic tokens if the client supports it.
368 if self.config.semantic_tokens_refresh { 369 if self.config.semantic_tokens_refresh() {
369 self.semantic_tokens_cache.lock().clear(); 370 self.semantic_tokens_cache.lock().clear();
370 self.send_request::<lsp_types::request::SemanticTokensRefesh>((), |_, _| ()); 371 self.send_request::<lsp_types::request::SemanticTokensRefesh>((), |_, _| ());
371 } 372 }
372 373
373 // Refresh code lens if the client supports it. 374 // Refresh code lens if the client supports it.
374 if self.config.code_lens_refresh { 375 if self.config.code_lens_refresh() {
375 self.send_request::<lsp_types::request::CodeLensRefresh>((), |_, _| ()); 376 self.send_request::<lsp_types::request::CodeLensRefresh>((), |_, _| ());
376 } 377 }
377 } 378 }
@@ -658,7 +659,7 @@ impl GlobalState {
658 .collect::<Vec<_>>(); 659 .collect::<Vec<_>>();
659 660
660 log::trace!("updating notifications for {:?}", subscriptions); 661 log::trace!("updating notifications for {:?}", subscriptions);
661 if self.config.publish_diagnostics { 662 if self.config.publish_diagnostics() {
662 let snapshot = self.snapshot(); 663 let snapshot = self.snapshot();
663 self.task_pool.handle.spawn(move || { 664 self.task_pool.handle.spawn(move || {
664 let diagnostics = subscriptions 665 let diagnostics = subscriptions