mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-24 15:54:15 +00:00
Feature flag for arg snippets
This commit is contained in:
parent
21f40f2b8f
commit
4e7f6c2354
@ -221,16 +221,25 @@ impl Completions {
|
||||
let (snippet, label) = if params.is_empty() || has_self_param && params.len() == 1 {
|
||||
(format!("{}()$0", name), format!("{}()", name))
|
||||
} else {
|
||||
let to_skip = if has_self_param { 1 } else { 0 };
|
||||
let function_params_snippet =
|
||||
join(
|
||||
let snippet = if ctx
|
||||
.db
|
||||
.feature_flags
|
||||
.get("completion.insertion.add-argument-sippets")
|
||||
{
|
||||
let to_skip = if has_self_param { 1 } else { 0 };
|
||||
let function_params_snippet = join(
|
||||
function_signature.parameter_names.iter().skip(to_skip).enumerate().map(
|
||||
|(index, param_name)| format!("${{{}:{}}}", index + 1, param_name),
|
||||
),
|
||||
)
|
||||
.separator(", ")
|
||||
.to_string();
|
||||
(format!("{}({})$0", name, function_params_snippet), format!("{}(…)", name))
|
||||
format!("{}({})$0", name, function_params_snippet)
|
||||
} else {
|
||||
format!("{}($0)", name)
|
||||
};
|
||||
|
||||
(snippet, format!("{}(…)", name))
|
||||
};
|
||||
builder = builder.lookup_by(name).label(label).insert_snippet(snippet);
|
||||
}
|
||||
|
@ -54,6 +54,7 @@ impl Default for FeatureFlags {
|
||||
FeatureFlags::new(&[
|
||||
("lsp.diagnostics", true),
|
||||
("completion.insertion.add-call-parenthesis", true),
|
||||
("completion.insertion.add-argument-sippets", true),
|
||||
("completion.enable-postfix", true),
|
||||
("notifications.workspace-loaded", true),
|
||||
("notifications.cargo-toml-not-found", true),
|
||||
|
@ -197,6 +197,10 @@
|
||||
"type": "boolean",
|
||||
"description": "Whether to add parenthesis when completing functions"
|
||||
},
|
||||
"completion.insertion.add-argument-sippets": {
|
||||
"type": "boolean",
|
||||
"description": "Whether to add argument snippets when completing functions"
|
||||
},
|
||||
"completion.enable-postfix": {
|
||||
"type": "boolean",
|
||||
"description": "Whether to show postfix snippets like `dbg`, `if`, `not`, etc."
|
||||
|
Loading…
Reference in New Issue
Block a user