Skip to content

Commit cbd3717

Browse files
Better config name
1 parent 3183ff3 commit cbd3717

File tree

6 files changed

+19
-16
lines changed

6 files changed

+19
-16
lines changed

crates/completion/src/completions/unqualified_path.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub(crate) fn complete_unqualified_path(acc: &mut Completions, ctx: &CompletionC
4444
acc.add_resolution(ctx, name.to_string(), &res)
4545
});
4646

47-
if !ctx.config.disable_fuzzy_autoimports && ctx.config.resolve_additional_edits_lazily() {
47+
if ctx.config.enable_autoimport_completions && ctx.config.resolve_additional_edits_lazily() {
4848
fuzzy_completion(acc, ctx).unwrap_or_default()
4949
}
5050
}
@@ -116,7 +116,9 @@ fn complete_enum_variants(acc: &mut Completions, ctx: &CompletionContext, ty: &T
116116
//
117117
// .Feature toggle
118118
//
119-
// The feature can be forcefully turned off in the settings with the `rust-analyzer.completion.disableFuzzyAutoimports` flag.
119+
// The feature can be forcefully turned off in the settings with the `rust-analyzer.completion.enableAutoimportCompletions` flag.
120+
// Note that having this flag set to `true` does not guarantee that the feature is enabled: your client needs to have the corredponding
121+
// capability enabled.
120122
fn fuzzy_completion(acc: &mut Completions, ctx: &CompletionContext) -> Option<()> {
121123
let _p = profile::span("fuzzy_completion");
122124
let potential_import_name = ctx.token.to_string();

crates/completion/src/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use rustc_hash::FxHashSet;
1010
#[derive(Clone, Debug, PartialEq, Eq)]
1111
pub struct CompletionConfig {
1212
pub enable_postfix_completions: bool,
13-
pub disable_fuzzy_autoimports: bool,
13+
pub enable_autoimport_completions: bool,
1414
pub add_call_parenthesis: bool,
1515
pub add_call_argument_snippets: bool,
1616
pub snippet_cap: Option<SnippetCap>,
@@ -52,7 +52,7 @@ impl Default for CompletionConfig {
5252
fn default() -> Self {
5353
CompletionConfig {
5454
enable_postfix_completions: true,
55-
disable_fuzzy_autoimports: false,
55+
enable_autoimport_completions: true,
5656
add_call_parenthesis: true,
5757
add_call_argument_snippets: true,
5858
snippet_cap: Some(SnippetCap { _private: () }),

crates/completion/src/lib.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,9 @@ pub use crate::{
7373
// }
7474
// ```
7575
//
76-
// And experimental completions, enabled with the `rust-analyzer.completion.disableFuzzyAutoimports` setting.
77-
// This flag enables or disables:
78-
//
79-
// - Auto import: additional completion options with automatic `use` import and options from all project importable items, matched for the input
80-
//
81-
// Experimental completions might cause issues with performance and completion list look.
76+
// And the auto import completions, enabled with the `rust-analyzer.completion.autoimport.enable` setting and the corresponding LSP client capabilities.
77+
// Those are the additional completion options with automatic `use` import and options from all project importable items,
78+
// fuzzy matched agains the completion imput.
8279

8380
/// Main entry point for completion. We run completion as a two-phase process.
8481
///

crates/rust-analyzer/src/caps.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ pub fn server_capabilities(client_caps: &ClientCapabilities) -> ServerCapabiliti
9797

9898
fn completions_resolve_provider(client_caps: &ClientCapabilities) -> Option<bool> {
9999
if enabled_completions_resolve_capabilities(client_caps)?.is_empty() {
100+
log::info!("No `additionalTextEdits` completion resolve capability was found in the client capabilities, autoimport completion is disabled");
100101
None
101102
} else {
102103
Some(true)

crates/rust-analyzer/src/config.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ impl Config {
182182
},
183183
completion: CompletionConfig {
184184
enable_postfix_completions: true,
185-
disable_fuzzy_autoimports: false,
185+
enable_autoimport_completions: true,
186186
add_call_parenthesis: true,
187187
add_call_argument_snippets: true,
188188
..CompletionConfig::default()
@@ -305,7 +305,7 @@ impl Config {
305305
};
306306

307307
self.completion.enable_postfix_completions = data.completion_postfix_enable;
308-
self.completion.disable_fuzzy_autoimports = data.completion_disableFuzzyAutoimports;
308+
self.completion.enable_autoimport_completions = data.completion_autoimport_enable;
309309
self.completion.add_call_parenthesis = data.completion_addCallParenthesis;
310310
self.completion.add_call_argument_snippets = data.completion_addCallArgumentSnippets;
311311
self.completion.merge = self.assist.insert_use.merge;
@@ -508,7 +508,7 @@ config_data! {
508508
completion_addCallArgumentSnippets: bool = true,
509509
completion_addCallParenthesis: bool = true,
510510
completion_postfix_enable: bool = true,
511-
completion_disableFuzzyAutoimports: bool = false,
511+
completion_autoimport_enable: bool = true,
512512

513513
diagnostics_enable: bool = true,
514514
diagnostics_enableExperimental: bool = true,

editors/code/package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -460,10 +460,13 @@
460460
"default": true,
461461
"markdownDescription": "Whether to show postfix snippets like `dbg`, `if`, `not`, etc."
462462
},
463-
"rust-analyzer.completion.disableFuzzyAutoimports": {
463+
"rust-analyzer.completion.autoimport.enable": {
464464
"type": "boolean",
465-
"default": false,
466-
"markdownDescription": "Turns off extra completion suggestions that might be too noisy or slow"
465+
"default": true,
466+
"markdownDescription": [
467+
"Toggles the additional completions that automatically add imports when completed.",
468+
"Note that your client have to specify the `additionalTextEdits` LSP client capability to truly have this feature enabled"
469+
]
467470
},
468471
"rust-analyzer.callInfo.full": {
469472
"type": "boolean",

0 commit comments

Comments
 (0)