vim: navigate up/down completions with <c-j>/<c-k>

This commit is contained in:
Fernando Schauenburg 2024-03-17 23:37:42 +01:00
parent fee0d0f5c7
commit f39ac9a666

View file

@ -4,6 +4,7 @@ local make_keymap = function(cmp)
local select = { behavior = cmp.SelectBehavior.Select }
local if_visible = function(yes, no)
no = no or function(fallback) fallback() end
return function(fallback)
if cmp.visible() then
yes(fallback)
@ -19,6 +20,9 @@ local make_keymap = function(cmp)
["<c-n>"] = if_visible(cmp.mapping.select_next_item(select), cmp.mapping.complete()),
["<c-p>"] = if_visible(cmp.mapping.select_prev_item(select), cmp.mapping.complete()),
["<c-j>"] = if_visible(cmp.mapping.select_next_item(select), cmp.mapping.complete()),
["<c-k>"] = if_visible(cmp.mapping.select_prev_item(select)),
["<down>"] = cmp.mapping.select_next_item(select),
["<up>"] = cmp.mapping.select_prev_item(select),