Skip to content

Commit

Permalink
Optionally disable term search for autocompletion
Browse files Browse the repository at this point in the history
  • Loading branch information
kilpkonn committed Jan 27, 2024
1 parent ef2aed8 commit 50d9a91
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 0 deletions.
5 changes: 5 additions & 0 deletions crates/ide-completion/src/completions/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,11 @@ pub(crate) fn complete_expr_path(

pub(crate) fn complete_expr(acc: &mut Completions, ctx: &CompletionContext<'_>) {
let _p = profile::span("complete_expr");

if !ctx.config.enable_term_search {
return;
}

if !ctx.qualifier_ctx.none() {
return;
}
Expand Down
1 change: 1 addition & 0 deletions crates/ide-completion/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub struct CompletionConfig {
pub enable_imports_on_the_fly: bool,
pub enable_self_on_the_fly: bool,
pub enable_private_editable: bool,
pub enable_term_search: bool,
pub full_function_signatures: bool,
pub callable: Option<CallableSnippets>,
pub snippet_cap: Option<SnippetCap>,
Expand Down
1 change: 1 addition & 0 deletions crates/ide-completion/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ pub(crate) const TEST_CONFIG: CompletionConfig = CompletionConfig {
enable_imports_on_the_fly: true,
enable_self_on_the_fly: true,
enable_private_editable: false,
enable_term_search: true,
full_function_signatures: false,
callable: Some(CallableSnippets::FillArguments),
snippet_cap: SnippetCap::new(true),
Expand Down
3 changes: 3 additions & 0 deletions crates/rust-analyzer/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,8 @@ config_data! {
"scope": "expr"
}
}"#,
/// Whether to enable term search based snippets like `Some(foo.bar().baz())`.
completion_term_search_enable: bool = "true",

/// List of rust-analyzer diagnostics to disable.
diagnostics_disabled: FxHashSet<String> = "[]",
Expand Down Expand Up @@ -1517,6 +1519,7 @@ 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,
enable_term_search: self.data.completion_term_search_enable,
full_function_signatures: self.data.completion_fullFunctionSignatures_enable,
callable: match self.data.completion_callable_snippets {
CallableCompletionDef::FillArguments => Some(CallableSnippets::FillArguments),
Expand Down
3 changes: 3 additions & 0 deletions crates/rust-analyzer/src/integrated_benchmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ fn integrated_completion_benchmark() {
enable_imports_on_the_fly: true,
enable_self_on_the_fly: true,
enable_private_editable: true,
enable_term_search: true,
full_function_signatures: false,
callable: Some(CallableSnippets::FillArguments),
snippet_cap: SnippetCap::new(true),
Expand Down Expand Up @@ -176,6 +177,7 @@ fn integrated_completion_benchmark() {
enable_imports_on_the_fly: true,
enable_self_on_the_fly: true,
enable_private_editable: true,
enable_term_search: true,
full_function_signatures: false,
callable: Some(CallableSnippets::FillArguments),
snippet_cap: SnippetCap::new(true),
Expand Down Expand Up @@ -217,6 +219,7 @@ fn integrated_completion_benchmark() {
enable_imports_on_the_fly: true,
enable_self_on_the_fly: true,
enable_private_editable: true,
enable_term_search: true,
full_function_signatures: false,
callable: Some(CallableSnippets::FillArguments),
snippet_cap: SnippetCap::new(true),
Expand Down
5 changes: 5 additions & 0 deletions docs/user/generated_config.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,11 @@ Default:
----
Custom completion snippets.

--
[[rust-analyzer.completion.term.search.enable]]rust-analyzer.completion.term.search.enable (default: `true`)::
+
--
Whether to enable term search based snippets like `Some(foo.bar().baz())`.
--
[[rust-analyzer.diagnostics.disabled]]rust-analyzer.diagnostics.disabled (default: `[]`)::
+
Expand Down
5 changes: 5 additions & 0 deletions editors/code/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -897,6 +897,11 @@
},
"type": "object"
},
"rust-analyzer.completion.term.search.enable": {
"markdownDescription": "Whether to enable term search based snippets like `Some(foo.bar().baz())`.",
"default": true,
"type": "boolean"
},
"rust-analyzer.diagnostics.disabled": {
"markdownDescription": "List of rust-analyzer diagnostics to disable.",
"default": [],
Expand Down

0 comments on commit 50d9a91

Please sign in to comment.