feat(api): add replace_keycodes to nvim_set_keymap (#19598)

This commit is contained in:
ii14
2022-08-01 15:35:08 +02:00
committed by GitHub
parent 9f5d5aa3da
commit db6e93c48d
9 changed files with 56 additions and 29 deletions

View File

@@ -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