mirror of
https://github.com/neovim/neovim.git
synced 2025-09-23 03:28:33 +00:00
feat(api): add replace_keycodes to nvim_set_keymap (#19598)
This commit is contained in:
@@ -822,7 +822,7 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
|
||||
|
||||
it('can make lua expr mappings', function()
|
||||
exec_lua [[
|
||||
vim.api.nvim_set_keymap ('n', 'aa', '', {callback = function() return vim.api.nvim_replace_termcodes(':lua SomeValue = 99<cr>', true, false, true) end, expr = true })
|
||||
vim.api.nvim_set_keymap ('n', 'aa', '', {callback = function() return ':lua SomeValue = 99<cr>' end, expr = true, replace_keycodes = true })
|
||||
]]
|
||||
|
||||
feed('aa')
|
||||
@@ -830,6 +830,16 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
|
||||
eq(99, exec_lua[[return SomeValue]])
|
||||
end)
|
||||
|
||||
it('can make lua expr mappings without replacing keycodes', function()
|
||||
exec_lua [[
|
||||
vim.api.nvim_set_keymap ('i', 'aa', '', {callback = function() return '<space>' end, expr = true })
|
||||
]]
|
||||
|
||||
feed('iaa<esc>')
|
||||
|
||||
eq({'<space>'}, meths.buf_get_lines(0, 0, -1, false))
|
||||
end)
|
||||
|
||||
it('does not reset pum in lua mapping', function()
|
||||
eq(0, exec_lua [[
|
||||
VisibleCount = 0
|
||||
@@ -1020,7 +1030,7 @@ describe('nvim_buf_set_keymap, nvim_buf_del_keymap', function()
|
||||
|
||||
it('can make lua expr mappings', function()
|
||||
exec_lua [[
|
||||
vim.api.nvim_buf_set_keymap (0, 'n', 'aa', '', {callback = function() return vim.api.nvim_replace_termcodes(':lua SomeValue = 99<cr>', true, false, true) end, expr = true })
|
||||
vim.api.nvim_buf_set_keymap (0, 'n', 'aa', '', {callback = function() return ':lua SomeValue = 99<cr>' end, expr = true, replace_keycodes = true })
|
||||
]]
|
||||
|
||||
feed('aa')
|
||||
@@ -1028,6 +1038,17 @@ describe('nvim_buf_set_keymap, nvim_buf_del_keymap', function()
|
||||
eq(99, exec_lua[[return SomeValue ]])
|
||||
end)
|
||||
|
||||
it('can make lua expr mappings without replacing keycodes', function()
|
||||
exec_lua [[
|
||||
vim.api.nvim_buf_set_keymap (0, 'i', 'aa', '', {callback = function() return '<space>' end, expr = true })
|
||||
]]
|
||||
|
||||
feed('iaa<esc>')
|
||||
|
||||
eq({'<space>'}, meths.buf_get_lines(0, 0, -1, false))
|
||||
end)
|
||||
|
||||
|
||||
it('can overwrite lua mappings', function()
|
||||
eq(0, exec_lua [[
|
||||
GlobalCount = 0
|
||||
|
Reference in New Issue
Block a user