adjust completion list keymaps
disable up/down arrow key navigation in the completion list. up/down arrow keys will instead close the list. this helps reduce the feeling of interruption i sometimes get when a completion list is open but i (for whatever reason) need to navigate away from the current cursor position, which would otherwise require either accepting the completion or continuing to type at the cursor, or cancelling the completion with the escape key. it's a small thing, but this helps reduce some annoyances/frustrations with auto-completion by having less overloading of the cursor keys while in insert mode ctrl-j and ctrl-k now behave identically to the old completion list up/down arrow key mappings. also the escape key mapping now performs an abort instead of just closing the list. this feels a little bit more appropriate, but i'll probably have to try this out for a while and see if i feel like it is an improvement or just extra confusion.
This commit is contained in:
parent
c863e4cdfb
commit
dc90a7dd71
|
@ -39,6 +39,7 @@ return {
|
|||
config = function()
|
||||
-- See `:help cmp`
|
||||
local cmp = require 'cmp'
|
||||
local types = require 'cmp.types'
|
||||
local luasnip = require 'luasnip'
|
||||
luasnip.config.setup {}
|
||||
|
||||
|
@ -55,6 +56,15 @@ return {
|
|||
--
|
||||
-- No, but seriously. Please read `:help ins-completion`, it is really good!
|
||||
mapping = cmp.mapping.preset.insert {
|
||||
-- Disable use of <Up> and <Down> for navigation within a completion list.
|
||||
['<Down>'] = cmp.mapping.close(),
|
||||
['<Up>'] = cmp.mapping.close(),
|
||||
|
||||
-- Identical to old <Down> key behavior
|
||||
['<C-j>'] = cmp.mapping.select_next_item { behavior = types.cmp.SelectBehavior.Select },
|
||||
-- Identical to old <Up> key behavior
|
||||
['<C-k>'] = cmp.mapping.select_prev_item { behavior = types.cmp.SelectBehavior.Select },
|
||||
|
||||
-- Select the [n]ext item
|
||||
['<C-n>'] = cmp.mapping.select_next_item(),
|
||||
-- Select the [p]revious item
|
||||
|
@ -69,7 +79,8 @@ return {
|
|||
-- This will expand snippets if the LSP sent a snippet.
|
||||
['<C-y>'] = cmp.mapping.confirm { select = true },
|
||||
|
||||
['<Esc>'] = cmp.mapping.close(),
|
||||
-- Cancel/abort any selected/partial completion and close the completion list.
|
||||
['<Esc>'] = cmp.mapping.abort(),
|
||||
|
||||
-- If you prefer more traditional completion keymaps,
|
||||
-- you can uncomment the following lines
|
||||
|
|
Loading…
Reference in a new issue