From 2d4be2ef2a12886c526c07ad411406393c2c4b7e Mon Sep 17 00:00:00 2001 From: kjeremy Date: Fri, 23 Oct 2020 17:36:22 -0400 Subject: Request a refresh of semantic tokens if things are loaded up --- crates/rust-analyzer/src/config.rs | 10 ++++++++++ crates/rust-analyzer/src/main_loop.rs | 6 ++++++ 2 files changed, 16 insertions(+) (limited to 'crates') 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 { pub call_info_full: bool, pub lens: LensConfig, pub hover: HoverConfig, + pub semantic_tokens_refresh: bool, pub with_sysroot: bool, pub linked_projects: Vec, @@ -193,6 +194,7 @@ impl Config { call_info_full: true, lens: LensConfig::default(), hover: HoverConfig::default(), + semantic_tokens_refresh: false, linked_projects: Vec::new(), root_path, } @@ -402,6 +404,14 @@ impl Config { self.client_caps.hover_actions = get_bool("hoverActions"); self.client_caps.status_notification = get_bool("statusNotification"); } + + if let Some(workspace_caps) = caps.workspace.as_ref() { + if let Some(refresh_support) = + workspace_caps.semantic_tokens.as_ref().and_then(|it| it.refresh_support) + { + self.semantic_tokens_refresh = refresh_support; + } + } } } 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 { .collect::>(); self.update_file_notifications_on_threadpool(subscriptions); + + // Refresh semantic tokens if the client supports it. + if self.config.semantic_tokens_refresh { + self.semantic_tokens_cache.lock().clear(); + self.send_request::((), |_, _| ()); + } } if let Some(diagnostic_changes) = self.diagnostics.take_changes() { -- cgit v1.2.3