Request a refresh of semantic tokens if things are loaded up

This commit is contained in:
kjeremy 2020-10-23 17:36:22 -04:00
parent 5444978f68
commit 2d4be2ef2a
2 changed files with 16 additions and 0 deletions

View File

@ -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<LinkedProject>,
@ -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;
}
}
}
}

View File

@ -330,6 +330,12 @@ impl GlobalState {
.collect::<Vec<_>>();
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::<lsp_types::request::SemanticTokensRefesh>((), |_, _| ());
}
}
if let Some(diagnostic_changes) = self.diagnostics.take_changes() {