Add dedicated actions for LSP
completions insertion mode (#28121)
Adds actions so you can have customized keybindings for `insert` and `replace` modes. And add `shift-enter` as a default for `replace`, this will override the default setting `completions.lsp_insert_mode` which is set to `replace_suffix`, which tries to "smartly" decide whether to replace or insert based on the surrounding text. For those who come from VSCode, if you want to mimic their behavior, you only have to set `completions.lsp_insert_mode` to `insert`. If you want `tab` and `enter` to do different things, you need to remap them, here is an example: ```jsonc [ // ... { "context": "Editor && showing_completions", "bindings": { "enter": "editor::ConfirmCompletionInsert", "tab": "editor::ConfirmCompletionReplace" } }, ] ``` Closes #24577 - [x] Make LSP completion insertion mode decision in guest's machine (host is currently deciding it and not allowing guests to have their own setting for it) - [x] Add shift-enter as a hotkey for `replace` by default. - [x] Test actions. - [x] Respect the setting being specified per language, instead of using the "defaults". - [x] Move `insert_range` of `Completion` to the Lsp variant of `.source`. - [x] Fix broken default, forgotten after https://github.com/zed-industries/zed/pull/27453#pullrequestreview-2736906628, should be `replace_suffix` and not `insert`. Release Notes: - LSP completions: added actions `ConfirmCompletionInsert` and `ConfirmCompletionReplace` that control how completions are inserted, these override `completions.lsp_insert_mode`, by default, `shift-enter` triggers `ConfirmCompletionReplace` which replaces the whole word.
This commit is contained in:
parent
0459b1d303
commit
b15ee1b1cc
17 changed files with 400 additions and 207 deletions
|
@ -120,7 +120,7 @@ impl SlashCommandCompletionProvider {
|
|||
) as Arc<_>
|
||||
});
|
||||
Some(project::Completion {
|
||||
old_range: name_range.clone(),
|
||||
replace_range: name_range.clone(),
|
||||
documentation: Some(CompletionDocumentation::SingleLine(
|
||||
command.description().into(),
|
||||
)),
|
||||
|
@ -219,7 +219,7 @@ impl SlashCommandCompletionProvider {
|
|||
}
|
||||
|
||||
project::Completion {
|
||||
old_range: if new_argument.replace_previous_arguments {
|
||||
replace_range: if new_argument.replace_previous_arguments {
|
||||
argument_range.clone()
|
||||
} else {
|
||||
last_argument_range.clone()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue