neovim new style keymappings vs old
tommyjcarpenter opened this issue · 1 comments
tommyjcarpenter commented
Result from CocInfo
## versions
vim version: NVIM v0.10.2
node version: v22.9.0
coc.nvim version: 0.0.82-9fd8578 2024-09-21 00:59:00 +0900
coc.nvim directory: /Users/tcarpenter/.local/share/nvim/site/pack/packer/start/coc.nvim
term: tmux
platform: darwin
Describe the bug
Not sure if this is a bug, or an nvim limitation, etc.
I have some keybindings to use the arrowkeys in the autocompletion menu:
-- alias for key mapping
-- note: vim.keymap.set breaks up/down arrow keys
local keyset = vim.api.nvim_set_keymap
-- Use <Down> to move through CoC suggestions or behave as normal Down key
keyset(
'i', '<Down>',
[[coc#pum#visible() ? coc#pum#next(1) : "\<Down>"]],
{ noremap = true, expr = true, silent = true }
)
-- Use <Up> to move through CoC suggestions or behave as normal Up key
keyset(
'i', '<Up>',
[[coc#pum#visible() ? coc#pum#prev(1) : "\<Up>"]],
{ noremap = true, expr = true, silent = true }
)
Im using the latest neovim. And the above keybindings work. However, note that
local keyset = vim.api.nvim_set_keymap
is the old style keybinding; per https://neovim.io/doc/user/lua.html#vim.keymap.set(), Lua has moved to
vim.keymap.set
but using
local keyset = vim.keymap.set
breaks the "else" clause in those keyset
commands above; in insert mode, pressing the down or up arrow prints stuff like <80>kd
etc.
screenshot showing local keyset = vim.keymap.set
leading to garbage when the up or down key is pressed:
fannheyward commented