Skip to content

Commit

Permalink
Auto merge of rust-lang#12223 - Veykril:config-stuff, r=Veykril
Browse files Browse the repository at this point in the history
internal: Rename primeCaches config keys
  • Loading branch information
bors committed May 12, 2022
2 parents d121307 + 84176f6 commit 7a55863
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 34 deletions.
18 changes: 9 additions & 9 deletions crates/rust-analyzer/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ config_data! {
/// Placeholder expression to use for missing expressions in assists.
assist_expressionFillDefault: ExprFillDefaultDef = "\"todo\"",

/// Warm up caches on project load.
cachePriming_enable: bool = "true",
/// How many worker threads to to handle priming caches. The default `0` means to pick automatically.
cachePriming_numThreads: ParallelCachePrimingNumThreads = "0",

/// Automatically refresh project info via `cargo metadata` on
/// `Cargo.toml` or `.cargo/config.toml` changes.
cargo_autoreload: bool = "true",
Expand Down Expand Up @@ -320,11 +325,6 @@ config_data! {
/// Whether to show `can't find Cargo.toml` error message.
notifications_cargoTomlNotFound: bool = "true",

/// Warm up caches on project load.
primeCaches_enable: bool = "true",
/// How many worker threads to to handle priming caches. The default `0` means to pick automatically.
primeCaches_numThreads: ParallelPrimeCachesNumThreads = "0",

/// Expand attribute macros. Requires `#rust-analyzer.procMacro.enable#` to be set.
procMacro_attributes_enable: bool = "true",
/// Enable support for procedural macros, implies `#rust-analyzer.cargo.buildScripts.enable#`.
Expand Down Expand Up @@ -402,7 +402,7 @@ pub struct Config {
snippets: Vec<Snippet>,
}

type ParallelPrimeCachesNumThreads = u8;
type ParallelCachePrimingNumThreads = u8;

#[derive(Debug, Clone, Eq, PartialEq)]
pub enum LinkedProject {
Expand Down Expand Up @@ -716,7 +716,7 @@ impl Config {
}

pub fn prefill_caches(&self) -> bool {
self.data.primeCaches_enable
self.data.cachePriming_enable
}

pub fn location_link(&self) -> bool {
Expand Down Expand Up @@ -1189,7 +1189,7 @@ impl Config {
}

pub fn prime_caches_num_threads(&self) -> u8 {
match self.data.primeCaches_numThreads {
match self.data.cachePriming_numThreads {
0 => num_cpus::get_physical().try_into().unwrap_or(u8::MAX),
n => n,
}
Expand Down Expand Up @@ -1661,7 +1661,7 @@ fn field_props(field: &str, ty: &str, doc: &[&str], default: &str) -> serde_json
"Search for all symbols kinds"
],
},
"ParallelPrimeCachesNumThreads" => set! {
"ParallelCachePrimingNumThreads" => set! {
"type": "number",
"minimum": 0,
"maximum": 255
Expand Down
5 changes: 3 additions & 2 deletions crates/rust-analyzer/src/config/patch_old_style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ pub(super) fn patch_json_for_outdated_configs(json: &mut Value) {
assist.importMergeBehaviour -> imports.granularity.group;
assist.importGroup -> imports.group.enable;
assist.importPrefix -> imports.prefix;
cache.warmup -> primeCaches.enable;
primeCaches.enable -> cachePriming.enable;
cache.warmup -> cachePriming.enable;
cargo.loadOutDirsFromCheck -> cargo.buildScripts.enable;
cargo.runBuildScripts -> cargo.buildScripts.enable;
cargo.runBuildScriptsCommand -> cargo.buildScripts.overrideCommand;
Expand All @@ -50,7 +51,7 @@ pub(super) fn patch_json_for_outdated_configs(json: &mut Value) {
hover.linksInHover -> hover.links.enable;
hoverActions.linksInHover -> hover.links.enable;
hoverActions.debug -> hoverActions.debug.enable;
hoverActions.enable -> hoverActions.enable.enable;
hoverActions.enable -> hoverActions.enable;
hoverActions.gotoTypeDef -> hoverActions.gotoTypeDef.enable;
hoverActions.implementations -> hoverActions.implementations.enable;
hoverActions.references -> hoverActions.references.enable;
Expand Down
20 changes: 10 additions & 10 deletions docs/user/generated_config.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@
--
Placeholder expression to use for missing expressions in assists.
--
[[rust-analyzer.cachePriming.enable]]rust-analyzer.cachePriming.enable (default: `true`)::
+
--
Warm up caches on project load.
--
[[rust-analyzer.cachePriming.numThreads]]rust-analyzer.cachePriming.numThreads (default: `0`)::
+
--
How many worker threads to to handle priming caches. The default `0` means to pick automatically.
--
[[rust-analyzer.cargo.autoreload]]rust-analyzer.cargo.autoreload (default: `true`)::
+
--
Expand Down Expand Up @@ -477,16 +487,6 @@ Number of syntax trees rust-analyzer keeps in memory. Defaults to 128.
--
Whether to show `can't find Cargo.toml` error message.
--
[[rust-analyzer.primeCaches.enable]]rust-analyzer.primeCaches.enable (default: `true`)::
+
--
Warm up caches on project load.
--
[[rust-analyzer.primeCaches.numThreads]]rust-analyzer.primeCaches.numThreads (default: `0`)::
+
--
How many worker threads to to handle priming caches. The default `0` means to pick automatically.
--
[[rust-analyzer.procMacro.attributes.enable]]rust-analyzer.procMacro.attributes.enable (default: `true`)::
+
--
Expand Down
24 changes: 12 additions & 12 deletions editors/code/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,18 @@
"Fill missing expressions with reasonable defaults, `new` or `default` constructors."
]
},
"rust-analyzer.cachePriming.enable": {
"markdownDescription": "Warm up caches on project load.",
"default": true,
"type": "boolean"
},
"rust-analyzer.cachePriming.numThreads": {
"markdownDescription": "How many worker threads to to handle priming caches. The default `0` means to pick automatically.",
"default": 0,
"type": "number",
"minimum": 0,
"maximum": 255
},
"rust-analyzer.cargo.autoreload": {
"markdownDescription": "Automatically refresh project info via `cargo metadata` on\n`Cargo.toml` or `.cargo/config.toml` changes.",
"default": true,
Expand Down Expand Up @@ -918,18 +930,6 @@
"default": true,
"type": "boolean"
},
"rust-analyzer.primeCaches.enable": {
"markdownDescription": "Warm up caches on project load.",
"default": true,
"type": "boolean"
},
"rust-analyzer.primeCaches.numThreads": {
"markdownDescription": "How many worker threads to to handle priming caches. The default `0` means to pick automatically.",
"default": 0,
"type": "number",
"minimum": 0,
"maximum": 255
},
"rust-analyzer.procMacro.attributes.enable": {
"markdownDescription": "Expand attribute macros. Requires `#rust-analyzer.procMacro.enable#` to be set.",
"default": true,
Expand Down
3 changes: 2 additions & 1 deletion editors/code/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ export async function updateConfig(config: vscode.WorkspaceConfiguration) {
["assist.importMergeBehaviour", "imports.granularity.group",],
["assist.importGroup", "imports.group.enable",],
["assist.importPrefix", "imports.prefix",],
["cache.warmup", "primeCaches.enable",],
["primeCaches.enable", "cachePriming.enable",],
["cache.warmup", "cachePriming.enable",],
["cargo.loadOutDirsFromCheck", "cargo.buildScripts.enable",],
["cargo.runBuildScripts", "cargo.buildScripts.enable",],
["cargo.runBuildScriptsCommand", "cargo.buildScripts.overrideCommand",],
Expand Down

0 comments on commit 7a55863

Please sign in to comment.