about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLukas Wirth <lukastw97@gmail.com>2022-05-14 13:53:41 +0200
committerLukas Wirth <lukastw97@gmail.com>2022-05-14 13:53:41 +0200
commit622defb3733d6d1c64d87fc488622ce5cc0875c0 (patch)
tree0949ab58432188e072576ad3e1d11b9d5cd859db
parent8496633c875c22e93c71c48c4103b54a464c388f (diff)
downloadrust-622defb3733d6d1c64d87fc488622ce5cc0875c0.tar.gz
rust-622defb3733d6d1c64d87fc488622ce5cc0875c0.zip
internal: Make VSCode config more GUI edit friendly
-rw-r--r--crates/rust-analyzer/src/config.rs107
-rw-r--r--docs/user/generated_config.adoc3
-rw-r--r--editors/code/package.json117
3 files changed, 106 insertions, 121 deletions
diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs
index 150cc21a17b..3e5561ad389 100644
--- a/crates/rust-analyzer/src/config.rs
+++ b/crates/rust-analyzer/src/config.rs
@@ -109,7 +109,8 @@ config_data! {
         ///
         /// Set to `"all"` to pass `--all-features` to cargo.
         checkOnSave_features: Option<CargoFeatures>      = "null",
-        /// Do not activate the `default` feature.
+        /// Whether to pass `--no-default-features` to cargo. Defaults to
+        /// `#rust-analyzer.cargo.noDefaultFeatures#`.
         checkOnSave_noDefaultFeatures: Option<bool>      = "null",
         /// Override the command rust-analyzer uses to  run build scripts and
         /// build procedural macros. The command is required to output json
@@ -134,7 +135,7 @@ config_data! {
         /// with `self` prefixed to them when inside a method.
         completion_autoself_enable: bool        = "true",
         /// Whether to add parenthesis and argument snippets when completing function.
-        completion_callable_snippets: Option<CallableCompletionDef>  = "\"fill_arguments\"",
+        completion_callable_snippets: CallableCompletionDef  = "\"fill_arguments\"",
         /// Whether to show postfix snippets like `dbg`, `if`, `not`, etc.
         completion_postfix_enable: bool         = "true",
         /// Enables completions of private items and fields that are defined in the current workspace even if they are not visible at the current position.
@@ -1030,10 +1031,11 @@ impl Config {
                 && completion_item_edit_resolve(&self.caps),
             enable_self_on_the_fly: self.data.completion_autoself_enable,
             enable_private_editable: self.data.completion_privateEditable_enable,
-            callable: self.data.completion_callable_snippets.map(|it| match it {
-                CallableCompletionDef::FillArguments => CallableSnippets::FillArguments,
-                CallableCompletionDef::AddParentheses => CallableSnippets::AddParentheses,
-            }),
+            callable: match self.data.completion_callable_snippets {
+                CallableCompletionDef::FillArguments => Some(CallableSnippets::FillArguments),
+                CallableCompletionDef::AddParentheses => Some(CallableSnippets::AddParentheses),
+                CallableCompletionDef::None => None,
+            },
             insert_use: self.insert_use_config(),
             snippet_cap: SnippetCap::new(try_or_def!(
                 self.caps
@@ -1385,6 +1387,7 @@ enum ImportGranularityDef {
 enum CallableCompletionDef {
     FillArguments,
     AddParentheses,
+    None,
 }
 
 #[derive(Deserialize, Debug, Clone)]
@@ -1662,16 +1665,16 @@ fn field_props(field: &str, ty: &str, doc: &[&str], default: &str) -> serde_json
             "type": "string",
             "enum": ["workspace", "workspace_and_dependencies"],
             "enumDescriptions": [
-                "Search in current workspace only",
-                "Search in current workspace and dependencies"
+                "Search in current workspace only.",
+                "Search in current workspace and dependencies."
             ],
         },
         "WorkspaceSymbolSearchKindDef" => set! {
             "type": "string",
             "enum": ["only_types", "all_symbols"],
             "enumDescriptions": [
-                "Search for types only",
-                "Search for all symbols kinds"
+                "Search for types only.",
+                "Search for all symbols kinds."
             ],
         },
         "ParallelCachePrimingNumThreads" => set! {
@@ -1680,47 +1683,46 @@ fn field_props(field: &str, ty: &str, doc: &[&str], default: &str) -> serde_json
             "maximum": 255
         },
         "LifetimeElisionDef" => set! {
-            "anyOf": [
-                {
-                    "type": "string",
-                    "enum": [
-                        "always",
-                        "never",
-                        "skip_trivial"
-                    ],
-                    "enumDescriptions": [
-                        "Always show lifetime elision hints.",
-                        "Never show lifetime elision hints.",
-                        "Only show lifetime elision hints if a return type is involved."
-                    ]
-                },
-                { "type": "boolean" }
+            "type": "string",
+            "enum": [
+                "always",
+                "never",
+                "skip_trivial"
             ],
+            "enumDescriptions": [
+                "Always show lifetime elision hints.",
+                "Never show lifetime elision hints.",
+                "Only show lifetime elision hints if a return type is involved."
+            ]
         },
         "ReborrowHintsDef" => set! {
+            "type": "string",
+            "enum": [
+                "always",
+                "never",
+                "mutable"
+            ],
+            "enumDescriptions": [
+                "Always show reborrow hints.",
+                "Never show reborrow hints.",
+                "Only show mutable reborrow hints."
+            ]
+        },
+        "CargoFeatures" => set! {
             "anyOf": [
                 {
                     "type": "string",
                     "enum": [
-                        "always",
-                        "never",
-                        "mutable"
+                        "all"
                     ],
                     "enumDescriptions": [
-                        "Always show reborrow hints.",
-                        "Never show reborrow hints.",
-                        "Only show mutable reborrow hints."
+                        "Pass `--all-features` to cargo",
                     ]
                 },
-                { "type": "boolean" }
-            ],
-        },
-        "CargoFeatures" => set! {
-            "type": ["string", "array"],
-            "items": { "type": "string" },
-            "enum": ["all"],
-            "enumDescriptions": [
-                "Pass `--all-features` to cargo",
+                {
+                    "type": "array",
+                    "items": { "type": "string" }
+                }
             ],
         },
         "Option<CargoFeatures>" => set! {
@@ -1741,21 +1743,18 @@ fn field_props(field: &str, ty: &str, doc: &[&str], default: &str) -> serde_json
                 { "type": "null" }
             ],
         },
-        "Option<CallableCompletionDef>" => set! {
-            "anyOf": [
-                {
-                    "type": "string",
-                    "enum": [
-                        "fill_arguments",
-                        "add_parentheses"
-                    ],
-                    "enumDescriptions": [
-                        "Add call parentheses and pre-fill arguments",
-                        "Add call parentheses"
-                    ]
-                },
-                { "type": "null" }
+        "CallableCompletionDef" => set! {
+            "type": "string",
+            "enum": [
+                "fill_arguments",
+                "add_parentheses",
+                "none",
             ],
+            "enumDescriptions": [
+                "Add call parentheses and pre-fill arguments.",
+                "Add call parentheses.",
+                "Do no snippet completions for callables."
+            ]
         },
         "SignatureDetail" => set! {
             "type": "string",
diff --git a/docs/user/generated_config.adoc b/docs/user/generated_config.adoc
index 35e0a4082eb..f2c8cb95c9b 100644
--- a/docs/user/generated_config.adoc
+++ b/docs/user/generated_config.adoc
@@ -104,7 +104,8 @@ Set to `"all"` to pass `--all-features` to cargo.
 [[rust-analyzer.checkOnSave.noDefaultFeatures]]rust-analyzer.checkOnSave.noDefaultFeatures (default: `null`)::
 +
 --
-Do not activate the `default` feature.
+Whether to pass `--no-default-features` to cargo. Defaults to
+`#rust-analyzer.cargo.noDefaultFeatures#`.
 --
 [[rust-analyzer.checkOnSave.overrideCommand]]rust-analyzer.checkOnSave.overrideCommand (default: `null`)::
 +
diff --git a/editors/code/package.json b/editors/code/package.json
index 62b0f3c0baf..08c5e729720 100644
--- a/editors/code/package.json
+++ b/editors/code/package.json
@@ -423,18 +423,22 @@
                 "rust-analyzer.cargo.features": {
                     "markdownDescription": "List of features to activate.\n\nSet this to `\"all\"` to pass `--all-features` to cargo.",
                     "default": [],
-                    "type": [
-                        "string",
-                        "array"
-                    ],
-                    "items": {
-                        "type": "string"
-                    },
-                    "enum": [
-                        "all"
-                    ],
-                    "enumDescriptions": [
-                        "Pass `--all-features` to cargo"
+                    "anyOf": [
+                        {
+                            "type": "string",
+                            "enum": [
+                                "all"
+                            ],
+                            "enumDescriptions": [
+                                "Pass `--all-features` to cargo"
+                            ]
+                        },
+                        {
+                            "type": "array",
+                            "items": {
+                                "type": "string"
+                            }
+                        }
                     ]
                 },
                 "rust-analyzer.cargo.noDefaultFeatures": {
@@ -513,7 +517,7 @@
                     ]
                 },
                 "rust-analyzer.checkOnSave.noDefaultFeatures": {
-                    "markdownDescription": "Do not activate the `default` feature.",
+                    "markdownDescription": "Whether to pass `--no-default-features` to cargo. Defaults to\n`#rust-analyzer.cargo.noDefaultFeatures#`.",
                     "default": null,
                     "type": [
                         "null",
@@ -552,21 +556,16 @@
                 "rust-analyzer.completion.callable.snippets": {
                     "markdownDescription": "Whether to add parenthesis and argument snippets when completing function.",
                     "default": "fill_arguments",
-                    "anyOf": [
-                        {
-                            "type": "string",
-                            "enum": [
-                                "fill_arguments",
-                                "add_parentheses"
-                            ],
-                            "enumDescriptions": [
-                                "Add call parentheses and pre-fill arguments",
-                                "Add call parentheses"
-                            ]
-                        },
-                        {
-                            "type": "null"
-                        }
+                    "type": "string",
+                    "enum": [
+                        "fill_arguments",
+                        "add_parentheses",
+                        "none"
+                    ],
+                    "enumDescriptions": [
+                        "Add call parentheses and pre-fill arguments.",
+                        "Add call parentheses.",
+                        "Do no snippet completions for callables."
                     ]
                 },
                 "rust-analyzer.completion.postfix.enable": {
@@ -797,23 +796,16 @@
                 "rust-analyzer.inlayHints.lifetimeElisionHints.enable": {
                     "markdownDescription": "Whether to show inlay type hints for elided lifetimes in function signatures.",
                     "default": "never",
-                    "anyOf": [
-                        {
-                            "type": "string",
-                            "enum": [
-                                "always",
-                                "never",
-                                "skip_trivial"
-                            ],
-                            "enumDescriptions": [
-                                "Always show lifetime elision hints.",
-                                "Never show lifetime elision hints.",
-                                "Only show lifetime elision hints if a return type is involved."
-                            ]
-                        },
-                        {
-                            "type": "boolean"
-                        }
+                    "type": "string",
+                    "enum": [
+                        "always",
+                        "never",
+                        "skip_trivial"
+                    ],
+                    "enumDescriptions": [
+                        "Always show lifetime elision hints.",
+                        "Never show lifetime elision hints.",
+                        "Only show lifetime elision hints if a return type is involved."
                     ]
                 },
                 "rust-analyzer.inlayHints.lifetimeElisionHints.useParameterNames": {
@@ -838,23 +830,16 @@
                 "rust-analyzer.inlayHints.reborrowHints.enable": {
                     "markdownDescription": "Whether to show inlay type hints for compiler inserted reborrows.",
                     "default": "never",
-                    "anyOf": [
-                        {
-                            "type": "string",
-                            "enum": [
-                                "always",
-                                "never",
-                                "mutable"
-                            ],
-                            "enumDescriptions": [
-                                "Always show reborrow hints.",
-                                "Never show reborrow hints.",
-                                "Only show mutable reborrow hints."
-                            ]
-                        },
-                        {
-                            "type": "boolean"
-                        }
+                    "type": "string",
+                    "enum": [
+                        "always",
+                        "never",
+                        "mutable"
+                    ],
+                    "enumDescriptions": [
+                        "Always show reborrow hints.",
+                        "Never show reborrow hints.",
+                        "Only show mutable reborrow hints."
                     ]
                 },
                 "rust-analyzer.inlayHints.renderColons": {
@@ -1065,8 +1050,8 @@
                         "all_symbols"
                     ],
                     "enumDescriptions": [
-                        "Search for types only",
-                        "Search for all symbols kinds"
+                        "Search for types only.",
+                        "Search for all symbols kinds."
                     ]
                 },
                 "rust-analyzer.workspace.symbol.search.limit": {
@@ -1084,8 +1069,8 @@
                         "workspace_and_dependencies"
                     ],
                     "enumDescriptions": [
-                        "Search in current workspace only",
-                        "Search in current workspace and dependencies"
+                        "Search in current workspace only.",
+                        "Search in current workspace and dependencies."
                     ]
                 },
                 "$generated-end": {}