Allow disabling snippet completion by setting snippet_sort_order
to none
(#34565)
This mirrors VSCode setting that inspired `snippet_sort_order` to begin with; VSCode supports inline/top/bottom/none, with none completely disabling snippet completion. See https://code.visualstudio.com/docs/editing/intellisense#_snippets-in-suggestions This is helpful for LSPs that do not allow configuring snippets via configuration such as clangd. Release Notes: - Added `none` as one of the values for `snippet_sort_order` to completely disable snippet completion.
This commit is contained in:
parent
acb3ecef0c
commit
758c5fb955
5 changed files with 26 additions and 1 deletions
|
@ -197,6 +197,8 @@
|
||||||
// "inline"
|
// "inline"
|
||||||
// 3. Place snippets at the bottom of the completion list:
|
// 3. Place snippets at the bottom of the completion list:
|
||||||
// "bottom"
|
// "bottom"
|
||||||
|
// 4. Do not show snippets in the completion list:
|
||||||
|
// "none"
|
||||||
"snippet_sort_order": "inline",
|
"snippet_sort_order": "inline",
|
||||||
// How to highlight the current line in the editor.
|
// How to highlight the current line in the editor.
|
||||||
//
|
//
|
||||||
|
|
|
@ -1074,6 +1074,20 @@ impl CompletionsMenu {
|
||||||
.and_then(|q| q.chars().next())
|
.and_then(|q| q.chars().next())
|
||||||
.and_then(|c| c.to_lowercase().next());
|
.and_then(|c| c.to_lowercase().next());
|
||||||
|
|
||||||
|
if snippet_sort_order == SnippetSortOrder::None {
|
||||||
|
matches.retain(|string_match| {
|
||||||
|
let completion = &completions[string_match.candidate_id];
|
||||||
|
|
||||||
|
let is_snippet = matches!(
|
||||||
|
&completion.source,
|
||||||
|
CompletionSource::Lsp { lsp_completion, .. }
|
||||||
|
if lsp_completion.kind == Some(CompletionItemKind::SNIPPET)
|
||||||
|
);
|
||||||
|
|
||||||
|
!is_snippet
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
matches.sort_unstable_by_key(|string_match| {
|
matches.sort_unstable_by_key(|string_match| {
|
||||||
let completion = &completions[string_match.candidate_id];
|
let completion = &completions[string_match.candidate_id];
|
||||||
|
|
||||||
|
@ -1112,6 +1126,7 @@ impl CompletionsMenu {
|
||||||
SnippetSortOrder::Top => Reverse(if is_snippet { 1 } else { 0 }),
|
SnippetSortOrder::Top => Reverse(if is_snippet { 1 } else { 0 }),
|
||||||
SnippetSortOrder::Bottom => Reverse(if is_snippet { 0 } else { 1 }),
|
SnippetSortOrder::Bottom => Reverse(if is_snippet { 0 } else { 1 }),
|
||||||
SnippetSortOrder::Inline => Reverse(0),
|
SnippetSortOrder::Inline => Reverse(0),
|
||||||
|
SnippetSortOrder::None => Reverse(0),
|
||||||
};
|
};
|
||||||
let sort_positions = string_match.positions.clone();
|
let sort_positions = string_match.positions.clone();
|
||||||
let sort_exact = Reverse(if Some(completion.label.filter_text()) == query {
|
let sort_exact = Reverse(if Some(completion.label.filter_text()) == query {
|
||||||
|
|
|
@ -395,6 +395,8 @@ pub enum SnippetSortOrder {
|
||||||
Inline,
|
Inline,
|
||||||
/// Place snippets at the bottom of the completion list
|
/// Place snippets at the bottom of the completion list
|
||||||
Bottom,
|
Bottom,
|
||||||
|
/// Do not show snippets in the completion list
|
||||||
|
None,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Default, Serialize, Deserialize, JsonSchema)]
|
#[derive(Clone, Default, Serialize, Deserialize, JsonSchema)]
|
||||||
|
|
|
@ -639,6 +639,12 @@ List of `string` values
|
||||||
"snippet_sort_order": "bottom"
|
"snippet_sort_order": "bottom"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
4. Do not show snippets in the completion list at all:
|
||||||
|
|
||||||
|
```json
|
||||||
|
"snippet_sort_order": "none"
|
||||||
|
```
|
||||||
|
|
||||||
## Editor Scrollbar
|
## Editor Scrollbar
|
||||||
|
|
||||||
- Description: Whether or not to show the editor scrollbar and various elements in it.
|
- Description: Whether or not to show the editor scrollbar and various elements in it.
|
||||||
|
|
|
@ -317,7 +317,7 @@ TBD: Centered layout related settings
|
||||||
### Editor Completions, Snippets, Actions, Diagnostics {#editor-lsp}
|
### Editor Completions, Snippets, Actions, Diagnostics {#editor-lsp}
|
||||||
|
|
||||||
```json
|
```json
|
||||||
"snippet_sort_order": "inline", // Snippets completions: top, inline, bottom
|
"snippet_sort_order": "inline", // Snippets completions: top, inline, bottom, none
|
||||||
"show_completions_on_input": true, // Show completions while typing
|
"show_completions_on_input": true, // Show completions while typing
|
||||||
"show_completion_documentation": true, // Show documentation in completions
|
"show_completion_documentation": true, // Show documentation in completions
|
||||||
"auto_signature_help": false, // Show method signatures inside parentheses
|
"auto_signature_help": false, // Show method signatures inside parentheses
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue