From a68ce62f6a33d3e5777c1d64c946e0f1d9c7f457 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Fri, 19 Nov 2021 17:56:46 +0200 Subject: [PATCH] Add toggle to disable cache priming --- crates/rust-analyzer/src/config.rs | 7 +++++++ crates/rust-analyzer/src/main_loop.rs | 4 +++- docs/user/generated_config.adoc | 5 +++++ editors/code/package.json | 5 +++++ 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs index 6a72c4e3261..5826b6b114c 100644 --- a/crates/rust-analyzer/src/config.rs +++ b/crates/rust-analyzer/src/config.rs @@ -58,6 +58,9 @@ config_data! { /// Whether to allow import insertion to merge new imports into single path glob imports like `use std::fmt::*;`. assist_allowMergingIntoGlobImports: bool = "true", + /// Warm up caches on project load. + cache_warmup: bool = "true", + /// Show function name and docs in parameter hints. callInfo_full: bool = "true", @@ -545,6 +548,10 @@ impl Config { ) } + pub fn prefill_caches(&self) -> bool { + self.data.cache_warmup + } + pub fn location_link(&self) -> bool { try_or!(self.caps.text_document.as_ref()?.definition?.link_support?, false) } diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs index eab4b2e6a30..979b3b15221 100644 --- a/crates/rust-analyzer/src/main_loop.rs +++ b/crates/rust-analyzer/src/main_loop.rs @@ -433,7 +433,9 @@ impl GlobalState { for flycheck in &self.flycheck { flycheck.update(); } - self.prime_caches_queue.request_op(); + if self.config.prefill_caches() { + self.prime_caches_queue.request_op(); + } } if !was_quiescent || state_changed { diff --git a/docs/user/generated_config.adoc b/docs/user/generated_config.adoc index c7bb1bf6420..9f6f046014c 100644 --- a/docs/user/generated_config.adoc +++ b/docs/user/generated_config.adoc @@ -23,6 +23,11 @@ Group inserted imports by the https://rust-analyzer.github.io/manual.html#auto-i -- Whether to allow import insertion to merge new imports into single path glob imports like `use std::fmt::*;`. -- +[[rust-analyzer.cache.warmup]]rust-analyzer.cache.warmup (default: `true`):: ++ +-- +Warm up caches on project load. +-- [[rust-analyzer.callInfo.full]]rust-analyzer.callInfo.full (default: `true`):: + -- diff --git a/editors/code/package.json b/editors/code/package.json index e1cbe8ba640..52ba1327459 100644 --- a/editors/code/package.json +++ b/editors/code/package.json @@ -445,6 +445,11 @@ "default": true, "type": "boolean" }, + "rust-analyzer.cache.warmup": { + "markdownDescription": "Warm up caches on project load.", + "default": true, + "type": "boolean" + }, "rust-analyzer.callInfo.full": { "markdownDescription": "Show function name and docs in parameter hints.", "default": true,