]> git.lizzy.rs Git - rust.git/commitdiff
Better config name
authorKirill Bulatov <mail4score@gmail.com>
Tue, 8 Dec 2020 12:27:18 +0000 (14:27 +0200)
committerKirill Bulatov <mail4score@gmail.com>
Tue, 8 Dec 2020 12:27:18 +0000 (14:27 +0200)
crates/completion/src/completions/unqualified_path.rs
crates/completion/src/config.rs
crates/completion/src/lib.rs
crates/rust-analyzer/src/caps.rs
crates/rust-analyzer/src/config.rs
editors/code/package.json

index 2a315cb864a89992e5e23e93b1082fb52f14f7a4..f65709adf0bf25a33eddc6468f13cf7ff4cd77b6 100644 (file)
@@ -44,7 +44,7 @@ pub(crate) fn complete_unqualified_path(acc: &mut Completions, ctx: &CompletionC
         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()
     }
 }
@@ -116,7 +116,9 @@ fn complete_enum_variants(acc: &mut Completions, ctx: &CompletionContext, ty: &T
 //
 // .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<()> {
     let _p = profile::span("fuzzy_completion");
     let potential_import_name = ctx.token.to_string();
index 8082ec9cb001b3defccbefd1ef0603a8d8ebd548..5175b9d69dc2517a7f585dfd6bb6d0a2245e62c2 100644 (file)
@@ -10,7 +10,7 @@
 #[derive(Clone, Debug, PartialEq, Eq)]
 pub struct CompletionConfig {
     pub enable_postfix_completions: bool,
-    pub disable_fuzzy_autoimports: bool,
+    pub enable_autoimport_completions: bool,
     pub add_call_parenthesis: bool,
     pub add_call_argument_snippets: bool,
     pub snippet_cap: Option<SnippetCap>,
@@ -52,7 +52,7 @@ impl Default for CompletionConfig {
     fn default() -> Self {
         CompletionConfig {
             enable_postfix_completions: true,
-            disable_fuzzy_autoimports: false,
+            enable_autoimport_completions: true,
             add_call_parenthesis: true,
             add_call_argument_snippets: true,
             snippet_cap: Some(SnippetCap { _private: () }),
index 8df9f00fe299c287e013713240ecfac2b7aa9e13..f60f87243fb03862c4faee8045284addbce4ffaa 100644 (file)
 // }
 // ```
 //
-// And experimental completions, enabled with the `rust-analyzer.completion.disableFuzzyAutoimports` setting.
-// This flag enables or disables:
-//
-// - 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.
+// And the auto import completions, enabled with the `rust-analyzer.completion.autoimport.enable` setting and the corresponding LSP client capabilities.
+// Those are the additional completion options with automatic `use` import and options from all project importable items,
+// fuzzy matched agains the completion imput.
 
 /// Main entry point for completion. We run completion as a two-phase process.
 ///
index 1e0ee10e409fd17ddfdde4a1964e19902dc29ead..5e4c22bc5c88c1e7e28303b293655c54a8f67bd7 100644 (file)
@@ -97,6 +97,7 @@ pub fn server_capabilities(client_caps: &ClientCapabilities) -> ServerCapabiliti
 
 fn completions_resolve_provider(client_caps: &ClientCapabilities) -> Option<bool> {
     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
     } else {
         Some(true)
index f46aa2dd4b7ec343a63a614c02b3a7eaf3782412..5243b50c801c47e71d19e942c381280e2f5ff618 100644 (file)
@@ -182,7 +182,7 @@ pub fn new(root_path: AbsPathBuf) -> Self {
             },
             completion: CompletionConfig {
                 enable_postfix_completions: true,
-                disable_fuzzy_autoimports: false,
+                enable_autoimport_completions: true,
                 add_call_parenthesis: true,
                 add_call_argument_snippets: true,
                 ..CompletionConfig::default()
@@ -305,7 +305,7 @@ pub fn update(&mut self, json: serde_json::Value) {
         };
 
         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_argument_snippets = data.completion_addCallArgumentSnippets;
         self.completion.merge = self.assist.insert_use.merge;
@@ -508,7 +508,7 @@ struct ConfigData {
         completion_addCallArgumentSnippets: bool = true,
         completion_addCallParenthesis: bool      = true,
         completion_postfix_enable: bool          = true,
-        completion_disableFuzzyAutoimports: bool = false,
+        completion_autoimport_enable: bool       = true,
 
         diagnostics_enable: bool                = true,
         diagnostics_enableExperimental: bool    = true,
index 4b0f41a243dae4458cdaedb2b2bf9d9ac0744b45..dbde37005c92aae22d848b26f6e6e20c3be41853 100644 (file)
                     "default": true,
                     "markdownDescription": "Whether to show postfix snippets like `dbg`, `if`, `not`, etc."
                 },
-                "rust-analyzer.completion.disableFuzzyAutoimports": {
+                "rust-analyzer.completion.autoimport.enable": {
                     "type": "boolean",
-                    "default": false,
-                    "markdownDescription": "Turns off extra completion suggestions that might be too noisy or slow"
+                    "default": true,
+                    "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": {
                     "type": "boolean",