Skip to content

Commit 84a6bc9

Browse files
committed
Auto merge of rust-lang#12742 - TonalidadeHidrica:fix-obsolete-config-keys, r=Veykril
Fix obsolete config keys The config keys were drastically reorganized by rust-lang#12010, but the docs don't reflect the updates, causing inconsistency and confusion. I checked for such obsolete configuration keys and updated to the new one. For reproducibility, I attach a small shell script that I used to examine the old keys. Now the script only detects `cargoExtraArgs` and `overrideCargo`, which originates from other type definition in the code but not from the configuration. <details><summary>script</summary> ```bash echo "allowMergingIntoGlobImports exprFillDefault importEnforceGranularity importGranularity importMergeBehavior importMergeBehaviour importGroup importPrefix warmup loadOutDirsFromCheck runBuildScripts runBuildScriptsCommand useRustcWrapperForBuildScripts enableExperimental procAttrMacros breakPoints exitPoints yieldPoints linksInHover linksInHover gotoTypeDef chainingHints closureReturnTypeHints hideNamedConstructorHints parameterHints reborrowHints typeHints lruCapacity cargoExtraArgs overrideCargo rustcSource enableRangeFormatting assist\.allowMergingIntoGlobImports assist\.exprFillDefault assist\.importEnforceGranularity assist\.importGranularity assist\.importMergeBehavior assist\.importMergeBehaviour assist\.importGroup assist\.importPrefix primeCaches\.enable cache\.warmup cargo\.loadOutDirsFromCheck cargo\.runBuildScripts cargo\.runBuildScriptsCommand cargo\.useRustcWrapperForBuildScripts completion\.snippets diagnostics\.enableExperimental experimental\.procAttrMacros highlighting\.strings highlightRelated\.breakPoints highlightRelated\.exitPoints highlightRelated\.yieldPoints highlightRelated\.references hover\.documentation hover\.linksInHover hoverActions\.linksInHover hoverActions\.debug hoverActions\.enable hoverActions\.gotoTypeDef hoverActions\.implementations hoverActions\.references hoverActions\.run inlayHints\.chainingHints inlayHints\.closureReturnTypeHints inlayHints\.hideNamedConstructorHints inlayHints\.parameterHints inlayHints\.reborrowHints inlayHints\.typeHints lruCapacity runnables\.cargoExtraArgs runnables\.overrideCargo rustcSource rustfmt\.enableRangeFormatting allFeatures addCallArgumentSnippets addCallParenthesis callInfo\.full cargo\.allFeatures checkOnSave\.allFeatures completion\.addCallArgumentSnippets completion\.addCallParenthesis" | while read -r pattern do rg '\b'$pattern'\b([^.]|$)' . -g "!crates/rust-analyzer/src/config/patch_old_style.rs" -g "!editors/code/src/config.ts" -g "!a.sh" --no-heading --color=always --line-number done exit excluded # debug # enable # run # implementations # references # documentation # references # snippets # strings # full ``` </details>
2 parents 4cbf23c + e3bde57 commit 84a6bc9

File tree

6 files changed

+25
-17
lines changed

6 files changed

+25
-17
lines changed

crates/ide-assists/src/handlers/auto_import.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists, GroupLabel};
4040
//
4141
// .Import Granularity
4242
//
43-
// It is possible to configure how use-trees are merged with the `importGranularity` setting.
43+
// It is possible to configure how use-trees are merged with the `imports.granularity.group` setting.
4444
// It has the following configurations:
4545
//
4646
// - `crate`: Merge imports from the same crate into a single use statement. This kind of
@@ -50,11 +50,11 @@ use crate::{AssistContext, AssistId, AssistKind, Assists, GroupLabel};
5050
// - `preserve`: Do not change the granularity of any imports. For auto-import this has the same
5151
// effect as `item`.
5252
//
53-
// In `VS Code` the configuration for this is `rust-analyzer.assist.importGranularity`.
53+
// In `VS Code` the configuration for this is `rust-analyzer.imports.granularity.group`.
5454
//
5555
// .Import Prefix
5656
//
57-
// The style of imports in the same crate is configurable through the `importPrefix` setting.
57+
// The style of imports in the same crate is configurable through the `imports.prefix` setting.
5858
// It has the following configurations:
5959
//
6060
// - `crate`: This setting will force paths to be always absolute, starting with the `crate`
@@ -64,7 +64,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists, GroupLabel};
6464
// `super` or an extern crate identifier.
6565
// - `plain`: This setting does not impose any restrictions in imports.
6666
//
67-
// In `VS Code` the configuration for this is `rust-analyzer.assist.importPrefix`.
67+
// In `VS Code` the configuration for this is `rust-analyzer.imports.prefix`.
6868
//
6969
// image::https://user-images.githubusercontent.com/48062697/113020673-b85be580-917a-11eb-9022-59585f35d4f8.gif[]
7070

crates/ide-completion/src/completions/flyimport.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ use super::Completions;
9595
//
9696
// .Import configuration
9797
//
98-
// It is possible to configure how use-trees are merged with the `importMergeBehavior` setting.
98+
// It is possible to configure how use-trees are merged with the `imports.granularity.group` setting.
9999
// Mimics the corresponding behavior of the `Auto Import` feature.
100100
//
101101
// .LSP and performance implications

crates/ide-completion/src/snippet.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
//
77
// rust-analyzer allows the user to define custom (postfix)-snippets that may depend on items to be accessible for the current scope to be applicable.
88
//
9-
// A custom snippet can be defined by adding it to the `rust-analyzer.completion.snippets` object respectively.
9+
// A custom snippet can be defined by adding it to the `rust-analyzer.completion.snippets.custom` object respectively.
1010
//
1111
// [source,json]
1212
// ----
1313
// {
14-
// "rust-analyzer.completion.snippets": {
14+
// "rust-analyzer.completion.snippets.custom": {
1515
// "thread spawn": {
1616
// "prefix": ["spawn", "tspawn"],
1717
// "body": [

crates/project-model/src/workspace.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ fn handle_rustc_crates(
737737
let root_pkg =
738738
rustc_workspace.packages().find(|package| rustc_workspace[*package].name == "rustc_driver");
739739
// The rustc workspace might be incomplete (such as if rustc-dev is not
740-
// installed for the current toolchain) and `rustcSource` is set to discover.
740+
// installed for the current toolchain) and `rustc_source` is set to discover.
741741
if let Some(root_pkg) = root_pkg {
742742
// Iterate through every crate in the dependency subtree of rustc_driver using BFS
743743
let mut queue = VecDeque::new();
@@ -822,7 +822,7 @@ fn handle_rustc_crates(
822822
for (from, _) in pkg_crates.get(&pkg).into_iter().flatten() {
823823
// Avoid creating duplicate dependencies
824824
// This avoids the situation where `from` depends on e.g. `arrayvec`, but
825-
// `rust_analyzer` thinks that it should use the one from the `rustcSource`
825+
// `rust_analyzer` thinks that it should use the one from the `rustc_source`
826826
// instead of the one from `crates.io`
827827
if !crate_graph[*from].dependencies.iter().any(|d| d.name == name) {
828828
add_dep(crate_graph, *from, name.clone(), to);

crates/rust-analyzer/src/handlers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1798,7 +1798,7 @@ fn run_rustfmt(
17981798
String::from(
17991799
"rustfmt range formatting is unstable. \
18001800
Opt-in by using a nightly build of rustfmt and setting \
1801-
`rustfmt.enableRangeFormatting` to true in your LSP configuration",
1801+
`rustfmt.rangeFormatting.enable` to true in your LSP configuration",
18021802
),
18031803
)
18041804
.into());

docs/user/manual.adoc

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -308,12 +308,16 @@ nvim_lsp.rust_analyzer.setup({
308308
on_attach=on_attach,
309309
settings = {
310310
["rust-analyzer"] = {
311-
assist = {
312-
importGranularity = "module",
313-
importPrefix = "self",
311+
imports = {
312+
granularity = {
313+
group = "module",
314+
},
315+
prefix = "self",
314316
},
315317
cargo = {
316-
loadOutDirsFromCheck = true
318+
buildScripts = {
319+
enable = true,
320+
},
317321
},
318322
procMacro = {
319323
enable = true
@@ -364,7 +368,9 @@ if executable('rust-analyzer')
364368
\ 'whitelist': ['rust'],
365369
\ 'initialization_options': {
366370
\ 'cargo': {
367-
\ 'loadOutDirsFromCheck': v:true,
371+
\ 'buildScripts': {
372+
\ 'enable': v:true,
373+
\ },
368374
\ },
369375
\ 'procMacro': {
370376
\ 'enable': v:true,
@@ -527,7 +533,9 @@ For example, a very common configuration is to enable proc-macro support, can be
527533
----
528534
{
529535
"cargo": {
530-
"loadOutDirsFromCheck": true,
536+
"buildScripts": {
537+
"enable": true,
538+
},
531539
},
532540
"procMacro": {
533541
"enable": true,
@@ -705,7 +713,7 @@ include::./generated_assists.adoc[]
705713
== Diagnostics
706714

707715
While most errors and warnings provided by rust-analyzer come from the `cargo check` integration, there's a growing number of diagnostics implemented using rust-analyzer's own analysis.
708-
Some of these diagnostics don't respect `\#[allow]` or `\#[deny]` attributes yet, but can be turned off using the `rust-analyzer.diagnostics.enable`, `rust-analyzer.diagnostics.enableExperimental` or `rust-analyzer.diagnostics.disabled` settings.
716+
Some of these diagnostics don't respect `\#[allow]` or `\#[deny]` attributes yet, but can be turned off using the `rust-analyzer.diagnostics.enable`, `rust-analyzer.diagnostics.experimental.enable` or `rust-analyzer.diagnostics.disabled` settings.
709717

710718
include::./generated_diagnostic.adoc[]
711719

0 commit comments

Comments
 (0)