Closed mawkler closed 8 months ago
I see what's going on here— sorry in advance for the confusion. Keys are not preprocessed by nvim_replace_termcodes
, just on the off case someone really does want to bind the sequence <
c
-
n
>
(and if you press that sequence in the the example mode you'll see it runs vim.notify
).
To fix it, you can do this:
local M = {}
-- neovim >= 0.10
local k = vim.keycode
-- neovim < 0.10
local function k(s)
return vim.api.nvim_replace_termcodes(s, true, true, true)
end
M.mode = {
-- (the rest of your mode)
-- ↓ call `k`
[k'<c-n>'] = function()
-- (the definition)
end,
-- ↓ call `k`
[k'<m-n>'] = function()
-- (the definition)
end
}
-- (the rest of the module)
Alternatively, in insert mode if you press <C-v>
and then another control sequence it will replace termcodes directly into the file (e.g. <C-v><Esc>
)
Ah, that makes sense. Thank you!
Mappings with modifiers like
ctrl
/meta
don't seem to work:M
to enter custom moden
produces notification'This works'
<c-n>
doesn't produce a notification<m-n>
throws an error