Skip to content

Commit

Permalink
feat: rename show_and_select to show_and_insert
Browse files Browse the repository at this point in the history
  • Loading branch information
Saghen committed Jan 16, 2025
1 parent 373535e commit 595a6a1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions docs/configuration/completion.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ completion.list.selection = { preselect = true, auto_insert = true }
```
Selects the first item automatically, and inserts a preview of the item on selection. The `cancel` keymap (default `<C-e>`) will close the menu and undo the preview.

You may use the `show_and_select` keymap to show the completion menu and select the first item, with `auto_insert`. The default keymap (`<C-space>`) uses the `show` command, which will have the first item selected, but will not `auto_insert`.
You may use the `show_and_insert` keymap to show the completion menu and select the first item, with `auto_insert`. The default keymap (`<C-space>`) uses the `show` command, which will have the first item selected, but will not `auto_insert`.

<video src="https://github.com/user-attachments/assets/ef295526-8332-4ad0-9a2a-e2f6484081b2" muted autoplay loop />

Expand All @@ -84,7 +84,7 @@ completion.list.selection = { preselect = false, auto_insert = false }

No item will be selected by default. You may use the `select_and_accept` keymap command to select the first item and accept it when there's no selection. The `accept` keymap command, on the other hand, will only trigger if an item is selected.

You may use the `show_and_select` keymap to show the completion menu and select the first item. The default keymap (`<C-space>`) uses the `show` command, which will not select the first item.
You may use the `show_and_insert` keymap to show the completion menu and select the first item. The default keymap (`<C-space>`) uses the `show` command, which will not select the first item.

<video src="https://github.com/user-attachments/assets/09cd9b4b-18b3-456b-bb0a-074ae54e9d77" muted autoplay loop />
== Manual, Auto Insert
Expand All @@ -94,7 +94,7 @@ completion.list.selection = { preselect = false, auto_insert = true }

Selecting an item will insert a "preview" of the item automatically. You may use the `select_and_accept` keymap command to select the first item and accept it when there's no selection. The `accept` keymap command will only trigger if an item is selected. The `cancel` keymap (default `<C-e>`) will close the menu and undo the preview.

You may use the `show_and_select` keymap to show the completion menu and select the first item, with `auto_insert`. The default keymap (`<C-space>`) uses the `show` command, which will not select the first item.
You may use the `show_and_insert` keymap to show the completion menu and select the first item, with `auto_insert`. The default keymap (`<C-space>`) uses the `show` command, which will not select the first item.

<video src="https://github.com/user-attachments/assets/4658b61d-1b95-404a-b6b5-3a4afbfb8112" muted autoplay loop />
:::
Expand Down
4 changes: 2 additions & 2 deletions lua/blink/cmp/config/keymap.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
--- @alias blink.cmp.KeymapCommand
--- | 'fallback' Fallback to the built-in behavior
--- | 'show' Show the completion window
--- | 'show_and_select' Show the completion window and select the first item
--- | 'show_and_insert' Show the completion window and select the first item
--- | 'hide' Hide the completion window
--- | 'cancel' Cancel the current completion, undoing the preview from auto_insert
--- | 'accept' Accept the current completion item
Expand Down Expand Up @@ -126,7 +126,7 @@ function keymap.validate(config)
local commands = {
'fallback',
'show',
'show_and_select',
'show_and_insert',
'hide',
'cancel',
'accept',
Expand Down
2 changes: 1 addition & 1 deletion lua/blink/cmp/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ end

-- Show the completion window and select the first item
--- @params opts? { providers?: string[], callback?: fun() }
function cmp.show_and_select(opts)
function cmp.show_and_insert(opts)
opts = opts or {}
opts.initial_selected_item_idx = 1
return cmp.show(opts)
Expand Down

0 comments on commit 595a6a1

Please sign in to comment.