aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/rust-analyzer/src/bin/main.rs5
-rw-r--r--crates/rust-analyzer/src/config.rs60
-rw-r--r--crates/rust-analyzer/src/main_loop.rs19
-rw-r--r--crates/rust-analyzer/tests/heavy_tests/support.rs1
4 files changed, 52 insertions, 33 deletions
diff --git a/crates/rust-analyzer/src/bin/main.rs b/crates/rust-analyzer/src/bin/main.rs
index 22a84b50c..be35faff0 100644
--- a/crates/rust-analyzer/src/bin/main.rs
+++ b/crates/rust-analyzer/src/bin/main.rs
@@ -100,9 +100,8 @@ fn run_server() -> Result<()> {
100 if let Some(value) = &initialize_params.initialization_options { 100 if let Some(value) = &initialize_params.initialization_options {
101 config.update(value); 101 config.update(value);
102 } 102 }
103 if let Some(caps) = &initialize_params.capabilities.text_document { 103 config.update_caps(&initialize_params.capabilities);
104 config.update_caps(caps); 104
105 }
106 config 105 config
107 }; 106 };
108 107
diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs
index ccc38e3bb..53aee833d 100644
--- a/crates/rust-analyzer/src/config.rs
+++ b/crates/rust-analyzer/src/config.rs
@@ -9,7 +9,7 @@
9 9
10use std::{ffi::OsString, path::PathBuf}; 10use std::{ffi::OsString, path::PathBuf};
11 11
12use lsp_types::TextDocumentClientCapabilities; 12use lsp_types::ClientCapabilities;
13use ra_flycheck::FlycheckConfig; 13use ra_flycheck::FlycheckConfig;
14use ra_ide::{CompletionConfig, InlayHintsConfig}; 14use ra_ide::{CompletionConfig, InlayHintsConfig};
15use ra_project_model::CargoConfig; 15use ra_project_model::CargoConfig;
@@ -70,6 +70,7 @@ pub struct ClientCapsConfig {
70 pub line_folding_only: bool, 70 pub line_folding_only: bool,
71 pub hierarchical_symbols: bool, 71 pub hierarchical_symbols: bool,
72 pub code_action_literals: bool, 72 pub code_action_literals: bool,
73 pub work_done_progress: bool,
73} 74}
74 75
75impl Default for Config { 76impl Default for Config {
@@ -208,30 +209,43 @@ impl Config {
208 } 209 }
209 } 210 }
210 211
211 pub fn update_caps(&mut self, caps: &TextDocumentClientCapabilities) { 212 pub fn update_caps(&mut self, caps: &ClientCapabilities) {
212 if let Some(value) = caps.definition.as_ref().and_then(|it| it.link_support) { 213 if let Some(doc_caps) = caps.text_document.as_ref() {
213 self.client_caps.location_link = value; 214 if let Some(value) = doc_caps.definition.as_ref().and_then(|it| it.link_support) {
214 } 215 self.client_caps.location_link = value;
215 if let Some(value) = caps.folding_range.as_ref().and_then(|it| it.line_folding_only) { 216 }
216 self.client_caps.line_folding_only = value 217 if let Some(value) = doc_caps.folding_range.as_ref().and_then(|it| it.line_folding_only)
217 } 218 {
218 if let Some(value) = 219 self.client_caps.line_folding_only = value
219 caps.document_symbol.as_ref().and_then(|it| it.hierarchical_document_symbol_support) 220 }
220 { 221 if let Some(value) = doc_caps
221 self.client_caps.hierarchical_symbols = value 222 .document_symbol
222 } 223 .as_ref()
223 if let Some(value) = 224 .and_then(|it| it.hierarchical_document_symbol_support)
224 caps.code_action.as_ref().and_then(|it| Some(it.code_action_literal_support.is_some())) 225 {
225 { 226 self.client_caps.hierarchical_symbols = value
226 self.client_caps.code_action_literals = value; 227 }
227 } 228 if let Some(value) = doc_caps
228 self.completion.allow_snippets(false); 229 .code_action
229 if let Some(completion) = &caps.completion { 230 .as_ref()
230 if let Some(completion_item) = &completion.completion_item { 231 .and_then(|it| Some(it.code_action_literal_support.is_some()))
231 if let Some(value) = completion_item.snippet_support { 232 {
232 self.completion.allow_snippets(value); 233 self.client_caps.code_action_literals = value;
234 }
235 self.completion.allow_snippets(false);
236 if let Some(completion) = &doc_caps.completion {
237 if let Some(completion_item) = &completion.completion_item {
238 if let Some(value) = completion_item.snippet_support {
239 self.completion.allow_snippets(value);
240 }
233 } 241 }
234 } 242 }
235 } 243 }
244
245 if let Some(window_caps) = caps.window.as_ref() {
246 if let Some(value) = window_caps.work_done_progress {
247 self.client_caps.work_done_progress = value;
248 }
249 }
236 } 250 }
237} 251}
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs
index 3f12dd718..13d305b97 100644
--- a/crates/rust-analyzer/src/main_loop.rs
+++ b/crates/rust-analyzer/src/main_loop.rs
@@ -415,7 +415,8 @@ fn loop_turn(
415 }); 415 });
416 } 416 }
417 417
418 let show_progress = !loop_state.workspace_loaded; 418 let show_progress =
419 !loop_state.workspace_loaded && world_state.config.client_caps.work_done_progress;
419 420
420 if !loop_state.workspace_loaded 421 if !loop_state.workspace_loaded
421 && loop_state.roots_scanned == loop_state.roots_total 422 && loop_state.roots_scanned == loop_state.roots_total
@@ -750,12 +751,16 @@ fn on_check_task(
750 } 751 }
751 752
752 CheckTask::Status(progress) => { 753 CheckTask::Status(progress) => {
753 let params = lsp_types::ProgressParams { 754 if world_state.config.client_caps.work_done_progress {
754 token: lsp_types::ProgressToken::String("rustAnalyzer/cargoWatcher".to_string()), 755 let params = lsp_types::ProgressParams {
755 value: lsp_types::ProgressParamsValue::WorkDone(progress), 756 token: lsp_types::ProgressToken::String(
756 }; 757 "rustAnalyzer/cargoWatcher".to_string(),
757 let not = notification_new::<lsp_types::notification::Progress>(params); 758 ),
758 task_sender.send(Task::Notify(not)).unwrap(); 759 value: lsp_types::ProgressParamsValue::WorkDone(progress),
760 };
761 let not = notification_new::<lsp_types::notification::Progress>(params);
762 task_sender.send(Task::Notify(not)).unwrap();
763 }
759 } 764 }
760 }; 765 };
761 766
diff --git a/crates/rust-analyzer/tests/heavy_tests/support.rs b/crates/rust-analyzer/tests/heavy_tests/support.rs
index 8756ad4a3..9acbae066 100644
--- a/crates/rust-analyzer/tests/heavy_tests/support.rs
+++ b/crates/rust-analyzer/tests/heavy_tests/support.rs
@@ -80,6 +80,7 @@ impl<'a> Project<'a> {
80 client_caps: ClientCapsConfig { 80 client_caps: ClientCapsConfig {
81 location_link: true, 81 location_link: true,
82 code_action_literals: true, 82 code_action_literals: true,
83 work_done_progress: true,
83 ..Default::default() 84 ..Default::default()
84 }, 85 },
85 with_sysroot: self.with_sysroot, 86 with_sysroot: self.with_sysroot,