diff options
author | ii14 <59243201+ii14@users.noreply.github.com> | 2022-08-01 15:35:08 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-01 21:35:08 +0800 |
commit | db6e93c48df551e2906c9e0f4472f9e54cea3dd9 (patch) | |
tree | a62b94332e6f23a49adce724759a4c23edf7cf03 /test/functional/api/keymap_spec.lua | |
parent | 9f5d5aa3da30aab40bbb38fddfc70257444d50a8 (diff) | |
download | rneovim-db6e93c48df551e2906c9e0f4472f9e54cea3dd9.tar.gz rneovim-db6e93c48df551e2906c9e0f4472f9e54cea3dd9.tar.bz2 rneovim-db6e93c48df551e2906c9e0f4472f9e54cea3dd9.zip |
feat(api): add replace_keycodes to nvim_set_keymap (#19598)
Diffstat (limited to 'test/functional/api/keymap_spec.lua')
-rw-r--r-- | test/functional/api/keymap_spec.lua | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/test/functional/api/keymap_spec.lua b/test/functional/api/keymap_spec.lua index 6bc6651e04..23c0a14d39 100644 --- a/test/functional/api/keymap_spec.lua +++ b/test/functional/api/keymap_spec.lua @@ -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 |