Skip to content

Commit a118e08

Browse files
committed
Add toggle to disable cache priming
1 parent cf2ddb9 commit a118e08

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

crates/rust-analyzer/src/config.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,9 @@ config_data! {
246246
/// `rust-project.json`, or JSON objects in `rust-project.json` format.
247247
linkedProjects: Vec<ManifestOrProjectJson> = "[]",
248248

249+
/// Pre-fill caches on project load.
250+
load_prefillCaches: bool = "true",
251+
249252
/// Number of syntax trees rust-analyzer keeps in memory. Defaults to 128.
250253
lruCapacity: Option<usize> = "null",
251254

@@ -545,6 +548,10 @@ impl Config {
545548
)
546549
}
547550

551+
pub fn prefill_caches(&self) -> bool {
552+
self.data.load_prefillCaches
553+
}
554+
548555
pub fn location_link(&self) -> bool {
549556
try_or!(self.caps.text_document.as_ref()?.definition?.link_support?, false)
550557
}

crates/rust-analyzer/src/main_loop.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,9 @@ impl GlobalState {
433433
for flycheck in &self.flycheck {
434434
flycheck.update();
435435
}
436-
self.prime_caches_queue.request_op();
436+
if self.config.prefill_caches() {
437+
self.prime_caches_queue.request_op();
438+
}
437439
}
438440

439441
if !was_quiescent || state_changed {

docs/user/generated_config.adoc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,11 @@ of projects.
389389
Elements must be paths pointing to `Cargo.toml`,
390390
`rust-project.json`, or JSON objects in `rust-project.json` format.
391391
--
392+
[[rust-analyzer.load.prefillCaches]]rust-analyzer.load.prefillCaches (default: `true`)::
393+
+
394+
--
395+
Pre-fill caches on project load.
396+
--
392397
[[rust-analyzer.lruCapacity]]rust-analyzer.lruCapacity (default: `null`)::
393398
+
394399
--

editors/code/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -828,6 +828,11 @@
828828
]
829829
}
830830
},
831+
"rust-analyzer.load.prefillCaches": {
832+
"markdownDescription": "Pre-fill caches on project load.",
833+
"default": true,
834+
"type": "boolean"
835+
},
831836
"rust-analyzer.lruCapacity": {
832837
"markdownDescription": "Number of syntax trees rust-analyzer keeps in memory. Defaults to 128.",
833838
"default": null,

0 commit comments

Comments
 (0)