aboutsummaryrefslogtreecommitdiff
path: root/test/functional/ex_cmds/map_spec.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/ex_cmds/map_spec.lua')
-rw-r--r--test/functional/ex_cmds/map_spec.lua85
1 files changed, 34 insertions, 51 deletions
diff --git a/test/functional/ex_cmds/map_spec.lua b/test/functional/ex_cmds/map_spec.lua
index a580e88b93..d3b027e6f4 100644
--- a/test/functional/ex_cmds/map_spec.lua
+++ b/test/functional/ex_cmds/map_spec.lua
@@ -1,11 +1,11 @@
-local helpers = require("test.functional.helpers")(after_each)
+local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local eq = helpers.eq
local exec = helpers.exec
local exec_capture = helpers.exec_capture
local feed = helpers.feed
-local meths = helpers.meths
+local api = helpers.api
local clear = helpers.clear
local command = helpers.command
local expect = helpers.expect
@@ -16,13 +16,13 @@ describe(':*map', function()
before_each(clear)
it('are not affected by &isident', function()
- meths.set_var('counter', 0)
+ api.nvim_set_var('counter', 0)
command('nnoremap <C-x> :let counter+=1<CR>')
- meths.set_option_value('isident', ('%u'):format(('>'):byte()), {})
+ api.nvim_set_option_value('isident', ('%u'):format(('>'):byte()), {})
command('nnoremap <C-y> :let counter+=1<CR>')
-- &isident used to disable keycode parsing here as well
feed('\24\25<C-x><C-y>')
- eq(4, meths.get_var('counter'))
+ eq(4, api.nvim_get_var('counter'))
end)
it(':imap <M-">', function()
@@ -33,56 +33,60 @@ describe(':*map', function()
it('shows <Nop> as mapping rhs', function()
command('nmap asdf <Nop>')
- eq([[
+ eq(
+ [[
n asdf <Nop>]],
- exec_capture('nmap asdf'))
+ exec_capture('nmap asdf')
+ )
end)
it('mappings with description can be filtered', function()
- meths.set_keymap('n', 'asdf1', 'qwert', {desc='do the one thing'})
- meths.set_keymap('n', 'asdf2', 'qwert', {desc='doesnot really do anything'})
- meths.set_keymap('n', 'asdf3', 'qwert', {desc='do the other thing'})
- eq([[
+ api.nvim_set_keymap('n', 'asdf1', 'qwert', { desc = 'do the one thing' })
+ api.nvim_set_keymap('n', 'asdf2', 'qwert', { desc = 'doesnot really do anything' })
+ api.nvim_set_keymap('n', 'asdf3', 'qwert', { desc = 'do the other thing' })
+ eq(
+ [[
n asdf3 qwert
do the other thing
n asdf1 qwert
do the one thing]],
- exec_capture('filter the nmap'))
+ exec_capture('filter the nmap')
+ )
end)
it('<Plug> mappings ignore nore', function()
command('let x = 0')
- eq(0, meths.eval('x'))
+ eq(0, api.nvim_eval('x'))
command [[
nnoremap <Plug>(Increase_x) <cmd>let x+=1<cr>
nmap increase_x_remap <Plug>(Increase_x)
nnoremap increase_x_noremap <Plug>(Increase_x)
]]
feed('increase_x_remap')
- eq(1, meths.eval('x'))
+ eq(1, api.nvim_eval('x'))
feed('increase_x_noremap')
- eq(2, meths.eval('x'))
+ eq(2, api.nvim_eval('x'))
end)
it("Doesn't auto ignore nore for keys before or after <Plug> mapping", function()
command('let x = 0')
- eq(0, meths.eval('x'))
+ eq(0, api.nvim_eval('x'))
command [[
nnoremap x <nop>
nnoremap <Plug>(Increase_x) <cmd>let x+=1<cr>
nmap increase_x_remap x<Plug>(Increase_x)x
nnoremap increase_x_noremap x<Plug>(Increase_x)x
]]
- insert("Some text")
+ insert('Some text')
eq('Some text', eval("getline('.')"))
feed('increase_x_remap')
- eq(1, meths.eval('x'))
+ eq(1, api.nvim_eval('x'))
eq('Some text', eval("getline('.')"))
feed('increase_x_noremap')
- eq(2, meths.eval('x'))
+ eq(2, api.nvim_eval('x'))
eq('Some te', eval("getline('.')"))
end)
@@ -105,25 +109,19 @@ describe('Screen', function()
command('map <expr> x input("> ")')
screen:expect([[
^ |
- ~ |
- ~ |
- ~ |
+ ~ |*3
|
]])
feed('x')
screen:expect([[
|
- ~ |
- ~ |
- ~ |
+ ~ |*3
> ^ |
]])
feed('\n')
screen:expect([[
^ |
- ~ |
- ~ |
- ~ |
+ ~ |*3
> |
]])
end)
@@ -133,25 +131,19 @@ describe('Screen', function()
feed('i')
screen:expect([[
^ |
- ~ |
- ~ |
- ~ |
+ ~ |*3
-- INSERT -- |
]])
feed('x')
screen:expect([[
|
- ~ |
- ~ |
- ~ |
+ ~ |*3
> ^ |
]])
feed('\n')
screen:expect([[
^ |
- ~ |
- ~ |
- ~ |
+ ~ |*3
-- INSERT -- |
]])
end)
@@ -161,9 +153,7 @@ describe('Screen', function()
feed(':<F2>')
screen:expect([[
|
- ~ |
- ~ |
- ~ |
+ ~ |*3
:^ |
]])
end)
@@ -201,8 +191,7 @@ describe('Screen', function()
command('nmap <expr> <F2> execute("throw 42")')
feed('<F2>')
screen:expect([[
- |
- |
+ |*2
Error detected while processing : |
E605: Exception not caught: 42 |
Press ENTER or type command to continue^ |
@@ -210,9 +199,7 @@ describe('Screen', function()
feed('<CR>')
screen:expect([[
^ |
- ~ |
- ~ |
- ~ |
+ ~ |*3
|
]])
end)
@@ -223,9 +210,7 @@ describe('Screen', function()
feed(':echo "foo')
screen:expect([[
|
- ~ |
- ~ |
- ~ |
+ ~ |*3
:echo "foo^ |
]])
feed('<F2>')
@@ -261,9 +246,7 @@ describe('Screen', function()
feed(': nmap a<CR>')
screen:expect([[
^ |
- ~ |
- ~ |
- ~ |
+ ~ |*3
n a b |
]])
end)