mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-26 11:55:04 +00:00
Better config name
This commit is contained in:
parent
3183ff3a7b
commit
cbd3717f2c
6 changed files with 19 additions and 16 deletions
|
@ -44,7 +44,7 @@ pub(crate) fn complete_unqualified_path(acc: &mut Completions, ctx: &CompletionC
|
||||||
acc.add_resolution(ctx, name.to_string(), &res)
|
acc.add_resolution(ctx, name.to_string(), &res)
|
||||||
});
|
});
|
||||||
|
|
||||||
if !ctx.config.disable_fuzzy_autoimports && ctx.config.resolve_additional_edits_lazily() {
|
if ctx.config.enable_autoimport_completions && ctx.config.resolve_additional_edits_lazily() {
|
||||||
fuzzy_completion(acc, ctx).unwrap_or_default()
|
fuzzy_completion(acc, ctx).unwrap_or_default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -116,7 +116,9 @@ fn complete_enum_variants(acc: &mut Completions, ctx: &CompletionContext, ty: &T
|
||||||
//
|
//
|
||||||
// .Feature toggle
|
// .Feature toggle
|
||||||
//
|
//
|
||||||
// The feature can be forcefully turned off in the settings with the `rust-analyzer.completion.disableFuzzyAutoimports` flag.
|
// The feature can be forcefully turned off in the settings with the `rust-analyzer.completion.enableAutoimportCompletions` flag.
|
||||||
|
// Note that having this flag set to `true` does not guarantee that the feature is enabled: your client needs to have the corredponding
|
||||||
|
// capability enabled.
|
||||||
fn fuzzy_completion(acc: &mut Completions, ctx: &CompletionContext) -> Option<()> {
|
fn fuzzy_completion(acc: &mut Completions, ctx: &CompletionContext) -> Option<()> {
|
||||||
let _p = profile::span("fuzzy_completion");
|
let _p = profile::span("fuzzy_completion");
|
||||||
let potential_import_name = ctx.token.to_string();
|
let potential_import_name = ctx.token.to_string();
|
||||||
|
|
|
@ -10,7 +10,7 @@ use rustc_hash::FxHashSet;
|
||||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||||
pub struct CompletionConfig {
|
pub struct CompletionConfig {
|
||||||
pub enable_postfix_completions: bool,
|
pub enable_postfix_completions: bool,
|
||||||
pub disable_fuzzy_autoimports: bool,
|
pub enable_autoimport_completions: bool,
|
||||||
pub add_call_parenthesis: bool,
|
pub add_call_parenthesis: bool,
|
||||||
pub add_call_argument_snippets: bool,
|
pub add_call_argument_snippets: bool,
|
||||||
pub snippet_cap: Option<SnippetCap>,
|
pub snippet_cap: Option<SnippetCap>,
|
||||||
|
@ -52,7 +52,7 @@ impl Default for CompletionConfig {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
CompletionConfig {
|
CompletionConfig {
|
||||||
enable_postfix_completions: true,
|
enable_postfix_completions: true,
|
||||||
disable_fuzzy_autoimports: false,
|
enable_autoimport_completions: true,
|
||||||
add_call_parenthesis: true,
|
add_call_parenthesis: true,
|
||||||
add_call_argument_snippets: true,
|
add_call_argument_snippets: true,
|
||||||
snippet_cap: Some(SnippetCap { _private: () }),
|
snippet_cap: Some(SnippetCap { _private: () }),
|
||||||
|
|
|
@ -73,12 +73,9 @@ pub use crate::{
|
||||||
// }
|
// }
|
||||||
// ```
|
// ```
|
||||||
//
|
//
|
||||||
// And experimental completions, enabled with the `rust-analyzer.completion.disableFuzzyAutoimports` setting.
|
// And the auto import completions, enabled with the `rust-analyzer.completion.autoimport.enable` setting and the corresponding LSP client capabilities.
|
||||||
// This flag enables or disables:
|
// Those are the additional completion options with automatic `use` import and options from all project importable items,
|
||||||
//
|
// fuzzy matched agains the completion imput.
|
||||||
// - Auto import: additional completion options with automatic `use` import and options from all project importable items, matched for the input
|
|
||||||
//
|
|
||||||
// Experimental completions might cause issues with performance and completion list look.
|
|
||||||
|
|
||||||
/// Main entry point for completion. We run completion as a two-phase process.
|
/// Main entry point for completion. We run completion as a two-phase process.
|
||||||
///
|
///
|
||||||
|
|
|
@ -97,6 +97,7 @@ pub fn server_capabilities(client_caps: &ClientCapabilities) -> ServerCapabiliti
|
||||||
|
|
||||||
fn completions_resolve_provider(client_caps: &ClientCapabilities) -> Option<bool> {
|
fn completions_resolve_provider(client_caps: &ClientCapabilities) -> Option<bool> {
|
||||||
if enabled_completions_resolve_capabilities(client_caps)?.is_empty() {
|
if enabled_completions_resolve_capabilities(client_caps)?.is_empty() {
|
||||||
|
log::info!("No `additionalTextEdits` completion resolve capability was found in the client capabilities, autoimport completion is disabled");
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
Some(true)
|
Some(true)
|
||||||
|
|
|
@ -182,7 +182,7 @@ impl Config {
|
||||||
},
|
},
|
||||||
completion: CompletionConfig {
|
completion: CompletionConfig {
|
||||||
enable_postfix_completions: true,
|
enable_postfix_completions: true,
|
||||||
disable_fuzzy_autoimports: false,
|
enable_autoimport_completions: true,
|
||||||
add_call_parenthesis: true,
|
add_call_parenthesis: true,
|
||||||
add_call_argument_snippets: true,
|
add_call_argument_snippets: true,
|
||||||
..CompletionConfig::default()
|
..CompletionConfig::default()
|
||||||
|
@ -305,7 +305,7 @@ impl Config {
|
||||||
};
|
};
|
||||||
|
|
||||||
self.completion.enable_postfix_completions = data.completion_postfix_enable;
|
self.completion.enable_postfix_completions = data.completion_postfix_enable;
|
||||||
self.completion.disable_fuzzy_autoimports = data.completion_disableFuzzyAutoimports;
|
self.completion.enable_autoimport_completions = data.completion_autoimport_enable;
|
||||||
self.completion.add_call_parenthesis = data.completion_addCallParenthesis;
|
self.completion.add_call_parenthesis = data.completion_addCallParenthesis;
|
||||||
self.completion.add_call_argument_snippets = data.completion_addCallArgumentSnippets;
|
self.completion.add_call_argument_snippets = data.completion_addCallArgumentSnippets;
|
||||||
self.completion.merge = self.assist.insert_use.merge;
|
self.completion.merge = self.assist.insert_use.merge;
|
||||||
|
@ -508,7 +508,7 @@ config_data! {
|
||||||
completion_addCallArgumentSnippets: bool = true,
|
completion_addCallArgumentSnippets: bool = true,
|
||||||
completion_addCallParenthesis: bool = true,
|
completion_addCallParenthesis: bool = true,
|
||||||
completion_postfix_enable: bool = true,
|
completion_postfix_enable: bool = true,
|
||||||
completion_disableFuzzyAutoimports: bool = false,
|
completion_autoimport_enable: bool = true,
|
||||||
|
|
||||||
diagnostics_enable: bool = true,
|
diagnostics_enable: bool = true,
|
||||||
diagnostics_enableExperimental: bool = true,
|
diagnostics_enableExperimental: bool = true,
|
||||||
|
|
|
@ -460,10 +460,13 @@
|
||||||
"default": true,
|
"default": true,
|
||||||
"markdownDescription": "Whether to show postfix snippets like `dbg`, `if`, `not`, etc."
|
"markdownDescription": "Whether to show postfix snippets like `dbg`, `if`, `not`, etc."
|
||||||
},
|
},
|
||||||
"rust-analyzer.completion.disableFuzzyAutoimports": {
|
"rust-analyzer.completion.autoimport.enable": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"default": false,
|
"default": true,
|
||||||
"markdownDescription": "Turns off extra completion suggestions that might be too noisy or slow"
|
"markdownDescription": [
|
||||||
|
"Toggles the additional completions that automatically add imports when completed.",
|
||||||
|
"Note that your client have to specify the `additionalTextEdits` LSP client capability to truly have this feature enabled"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"rust-analyzer.callInfo.full": {
|
"rust-analyzer.callInfo.full": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
|
|
Loading…
Reference in a new issue