diff options
Diffstat (limited to 'test/functional/lua/vim_spec.lua')
-rw-r--r-- | test/functional/lua/vim_spec.lua | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/test/functional/lua/vim_spec.lua b/test/functional/lua/vim_spec.lua index 1547f3244e..ae6a1d5765 100644 --- a/test/functional/lua/vim_spec.lua +++ b/test/functional/lua/vim_spec.lua @@ -2755,6 +2755,39 @@ describe('vim.keymap', function() eq('\nNo mapping found', helpers.exec_capture('nmap asdf')) end) + it('works with buffer-local mappings', function() + eq(0, exec_lua [[ + GlobalCount = 0 + vim.keymap.set('n', 'asdf', function() GlobalCount = GlobalCount + 1 end, {buffer=true}) + return GlobalCount + ]]) + + feed('asdf\n') + + eq(1, exec_lua[[return GlobalCount]]) + + exec_lua [[ + vim.keymap.del('n', 'asdf', {buffer=true}) + ]] + + feed('asdf\n') + + eq(1, exec_lua[[return GlobalCount]]) + eq('\nNo mapping found', helpers.exec_capture('nmap asdf')) + end) + + it('does not mutate the opts parameter', function() + eq(true, exec_lua [[ + opts = {buffer=true} + vim.keymap.set('n', 'asdf', function() end, opts) + return opts.buffer + ]]) + eq(true, exec_lua [[ + vim.keymap.del('n', 'asdf', opts) + return opts.buffer + ]]) + end) + it('can do <Plug> mappings', function() eq(0, exec_lua [[ GlobalCount = 0 |