aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorkjeremy <[email protected]>2020-10-23 22:36:22 +0100
committerkjeremy <[email protected]>2020-10-26 13:23:34 +0000
commit2d4be2ef2a12886c526c07ad411406393c2c4b7e (patch)
tree1d3bf49b3c35cf59553e4e6d41a85166cf49e39c /crates
parent5444978f682b9a5e437e1080fb9343f2d66e1804 (diff)
Request a refresh of semantic tokens if things are loaded up
Diffstat (limited to 'crates')
-rw-r--r--crates/rust-analyzer/src/config.rs10
-rw-r--r--crates/rust-analyzer/src/main_loop.rs6
2 files changed, 16 insertions, 0 deletions
diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs
index 1b9b24698..2ed6a0d82 100644
--- a/crates/rust-analyzer/src/config.rs
+++ b/crates/rust-analyzer/src/config.rs
@@ -47,6 +47,7 @@ pub struct Config {
47 pub call_info_full: bool, 47 pub call_info_full: bool,
48 pub lens: LensConfig, 48 pub lens: LensConfig,
49 pub hover: HoverConfig, 49 pub hover: HoverConfig,
50 pub semantic_tokens_refresh: bool,
50 51
51 pub with_sysroot: bool, 52 pub with_sysroot: bool,
52 pub linked_projects: Vec<LinkedProject>, 53 pub linked_projects: Vec<LinkedProject>,
@@ -193,6 +194,7 @@ impl Config {
193 call_info_full: true, 194 call_info_full: true,
194 lens: LensConfig::default(), 195 lens: LensConfig::default(),
195 hover: HoverConfig::default(), 196 hover: HoverConfig::default(),
197 semantic_tokens_refresh: false,
196 linked_projects: Vec::new(), 198 linked_projects: Vec::new(),
197 root_path, 199 root_path,
198 } 200 }
@@ -402,6 +404,14 @@ impl Config {
402 self.client_caps.hover_actions = get_bool("hoverActions"); 404 self.client_caps.hover_actions = get_bool("hoverActions");
403 self.client_caps.status_notification = get_bool("statusNotification"); 405 self.client_caps.status_notification = get_bool("statusNotification");
404 } 406 }
407
408 if let Some(workspace_caps) = caps.workspace.as_ref() {
409 if let Some(refresh_support) =
410 workspace_caps.semantic_tokens.as_ref().and_then(|it| it.refresh_support)
411 {
412 self.semantic_tokens_refresh = refresh_support;
413 }
414 }
405 } 415 }
406} 416}
407 417
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs
index ed5292733..ff855fe1a 100644
--- a/crates/rust-analyzer/src/main_loop.rs
+++ b/crates/rust-analyzer/src/main_loop.rs
@@ -330,6 +330,12 @@ impl GlobalState {
330 .collect::<Vec<_>>(); 330 .collect::<Vec<_>>();
331 331
332 self.update_file_notifications_on_threadpool(subscriptions); 332 self.update_file_notifications_on_threadpool(subscriptions);
333
334 // Refresh semantic tokens if the client supports it.
335 if self.config.semantic_tokens_refresh {
336 self.semantic_tokens_cache.lock().clear();
337 self.send_request::<lsp_types::request::SemanticTokensRefesh>((), |_, _| ());
338 }
333 } 339 }
334 340
335 if let Some(diagnostic_changes) = self.diagnostics.take_changes() { 341 if let Some(diagnostic_changes) = self.diagnostics.take_changes() {