mirror of
https://github.com/neovim/neovim.git
synced 2025-11-17 15:51:32 +00:00
test: rename (meths, funcs) -> (api, fn)
This commit is contained in:
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,8 +1,8 @@
|
||||
local helpers = require('test.functional.helpers')(after_each)
|
||||
local clear = helpers.clear
|
||||
local eq, ok = helpers.eq, helpers.ok
|
||||
local funcs = helpers.funcs
|
||||
local meths = helpers.meths
|
||||
local fn = helpers.fn
|
||||
local api = helpers.api
|
||||
local command, eval, next_msg = helpers.command, helpers.eval, helpers.next_msg
|
||||
local nvim_prog = helpers.nvim_prog
|
||||
local pcall_err = helpers.pcall_err
|
||||
@@ -24,7 +24,7 @@ local function expectn(name, args)
|
||||
end
|
||||
|
||||
local function sendkeys(keys)
|
||||
meths.nvim_input(keys)
|
||||
api.nvim_input(keys)
|
||||
-- give nvim some time to process msgpack requests before possibly sending
|
||||
-- more key presses - otherwise they all pile up in the queue and get
|
||||
-- processed at once
|
||||
@@ -37,7 +37,7 @@ local function open(activate, lines)
|
||||
local filename = helpers.tmpname()
|
||||
write_file(filename, table.concat(lines, '\n') .. '\n', true)
|
||||
command('edit ' .. filename)
|
||||
local b = meths.nvim_get_current_buf()
|
||||
local b = api.nvim_get_current_buf()
|
||||
-- what is the value of b:changedtick?
|
||||
local tick = eval('b:changedtick')
|
||||
|
||||
@@ -45,7 +45,7 @@ local function open(activate, lines)
|
||||
-- arrive as expected
|
||||
if activate then
|
||||
local firstline = 0
|
||||
ok(meths.nvim_buf_attach(b, true, {}))
|
||||
ok(api.nvim_buf_attach(b, true, {}))
|
||||
expectn('nvim_buf_lines_event', { b, tick, firstline, -1, lines, false })
|
||||
end
|
||||
|
||||
@@ -62,12 +62,12 @@ local function editoriginal(activate, lines)
|
||||
end
|
||||
|
||||
local function reopen(buf, expectedlines)
|
||||
ok(meths.nvim_buf_detach(buf))
|
||||
ok(api.nvim_buf_detach(buf))
|
||||
expectn('nvim_buf_detach_event', { buf })
|
||||
-- for some reason the :edit! increments tick by 2
|
||||
command('edit!')
|
||||
local tick = eval('b:changedtick')
|
||||
ok(meths.nvim_buf_attach(buf, true, {}))
|
||||
ok(api.nvim_buf_attach(buf, true, {}))
|
||||
local firstline = 0
|
||||
expectn('nvim_buf_lines_event', { buf, tick, firstline, -1, expectedlines, false })
|
||||
command('normal! gg')
|
||||
@@ -197,21 +197,21 @@ describe('API: buffer events:', function()
|
||||
-- add a line at the start of an empty file
|
||||
command('enew')
|
||||
tick = eval('b:changedtick')
|
||||
local b2 = meths.nvim_get_current_buf()
|
||||
ok(meths.nvim_buf_attach(b2, true, {}))
|
||||
local b2 = api.nvim_get_current_buf()
|
||||
ok(api.nvim_buf_attach(b2, true, {}))
|
||||
expectn('nvim_buf_lines_event', { b2, tick, 0, -1, { '' }, false })
|
||||
eval('append(0, ["new line 1"])')
|
||||
tick = tick + 1
|
||||
expectn('nvim_buf_lines_event', { b2, tick, 0, 0, { 'new line 1' }, false })
|
||||
|
||||
-- turn off buffer events manually
|
||||
meths.nvim_buf_detach(b2)
|
||||
api.nvim_buf_detach(b2)
|
||||
expectn('nvim_buf_detach_event', { b2 })
|
||||
|
||||
-- add multiple lines to a blank file
|
||||
command('enew!')
|
||||
local b3 = meths.nvim_get_current_buf()
|
||||
ok(meths.nvim_buf_attach(b3, true, {}))
|
||||
local b3 = api.nvim_get_current_buf()
|
||||
ok(api.nvim_buf_attach(b3, true, {}))
|
||||
tick = eval('b:changedtick')
|
||||
expectn('nvim_buf_lines_event', { b3, tick, 0, -1, { '' }, false })
|
||||
eval('append(0, ["new line 1", "new line 2", "new line 3"])')
|
||||
@@ -222,7 +222,7 @@ describe('API: buffer events:', function()
|
||||
)
|
||||
|
||||
-- use the API itself to add a line to the start of the buffer
|
||||
meths.nvim_buf_set_lines(b3, 0, 0, true, { 'New First Line' })
|
||||
api.nvim_buf_set_lines(b3, 0, 0, true, { 'New First Line' })
|
||||
tick = tick + 1
|
||||
expectn('nvim_buf_lines_event', { b3, tick, 0, 0, { 'New First Line' }, false })
|
||||
end)
|
||||
@@ -306,8 +306,8 @@ describe('API: buffer events:', function()
|
||||
command('bdelete!')
|
||||
tick = 2
|
||||
expectn('nvim_buf_detach_event', { b })
|
||||
local bnew = meths.nvim_get_current_buf()
|
||||
ok(meths.nvim_buf_attach(bnew, true, {}))
|
||||
local bnew = api.nvim_get_current_buf()
|
||||
ok(api.nvim_buf_attach(bnew, true, {}))
|
||||
expectn('nvim_buf_lines_event', { bnew, tick, 0, -1, { '' }, false })
|
||||
sendkeys('i')
|
||||
sendkeys('h')
|
||||
@@ -472,25 +472,25 @@ describe('API: buffer events:', function()
|
||||
end)
|
||||
|
||||
it('does not get confused if enabled/disabled many times', function()
|
||||
local channel = meths.nvim_get_api_info()[1]
|
||||
local channel = api.nvim_get_api_info()[1]
|
||||
local b, tick = editoriginal(false)
|
||||
|
||||
-- Enable buffer events many times.
|
||||
ok(meths.nvim_buf_attach(b, true, {}))
|
||||
ok(meths.nvim_buf_attach(b, true, {}))
|
||||
ok(meths.nvim_buf_attach(b, true, {}))
|
||||
ok(meths.nvim_buf_attach(b, true, {}))
|
||||
ok(meths.nvim_buf_attach(b, true, {}))
|
||||
ok(api.nvim_buf_attach(b, true, {}))
|
||||
ok(api.nvim_buf_attach(b, true, {}))
|
||||
ok(api.nvim_buf_attach(b, true, {}))
|
||||
ok(api.nvim_buf_attach(b, true, {}))
|
||||
ok(api.nvim_buf_attach(b, true, {}))
|
||||
expectn('nvim_buf_lines_event', { b, tick, 0, -1, origlines, false })
|
||||
eval('rpcnotify(' .. channel .. ', "Hello There")')
|
||||
expectn('Hello There', {})
|
||||
|
||||
-- Disable buffer events many times.
|
||||
ok(meths.nvim_buf_detach(b))
|
||||
ok(meths.nvim_buf_detach(b))
|
||||
ok(meths.nvim_buf_detach(b))
|
||||
ok(meths.nvim_buf_detach(b))
|
||||
ok(meths.nvim_buf_detach(b))
|
||||
ok(api.nvim_buf_detach(b))
|
||||
ok(api.nvim_buf_detach(b))
|
||||
ok(api.nvim_buf_detach(b))
|
||||
ok(api.nvim_buf_detach(b))
|
||||
ok(api.nvim_buf_detach(b))
|
||||
expectn('nvim_buf_detach_event', { b })
|
||||
eval('rpcnotify(' .. channel .. ', "Hello Again")')
|
||||
expectn('Hello Again', {})
|
||||
@@ -573,7 +573,7 @@ describe('API: buffer events:', function()
|
||||
|
||||
it('works with :diffput and :diffget', function()
|
||||
local b1, tick1 = editoriginal(true, { 'AAA', 'BBB' })
|
||||
local channel = meths.nvim_get_api_info()[1]
|
||||
local channel = api.nvim_get_api_info()[1]
|
||||
command('diffthis')
|
||||
command('rightbelow vsplit')
|
||||
local b2, tick2 = open(true, { 'BBB', 'CCC' })
|
||||
@@ -690,7 +690,7 @@ describe('API: buffer events:', function()
|
||||
|
||||
it('detaches if the buffer is closed', function()
|
||||
local b, tick = editoriginal(true, { 'AAA' })
|
||||
local channel = meths.nvim_get_api_info()[1]
|
||||
local channel = api.nvim_get_api_info()[1]
|
||||
|
||||
-- Test that buffer events are working.
|
||||
command('normal! x')
|
||||
@@ -729,7 +729,7 @@ describe('API: buffer events:', function()
|
||||
|
||||
it(':enew! does not detach hidden buffer', function()
|
||||
local b, tick = editoriginal(true, { 'AAA', 'BBB' })
|
||||
local channel = meths.nvim_get_api_info()[1]
|
||||
local channel = api.nvim_get_api_info()[1]
|
||||
|
||||
command('set undoreload=1 hidden')
|
||||
command('normal! x')
|
||||
@@ -743,7 +743,7 @@ describe('API: buffer events:', function()
|
||||
|
||||
it('stays attached if the buffer is hidden', function()
|
||||
local b, tick = editoriginal(true, { 'AAA' })
|
||||
local channel = meths.nvim_get_api_info()[1]
|
||||
local channel = api.nvim_get_api_info()[1]
|
||||
|
||||
-- Test that buffer events are working.
|
||||
command('normal! x')
|
||||
@@ -790,14 +790,14 @@ describe('API: buffer events:', function()
|
||||
it('does not send the buffer content if not requested', function()
|
||||
clear()
|
||||
local b, tick = editoriginal(false)
|
||||
ok(meths.nvim_buf_attach(b, false, {}))
|
||||
ok(api.nvim_buf_attach(b, false, {}))
|
||||
expectn('nvim_buf_changedtick_event', { b, tick })
|
||||
end)
|
||||
|
||||
it('returns a proper error on nonempty options dict', function()
|
||||
clear()
|
||||
local b = editoriginal(false)
|
||||
eq("Invalid key: 'builtin'", pcall_err(meths.nvim_buf_attach, b, false, { builtin = 'asfd' }))
|
||||
eq("Invalid key: 'builtin'", pcall_err(api.nvim_buf_attach, b, false, { builtin = 'asfd' }))
|
||||
end)
|
||||
|
||||
it('nvim_buf_attach returns response after delay #8634', function()
|
||||
@@ -869,12 +869,12 @@ describe('API: buffer events:', function()
|
||||
it('when :terminal lines change', function()
|
||||
local buffer_lines = {}
|
||||
local expected_lines = {}
|
||||
funcs.termopen({ nvim_prog, '-u', 'NONE', '-i', 'NONE', '-n', '-c', 'set shortmess+=A' }, {
|
||||
fn.termopen({ nvim_prog, '-u', 'NONE', '-i', 'NONE', '-n', '-c', 'set shortmess+=A' }, {
|
||||
env = { VIMRUNTIME = os.getenv('VIMRUNTIME') },
|
||||
})
|
||||
|
||||
local b = meths.nvim_get_current_buf()
|
||||
ok(meths.nvim_buf_attach(b, true, {}))
|
||||
local b = api.nvim_get_current_buf()
|
||||
ok(api.nvim_buf_attach(b, true, {}))
|
||||
|
||||
for _ = 1, 22 do
|
||||
table.insert(expected_lines, '~')
|
||||
|
||||
@@ -4,14 +4,14 @@ local NIL = vim.NIL
|
||||
local clear = helpers.clear
|
||||
local command = helpers.command
|
||||
local eq = helpers.eq
|
||||
local meths = helpers.meths
|
||||
local api = helpers.api
|
||||
local matches = helpers.matches
|
||||
local source = helpers.source
|
||||
local pcall_err = helpers.pcall_err
|
||||
local exec_lua = helpers.exec_lua
|
||||
local assert_alive = helpers.assert_alive
|
||||
local feed = helpers.feed
|
||||
local funcs = helpers.funcs
|
||||
local fn = helpers.fn
|
||||
|
||||
describe('nvim_get_commands', function()
|
||||
local cmd_dict = {
|
||||
@@ -49,39 +49,39 @@ describe('nvim_get_commands', function()
|
||||
before_each(clear)
|
||||
|
||||
it('gets empty list if no commands were defined', function()
|
||||
eq({}, meths.nvim_get_commands({ builtin = false }))
|
||||
eq({}, api.nvim_get_commands({ builtin = false }))
|
||||
end)
|
||||
|
||||
it('validation', function()
|
||||
eq('builtin=true not implemented', pcall_err(meths.nvim_get_commands, { builtin = true }))
|
||||
eq("Invalid key: 'foo'", pcall_err(meths.nvim_get_commands, { foo = 'blah' }))
|
||||
eq('builtin=true not implemented', pcall_err(api.nvim_get_commands, { builtin = true }))
|
||||
eq("Invalid key: 'foo'", pcall_err(api.nvim_get_commands, { foo = 'blah' }))
|
||||
end)
|
||||
|
||||
it('gets global user-defined commands', function()
|
||||
-- Define a command.
|
||||
command('command -nargs=1 Hello echo "Hello World"')
|
||||
eq({ Hello = cmd_dict }, meths.nvim_get_commands({ builtin = false }))
|
||||
eq({ Hello = cmd_dict }, api.nvim_get_commands({ builtin = false }))
|
||||
-- Define another command.
|
||||
command('command -nargs=? Pwd pwd')
|
||||
eq({ Hello = cmd_dict, Pwd = cmd_dict2 }, meths.nvim_get_commands({ builtin = false }))
|
||||
eq({ Hello = cmd_dict, Pwd = cmd_dict2 }, api.nvim_get_commands({ builtin = false }))
|
||||
-- Delete a command.
|
||||
command('delcommand Pwd')
|
||||
eq({ Hello = cmd_dict }, meths.nvim_get_commands({ builtin = false }))
|
||||
eq({ Hello = cmd_dict }, api.nvim_get_commands({ builtin = false }))
|
||||
end)
|
||||
|
||||
it('gets buffer-local user-defined commands', function()
|
||||
-- Define a buffer-local command.
|
||||
command('command -buffer -nargs=1 Hello echo "Hello World"')
|
||||
eq({ Hello = cmd_dict }, meths.nvim_buf_get_commands(0, { builtin = false }))
|
||||
eq({ Hello = cmd_dict }, api.nvim_buf_get_commands(0, { builtin = false }))
|
||||
-- Define another buffer-local command.
|
||||
command('command -buffer -nargs=? Pwd pwd')
|
||||
eq({ Hello = cmd_dict, Pwd = cmd_dict2 }, meths.nvim_buf_get_commands(0, { builtin = false }))
|
||||
eq({ Hello = cmd_dict, Pwd = cmd_dict2 }, api.nvim_buf_get_commands(0, { builtin = false }))
|
||||
-- Delete a command.
|
||||
command('delcommand Pwd')
|
||||
eq({ Hello = cmd_dict }, meths.nvim_buf_get_commands(0, { builtin = false }))
|
||||
eq({ Hello = cmd_dict }, api.nvim_buf_get_commands(0, { builtin = false }))
|
||||
|
||||
-- {builtin=true} always returns empty for buffer-local case.
|
||||
eq({}, meths.nvim_buf_get_commands(0, { builtin = true }))
|
||||
eq({}, api.nvim_buf_get_commands(0, { builtin = true }))
|
||||
end)
|
||||
|
||||
it('gets various command attributes', function()
|
||||
@@ -169,9 +169,9 @@ describe('nvim_get_commands', function()
|
||||
let s:foo = 1
|
||||
command -complete=custom,ListUsers -nargs=+ Finger !finger <args>
|
||||
]])
|
||||
eq({ Finger = cmd1 }, meths.nvim_get_commands({ builtin = false }))
|
||||
eq({ Finger = cmd1 }, api.nvim_get_commands({ builtin = false }))
|
||||
command('command -nargs=1 -complete=dir -addr=arguments -count=10 TestCmd pwd <args>')
|
||||
eq({ Finger = cmd1, TestCmd = cmd0 }, meths.nvim_get_commands({ builtin = false }))
|
||||
eq({ Finger = cmd1, TestCmd = cmd0 }, api.nvim_get_commands({ builtin = false }))
|
||||
|
||||
source([[
|
||||
function! s:foo() abort
|
||||
@@ -191,7 +191,7 @@ describe('nvim_get_commands', function()
|
||||
-- TODO(justinmk): Order is stable but undefined. Sort before return?
|
||||
eq(
|
||||
{ Cmd2 = cmd2, Cmd3 = cmd3, Cmd4 = cmd4, Finger = cmd1, TestCmd = cmd0 },
|
||||
meths.nvim_get_commands({ builtin = false })
|
||||
api.nvim_get_commands({ builtin = false })
|
||||
)
|
||||
end)
|
||||
end)
|
||||
@@ -200,9 +200,9 @@ describe('nvim_create_user_command', function()
|
||||
before_each(clear)
|
||||
|
||||
it('works with strings', function()
|
||||
meths.nvim_create_user_command('SomeCommand', 'let g:command_fired = <args>', { nargs = 1 })
|
||||
api.nvim_create_user_command('SomeCommand', 'let g:command_fired = <args>', { nargs = 1 })
|
||||
command('SomeCommand 42')
|
||||
eq(42, meths.nvim_eval('g:command_fired'))
|
||||
eq(42, api.nvim_eval('g:command_fired'))
|
||||
end)
|
||||
|
||||
it('works with Lua functions', function()
|
||||
@@ -644,10 +644,10 @@ describe('nvim_create_user_command', function()
|
||||
end)
|
||||
|
||||
it('can define buffer-local commands', function()
|
||||
local bufnr = meths.nvim_create_buf(false, false)
|
||||
meths.nvim_buf_create_user_command(bufnr, 'Hello', '', {})
|
||||
local bufnr = api.nvim_create_buf(false, false)
|
||||
api.nvim_buf_create_user_command(bufnr, 'Hello', '', {})
|
||||
matches('Not an editor command: Hello', pcall_err(command, 'Hello'))
|
||||
meths.nvim_set_current_buf(bufnr)
|
||||
api.nvim_set_current_buf(bufnr)
|
||||
command('Hello')
|
||||
assert_alive()
|
||||
end)
|
||||
@@ -670,9 +670,9 @@ describe('nvim_create_user_command', function()
|
||||
]]
|
||||
|
||||
feed(':Test a<Tab>')
|
||||
eq('Test aaa', funcs.getcmdline())
|
||||
eq('Test aaa', fn.getcmdline())
|
||||
feed('<C-U>Test b<Tab>')
|
||||
eq('Test bbb', funcs.getcmdline())
|
||||
eq('Test bbb', fn.getcmdline())
|
||||
end)
|
||||
|
||||
it('does not allow invalid command names', function()
|
||||
@@ -729,29 +729,29 @@ describe('nvim_create_user_command', function()
|
||||
vim.api.nvim_cmd({ cmd = 'echo', args = { '&verbose' }, mods = opts.smods }, {})
|
||||
end, {})
|
||||
]]
|
||||
eq('3', meths.nvim_cmd({ cmd = 'MyEcho', mods = { verbose = 3 } }, { output = true }))
|
||||
eq('3', api.nvim_cmd({ cmd = 'MyEcho', mods = { verbose = 3 } }, { output = true }))
|
||||
|
||||
eq(1, #meths.nvim_list_tabpages())
|
||||
eq(1, #api.nvim_list_tabpages())
|
||||
exec_lua [[
|
||||
vim.api.nvim_create_user_command('MySplit', function(opts)
|
||||
vim.api.nvim_cmd({ cmd = 'split', mods = opts.smods }, {})
|
||||
end, {})
|
||||
]]
|
||||
meths.nvim_cmd({ cmd = 'MySplit' }, {})
|
||||
eq(1, #meths.nvim_list_tabpages())
|
||||
eq(2, #meths.nvim_list_wins())
|
||||
meths.nvim_cmd({ cmd = 'MySplit', mods = { tab = 1 } }, {})
|
||||
eq(2, #meths.nvim_list_tabpages())
|
||||
eq(2, funcs.tabpagenr())
|
||||
meths.nvim_cmd({ cmd = 'MySplit', mods = { tab = 1 } }, {})
|
||||
eq(3, #meths.nvim_list_tabpages())
|
||||
eq(2, funcs.tabpagenr())
|
||||
meths.nvim_cmd({ cmd = 'MySplit', mods = { tab = 3 } }, {})
|
||||
eq(4, #meths.nvim_list_tabpages())
|
||||
eq(4, funcs.tabpagenr())
|
||||
meths.nvim_cmd({ cmd = 'MySplit', mods = { tab = 0 } }, {})
|
||||
eq(5, #meths.nvim_list_tabpages())
|
||||
eq(1, funcs.tabpagenr())
|
||||
api.nvim_cmd({ cmd = 'MySplit' }, {})
|
||||
eq(1, #api.nvim_list_tabpages())
|
||||
eq(2, #api.nvim_list_wins())
|
||||
api.nvim_cmd({ cmd = 'MySplit', mods = { tab = 1 } }, {})
|
||||
eq(2, #api.nvim_list_tabpages())
|
||||
eq(2, fn.tabpagenr())
|
||||
api.nvim_cmd({ cmd = 'MySplit', mods = { tab = 1 } }, {})
|
||||
eq(3, #api.nvim_list_tabpages())
|
||||
eq(2, fn.tabpagenr())
|
||||
api.nvim_cmd({ cmd = 'MySplit', mods = { tab = 3 } }, {})
|
||||
eq(4, #api.nvim_list_tabpages())
|
||||
eq(4, fn.tabpagenr())
|
||||
api.nvim_cmd({ cmd = 'MySplit', mods = { tab = 0 } }, {})
|
||||
eq(5, #api.nvim_list_tabpages())
|
||||
eq(1, fn.tabpagenr())
|
||||
end)
|
||||
end)
|
||||
|
||||
@@ -759,16 +759,16 @@ describe('nvim_del_user_command', function()
|
||||
before_each(clear)
|
||||
|
||||
it('can delete global commands', function()
|
||||
meths.nvim_create_user_command('Hello', 'echo "Hi"', {})
|
||||
api.nvim_create_user_command('Hello', 'echo "Hi"', {})
|
||||
command('Hello')
|
||||
meths.nvim_del_user_command('Hello')
|
||||
api.nvim_del_user_command('Hello')
|
||||
matches('Not an editor command: Hello', pcall_err(command, 'Hello'))
|
||||
end)
|
||||
|
||||
it('can delete buffer-local commands', function()
|
||||
meths.nvim_buf_create_user_command(0, 'Hello', 'echo "Hi"', {})
|
||||
api.nvim_buf_create_user_command(0, 'Hello', 'echo "Hi"', {})
|
||||
command('Hello')
|
||||
meths.nvim_buf_del_user_command(0, 'Hello')
|
||||
api.nvim_buf_del_user_command(0, 'Hello')
|
||||
matches('Not an editor command: Hello', pcall_err(command, 'Hello'))
|
||||
end)
|
||||
end)
|
||||
|
||||
@@ -10,7 +10,7 @@ local feed = helpers.feed
|
||||
local clear = helpers.clear
|
||||
local command = helpers.command
|
||||
local exec = helpers.exec
|
||||
local meths = helpers.meths
|
||||
local api = helpers.api
|
||||
local assert_alive = helpers.assert_alive
|
||||
|
||||
local function expect(contents)
|
||||
@@ -24,21 +24,21 @@ local function set_extmark(ns_id, id, line, col, opts)
|
||||
if id ~= nil and id ~= 0 then
|
||||
opts.id = id
|
||||
end
|
||||
return meths.nvim_buf_set_extmark(0, ns_id, line, col, opts)
|
||||
return api.nvim_buf_set_extmark(0, ns_id, line, col, opts)
|
||||
end
|
||||
|
||||
local function get_extmarks(ns_id, start, end_, opts)
|
||||
if opts == nil then
|
||||
opts = {}
|
||||
end
|
||||
return meths.nvim_buf_get_extmarks(0, ns_id, start, end_, opts)
|
||||
return api.nvim_buf_get_extmarks(0, ns_id, start, end_, opts)
|
||||
end
|
||||
|
||||
local function get_extmark_by_id(ns_id, id, opts)
|
||||
if opts == nil then
|
||||
opts = {}
|
||||
end
|
||||
return meths.nvim_buf_get_extmark_by_id(0, ns_id, id, opts)
|
||||
return api.nvim_buf_get_extmark_by_id(0, ns_id, id, opts)
|
||||
end
|
||||
|
||||
local function check_undo_redo(ns, mark, sr, sc, er, ec) --s = start, e = end
|
||||
@@ -196,11 +196,11 @@ describe('API/extmarks', function()
|
||||
eq({ row, col }, rv)
|
||||
|
||||
-- remove the test marks
|
||||
eq(true, meths.nvim_buf_del_extmark(0, ns, marks[1]))
|
||||
eq(false, meths.nvim_buf_del_extmark(0, ns, marks[1]))
|
||||
eq(true, meths.nvim_buf_del_extmark(0, ns, marks[2]))
|
||||
eq(false, meths.nvim_buf_del_extmark(0, ns, marks[3]))
|
||||
eq(false, meths.nvim_buf_del_extmark(0, ns, 1000))
|
||||
eq(true, api.nvim_buf_del_extmark(0, ns, marks[1]))
|
||||
eq(false, api.nvim_buf_del_extmark(0, ns, marks[1]))
|
||||
eq(true, api.nvim_buf_del_extmark(0, ns, marks[2]))
|
||||
eq(false, api.nvim_buf_del_extmark(0, ns, marks[3]))
|
||||
eq(false, api.nvim_buf_del_extmark(0, ns, 1000))
|
||||
end)
|
||||
|
||||
it('can clear a specific namespace range', function()
|
||||
@@ -208,7 +208,7 @@ describe('API/extmarks', function()
|
||||
set_extmark(ns2, 1, 0, 1)
|
||||
-- force a new undo buffer
|
||||
feed('o<esc>')
|
||||
meths.nvim_buf_clear_namespace(0, ns2, 0, -1)
|
||||
api.nvim_buf_clear_namespace(0, ns2, 0, -1)
|
||||
eq({ { 1, 0, 1 } }, get_extmarks(ns, { 0, 0 }, { -1, -1 }))
|
||||
eq({}, get_extmarks(ns2, { 0, 0 }, { -1, -1 }))
|
||||
feed('u')
|
||||
@@ -224,7 +224,7 @@ describe('API/extmarks', function()
|
||||
set_extmark(ns2, 1, 0, 1)
|
||||
-- force a new undo buffer
|
||||
feed('o<esc>')
|
||||
meths.nvim_buf_clear_namespace(0, -1, 0, -1)
|
||||
api.nvim_buf_clear_namespace(0, -1, 0, -1)
|
||||
eq({}, get_extmarks(ns, { 0, 0 }, { -1, -1 }))
|
||||
eq({}, get_extmarks(ns2, { 0, 0 }, { -1, -1 }))
|
||||
feed('u')
|
||||
@@ -242,14 +242,14 @@ describe('API/extmarks', function()
|
||||
eq({ { 1, 0, 0 }, { 2, 1, 0 } }, get_extmarks(ns, { 0, 0 }, { -1, -1 }))
|
||||
feed('dd')
|
||||
eq({ { 1, 1, 0 }, { 2, 1, 0 } }, get_extmarks(ns, { 0, 0 }, { -1, -1 }))
|
||||
meths.nvim_buf_clear_namespace(0, ns, 0, -1)
|
||||
api.nvim_buf_clear_namespace(0, ns, 0, -1)
|
||||
eq({}, get_extmarks(ns, { 0, 0 }, { -1, -1 }))
|
||||
set_extmark(ns, 1, 0, 0, { right_gravity = false })
|
||||
set_extmark(ns, 2, 1, 0, { right_gravity = false })
|
||||
eq({ { 1, 0, 0 }, { 2, 1, 0 } }, get_extmarks(ns, { 0, 0 }, { -1, -1 }))
|
||||
feed('u')
|
||||
eq({ { 1, 0, 0 }, { 2, 1, 0 } }, get_extmarks(ns, { 0, 0 }, { -1, -1 }))
|
||||
meths.nvim_buf_clear_namespace(0, ns, 0, -1)
|
||||
api.nvim_buf_clear_namespace(0, ns, 0, -1)
|
||||
end)
|
||||
|
||||
it('querying for information and ranges', function()
|
||||
@@ -931,7 +931,7 @@ describe('API/extmarks', function()
|
||||
|
||||
-- Test unset
|
||||
feed('o<esc>')
|
||||
meths.nvim_buf_del_extmark(0, ns, marks[3])
|
||||
api.nvim_buf_del_extmark(0, ns, marks[3])
|
||||
feed('u')
|
||||
rv = get_extmarks(ns, { 0, 0 }, { -1, -1 })
|
||||
-- undo does NOT restore deleted marks
|
||||
@@ -987,10 +987,10 @@ describe('API/extmarks', function()
|
||||
rv = get_extmarks(ns2, positions[2], positions[1])
|
||||
eq(2, #rv)
|
||||
|
||||
meths.nvim_buf_del_extmark(0, ns, marks[1])
|
||||
api.nvim_buf_del_extmark(0, ns, marks[1])
|
||||
rv = get_extmarks(ns, { 0, 0 }, { -1, -1 })
|
||||
eq(2, #rv)
|
||||
meths.nvim_buf_del_extmark(0, ns2, marks[1])
|
||||
api.nvim_buf_del_extmark(0, ns2, marks[1])
|
||||
rv = get_extmarks(ns2, { 0, 0 }, { -1, -1 })
|
||||
eq(2, #rv)
|
||||
end)
|
||||
@@ -1427,7 +1427,7 @@ describe('API/extmarks', function()
|
||||
"Invalid 'ns_id': 3",
|
||||
pcall_err(set_extmark, ns_invalid, marks[1], positions[1][1], positions[1][2])
|
||||
)
|
||||
eq("Invalid 'ns_id': 3", pcall_err(meths.nvim_buf_del_extmark, 0, ns_invalid, marks[1]))
|
||||
eq("Invalid 'ns_id': 3", pcall_err(api.nvim_buf_del_extmark, 0, ns_invalid, marks[1]))
|
||||
eq("Invalid 'ns_id': 3", pcall_err(get_extmarks, ns_invalid, positions[1], positions[2]))
|
||||
eq("Invalid 'ns_id': 3", pcall_err(get_extmark_by_id, ns_invalid, marks[1]))
|
||||
end)
|
||||
@@ -1470,7 +1470,7 @@ describe('API/extmarks', function()
|
||||
|
||||
it('in read-only buffer', function()
|
||||
command('view! runtime/doc/help.txt')
|
||||
eq(true, meths.nvim_get_option_value('ro', {}))
|
||||
eq(true, api.nvim_get_option_value('ro', {}))
|
||||
local id = set_extmark(ns, 0, 0, 2)
|
||||
eq({ { id, 0, 2 } }, get_extmarks(ns, 0, -1))
|
||||
end)
|
||||
@@ -1478,8 +1478,8 @@ describe('API/extmarks', function()
|
||||
it('can set a mark to other buffer', function()
|
||||
local buf = request('nvim_create_buf', 0, 1)
|
||||
request('nvim_buf_set_lines', buf, 0, -1, 1, { '', '' })
|
||||
local id = meths.nvim_buf_set_extmark(buf, ns, 1, 0, {})
|
||||
eq({ { id, 1, 0 } }, meths.nvim_buf_get_extmarks(buf, ns, 0, -1, {}))
|
||||
local id = api.nvim_buf_set_extmark(buf, ns, 1, 0, {})
|
||||
eq({ { id, 1, 0 } }, api.nvim_buf_get_extmarks(buf, ns, 0, -1, {}))
|
||||
end)
|
||||
|
||||
it('does not crash with append/delete/undo sequence', function()
|
||||
@@ -1495,30 +1495,30 @@ describe('API/extmarks', function()
|
||||
it('works with left and right gravity', function()
|
||||
-- right gravity should move with inserted text, while
|
||||
-- left gravity should stay in place.
|
||||
meths.nvim_buf_set_extmark(0, ns, 0, 5, { right_gravity = false })
|
||||
meths.nvim_buf_set_extmark(0, ns, 0, 5, { right_gravity = true })
|
||||
api.nvim_buf_set_extmark(0, ns, 0, 5, { right_gravity = false })
|
||||
api.nvim_buf_set_extmark(0, ns, 0, 5, { right_gravity = true })
|
||||
feed([[Aasdfasdf]])
|
||||
|
||||
eq({ { 1, 0, 5 }, { 2, 0, 13 } }, meths.nvim_buf_get_extmarks(0, ns, 0, -1, {}))
|
||||
eq({ { 1, 0, 5 }, { 2, 0, 13 } }, api.nvim_buf_get_extmarks(0, ns, 0, -1, {}))
|
||||
|
||||
-- but both move when text is inserted before
|
||||
feed([[<esc>Iasdf<esc>]])
|
||||
-- eq({}, meths.nvim_buf_get_lines(0, 0, -1, true))
|
||||
eq({ { 1, 0, 9 }, { 2, 0, 17 } }, meths.nvim_buf_get_extmarks(0, ns, 0, -1, {}))
|
||||
-- eq({}, api.nvim_buf_get_lines(0, 0, -1, true))
|
||||
eq({ { 1, 0, 9 }, { 2, 0, 17 } }, api.nvim_buf_get_extmarks(0, ns, 0, -1, {}))
|
||||
|
||||
-- clear text
|
||||
meths.nvim_buf_set_text(0, 0, 0, 0, 17, {})
|
||||
api.nvim_buf_set_text(0, 0, 0, 0, 17, {})
|
||||
|
||||
-- handles set_text correctly as well
|
||||
eq({ { 1, 0, 0 }, { 2, 0, 0 } }, meths.nvim_buf_get_extmarks(0, ns, 0, -1, {}))
|
||||
meths.nvim_buf_set_text(0, 0, 0, 0, 0, { 'asdfasdf' })
|
||||
eq({ { 1, 0, 0 }, { 2, 0, 8 } }, meths.nvim_buf_get_extmarks(0, ns, 0, -1, {}))
|
||||
eq({ { 1, 0, 0 }, { 2, 0, 0 } }, api.nvim_buf_get_extmarks(0, ns, 0, -1, {}))
|
||||
api.nvim_buf_set_text(0, 0, 0, 0, 0, { 'asdfasdf' })
|
||||
eq({ { 1, 0, 0 }, { 2, 0, 8 } }, api.nvim_buf_get_extmarks(0, ns, 0, -1, {}))
|
||||
|
||||
feed('u')
|
||||
-- handles pasting
|
||||
exec([[let @a='asdfasdf']])
|
||||
feed([["ap]])
|
||||
eq({ { 1, 0, 0 }, { 2, 0, 8 } }, meths.nvim_buf_get_extmarks(0, ns, 0, -1, {}))
|
||||
eq({ { 1, 0, 0 }, { 2, 0, 8 } }, api.nvim_buf_get_extmarks(0, ns, 0, -1, {}))
|
||||
end)
|
||||
|
||||
it('can accept "end_row" or "end_line" #16548', function()
|
||||
@@ -1545,7 +1545,7 @@ describe('API/extmarks', function()
|
||||
it('in prompt buffer', function()
|
||||
feed('dd')
|
||||
local id = set_extmark(ns, marks[1], 0, 0, {})
|
||||
meths.nvim_set_option_value('buftype', 'prompt', {})
|
||||
api.nvim_set_option_value('buftype', 'prompt', {})
|
||||
feed('i<esc>')
|
||||
eq({ { id, 0, 2 } }, get_extmarks(ns, 0, -1))
|
||||
end)
|
||||
@@ -1639,7 +1639,7 @@ describe('API/extmarks', function()
|
||||
right_gravity = true,
|
||||
},
|
||||
}, get_extmark_by_id(ns, marks[3], { details = true }))
|
||||
meths.nvim_buf_clear_namespace(0, ns, 0, -1)
|
||||
api.nvim_buf_clear_namespace(0, ns, 0, -1)
|
||||
-- legacy sign mark includes sign name
|
||||
command('sign define sign1 text=s1 texthl=Title linehl=LineNR numhl=Normal culhl=CursorLine')
|
||||
command('sign place 1 name=sign1 line=1')
|
||||
@@ -1693,7 +1693,7 @@ describe('API/extmarks', function()
|
||||
screen = Screen.new(40, 6)
|
||||
screen:attach()
|
||||
feed('dd6iaaa bbb ccc<CR><ESC>gg')
|
||||
meths.nvim_set_option_value('signcolumn', 'auto:2', {})
|
||||
api.nvim_set_option_value('signcolumn', 'auto:2', {})
|
||||
set_extmark(ns, 1, 0, 0, { invalidate = true, sign_text = 'S1', end_row = 1 })
|
||||
set_extmark(ns, 2, 1, 0, { invalidate = true, sign_text = 'S2', end_row = 2 })
|
||||
-- mark with invalidate is removed
|
||||
@@ -1768,7 +1768,7 @@ describe('Extmarks buffer api with many marks', function()
|
||||
for i = 1, 30 do
|
||||
lines[#lines + 1] = string.rep('x ', i)
|
||||
end
|
||||
meths.nvim_buf_set_lines(0, 0, -1, true, lines)
|
||||
api.nvim_buf_set_lines(0, 0, -1, true, lines)
|
||||
local ns = ns1
|
||||
local q = 0
|
||||
for i = 0, 29 do
|
||||
@@ -1802,16 +1802,16 @@ describe('Extmarks buffer api with many marks', function()
|
||||
end)
|
||||
|
||||
it('can clear all marks in ns', function()
|
||||
meths.nvim_buf_clear_namespace(0, ns1, 0, -1)
|
||||
api.nvim_buf_clear_namespace(0, ns1, 0, -1)
|
||||
eq({}, get_marks(ns1))
|
||||
eq(ns_marks[ns2], get_marks(ns2))
|
||||
meths.nvim_buf_clear_namespace(0, ns2, 0, -1)
|
||||
api.nvim_buf_clear_namespace(0, ns2, 0, -1)
|
||||
eq({}, get_marks(ns1))
|
||||
eq({}, get_marks(ns2))
|
||||
end)
|
||||
|
||||
it('can clear line range', function()
|
||||
meths.nvim_buf_clear_namespace(0, ns1, 10, 20)
|
||||
api.nvim_buf_clear_namespace(0, ns1, 10, 20)
|
||||
for id, mark in pairs(ns_marks[ns1]) do
|
||||
if 10 <= mark[1] and mark[1] < 20 then
|
||||
ns_marks[ns1][id] = nil
|
||||
|
||||
@@ -4,8 +4,8 @@ local Screen = require('test.functional.ui.screen')
|
||||
local eq, eval = helpers.eq, helpers.eval
|
||||
local command = helpers.command
|
||||
local exec_capture = helpers.exec_capture
|
||||
local meths = helpers.meths
|
||||
local funcs = helpers.funcs
|
||||
local api = helpers.api
|
||||
local fn = helpers.fn
|
||||
local pcall_err = helpers.pcall_err
|
||||
local ok = helpers.ok
|
||||
local assert_alive = helpers.assert_alive
|
||||
@@ -52,128 +52,125 @@ describe('API: highlight', function()
|
||||
|
||||
it('nvim_get_hl_by_id', function()
|
||||
local hl_id = eval("hlID('NewHighlight')")
|
||||
eq(expected_cterm, meths.nvim_get_hl_by_id(hl_id, false))
|
||||
eq(expected_cterm, api.nvim_get_hl_by_id(hl_id, false))
|
||||
|
||||
hl_id = eval("hlID('NewHighlight')")
|
||||
-- Test valid id.
|
||||
eq(expected_rgb, meths.nvim_get_hl_by_id(hl_id, true))
|
||||
eq(expected_rgb, api.nvim_get_hl_by_id(hl_id, true))
|
||||
|
||||
-- Test invalid id.
|
||||
eq('Invalid highlight id: 30000', pcall_err(meths.nvim_get_hl_by_id, 30000, false))
|
||||
eq('Invalid highlight id: 30000', pcall_err(api.nvim_get_hl_by_id, 30000, false))
|
||||
|
||||
-- Test all highlight properties.
|
||||
command('hi NewHighlight gui=underline,bold,italic,reverse,strikethrough,altfont,nocombine')
|
||||
eq(expected_rgb2, meths.nvim_get_hl_by_id(hl_id, true))
|
||||
eq(expected_rgb2, api.nvim_get_hl_by_id(hl_id, true))
|
||||
|
||||
-- Test undercurl
|
||||
command('hi NewHighlight gui=undercurl')
|
||||
eq(expected_undercurl, meths.nvim_get_hl_by_id(hl_id, true))
|
||||
eq(expected_undercurl, api.nvim_get_hl_by_id(hl_id, true))
|
||||
|
||||
-- Test nil argument.
|
||||
eq(
|
||||
'Wrong type for argument 1 when calling nvim_get_hl_by_id, expecting Integer',
|
||||
pcall_err(meths.nvim_get_hl_by_id, { nil }, false)
|
||||
pcall_err(api.nvim_get_hl_by_id, { nil }, false)
|
||||
)
|
||||
|
||||
-- Test 0 argument.
|
||||
eq('Invalid highlight id: 0', pcall_err(meths.nvim_get_hl_by_id, 0, false))
|
||||
eq('Invalid highlight id: 0', pcall_err(api.nvim_get_hl_by_id, 0, false))
|
||||
|
||||
-- Test -1 argument.
|
||||
eq('Invalid highlight id: -1', pcall_err(meths.nvim_get_hl_by_id, -1, false))
|
||||
eq('Invalid highlight id: -1', pcall_err(api.nvim_get_hl_by_id, -1, false))
|
||||
|
||||
-- Test highlight group without ctermbg value.
|
||||
command('hi Normal ctermfg=red ctermbg=yellow')
|
||||
command('hi NewConstant ctermfg=green guifg=white guibg=blue')
|
||||
hl_id = eval("hlID('NewConstant')")
|
||||
eq({ foreground = 10 }, meths.nvim_get_hl_by_id(hl_id, false))
|
||||
eq({ foreground = 10 }, api.nvim_get_hl_by_id(hl_id, false))
|
||||
|
||||
-- Test highlight group without ctermfg value.
|
||||
command('hi clear NewConstant')
|
||||
command('hi NewConstant ctermbg=Magenta guifg=white guibg=blue')
|
||||
eq({ background = 13 }, meths.nvim_get_hl_by_id(hl_id, false))
|
||||
eq({ background = 13 }, api.nvim_get_hl_by_id(hl_id, false))
|
||||
|
||||
-- Test highlight group with ctermfg and ctermbg values.
|
||||
command('hi clear NewConstant')
|
||||
command('hi NewConstant ctermfg=green ctermbg=Magenta guifg=white guibg=blue')
|
||||
eq({ foreground = 10, background = 13 }, meths.nvim_get_hl_by_id(hl_id, false))
|
||||
eq({ foreground = 10, background = 13 }, api.nvim_get_hl_by_id(hl_id, false))
|
||||
end)
|
||||
|
||||
it('nvim_get_hl_by_name', function()
|
||||
local expected_normal = { background = Screen.colors.Yellow, foreground = Screen.colors.Red }
|
||||
|
||||
-- Test `Normal` default values.
|
||||
eq({}, meths.nvim_get_hl_by_name('Normal', true))
|
||||
eq({}, api.nvim_get_hl_by_name('Normal', true))
|
||||
|
||||
eq(expected_cterm, meths.nvim_get_hl_by_name('NewHighlight', false))
|
||||
eq(expected_rgb, meths.nvim_get_hl_by_name('NewHighlight', true))
|
||||
eq(expected_cterm, api.nvim_get_hl_by_name('NewHighlight', false))
|
||||
eq(expected_rgb, api.nvim_get_hl_by_name('NewHighlight', true))
|
||||
|
||||
-- Test `Normal` modified values.
|
||||
command('hi Normal guifg=red guibg=yellow')
|
||||
eq(expected_normal, meths.nvim_get_hl_by_name('Normal', true))
|
||||
eq(expected_normal, api.nvim_get_hl_by_name('Normal', true))
|
||||
|
||||
-- Test invalid name.
|
||||
eq(
|
||||
"Invalid highlight name: 'unknown_highlight'",
|
||||
pcall_err(meths.nvim_get_hl_by_name, 'unknown_highlight', false)
|
||||
pcall_err(api.nvim_get_hl_by_name, 'unknown_highlight', false)
|
||||
)
|
||||
|
||||
-- Test nil argument.
|
||||
eq(
|
||||
'Wrong type for argument 1 when calling nvim_get_hl_by_name, expecting String',
|
||||
pcall_err(meths.nvim_get_hl_by_name, { nil }, false)
|
||||
pcall_err(api.nvim_get_hl_by_name, { nil }, false)
|
||||
)
|
||||
|
||||
-- Test empty string argument.
|
||||
eq('Invalid highlight name', pcall_err(meths.nvim_get_hl_by_name, '', false))
|
||||
eq('Invalid highlight name', pcall_err(api.nvim_get_hl_by_name, '', false))
|
||||
|
||||
-- Test "standout" attribute. #8054
|
||||
eq({ underline = true }, meths.nvim_get_hl_by_name('cursorline', 0))
|
||||
eq({ underline = true }, api.nvim_get_hl_by_name('cursorline', 0))
|
||||
command('hi CursorLine cterm=standout,underline term=standout,underline gui=standout,underline')
|
||||
command('set cursorline')
|
||||
eq({ underline = true, standout = true }, meths.nvim_get_hl_by_name('cursorline', 0))
|
||||
eq({ underline = true, standout = true }, api.nvim_get_hl_by_name('cursorline', 0))
|
||||
|
||||
-- Test cterm & Normal values. #18024 (tail) & #18980
|
||||
-- Ensure Normal, and groups that match Normal return their fg & bg cterm values
|
||||
meths.nvim_set_hl(0, 'Normal', { ctermfg = 17, ctermbg = 213 })
|
||||
meths.nvim_set_hl(0, 'NotNormal', { ctermfg = 17, ctermbg = 213, nocombine = true })
|
||||
api.nvim_set_hl(0, 'Normal', { ctermfg = 17, ctermbg = 213 })
|
||||
api.nvim_set_hl(0, 'NotNormal', { ctermfg = 17, ctermbg = 213, nocombine = true })
|
||||
-- Note colors are "cterm" values, not rgb-as-ints
|
||||
eq({ foreground = 17, background = 213 }, meths.nvim_get_hl_by_name('Normal', false))
|
||||
eq({ foreground = 17, background = 213 }, api.nvim_get_hl_by_name('Normal', false))
|
||||
eq(
|
||||
{ foreground = 17, background = 213, nocombine = true },
|
||||
meths.nvim_get_hl_by_name('NotNormal', false)
|
||||
api.nvim_get_hl_by_name('NotNormal', false)
|
||||
)
|
||||
end)
|
||||
|
||||
it('nvim_get_hl_id_by_name', function()
|
||||
-- precondition: use a hl group that does not yet exist
|
||||
eq(
|
||||
"Invalid highlight name: 'Shrubbery'",
|
||||
pcall_err(meths.nvim_get_hl_by_name, 'Shrubbery', true)
|
||||
)
|
||||
eq(0, funcs.hlID('Shrubbery'))
|
||||
eq("Invalid highlight name: 'Shrubbery'", pcall_err(api.nvim_get_hl_by_name, 'Shrubbery', true))
|
||||
eq(0, fn.hlID('Shrubbery'))
|
||||
|
||||
local hl_id = meths.nvim_get_hl_id_by_name('Shrubbery')
|
||||
local hl_id = api.nvim_get_hl_id_by_name('Shrubbery')
|
||||
ok(hl_id > 0)
|
||||
eq(hl_id, funcs.hlID('Shrubbery'))
|
||||
eq(hl_id, fn.hlID('Shrubbery'))
|
||||
|
||||
command('hi Shrubbery guifg=#888888 guibg=#888888')
|
||||
eq(
|
||||
{ foreground = tonumber('0x888888'), background = tonumber('0x888888') },
|
||||
meths.nvim_get_hl_by_id(hl_id, true)
|
||||
api.nvim_get_hl_by_id(hl_id, true)
|
||||
)
|
||||
eq(
|
||||
{ foreground = tonumber('0x888888'), background = tonumber('0x888888') },
|
||||
meths.nvim_get_hl_by_name('Shrubbery', true)
|
||||
api.nvim_get_hl_by_name('Shrubbery', true)
|
||||
)
|
||||
end)
|
||||
|
||||
it("nvim_buf_add_highlight to other buffer doesn't crash if undo is disabled #12873", function()
|
||||
command('vsplit file')
|
||||
local err, _ = pcall(meths.nvim_set_option_value, 'undofile', false, { buf = 1 })
|
||||
local err, _ = pcall(api.nvim_set_option_value, 'undofile', false, { buf = 1 })
|
||||
eq(true, err)
|
||||
err, _ = pcall(meths.nvim_set_option_value, 'undolevels', -1, { buf = 1 })
|
||||
err, _ = pcall(api.nvim_set_option_value, 'undolevels', -1, { buf = 1 })
|
||||
eq(true, err)
|
||||
err, _ = pcall(meths.nvim_buf_add_highlight, 1, -1, 'Question', 0, 0, -1)
|
||||
err, _ = pcall(api.nvim_buf_add_highlight, 1, -1, 'Question', 0, 0, -1)
|
||||
eq(true, err)
|
||||
assert_alive()
|
||||
end)
|
||||
@@ -244,8 +241,8 @@ describe('API: set highlight', function()
|
||||
}
|
||||
|
||||
local function get_ns()
|
||||
local ns = meths.nvim_create_namespace('Test_set_hl')
|
||||
meths.nvim_set_hl_ns(ns)
|
||||
local ns = api.nvim_create_namespace('Test_set_hl')
|
||||
api.nvim_set_hl_ns(ns)
|
||||
return ns
|
||||
end
|
||||
|
||||
@@ -254,51 +251,51 @@ describe('API: set highlight', function()
|
||||
it('validation', function()
|
||||
eq(
|
||||
"Invalid 'blend': out of range",
|
||||
pcall_err(meths.nvim_set_hl, 0, 'Test_hl3', { fg = '#FF00FF', blend = 999 })
|
||||
pcall_err(api.nvim_set_hl, 0, 'Test_hl3', { fg = '#FF00FF', blend = 999 })
|
||||
)
|
||||
eq(
|
||||
"Invalid 'blend': expected Integer, got Array",
|
||||
pcall_err(meths.nvim_set_hl, 0, 'Test_hl3', { fg = '#FF00FF', blend = {} })
|
||||
pcall_err(api.nvim_set_hl, 0, 'Test_hl3', { fg = '#FF00FF', blend = {} })
|
||||
)
|
||||
end)
|
||||
|
||||
it('can set gui highlight', function()
|
||||
local ns = get_ns()
|
||||
meths.nvim_set_hl(ns, 'Test_hl', highlight1)
|
||||
eq(highlight1, meths.nvim_get_hl_by_name('Test_hl', true))
|
||||
api.nvim_set_hl(ns, 'Test_hl', highlight1)
|
||||
eq(highlight1, api.nvim_get_hl_by_name('Test_hl', true))
|
||||
end)
|
||||
|
||||
it('can set cterm highlight', function()
|
||||
local ns = get_ns()
|
||||
meths.nvim_set_hl(ns, 'Test_hl', highlight2_config)
|
||||
eq(highlight2_result, meths.nvim_get_hl_by_name('Test_hl', false))
|
||||
api.nvim_set_hl(ns, 'Test_hl', highlight2_config)
|
||||
eq(highlight2_result, api.nvim_get_hl_by_name('Test_hl', false))
|
||||
end)
|
||||
|
||||
it('can set empty cterm attr', function()
|
||||
local ns = get_ns()
|
||||
meths.nvim_set_hl(ns, 'Test_hl', { cterm = {} })
|
||||
eq({}, meths.nvim_get_hl_by_name('Test_hl', false))
|
||||
api.nvim_set_hl(ns, 'Test_hl', { cterm = {} })
|
||||
eq({}, api.nvim_get_hl_by_name('Test_hl', false))
|
||||
end)
|
||||
|
||||
it('cterm attr defaults to gui attr', function()
|
||||
local ns = get_ns()
|
||||
meths.nvim_set_hl(ns, 'Test_hl', highlight1)
|
||||
api.nvim_set_hl(ns, 'Test_hl', highlight1)
|
||||
eq({
|
||||
bold = true,
|
||||
italic = true,
|
||||
}, meths.nvim_get_hl_by_name('Test_hl', false))
|
||||
}, api.nvim_get_hl_by_name('Test_hl', false))
|
||||
end)
|
||||
|
||||
it('can overwrite attr for cterm', function()
|
||||
local ns = get_ns()
|
||||
meths.nvim_set_hl(ns, 'Test_hl', highlight3_config)
|
||||
eq(highlight3_result_gui, meths.nvim_get_hl_by_name('Test_hl', true))
|
||||
eq(highlight3_result_cterm, meths.nvim_get_hl_by_name('Test_hl', false))
|
||||
api.nvim_set_hl(ns, 'Test_hl', highlight3_config)
|
||||
eq(highlight3_result_gui, api.nvim_get_hl_by_name('Test_hl', true))
|
||||
eq(highlight3_result_cterm, api.nvim_get_hl_by_name('Test_hl', false))
|
||||
end)
|
||||
|
||||
it('only allows one underline attribute #22371', function()
|
||||
local ns = get_ns()
|
||||
meths.nvim_set_hl(ns, 'Test_hl', {
|
||||
api.nvim_set_hl(ns, 'Test_hl', {
|
||||
underdouble = true,
|
||||
underdotted = true,
|
||||
cterm = {
|
||||
@@ -306,21 +303,21 @@ describe('API: set highlight', function()
|
||||
undercurl = true,
|
||||
},
|
||||
})
|
||||
eq({ undercurl = true }, meths.nvim_get_hl_by_name('Test_hl', false))
|
||||
eq({ underdotted = true }, meths.nvim_get_hl_by_name('Test_hl', true))
|
||||
eq({ undercurl = true }, api.nvim_get_hl_by_name('Test_hl', false))
|
||||
eq({ underdotted = true }, api.nvim_get_hl_by_name('Test_hl', true))
|
||||
end)
|
||||
|
||||
it('can set a highlight in the global namespace', function()
|
||||
meths.nvim_set_hl(0, 'Test_hl', highlight2_config)
|
||||
api.nvim_set_hl(0, 'Test_hl', highlight2_config)
|
||||
eq(
|
||||
'Test_hl xxx cterm=underline,reverse ctermfg=8 ctermbg=15 gui=underline,reverse',
|
||||
exec_capture('highlight Test_hl')
|
||||
)
|
||||
|
||||
meths.nvim_set_hl(0, 'Test_hl', { background = highlight_color.bg })
|
||||
api.nvim_set_hl(0, 'Test_hl', { background = highlight_color.bg })
|
||||
eq('Test_hl xxx guibg=#0032aa', exec_capture('highlight Test_hl'))
|
||||
|
||||
meths.nvim_set_hl(0, 'Test_hl2', highlight3_config)
|
||||
api.nvim_set_hl(0, 'Test_hl2', highlight3_config)
|
||||
eq(
|
||||
'Test_hl2 xxx cterm=italic,reverse,strikethrough,altfont,nocombine ctermfg=8 ctermbg=15 gui=bold,underdashed,italic,reverse,strikethrough,altfont guifg=#ff0000 guibg=#0032aa',
|
||||
exec_capture('highlight Test_hl2')
|
||||
@@ -328,63 +325,63 @@ describe('API: set highlight', function()
|
||||
|
||||
-- Colors are stored with the name they are defined, but
|
||||
-- with canonical casing
|
||||
meths.nvim_set_hl(0, 'Test_hl3', { bg = 'reD', fg = 'bLue' })
|
||||
api.nvim_set_hl(0, 'Test_hl3', { bg = 'reD', fg = 'bLue' })
|
||||
eq('Test_hl3 xxx guifg=Blue guibg=Red', exec_capture('highlight Test_hl3'))
|
||||
end)
|
||||
|
||||
it('can modify a highlight in the global namespace', function()
|
||||
meths.nvim_set_hl(0, 'Test_hl3', { bg = 'red', fg = 'blue' })
|
||||
api.nvim_set_hl(0, 'Test_hl3', { bg = 'red', fg = 'blue' })
|
||||
eq('Test_hl3 xxx guifg=Blue guibg=Red', exec_capture('highlight Test_hl3'))
|
||||
|
||||
meths.nvim_set_hl(0, 'Test_hl3', { bg = 'red' })
|
||||
api.nvim_set_hl(0, 'Test_hl3', { bg = 'red' })
|
||||
eq('Test_hl3 xxx guibg=Red', exec_capture('highlight Test_hl3'))
|
||||
|
||||
meths.nvim_set_hl(0, 'Test_hl3', { ctermbg = 9, ctermfg = 12 })
|
||||
api.nvim_set_hl(0, 'Test_hl3', { ctermbg = 9, ctermfg = 12 })
|
||||
eq('Test_hl3 xxx ctermfg=12 ctermbg=9', exec_capture('highlight Test_hl3'))
|
||||
|
||||
meths.nvim_set_hl(0, 'Test_hl3', { ctermbg = 'red', ctermfg = 'blue' })
|
||||
api.nvim_set_hl(0, 'Test_hl3', { ctermbg = 'red', ctermfg = 'blue' })
|
||||
eq('Test_hl3 xxx ctermfg=12 ctermbg=9', exec_capture('highlight Test_hl3'))
|
||||
|
||||
meths.nvim_set_hl(0, 'Test_hl3', { ctermbg = 9 })
|
||||
api.nvim_set_hl(0, 'Test_hl3', { ctermbg = 9 })
|
||||
eq('Test_hl3 xxx ctermbg=9', exec_capture('highlight Test_hl3'))
|
||||
|
||||
eq(
|
||||
"Invalid highlight color: 'redd'",
|
||||
pcall_err(meths.nvim_set_hl, 0, 'Test_hl3', { fg = 'redd' })
|
||||
pcall_err(api.nvim_set_hl, 0, 'Test_hl3', { fg = 'redd' })
|
||||
)
|
||||
|
||||
eq(
|
||||
"Invalid highlight color: 'bleu'",
|
||||
pcall_err(meths.nvim_set_hl, 0, 'Test_hl3', { ctermfg = 'bleu' })
|
||||
pcall_err(api.nvim_set_hl, 0, 'Test_hl3', { ctermfg = 'bleu' })
|
||||
)
|
||||
|
||||
meths.nvim_set_hl(0, 'Test_hl3', { fg = '#FF00FF' })
|
||||
api.nvim_set_hl(0, 'Test_hl3', { fg = '#FF00FF' })
|
||||
eq('Test_hl3 xxx guifg=#ff00ff', exec_capture('highlight Test_hl3'))
|
||||
|
||||
eq(
|
||||
"Invalid highlight color: '#FF00FF'",
|
||||
pcall_err(meths.nvim_set_hl, 0, 'Test_hl3', { ctermfg = '#FF00FF' })
|
||||
pcall_err(api.nvim_set_hl, 0, 'Test_hl3', { ctermfg = '#FF00FF' })
|
||||
)
|
||||
|
||||
for _, fg_val in ipairs { nil, 'NONE', 'nOnE', '', -1 } do
|
||||
meths.nvim_set_hl(0, 'Test_hl3', { fg = fg_val })
|
||||
api.nvim_set_hl(0, 'Test_hl3', { fg = fg_val })
|
||||
eq('Test_hl3 xxx cleared', exec_capture('highlight Test_hl3'))
|
||||
end
|
||||
|
||||
meths.nvim_set_hl(0, 'Test_hl3', { fg = '#FF00FF', blend = 50 })
|
||||
api.nvim_set_hl(0, 'Test_hl3', { fg = '#FF00FF', blend = 50 })
|
||||
eq('Test_hl3 xxx guifg=#ff00ff blend=50', exec_capture('highlight Test_hl3'))
|
||||
end)
|
||||
|
||||
it("correctly sets 'Normal' internal properties", function()
|
||||
-- Normal has some special handling internally. #18024
|
||||
meths.nvim_set_hl(0, 'Normal', { fg = '#000083', bg = '#0000F3' })
|
||||
eq({ foreground = 131, background = 243 }, meths.nvim_get_hl_by_name('Normal', true))
|
||||
api.nvim_set_hl(0, 'Normal', { fg = '#000083', bg = '#0000F3' })
|
||||
eq({ foreground = 131, background = 243 }, api.nvim_get_hl_by_name('Normal', true))
|
||||
end)
|
||||
|
||||
it('does not segfault on invalid group name #20009', function()
|
||||
eq(
|
||||
"Invalid highlight name: 'foo bar'",
|
||||
pcall_err(meths.nvim_set_hl, 0, 'foo bar', { bold = true })
|
||||
pcall_err(api.nvim_set_hl, 0, 'foo bar', { bold = true })
|
||||
)
|
||||
assert_alive()
|
||||
end)
|
||||
@@ -452,14 +449,14 @@ describe('API: get highlight', function()
|
||||
|
||||
local function get_ns()
|
||||
-- Test namespace filtering behavior
|
||||
local ns2 = meths.nvim_create_namespace('Another_namespace')
|
||||
meths.nvim_set_hl(ns2, 'Test_hl', { ctermfg = 23 })
|
||||
meths.nvim_set_hl(ns2, 'Test_another_hl', { link = 'Test_hl' })
|
||||
meths.nvim_set_hl(ns2, 'Test_hl_link', { link = 'Test_another_hl' })
|
||||
meths.nvim_set_hl(ns2, 'Test_another_hl_link', { link = 'Test_hl_link' })
|
||||
local ns2 = api.nvim_create_namespace('Another_namespace')
|
||||
api.nvim_set_hl(ns2, 'Test_hl', { ctermfg = 23 })
|
||||
api.nvim_set_hl(ns2, 'Test_another_hl', { link = 'Test_hl' })
|
||||
api.nvim_set_hl(ns2, 'Test_hl_link', { link = 'Test_another_hl' })
|
||||
api.nvim_set_hl(ns2, 'Test_another_hl_link', { link = 'Test_hl_link' })
|
||||
|
||||
local ns = meths.nvim_create_namespace('Test_set_hl')
|
||||
meths.nvim_set_hl_ns(ns)
|
||||
local ns = api.nvim_create_namespace('Test_set_hl')
|
||||
api.nvim_set_hl_ns(ns)
|
||||
|
||||
return ns
|
||||
end
|
||||
@@ -469,24 +466,24 @@ describe('API: get highlight', function()
|
||||
it('validation', function()
|
||||
eq(
|
||||
"Invalid 'name': expected String, got Integer",
|
||||
pcall_err(meths.nvim_get_hl, 0, { name = 177 })
|
||||
pcall_err(api.nvim_get_hl, 0, { name = 177 })
|
||||
)
|
||||
eq('Highlight id out of bounds', pcall_err(meths.nvim_get_hl, 0, { name = 'Test set hl' }))
|
||||
eq('Highlight id out of bounds', pcall_err(api.nvim_get_hl, 0, { name = 'Test set hl' }))
|
||||
end)
|
||||
|
||||
it('nvim_get_hl with create flag', function()
|
||||
eq({}, meths.nvim_get_hl(0, { name = 'Foo', create = false }))
|
||||
eq(0, funcs.hlexists('Foo'))
|
||||
meths.nvim_get_hl(0, { name = 'Bar', create = true })
|
||||
eq(1, funcs.hlexists('Bar'))
|
||||
meths.nvim_get_hl(0, { name = 'FooBar' })
|
||||
eq(1, funcs.hlexists('FooBar'))
|
||||
eq({}, api.nvim_get_hl(0, { name = 'Foo', create = false }))
|
||||
eq(0, fn.hlexists('Foo'))
|
||||
api.nvim_get_hl(0, { name = 'Bar', create = true })
|
||||
eq(1, fn.hlexists('Bar'))
|
||||
api.nvim_get_hl(0, { name = 'FooBar' })
|
||||
eq(1, fn.hlexists('FooBar'))
|
||||
end)
|
||||
|
||||
it('can get all highlights in current namespace', function()
|
||||
local ns = get_ns()
|
||||
meths.nvim_set_hl(ns, 'Test_hl', { bg = '#B4BEFE' })
|
||||
meths.nvim_set_hl(ns, 'Test_hl_link', { link = 'Test_hl' })
|
||||
api.nvim_set_hl(ns, 'Test_hl', { bg = '#B4BEFE' })
|
||||
api.nvim_set_hl(ns, 'Test_hl_link', { link = 'Test_hl' })
|
||||
eq({
|
||||
Test_hl = {
|
||||
bg = 11845374,
|
||||
@@ -494,42 +491,42 @@ describe('API: get highlight', function()
|
||||
Test_hl_link = {
|
||||
link = 'Test_hl',
|
||||
},
|
||||
}, meths.nvim_get_hl(ns, {}))
|
||||
}, api.nvim_get_hl(ns, {}))
|
||||
end)
|
||||
|
||||
it('can get gui highlight', function()
|
||||
local ns = get_ns()
|
||||
meths.nvim_set_hl(ns, 'Test_hl', highlight1)
|
||||
eq(highlight1, meths.nvim_get_hl(ns, { name = 'Test_hl' }))
|
||||
api.nvim_set_hl(ns, 'Test_hl', highlight1)
|
||||
eq(highlight1, api.nvim_get_hl(ns, { name = 'Test_hl' }))
|
||||
end)
|
||||
|
||||
it('can get cterm highlight', function()
|
||||
local ns = get_ns()
|
||||
meths.nvim_set_hl(ns, 'Test_hl', highlight2)
|
||||
eq(highlight2, meths.nvim_get_hl(ns, { name = 'Test_hl' }))
|
||||
api.nvim_set_hl(ns, 'Test_hl', highlight2)
|
||||
eq(highlight2, api.nvim_get_hl(ns, { name = 'Test_hl' }))
|
||||
end)
|
||||
|
||||
it('can get empty cterm attr', function()
|
||||
local ns = get_ns()
|
||||
meths.nvim_set_hl(ns, 'Test_hl', { cterm = {} })
|
||||
eq({}, meths.nvim_get_hl(ns, { name = 'Test_hl' }))
|
||||
api.nvim_set_hl(ns, 'Test_hl', { cterm = {} })
|
||||
eq({}, api.nvim_get_hl(ns, { name = 'Test_hl' }))
|
||||
end)
|
||||
|
||||
it('cterm attr defaults to gui attr', function()
|
||||
local ns = get_ns()
|
||||
meths.nvim_set_hl(ns, 'Test_hl', highlight1)
|
||||
eq(highlight1, meths.nvim_get_hl(ns, { name = 'Test_hl' }))
|
||||
api.nvim_set_hl(ns, 'Test_hl', highlight1)
|
||||
eq(highlight1, api.nvim_get_hl(ns, { name = 'Test_hl' }))
|
||||
end)
|
||||
|
||||
it('can overwrite attr for cterm', function()
|
||||
local ns = get_ns()
|
||||
meths.nvim_set_hl(ns, 'Test_hl', highlight3_config)
|
||||
eq(highlight3_result, meths.nvim_get_hl(ns, { name = 'Test_hl' }))
|
||||
api.nvim_set_hl(ns, 'Test_hl', highlight3_config)
|
||||
eq(highlight3_result, api.nvim_get_hl(ns, { name = 'Test_hl' }))
|
||||
end)
|
||||
|
||||
it('only allows one underline attribute #22371', function()
|
||||
local ns = get_ns()
|
||||
meths.nvim_set_hl(ns, 'Test_hl', {
|
||||
api.nvim_set_hl(ns, 'Test_hl', {
|
||||
underdouble = true,
|
||||
underdotted = true,
|
||||
cterm = {
|
||||
@@ -539,33 +536,33 @@ describe('API: get highlight', function()
|
||||
})
|
||||
eq(
|
||||
{ underdotted = true, cterm = { undercurl = true } },
|
||||
meths.nvim_get_hl(ns, { name = 'Test_hl' })
|
||||
api.nvim_get_hl(ns, { name = 'Test_hl' })
|
||||
)
|
||||
end)
|
||||
|
||||
it('can get a highlight in the global namespace', function()
|
||||
meths.nvim_set_hl(0, 'Test_hl', highlight2)
|
||||
eq(highlight2, meths.nvim_get_hl(0, { name = 'Test_hl' }))
|
||||
api.nvim_set_hl(0, 'Test_hl', highlight2)
|
||||
eq(highlight2, api.nvim_get_hl(0, { name = 'Test_hl' }))
|
||||
|
||||
meths.nvim_set_hl(0, 'Test_hl', { background = highlight_color.bg })
|
||||
api.nvim_set_hl(0, 'Test_hl', { background = highlight_color.bg })
|
||||
eq({
|
||||
bg = 12970,
|
||||
}, meths.nvim_get_hl(0, { name = 'Test_hl' }))
|
||||
}, api.nvim_get_hl(0, { name = 'Test_hl' }))
|
||||
|
||||
meths.nvim_set_hl(0, 'Test_hl2', highlight3_config)
|
||||
eq(highlight3_result, meths.nvim_get_hl(0, { name = 'Test_hl2' }))
|
||||
api.nvim_set_hl(0, 'Test_hl2', highlight3_config)
|
||||
eq(highlight3_result, api.nvim_get_hl(0, { name = 'Test_hl2' }))
|
||||
|
||||
-- Colors are stored with the name they are defined, but
|
||||
-- with canonical casing
|
||||
meths.nvim_set_hl(0, 'Test_hl3', { bg = 'reD', fg = 'bLue' })
|
||||
api.nvim_set_hl(0, 'Test_hl3', { bg = 'reD', fg = 'bLue' })
|
||||
eq({
|
||||
bg = 16711680,
|
||||
fg = 255,
|
||||
}, meths.nvim_get_hl(0, { name = 'Test_hl3' }))
|
||||
}, api.nvim_get_hl(0, { name = 'Test_hl3' }))
|
||||
end)
|
||||
|
||||
it('nvim_get_hl by id', function()
|
||||
local hl_id = meths.nvim_get_hl_id_by_name('NewHighlight')
|
||||
local hl_id = api.nvim_get_hl_id_by_name('NewHighlight')
|
||||
|
||||
command(
|
||||
'hi NewHighlight cterm=underline ctermbg=green guifg=red guibg=yellow guisp=blue gui=bold'
|
||||
@@ -577,14 +574,14 @@ describe('API: get highlight', function()
|
||||
bold = true,
|
||||
ctermbg = 10,
|
||||
cterm = { underline = true },
|
||||
}, meths.nvim_get_hl(0, { id = hl_id }))
|
||||
}, api.nvim_get_hl(0, { id = hl_id }))
|
||||
|
||||
-- Test 0 argument
|
||||
eq('Highlight id out of bounds', pcall_err(meths.nvim_get_hl, 0, { id = 0 }))
|
||||
eq('Highlight id out of bounds', pcall_err(api.nvim_get_hl, 0, { id = 0 }))
|
||||
|
||||
eq(
|
||||
"Invalid 'id': expected Integer, got String",
|
||||
pcall_err(meths.nvim_get_hl, 0, { id = 'Test_set_hl' })
|
||||
pcall_err(api.nvim_get_hl, 0, { id = 'Test_set_hl' })
|
||||
)
|
||||
|
||||
-- Test all highlight properties.
|
||||
@@ -602,7 +599,7 @@ describe('API: get highlight', function()
|
||||
underline = true,
|
||||
ctermbg = 10,
|
||||
cterm = { underline = true },
|
||||
}, meths.nvim_get_hl(0, { id = hl_id }))
|
||||
}, api.nvim_get_hl(0, { id = hl_id }))
|
||||
|
||||
-- Test undercurl
|
||||
command('hi NewHighlight gui=undercurl')
|
||||
@@ -613,16 +610,16 @@ describe('API: get highlight', function()
|
||||
undercurl = true,
|
||||
ctermbg = 10,
|
||||
cterm = { underline = true },
|
||||
}, meths.nvim_get_hl(0, { id = hl_id }))
|
||||
}, api.nvim_get_hl(0, { id = hl_id }))
|
||||
end)
|
||||
|
||||
it('can correctly detect links', function()
|
||||
command('hi String guifg=#a6e3a1 ctermfg=NONE')
|
||||
command('hi link @string string')
|
||||
command('hi link @string.cpp @string')
|
||||
eq({ fg = 10937249 }, meths.nvim_get_hl(0, { name = 'String' }))
|
||||
eq({ link = 'String' }, meths.nvim_get_hl(0, { name = '@string' }))
|
||||
eq({ fg = 10937249 }, meths.nvim_get_hl(0, { name = '@string.cpp', link = false }))
|
||||
eq({ fg = 10937249 }, api.nvim_get_hl(0, { name = 'String' }))
|
||||
eq({ link = 'String' }, api.nvim_get_hl(0, { name = '@string' }))
|
||||
eq({ fg = 10937249 }, api.nvim_get_hl(0, { name = '@string.cpp', link = false }))
|
||||
end)
|
||||
|
||||
it('can get all attributes for a linked group', function()
|
||||
@@ -631,55 +628,55 @@ describe('API: get highlight', function()
|
||||
command('hi! link Foo Bar')
|
||||
eq(
|
||||
{ link = 'Bar', fg = tonumber('00ff00', 16), bold = true, underline = true },
|
||||
meths.nvim_get_hl(0, { name = 'Foo', link = true })
|
||||
api.nvim_get_hl(0, { name = 'Foo', link = true })
|
||||
)
|
||||
end)
|
||||
|
||||
it('can set link as well as other attributes', function()
|
||||
command('hi Bar guifg=red')
|
||||
local hl = { link = 'Bar', fg = tonumber('00ff00', 16), bold = true, cterm = { bold = true } }
|
||||
meths.nvim_set_hl(0, 'Foo', hl)
|
||||
eq(hl, meths.nvim_get_hl(0, { name = 'Foo', link = true }))
|
||||
api.nvim_set_hl(0, 'Foo', hl)
|
||||
eq(hl, api.nvim_get_hl(0, { name = 'Foo', link = true }))
|
||||
end)
|
||||
|
||||
it("doesn't contain unset groups", function()
|
||||
local id = meths.nvim_get_hl_id_by_name '@foobar.hubbabubba'
|
||||
local id = api.nvim_get_hl_id_by_name '@foobar.hubbabubba'
|
||||
ok(id > 0)
|
||||
|
||||
local data = meths.nvim_get_hl(0, {})
|
||||
local data = api.nvim_get_hl(0, {})
|
||||
eq(nil, data['@foobar.hubbabubba'])
|
||||
eq(nil, data['@foobar'])
|
||||
|
||||
command 'hi @foobar.hubbabubba gui=bold'
|
||||
data = meths.nvim_get_hl(0, {})
|
||||
data = api.nvim_get_hl(0, {})
|
||||
eq({ bold = true }, data['@foobar.hubbabubba'])
|
||||
eq(nil, data['@foobar'])
|
||||
|
||||
-- @foobar.hubbabubba was explicitly cleared and thus shows up
|
||||
-- but @foobar was never touched, and thus doesn't
|
||||
command 'hi clear @foobar.hubbabubba'
|
||||
data = meths.nvim_get_hl(0, {})
|
||||
data = api.nvim_get_hl(0, {})
|
||||
eq({}, data['@foobar.hubbabubba'])
|
||||
eq(nil, data['@foobar'])
|
||||
end)
|
||||
|
||||
it('should return default flag', function()
|
||||
meths.nvim_set_hl(0, 'Tried', { fg = '#00ff00', default = true })
|
||||
eq({ fg = tonumber('00ff00', 16), default = true }, meths.nvim_get_hl(0, { name = 'Tried' }))
|
||||
api.nvim_set_hl(0, 'Tried', { fg = '#00ff00', default = true })
|
||||
eq({ fg = tonumber('00ff00', 16), default = true }, api.nvim_get_hl(0, { name = 'Tried' }))
|
||||
end)
|
||||
|
||||
it('should not output empty gui and cterm #23474', function()
|
||||
meths.nvim_set_hl(0, 'Foo', { default = true })
|
||||
meths.nvim_set_hl(0, 'Bar', { default = true, fg = '#ffffff' })
|
||||
meths.nvim_set_hl(0, 'FooBar', { default = true, fg = '#ffffff', cterm = { bold = true } })
|
||||
meths.nvim_set_hl(
|
||||
api.nvim_set_hl(0, 'Foo', { default = true })
|
||||
api.nvim_set_hl(0, 'Bar', { default = true, fg = '#ffffff' })
|
||||
api.nvim_set_hl(0, 'FooBar', { default = true, fg = '#ffffff', cterm = { bold = true } })
|
||||
api.nvim_set_hl(
|
||||
0,
|
||||
'FooBarA',
|
||||
{ default = true, fg = '#ffffff', cterm = { bold = true, italic = true } }
|
||||
)
|
||||
|
||||
eq('Foo xxx cleared', exec_capture('highlight Foo'))
|
||||
eq({ default = true }, meths.nvim_get_hl(0, { name = 'Foo' }))
|
||||
eq({ default = true }, api.nvim_get_hl(0, { name = 'Foo' }))
|
||||
eq('Bar xxx guifg=#ffffff', exec_capture('highlight Bar'))
|
||||
eq('FooBar xxx cterm=bold guifg=#ffffff', exec_capture('highlight FooBar'))
|
||||
eq('FooBarA xxx cterm=bold,italic guifg=#ffffff', exec_capture('highlight FooBarA'))
|
||||
@@ -688,27 +685,27 @@ describe('API: get highlight', function()
|
||||
it('can override exist highlight group by force #20323', function()
|
||||
local white = tonumber('ffffff', 16)
|
||||
local green = tonumber('00ff00', 16)
|
||||
meths.nvim_set_hl(0, 'Foo', { fg = white })
|
||||
meths.nvim_set_hl(0, 'Foo', { fg = green, force = true })
|
||||
eq({ fg = green }, meths.nvim_get_hl(0, { name = 'Foo' }))
|
||||
meths.nvim_set_hl(0, 'Bar', { link = 'Comment', default = true })
|
||||
meths.nvim_set_hl(0, 'Bar', { link = 'Foo', default = true, force = true })
|
||||
eq({ link = 'Foo', default = true }, meths.nvim_get_hl(0, { name = 'Bar' }))
|
||||
api.nvim_set_hl(0, 'Foo', { fg = white })
|
||||
api.nvim_set_hl(0, 'Foo', { fg = green, force = true })
|
||||
eq({ fg = green }, api.nvim_get_hl(0, { name = 'Foo' }))
|
||||
api.nvim_set_hl(0, 'Bar', { link = 'Comment', default = true })
|
||||
api.nvim_set_hl(0, 'Bar', { link = 'Foo', default = true, force = true })
|
||||
eq({ link = 'Foo', default = true }, api.nvim_get_hl(0, { name = 'Bar' }))
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('API: set/get highlight namespace', function()
|
||||
it('set/get highlight namespace', function()
|
||||
eq(0, meths.nvim_get_hl_ns({}))
|
||||
local ns = meths.nvim_create_namespace('')
|
||||
meths.nvim_set_hl_ns(ns)
|
||||
eq(ns, meths.nvim_get_hl_ns({}))
|
||||
eq(0, api.nvim_get_hl_ns({}))
|
||||
local ns = api.nvim_create_namespace('')
|
||||
api.nvim_set_hl_ns(ns)
|
||||
eq(ns, api.nvim_get_hl_ns({}))
|
||||
end)
|
||||
|
||||
it('set/get window highlight namespace', function()
|
||||
eq(-1, meths.nvim_get_hl_ns({ winid = 0 }))
|
||||
local ns = meths.nvim_create_namespace('')
|
||||
meths.nvim_win_set_hl_ns(0, ns)
|
||||
eq(ns, meths.nvim_get_hl_ns({ winid = 0 }))
|
||||
eq(-1, api.nvim_get_hl_ns({ winid = 0 }))
|
||||
local ns = api.nvim_create_namespace('')
|
||||
api.nvim_win_set_hl_ns(0, ns)
|
||||
eq(ns, api.nvim_get_hl_ns({ winid = 0 }))
|
||||
end)
|
||||
end)
|
||||
|
||||
@@ -6,8 +6,8 @@ local eq, neq = helpers.eq, helpers.neq
|
||||
local exec_lua = helpers.exec_lua
|
||||
local exec = helpers.exec
|
||||
local feed = helpers.feed
|
||||
local funcs = helpers.funcs
|
||||
local meths = helpers.meths
|
||||
local fn = helpers.fn
|
||||
local api = helpers.api
|
||||
local source = helpers.source
|
||||
local pcall_err = helpers.pcall_err
|
||||
|
||||
@@ -55,7 +55,7 @@ describe('nvim_get_keymap', function()
|
||||
}
|
||||
|
||||
it('returns empty list when no map', function()
|
||||
eq({}, meths.nvim_get_keymap('n'))
|
||||
eq({}, api.nvim_get_keymap('n'))
|
||||
end)
|
||||
|
||||
it('returns list of all applicable mappings', function()
|
||||
@@ -64,8 +64,8 @@ describe('nvim_get_keymap', function()
|
||||
-- Should be the same as the dictionary we supplied earlier
|
||||
-- and the dictionary you would get from maparg
|
||||
-- since this is a global map, and not script local
|
||||
eq({ foo_bar_map_table }, meths.nvim_get_keymap('n'))
|
||||
eq({ funcs.maparg('foo', 'n', false, true) }, meths.nvim_get_keymap('n'))
|
||||
eq({ foo_bar_map_table }, api.nvim_get_keymap('n'))
|
||||
eq({ fn.maparg('foo', 'n', false, true) }, api.nvim_get_keymap('n'))
|
||||
|
||||
-- Add another mapping
|
||||
command('nnoremap foo_longer bar_longer')
|
||||
@@ -74,11 +74,11 @@ describe('nvim_get_keymap', function()
|
||||
foolong_bar_map_table['lhsraw'] = 'foo_longer'
|
||||
foolong_bar_map_table['rhs'] = 'bar_longer'
|
||||
|
||||
eq({ foolong_bar_map_table, foo_bar_map_table }, meths.nvim_get_keymap('n'))
|
||||
eq({ foolong_bar_map_table, foo_bar_map_table }, api.nvim_get_keymap('n'))
|
||||
|
||||
-- Remove a mapping
|
||||
command('unmap foo_longer')
|
||||
eq({ foo_bar_map_table }, meths.nvim_get_keymap('n'))
|
||||
eq({ foo_bar_map_table }, api.nvim_get_keymap('n'))
|
||||
end)
|
||||
|
||||
it('works for other modes', function()
|
||||
@@ -92,7 +92,7 @@ describe('nvim_get_keymap', function()
|
||||
insert_table['mode'] = 'i'
|
||||
insert_table['mode_bits'] = 0x10
|
||||
|
||||
eq({ insert_table }, meths.nvim_get_keymap('i'))
|
||||
eq({ insert_table }, api.nvim_get_keymap('i'))
|
||||
end)
|
||||
|
||||
it('considers scope', function()
|
||||
@@ -109,8 +109,8 @@ describe('nvim_get_keymap', function()
|
||||
command('nnoremap <buffer> foo bar')
|
||||
|
||||
-- The buffer mapping should not show up
|
||||
eq({ foolong_bar_map_table }, meths.nvim_get_keymap('n'))
|
||||
eq({ buffer_table }, meths.nvim_buf_get_keymap(0, 'n'))
|
||||
eq({ foolong_bar_map_table }, api.nvim_get_keymap('n'))
|
||||
eq({ buffer_table }, api.nvim_buf_get_keymap(0, 'n'))
|
||||
end)
|
||||
|
||||
it('considers scope for overlapping maps', function()
|
||||
@@ -121,12 +121,12 @@ describe('nvim_get_keymap', function()
|
||||
|
||||
command('nnoremap <buffer> foo bar')
|
||||
|
||||
eq({ foo_bar_map_table }, meths.nvim_get_keymap('n'))
|
||||
eq({ buffer_table }, meths.nvim_buf_get_keymap(0, 'n'))
|
||||
eq({ foo_bar_map_table }, api.nvim_get_keymap('n'))
|
||||
eq({ buffer_table }, api.nvim_buf_get_keymap(0, 'n'))
|
||||
end)
|
||||
|
||||
it('can retrieve mapping for different buffers', function()
|
||||
local original_buffer = meths.nvim_buf_get_number(0)
|
||||
local original_buffer = api.nvim_buf_get_number(0)
|
||||
-- Place something in each of the buffers to make sure they stick around
|
||||
-- and set hidden so we can leave them
|
||||
command('set hidden')
|
||||
@@ -135,21 +135,21 @@ describe('nvim_get_keymap', function()
|
||||
command('new')
|
||||
command('normal! ihello 3')
|
||||
|
||||
local final_buffer = meths.nvim_buf_get_number(0)
|
||||
local final_buffer = api.nvim_buf_get_number(0)
|
||||
|
||||
command('nnoremap <buffer> foo bar')
|
||||
-- Final buffer will have buffer mappings
|
||||
local buffer_table = shallowcopy(foo_bar_map_table)
|
||||
buffer_table['buffer'] = final_buffer
|
||||
eq({ buffer_table }, meths.nvim_buf_get_keymap(final_buffer, 'n'))
|
||||
eq({ buffer_table }, meths.nvim_buf_get_keymap(0, 'n'))
|
||||
eq({ buffer_table }, api.nvim_buf_get_keymap(final_buffer, 'n'))
|
||||
eq({ buffer_table }, api.nvim_buf_get_keymap(0, 'n'))
|
||||
|
||||
command('buffer ' .. original_buffer)
|
||||
eq(original_buffer, meths.nvim_buf_get_number(0))
|
||||
eq(original_buffer, api.nvim_buf_get_number(0))
|
||||
-- Original buffer won't have any mappings
|
||||
eq({}, meths.nvim_get_keymap('n'))
|
||||
eq({}, meths.nvim_buf_get_keymap(0, 'n'))
|
||||
eq({ buffer_table }, meths.nvim_buf_get_keymap(final_buffer, 'n'))
|
||||
eq({}, api.nvim_get_keymap('n'))
|
||||
eq({}, api.nvim_buf_get_keymap(0, 'n'))
|
||||
eq({ buffer_table }, api.nvim_buf_get_keymap(final_buffer, 'n'))
|
||||
end)
|
||||
|
||||
-- Test toggle switches for basic options
|
||||
@@ -189,7 +189,7 @@ describe('nvim_get_keymap', function()
|
||||
function()
|
||||
make_new_windows(new_windows)
|
||||
command(map .. ' ' .. option_token .. ' foo bar')
|
||||
local result = meths.nvim_get_keymap(mode)[1][option]
|
||||
local result = api.nvim_get_keymap(mode)[1][option]
|
||||
eq(global_on_result, result)
|
||||
end
|
||||
)
|
||||
@@ -207,7 +207,7 @@ describe('nvim_get_keymap', function()
|
||||
function()
|
||||
make_new_windows(new_windows)
|
||||
command(map .. ' <buffer> ' .. option_token .. ' foo bar')
|
||||
local result = meths.nvim_buf_get_keymap(0, mode)[1][option]
|
||||
local result = api.nvim_buf_get_keymap(0, mode)[1][option]
|
||||
eq(buffer_on_result, result)
|
||||
end
|
||||
)
|
||||
@@ -226,7 +226,7 @@ describe('nvim_get_keymap', function()
|
||||
function()
|
||||
make_new_windows(new_windows)
|
||||
command(map .. ' baz bat')
|
||||
local result = meths.nvim_get_keymap(mode)[1][option]
|
||||
local result = api.nvim_get_keymap(mode)[1][option]
|
||||
eq(global_off_result, result)
|
||||
end
|
||||
)
|
||||
@@ -244,7 +244,7 @@ describe('nvim_get_keymap', function()
|
||||
make_new_windows(new_windows)
|
||||
command(map .. ' <buffer> foo bar')
|
||||
|
||||
local result = meths.nvim_buf_get_keymap(0, mode)[1][option]
|
||||
local result = api.nvim_buf_get_keymap(0, mode)[1][option]
|
||||
eq(buffer_off_result, result)
|
||||
end
|
||||
)
|
||||
@@ -275,9 +275,9 @@ describe('nvim_get_keymap', function()
|
||||
|
||||
nnoremap fizz :call <SID>maparg_test_function()<CR>
|
||||
]])
|
||||
local sid_result = meths.nvim_get_keymap('n')[1]['sid']
|
||||
local sid_result = api.nvim_get_keymap('n')[1]['sid']
|
||||
eq(1, sid_result)
|
||||
eq('testing', meths.nvim_call_function('<SNR>' .. sid_result .. '_maparg_test_function', {}))
|
||||
eq('testing', api.nvim_call_function('<SNR>' .. sid_result .. '_maparg_test_function', {}))
|
||||
end)
|
||||
|
||||
it('returns script numbers for buffer maps', function()
|
||||
@@ -288,15 +288,15 @@ describe('nvim_get_keymap', function()
|
||||
|
||||
nnoremap <buffer> fizz :call <SID>maparg_test_function()<CR>
|
||||
]])
|
||||
local sid_result = meths.nvim_buf_get_keymap(0, 'n')[1]['sid']
|
||||
local sid_result = api.nvim_buf_get_keymap(0, 'n')[1]['sid']
|
||||
eq(1, sid_result)
|
||||
eq('testing', meths.nvim_call_function('<SNR>' .. sid_result .. '_maparg_test_function', {}))
|
||||
eq('testing', api.nvim_call_function('<SNR>' .. sid_result .. '_maparg_test_function', {}))
|
||||
end)
|
||||
|
||||
it('works with <F12> and others', function()
|
||||
command('nnoremap <F12> :let g:maparg_test_var = 1<CR>')
|
||||
eq('<F12>', meths.nvim_get_keymap('n')[1]['lhs'])
|
||||
eq(':let g:maparg_test_var = 1<CR>', meths.nvim_get_keymap('n')[1]['rhs'])
|
||||
eq('<F12>', api.nvim_get_keymap('n')[1]['lhs'])
|
||||
eq(':let g:maparg_test_var = 1<CR>', api.nvim_get_keymap('n')[1]['rhs'])
|
||||
end)
|
||||
|
||||
it('works correctly despite various &cpo settings', function()
|
||||
@@ -339,7 +339,7 @@ describe('nvim_get_keymap', function()
|
||||
|
||||
-- wrapper around get_keymap() that drops "lhsraw" and "lhsrawalt" which are hard to check
|
||||
local function get_keymap_noraw(...)
|
||||
local ret = meths.nvim_get_keymap(...)
|
||||
local ret = api.nvim_get_keymap(...)
|
||||
for _, item in ipairs(ret) do
|
||||
item.lhsraw = nil
|
||||
item.lhsrawalt = nil
|
||||
@@ -390,7 +390,7 @@ describe('nvim_get_keymap', function()
|
||||
lnum = 0,
|
||||
}
|
||||
command('nnoremap \\|<Char-0x20><Char-32><Space><Bar> \\|<Char-0x20><Char-32><Space> <Bar>')
|
||||
eq({ space_table }, meths.nvim_get_keymap('n'))
|
||||
eq({ space_table }, api.nvim_get_keymap('n'))
|
||||
end)
|
||||
|
||||
it('can handle lua mappings', function()
|
||||
@@ -419,7 +419,7 @@ describe('nvim_get_keymap', function()
|
||||
]])
|
||||
eq(3, exec_lua([[return GlobalCount]]))
|
||||
|
||||
local mapargs = meths.nvim_get_keymap('n')
|
||||
local mapargs = api.nvim_get_keymap('n')
|
||||
mapargs[1].callback = nil
|
||||
eq({
|
||||
lhs = 'asdf',
|
||||
@@ -440,7 +440,7 @@ describe('nvim_get_keymap', function()
|
||||
end)
|
||||
|
||||
it('can handle map descriptions', function()
|
||||
meths.nvim_set_keymap('n', 'lhs', 'rhs', { desc = 'map description' })
|
||||
api.nvim_set_keymap('n', 'lhs', 'rhs', { desc = 'map description' })
|
||||
eq({
|
||||
lhs = 'lhs',
|
||||
lhsraw = 'lhs',
|
||||
@@ -458,7 +458,7 @@ describe('nvim_get_keymap', function()
|
||||
noremap = 0,
|
||||
lnum = 0,
|
||||
desc = 'map description',
|
||||
}, meths.nvim_get_keymap('n')[1])
|
||||
}, api.nvim_get_keymap('n')[1])
|
||||
end)
|
||||
end)
|
||||
|
||||
@@ -511,7 +511,7 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
|
||||
|
||||
-- Gets a maparg() dict from Nvim, if one exists.
|
||||
local function get_mapargs(mode, lhs)
|
||||
local mapargs = funcs.maparg(lhs, normalize_mapmode(mode), mode:sub(-1) == 'a', true)
|
||||
local mapargs = fn.maparg(lhs, normalize_mapmode(mode), mode:sub(-1) == 'a', true)
|
||||
-- drop "lhsraw" and "lhsrawalt" which are hard to check
|
||||
mapargs.lhsraw = nil
|
||||
mapargs.lhsrawalt = nil
|
||||
@@ -520,9 +520,9 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
|
||||
|
||||
it('error on empty LHS', function()
|
||||
-- escape parentheses in lua string, else comparison fails erroneously
|
||||
eq('Invalid (empty) LHS', pcall_err(meths.nvim_set_keymap, '', '', 'rhs', {}))
|
||||
eq('Invalid (empty) LHS', pcall_err(meths.nvim_set_keymap, '', '', '', {}))
|
||||
eq('Invalid (empty) LHS', pcall_err(meths.nvim_del_keymap, '', ''))
|
||||
eq('Invalid (empty) LHS', pcall_err(api.nvim_set_keymap, '', '', 'rhs', {}))
|
||||
eq('Invalid (empty) LHS', pcall_err(api.nvim_set_keymap, '', '', '', {}))
|
||||
eq('Invalid (empty) LHS', pcall_err(api.nvim_del_keymap, '', ''))
|
||||
end)
|
||||
|
||||
it('error if LHS longer than MAXMAPLEN', function()
|
||||
@@ -534,19 +534,19 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
|
||||
end
|
||||
|
||||
-- exactly 50 chars should be fine
|
||||
meths.nvim_set_keymap('', lhs, 'rhs', {})
|
||||
api.nvim_set_keymap('', lhs, 'rhs', {})
|
||||
|
||||
-- del_keymap should unmap successfully
|
||||
meths.nvim_del_keymap('', lhs)
|
||||
api.nvim_del_keymap('', lhs)
|
||||
eq({}, get_mapargs('', lhs))
|
||||
|
||||
-- 51 chars should produce an error
|
||||
lhs = lhs .. '1'
|
||||
eq(
|
||||
'LHS exceeds maximum map length: ' .. lhs,
|
||||
pcall_err(meths.nvim_set_keymap, '', lhs, 'rhs', {})
|
||||
pcall_err(api.nvim_set_keymap, '', lhs, 'rhs', {})
|
||||
)
|
||||
eq('LHS exceeds maximum map length: ' .. lhs, pcall_err(meths.nvim_del_keymap, '', lhs))
|
||||
eq('LHS exceeds maximum map length: ' .. lhs, pcall_err(api.nvim_del_keymap, '', lhs))
|
||||
end)
|
||||
|
||||
it('does not throw errors when rhs is longer than MAXMAPLEN', function()
|
||||
@@ -556,65 +556,65 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
|
||||
rhs = rhs .. (i % 10)
|
||||
end
|
||||
rhs = rhs .. '1'
|
||||
meths.nvim_set_keymap('', 'lhs', rhs, {})
|
||||
api.nvim_set_keymap('', 'lhs', rhs, {})
|
||||
eq(generate_mapargs('', 'lhs', rhs), get_mapargs('', 'lhs'))
|
||||
end)
|
||||
|
||||
it('error on invalid mode shortname', function()
|
||||
eq('Invalid mode shortname: " "', pcall_err(meths.nvim_set_keymap, ' ', 'lhs', 'rhs', {}))
|
||||
eq('Invalid mode shortname: "m"', pcall_err(meths.nvim_set_keymap, 'm', 'lhs', 'rhs', {}))
|
||||
eq('Invalid mode shortname: "?"', pcall_err(meths.nvim_set_keymap, '?', 'lhs', 'rhs', {}))
|
||||
eq('Invalid mode shortname: "y"', pcall_err(meths.nvim_set_keymap, 'y', 'lhs', 'rhs', {}))
|
||||
eq('Invalid mode shortname: "p"', pcall_err(meths.nvim_set_keymap, 'p', 'lhs', 'rhs', {}))
|
||||
eq('Invalid mode shortname: "a"', pcall_err(meths.nvim_set_keymap, 'a', 'lhs', 'rhs', {}))
|
||||
eq('Invalid mode shortname: "oa"', pcall_err(meths.nvim_set_keymap, 'oa', 'lhs', 'rhs', {}))
|
||||
eq('Invalid mode shortname: "!o"', pcall_err(meths.nvim_set_keymap, '!o', 'lhs', 'rhs', {}))
|
||||
eq('Invalid mode shortname: "!i"', pcall_err(meths.nvim_set_keymap, '!i', 'lhs', 'rhs', {}))
|
||||
eq('Invalid mode shortname: "!!"', pcall_err(meths.nvim_set_keymap, '!!', 'lhs', 'rhs', {}))
|
||||
eq('Invalid mode shortname: "map"', pcall_err(meths.nvim_set_keymap, 'map', 'lhs', 'rhs', {}))
|
||||
eq('Invalid mode shortname: "vmap"', pcall_err(meths.nvim_set_keymap, 'vmap', 'lhs', 'rhs', {}))
|
||||
eq('Invalid mode shortname: " "', pcall_err(api.nvim_set_keymap, ' ', 'lhs', 'rhs', {}))
|
||||
eq('Invalid mode shortname: "m"', pcall_err(api.nvim_set_keymap, 'm', 'lhs', 'rhs', {}))
|
||||
eq('Invalid mode shortname: "?"', pcall_err(api.nvim_set_keymap, '?', 'lhs', 'rhs', {}))
|
||||
eq('Invalid mode shortname: "y"', pcall_err(api.nvim_set_keymap, 'y', 'lhs', 'rhs', {}))
|
||||
eq('Invalid mode shortname: "p"', pcall_err(api.nvim_set_keymap, 'p', 'lhs', 'rhs', {}))
|
||||
eq('Invalid mode shortname: "a"', pcall_err(api.nvim_set_keymap, 'a', 'lhs', 'rhs', {}))
|
||||
eq('Invalid mode shortname: "oa"', pcall_err(api.nvim_set_keymap, 'oa', 'lhs', 'rhs', {}))
|
||||
eq('Invalid mode shortname: "!o"', pcall_err(api.nvim_set_keymap, '!o', 'lhs', 'rhs', {}))
|
||||
eq('Invalid mode shortname: "!i"', pcall_err(api.nvim_set_keymap, '!i', 'lhs', 'rhs', {}))
|
||||
eq('Invalid mode shortname: "!!"', pcall_err(api.nvim_set_keymap, '!!', 'lhs', 'rhs', {}))
|
||||
eq('Invalid mode shortname: "map"', pcall_err(api.nvim_set_keymap, 'map', 'lhs', 'rhs', {}))
|
||||
eq('Invalid mode shortname: "vmap"', pcall_err(api.nvim_set_keymap, 'vmap', 'lhs', 'rhs', {}))
|
||||
eq(
|
||||
'Invalid mode shortname: "xnoremap"',
|
||||
pcall_err(meths.nvim_set_keymap, 'xnoremap', 'lhs', 'rhs', {})
|
||||
pcall_err(api.nvim_set_keymap, 'xnoremap', 'lhs', 'rhs', {})
|
||||
)
|
||||
eq('Invalid mode shortname: " "', pcall_err(meths.nvim_del_keymap, ' ', 'lhs'))
|
||||
eq('Invalid mode shortname: "m"', pcall_err(meths.nvim_del_keymap, 'm', 'lhs'))
|
||||
eq('Invalid mode shortname: "?"', pcall_err(meths.nvim_del_keymap, '?', 'lhs'))
|
||||
eq('Invalid mode shortname: "y"', pcall_err(meths.nvim_del_keymap, 'y', 'lhs'))
|
||||
eq('Invalid mode shortname: "p"', pcall_err(meths.nvim_del_keymap, 'p', 'lhs'))
|
||||
eq('Invalid mode shortname: "a"', pcall_err(meths.nvim_del_keymap, 'a', 'lhs'))
|
||||
eq('Invalid mode shortname: "oa"', pcall_err(meths.nvim_del_keymap, 'oa', 'lhs'))
|
||||
eq('Invalid mode shortname: "!o"', pcall_err(meths.nvim_del_keymap, '!o', 'lhs'))
|
||||
eq('Invalid mode shortname: "!i"', pcall_err(meths.nvim_del_keymap, '!i', 'lhs'))
|
||||
eq('Invalid mode shortname: "!!"', pcall_err(meths.nvim_del_keymap, '!!', 'lhs'))
|
||||
eq('Invalid mode shortname: "map"', pcall_err(meths.nvim_del_keymap, 'map', 'lhs'))
|
||||
eq('Invalid mode shortname: "vmap"', pcall_err(meths.nvim_del_keymap, 'vmap', 'lhs'))
|
||||
eq('Invalid mode shortname: "xnoremap"', pcall_err(meths.nvim_del_keymap, 'xnoremap', 'lhs'))
|
||||
eq('Invalid mode shortname: " "', pcall_err(api.nvim_del_keymap, ' ', 'lhs'))
|
||||
eq('Invalid mode shortname: "m"', pcall_err(api.nvim_del_keymap, 'm', 'lhs'))
|
||||
eq('Invalid mode shortname: "?"', pcall_err(api.nvim_del_keymap, '?', 'lhs'))
|
||||
eq('Invalid mode shortname: "y"', pcall_err(api.nvim_del_keymap, 'y', 'lhs'))
|
||||
eq('Invalid mode shortname: "p"', pcall_err(api.nvim_del_keymap, 'p', 'lhs'))
|
||||
eq('Invalid mode shortname: "a"', pcall_err(api.nvim_del_keymap, 'a', 'lhs'))
|
||||
eq('Invalid mode shortname: "oa"', pcall_err(api.nvim_del_keymap, 'oa', 'lhs'))
|
||||
eq('Invalid mode shortname: "!o"', pcall_err(api.nvim_del_keymap, '!o', 'lhs'))
|
||||
eq('Invalid mode shortname: "!i"', pcall_err(api.nvim_del_keymap, '!i', 'lhs'))
|
||||
eq('Invalid mode shortname: "!!"', pcall_err(api.nvim_del_keymap, '!!', 'lhs'))
|
||||
eq('Invalid mode shortname: "map"', pcall_err(api.nvim_del_keymap, 'map', 'lhs'))
|
||||
eq('Invalid mode shortname: "vmap"', pcall_err(api.nvim_del_keymap, 'vmap', 'lhs'))
|
||||
eq('Invalid mode shortname: "xnoremap"', pcall_err(api.nvim_del_keymap, 'xnoremap', 'lhs'))
|
||||
end)
|
||||
|
||||
it('error on invalid optnames', function()
|
||||
eq(
|
||||
"Invalid key: 'silentt'",
|
||||
pcall_err(meths.nvim_set_keymap, 'n', 'lhs', 'rhs', { silentt = true })
|
||||
pcall_err(api.nvim_set_keymap, 'n', 'lhs', 'rhs', { silentt = true })
|
||||
)
|
||||
eq("Invalid key: 'sidd'", pcall_err(meths.nvim_set_keymap, 'n', 'lhs', 'rhs', { sidd = false }))
|
||||
eq("Invalid key: 'sidd'", pcall_err(api.nvim_set_keymap, 'n', 'lhs', 'rhs', { sidd = false }))
|
||||
eq(
|
||||
"Invalid key: 'nowaiT'",
|
||||
pcall_err(meths.nvim_set_keymap, 'n', 'lhs', 'rhs', { nowaiT = false })
|
||||
pcall_err(api.nvim_set_keymap, 'n', 'lhs', 'rhs', { nowaiT = false })
|
||||
)
|
||||
end)
|
||||
|
||||
it('error on <buffer> option key', function()
|
||||
eq(
|
||||
"Invalid key: 'buffer'",
|
||||
pcall_err(meths.nvim_set_keymap, 'n', 'lhs', 'rhs', { buffer = true })
|
||||
pcall_err(api.nvim_set_keymap, 'n', 'lhs', 'rhs', { buffer = true })
|
||||
)
|
||||
end)
|
||||
|
||||
it('error when "replace_keycodes" is used without "expr"', function()
|
||||
eq(
|
||||
'"replace_keycodes" requires "expr"',
|
||||
pcall_err(meths.nvim_set_keymap, 'n', 'lhs', 'rhs', { replace_keycodes = true })
|
||||
pcall_err(api.nvim_set_keymap, 'n', 'lhs', 'rhs', { replace_keycodes = true })
|
||||
)
|
||||
end)
|
||||
|
||||
@@ -624,45 +624,45 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
|
||||
it('throws an error when given non-boolean value for ' .. opt, function()
|
||||
local opts = {}
|
||||
opts[opt] = 'fooo'
|
||||
eq(opt .. ' is not a boolean', pcall_err(meths.nvim_set_keymap, 'n', 'lhs', 'rhs', opts))
|
||||
eq(opt .. ' is not a boolean', pcall_err(api.nvim_set_keymap, 'n', 'lhs', 'rhs', opts))
|
||||
end)
|
||||
end
|
||||
|
||||
-- Perform tests of basic functionality
|
||||
it('sets ordinary mappings', function()
|
||||
meths.nvim_set_keymap('n', 'lhs', 'rhs', {})
|
||||
api.nvim_set_keymap('n', 'lhs', 'rhs', {})
|
||||
eq(generate_mapargs('n', 'lhs', 'rhs'), get_mapargs('n', 'lhs'))
|
||||
|
||||
meths.nvim_set_keymap('v', 'lhs', 'rhs', {})
|
||||
api.nvim_set_keymap('v', 'lhs', 'rhs', {})
|
||||
eq(generate_mapargs('v', 'lhs', 'rhs'), get_mapargs('v', 'lhs'))
|
||||
end)
|
||||
|
||||
it('does not throw when LHS or RHS have leading/trailing whitespace', function()
|
||||
meths.nvim_set_keymap('n', ' lhs', 'rhs', {})
|
||||
api.nvim_set_keymap('n', ' lhs', 'rhs', {})
|
||||
eq(generate_mapargs('n', '<Space><Space><Space>lhs', 'rhs'), get_mapargs('n', ' lhs'))
|
||||
|
||||
meths.nvim_set_keymap('n', 'lhs ', 'rhs', {})
|
||||
api.nvim_set_keymap('n', 'lhs ', 'rhs', {})
|
||||
eq(generate_mapargs('n', 'lhs<Space><Space><Space><Space>', 'rhs'), get_mapargs('n', 'lhs '))
|
||||
|
||||
meths.nvim_set_keymap('v', ' lhs ', '\trhs\t\f', {})
|
||||
api.nvim_set_keymap('v', ' lhs ', '\trhs\t\f', {})
|
||||
eq(generate_mapargs('v', '<Space>lhs<Space><Space>', '\trhs\t\f'), get_mapargs('v', ' lhs '))
|
||||
end)
|
||||
|
||||
it('can set noremap mappings', function()
|
||||
meths.nvim_set_keymap('x', 'lhs', 'rhs', { noremap = true })
|
||||
api.nvim_set_keymap('x', 'lhs', 'rhs', { noremap = true })
|
||||
eq(generate_mapargs('x', 'lhs', 'rhs', { noremap = true }), get_mapargs('x', 'lhs'))
|
||||
|
||||
meths.nvim_set_keymap('t', 'lhs', 'rhs', { noremap = true })
|
||||
api.nvim_set_keymap('t', 'lhs', 'rhs', { noremap = true })
|
||||
eq(generate_mapargs('t', 'lhs', 'rhs', { noremap = true }), get_mapargs('t', 'lhs'))
|
||||
end)
|
||||
|
||||
it('can unmap mappings', function()
|
||||
meths.nvim_set_keymap('v', 'lhs', 'rhs', {})
|
||||
meths.nvim_del_keymap('v', 'lhs')
|
||||
api.nvim_set_keymap('v', 'lhs', 'rhs', {})
|
||||
api.nvim_del_keymap('v', 'lhs')
|
||||
eq({}, get_mapargs('v', 'lhs'))
|
||||
|
||||
meths.nvim_set_keymap('t', 'lhs', 'rhs', { noremap = true })
|
||||
meths.nvim_del_keymap('t', 'lhs')
|
||||
api.nvim_set_keymap('t', 'lhs', 'rhs', { noremap = true })
|
||||
api.nvim_del_keymap('t', 'lhs')
|
||||
eq({}, get_mapargs('t', 'lhs'))
|
||||
end)
|
||||
|
||||
@@ -670,8 +670,8 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
|
||||
it('"!" and empty string are synonyms for mapmode-nvo', function()
|
||||
local nvo_shortnames = { '', '!' }
|
||||
for _, name in ipairs(nvo_shortnames) do
|
||||
meths.nvim_set_keymap(name, 'lhs', 'rhs', {})
|
||||
meths.nvim_del_keymap(name, 'lhs')
|
||||
api.nvim_set_keymap(name, 'lhs', 'rhs', {})
|
||||
api.nvim_del_keymap(name, 'lhs')
|
||||
eq({}, get_mapargs(name, 'lhs'))
|
||||
end
|
||||
end)
|
||||
@@ -681,48 +681,48 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
|
||||
for _, rhs in ipairs(special_chars) do
|
||||
local mapmode = '!'
|
||||
it('can set mappings with special characters, lhs: ' .. lhs .. ', rhs: ' .. rhs, function()
|
||||
meths.nvim_set_keymap(mapmode, lhs, rhs, {})
|
||||
api.nvim_set_keymap(mapmode, lhs, rhs, {})
|
||||
eq(generate_mapargs(mapmode, lhs, rhs), get_mapargs(mapmode, lhs))
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
it('can set mappings containing literal keycodes', function()
|
||||
meths.nvim_set_keymap('n', '\n\r\n', 'rhs', {})
|
||||
api.nvim_set_keymap('n', '\n\r\n', 'rhs', {})
|
||||
local expected = generate_mapargs('n', '<NL><CR><NL>', 'rhs')
|
||||
eq(expected, get_mapargs('n', '<NL><CR><NL>'))
|
||||
end)
|
||||
|
||||
it('can set mappings whose RHS is a <Nop>', function()
|
||||
meths.nvim_set_keymap('i', 'lhs', '<Nop>', {})
|
||||
api.nvim_set_keymap('i', 'lhs', '<Nop>', {})
|
||||
command('normal ilhs')
|
||||
eq({ '' }, meths.nvim_buf_get_lines(0, 0, -1, 0)) -- imap to <Nop> does nothing
|
||||
eq({ '' }, api.nvim_buf_get_lines(0, 0, -1, 0)) -- imap to <Nop> does nothing
|
||||
eq(generate_mapargs('i', 'lhs', '<Nop>', {}), get_mapargs('i', 'lhs'))
|
||||
|
||||
-- also test for case insensitivity
|
||||
meths.nvim_set_keymap('i', 'lhs', '<nOp>', {})
|
||||
api.nvim_set_keymap('i', 'lhs', '<nOp>', {})
|
||||
command('normal ilhs')
|
||||
eq({ '' }, meths.nvim_buf_get_lines(0, 0, -1, 0))
|
||||
eq({ '' }, api.nvim_buf_get_lines(0, 0, -1, 0))
|
||||
-- note: RHS in returned mapargs() dict reflects the original RHS
|
||||
-- provided by the user
|
||||
eq(generate_mapargs('i', 'lhs', '<nOp>', {}), get_mapargs('i', 'lhs'))
|
||||
|
||||
meths.nvim_set_keymap('i', 'lhs', '<NOP>', {})
|
||||
api.nvim_set_keymap('i', 'lhs', '<NOP>', {})
|
||||
command('normal ilhs')
|
||||
eq({ '' }, meths.nvim_buf_get_lines(0, 0, -1, 0))
|
||||
eq({ '' }, api.nvim_buf_get_lines(0, 0, -1, 0))
|
||||
eq(generate_mapargs('i', 'lhs', '<NOP>', {}), get_mapargs('i', 'lhs'))
|
||||
|
||||
-- a single ^V in RHS is also <Nop> (see :h map-empty-rhs)
|
||||
meths.nvim_set_keymap('i', 'lhs', '\022', {})
|
||||
api.nvim_set_keymap('i', 'lhs', '\022', {})
|
||||
command('normal ilhs')
|
||||
eq({ '' }, meths.nvim_buf_get_lines(0, 0, -1, 0))
|
||||
eq({ '' }, api.nvim_buf_get_lines(0, 0, -1, 0))
|
||||
eq(generate_mapargs('i', 'lhs', '\022', {}), get_mapargs('i', 'lhs'))
|
||||
end)
|
||||
|
||||
it('treats an empty RHS in a mapping like a <Nop>', function()
|
||||
meths.nvim_set_keymap('i', 'lhs', '', {})
|
||||
api.nvim_set_keymap('i', 'lhs', '', {})
|
||||
command('normal ilhs')
|
||||
eq({ '' }, meths.nvim_buf_get_lines(0, 0, -1, 0))
|
||||
eq({ '' }, api.nvim_buf_get_lines(0, 0, -1, 0))
|
||||
eq(generate_mapargs('i', 'lhs', '', {}), get_mapargs('i', 'lhs'))
|
||||
end)
|
||||
|
||||
@@ -730,8 +730,8 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
|
||||
-- Taken from the legacy test: test_mapping.vim. Exposes a bug in which
|
||||
-- replace_termcodes changes the length of the mapping's LHS, but
|
||||
-- do_map continues to use the *old* length of LHS.
|
||||
meths.nvim_set_keymap('i', '<M-">', 'foo', {})
|
||||
meths.nvim_del_keymap('i', '<M-">')
|
||||
api.nvim_set_keymap('i', '<M-">', 'foo', {})
|
||||
api.nvim_del_keymap('i', '<M-">')
|
||||
eq({}, get_mapargs('i', '<M-">'))
|
||||
end)
|
||||
|
||||
@@ -741,18 +741,18 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
|
||||
command([[call nvim_set_keymap('i', "\<space>", "\<tab>", {})]])
|
||||
eq(generate_mapargs('i', '<Space>', '\t', { sid = 0 }), get_mapargs('i', '<Space>'))
|
||||
feed('i ')
|
||||
eq({ '\t' }, meths.nvim_buf_get_lines(0, 0, -1, 0))
|
||||
eq({ '\t' }, api.nvim_buf_get_lines(0, 0, -1, 0))
|
||||
end
|
||||
)
|
||||
|
||||
it('throws appropriate error messages when setting <unique> maps', function()
|
||||
meths.nvim_set_keymap('l', 'lhs', 'rhs', {})
|
||||
api.nvim_set_keymap('l', 'lhs', 'rhs', {})
|
||||
eq(
|
||||
'E227: mapping already exists for lhs',
|
||||
pcall_err(meths.nvim_set_keymap, 'l', 'lhs', 'rhs', { unique = true })
|
||||
pcall_err(api.nvim_set_keymap, 'l', 'lhs', 'rhs', { unique = true })
|
||||
)
|
||||
-- different mapmode, no error should be thrown
|
||||
meths.nvim_set_keymap('t', 'lhs', 'rhs', { unique = true })
|
||||
api.nvim_set_keymap('t', 'lhs', 'rhs', { unique = true })
|
||||
end)
|
||||
|
||||
it('can set <expr> mappings whose RHS change dynamically', function()
|
||||
@@ -763,50 +763,50 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
|
||||
return g:flip
|
||||
endfunction
|
||||
]])
|
||||
eq(1, meths.nvim_call_function('FlipFlop', {}))
|
||||
eq(0, meths.nvim_call_function('FlipFlop', {}))
|
||||
eq(1, meths.nvim_call_function('FlipFlop', {}))
|
||||
eq(0, meths.nvim_call_function('FlipFlop', {}))
|
||||
eq(1, api.nvim_call_function('FlipFlop', {}))
|
||||
eq(0, api.nvim_call_function('FlipFlop', {}))
|
||||
eq(1, api.nvim_call_function('FlipFlop', {}))
|
||||
eq(0, api.nvim_call_function('FlipFlop', {}))
|
||||
|
||||
meths.nvim_set_keymap('i', 'lhs', 'FlipFlop()', { expr = true })
|
||||
api.nvim_set_keymap('i', 'lhs', 'FlipFlop()', { expr = true })
|
||||
command('normal ilhs')
|
||||
eq({ '1' }, meths.nvim_buf_get_lines(0, 0, -1, 0))
|
||||
eq({ '1' }, api.nvim_buf_get_lines(0, 0, -1, 0))
|
||||
|
||||
command('normal! ggVGd')
|
||||
|
||||
command('normal ilhs')
|
||||
eq({ '0' }, meths.nvim_buf_get_lines(0, 0, -1, 0))
|
||||
eq({ '0' }, api.nvim_buf_get_lines(0, 0, -1, 0))
|
||||
end)
|
||||
|
||||
it('can set mappings that do trigger other mappings', function()
|
||||
meths.nvim_set_keymap('i', 'mhs', 'rhs', {})
|
||||
meths.nvim_set_keymap('i', 'lhs', 'mhs', {})
|
||||
api.nvim_set_keymap('i', 'mhs', 'rhs', {})
|
||||
api.nvim_set_keymap('i', 'lhs', 'mhs', {})
|
||||
|
||||
command('normal imhs')
|
||||
eq({ 'rhs' }, meths.nvim_buf_get_lines(0, 0, -1, 0))
|
||||
eq({ 'rhs' }, api.nvim_buf_get_lines(0, 0, -1, 0))
|
||||
|
||||
command('normal! ggVGd')
|
||||
|
||||
command('normal ilhs')
|
||||
eq({ 'rhs' }, meths.nvim_buf_get_lines(0, 0, -1, 0))
|
||||
eq({ 'rhs' }, api.nvim_buf_get_lines(0, 0, -1, 0))
|
||||
end)
|
||||
|
||||
it("can set noremap mappings that don't trigger other mappings", function()
|
||||
meths.nvim_set_keymap('i', 'mhs', 'rhs', {})
|
||||
meths.nvim_set_keymap('i', 'lhs', 'mhs', { noremap = true })
|
||||
api.nvim_set_keymap('i', 'mhs', 'rhs', {})
|
||||
api.nvim_set_keymap('i', 'lhs', 'mhs', { noremap = true })
|
||||
|
||||
command('normal imhs')
|
||||
eq({ 'rhs' }, meths.nvim_buf_get_lines(0, 0, -1, 0))
|
||||
eq({ 'rhs' }, api.nvim_buf_get_lines(0, 0, -1, 0))
|
||||
|
||||
command('normal! ggVGd')
|
||||
|
||||
command('normal ilhs') -- shouldn't trigger mhs-to-rhs mapping
|
||||
eq({ 'mhs' }, meths.nvim_buf_get_lines(0, 0, -1, 0))
|
||||
eq({ 'mhs' }, api.nvim_buf_get_lines(0, 0, -1, 0))
|
||||
end)
|
||||
|
||||
it('can set nowait mappings that fire without waiting', function()
|
||||
meths.nvim_set_keymap('i', '123456', 'longer', {})
|
||||
meths.nvim_set_keymap('i', '123', 'shorter', { nowait = true })
|
||||
api.nvim_set_keymap('i', '123456', 'longer', {})
|
||||
api.nvim_set_keymap('i', '123', 'shorter', { nowait = true })
|
||||
|
||||
-- feed keys one at a time; if all keys arrive atomically, the longer
|
||||
-- mapping will trigger
|
||||
@@ -815,29 +815,29 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
|
||||
feed(c)
|
||||
sleep(5)
|
||||
end
|
||||
eq({ 'shorter456' }, meths.nvim_buf_get_lines(0, 0, -1, 0))
|
||||
eq({ 'shorter456' }, api.nvim_buf_get_lines(0, 0, -1, 0))
|
||||
end)
|
||||
|
||||
-- Perform exhaustive tests of basic functionality
|
||||
local mapmodes = { 'n', 'v', 'x', 's', 'o', '!', 'i', 'l', 'c', 't', '', 'ia', 'ca', '!a' }
|
||||
for _, mapmode in ipairs(mapmodes) do
|
||||
it('can set/unset normal mappings in mapmode ' .. mapmode, function()
|
||||
meths.nvim_set_keymap(mapmode, 'lhs', 'rhs', {})
|
||||
api.nvim_set_keymap(mapmode, 'lhs', 'rhs', {})
|
||||
eq(generate_mapargs(mapmode, 'lhs', 'rhs'), get_mapargs(mapmode, 'lhs'))
|
||||
|
||||
-- some mapmodes (like 'o') will prevent other mapmodes (like '!') from
|
||||
-- taking effect, so unmap after each mapping
|
||||
meths.nvim_del_keymap(mapmode, 'lhs')
|
||||
api.nvim_del_keymap(mapmode, 'lhs')
|
||||
eq({}, get_mapargs(mapmode, 'lhs'))
|
||||
end)
|
||||
end
|
||||
|
||||
for _, mapmode in ipairs(mapmodes) do
|
||||
it('can set/unset noremap mappings using mapmode ' .. mapmode, function()
|
||||
meths.nvim_set_keymap(mapmode, 'lhs', 'rhs', { noremap = true })
|
||||
api.nvim_set_keymap(mapmode, 'lhs', 'rhs', { noremap = true })
|
||||
eq(generate_mapargs(mapmode, 'lhs', 'rhs', { noremap = true }), get_mapargs(mapmode, 'lhs'))
|
||||
|
||||
meths.nvim_del_keymap(mapmode, 'lhs')
|
||||
api.nvim_del_keymap(mapmode, 'lhs')
|
||||
eq({}, get_mapargs(mapmode, 'lhs'))
|
||||
end)
|
||||
end
|
||||
@@ -849,12 +849,12 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
|
||||
-- Test with single mappings
|
||||
for _, maparg in ipairs(optnames) do
|
||||
it('can set/unset ' .. mapmode .. '-mappings with maparg: ' .. maparg, function()
|
||||
meths.nvim_set_keymap(mapmode, 'lhs', 'rhs', { [maparg] = true })
|
||||
api.nvim_set_keymap(mapmode, 'lhs', 'rhs', { [maparg] = true })
|
||||
eq(
|
||||
generate_mapargs(mapmode, 'lhs', 'rhs', { [maparg] = true }),
|
||||
get_mapargs(mapmode, 'lhs')
|
||||
)
|
||||
meths.nvim_del_keymap(mapmode, 'lhs')
|
||||
api.nvim_del_keymap(mapmode, 'lhs')
|
||||
eq({}, get_mapargs(mapmode, 'lhs'))
|
||||
end)
|
||||
it(
|
||||
@@ -864,9 +864,9 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
|
||||
.. maparg
|
||||
.. ', whose value is false',
|
||||
function()
|
||||
meths.nvim_set_keymap(mapmode, 'lhs', 'rhs', { [maparg] = false })
|
||||
api.nvim_set_keymap(mapmode, 'lhs', 'rhs', { [maparg] = false })
|
||||
eq(generate_mapargs(mapmode, 'lhs', 'rhs'), get_mapargs(mapmode, 'lhs'))
|
||||
meths.nvim_del_keymap(mapmode, 'lhs')
|
||||
api.nvim_del_keymap(mapmode, 'lhs')
|
||||
eq({}, get_mapargs(mapmode, 'lhs'))
|
||||
end
|
||||
)
|
||||
@@ -886,9 +886,9 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
|
||||
.. opt3,
|
||||
function()
|
||||
local opts = { [opt1] = true, [opt2] = false, [opt3] = true }
|
||||
meths.nvim_set_keymap(mapmode, 'lhs', 'rhs', opts)
|
||||
api.nvim_set_keymap(mapmode, 'lhs', 'rhs', opts)
|
||||
eq(generate_mapargs(mapmode, 'lhs', 'rhs', opts), get_mapargs(mapmode, 'lhs'))
|
||||
meths.nvim_del_keymap(mapmode, 'lhs')
|
||||
api.nvim_del_keymap(mapmode, 'lhs')
|
||||
eq({}, get_mapargs(mapmode, 'lhs'))
|
||||
end
|
||||
)
|
||||
@@ -926,7 +926,7 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
|
||||
exec_lua [[
|
||||
vim.api.nvim_set_keymap('n', 'asdf', '', {callback = function() print('jkl;') end })
|
||||
]]
|
||||
assert.truthy(string.match(funcs.mapcheck('asdf', 'n'), '^<Lua %d+>'))
|
||||
assert.truthy(string.match(fn.mapcheck('asdf', 'n'), '^<Lua %d+>'))
|
||||
end)
|
||||
|
||||
it('maparg() returns lua mapping correctly', function()
|
||||
@@ -939,9 +939,9 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
|
||||
]])
|
||||
)
|
||||
|
||||
assert.truthy(string.match(funcs.maparg('asdf', 'n'), '^<Lua %d+>'))
|
||||
assert.truthy(string.match(fn.maparg('asdf', 'n'), '^<Lua %d+>'))
|
||||
|
||||
local mapargs = funcs.maparg('asdf', 'n', false, true)
|
||||
local mapargs = fn.maparg('asdf', 'n', false, true)
|
||||
mapargs.callback = nil
|
||||
mapargs.lhsraw = nil
|
||||
mapargs.lhsrawalt = nil
|
||||
@@ -968,7 +968,7 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
|
||||
|
||||
feed('aa')
|
||||
|
||||
eq({ 'π<M-π>foo<' }, meths.nvim_buf_get_lines(0, 0, -1, false))
|
||||
eq({ 'π<M-π>foo<' }, api.nvim_buf_get_lines(0, 0, -1, false))
|
||||
end)
|
||||
|
||||
it('can make lua expr mappings without replacing keycodes', function()
|
||||
@@ -978,7 +978,7 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
|
||||
|
||||
feed('iaa<esc>')
|
||||
|
||||
eq({ '<space>' }, meths.nvim_buf_get_lines(0, 0, -1, false))
|
||||
eq({ '<space>' }, api.nvim_buf_get_lines(0, 0, -1, false))
|
||||
end)
|
||||
|
||||
it('lua expr mapping returning nil is equivalent to returning an empty string', function()
|
||||
@@ -988,7 +988,7 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
|
||||
|
||||
feed('iaa<esc>')
|
||||
|
||||
eq({ '' }, meths.nvim_buf_get_lines(0, 0, -1, false))
|
||||
eq({ '' }, api.nvim_buf_get_lines(0, 0, -1, false))
|
||||
end)
|
||||
|
||||
it('does not reset pum in lua mapping', function()
|
||||
@@ -1091,7 +1091,7 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
|
||||
end)
|
||||
|
||||
it('can set descriptions on mappings', function()
|
||||
meths.nvim_set_keymap('n', 'lhs', 'rhs', { desc = 'map description' })
|
||||
api.nvim_set_keymap('n', 'lhs', 'rhs', { desc = 'map description' })
|
||||
eq(generate_mapargs('n', 'lhs', 'rhs', { desc = 'map description' }), get_mapargs('n', 'lhs'))
|
||||
eq('\nn lhs rhs\n map description', helpers.exec_capture('nmap lhs'))
|
||||
end)
|
||||
@@ -1106,10 +1106,10 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
|
||||
]]
|
||||
|
||||
feed 'iThe foo and the bar and the foo again<esc>'
|
||||
eq('The 1 and the bar and the 2 again', meths.nvim_get_current_line())
|
||||
eq('The 1 and the bar and the 2 again', api.nvim_get_current_line())
|
||||
|
||||
feed ':let x = "The foo is the one"<cr>'
|
||||
eq('The 3 is the one', meths.nvim_eval 'x')
|
||||
eq('The 3 is the one', api.nvim_eval 'x')
|
||||
end)
|
||||
|
||||
it('can define insert mode abbreviations with lua callbacks', function()
|
||||
@@ -1122,10 +1122,10 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
|
||||
]]
|
||||
|
||||
feed 'iThe foo and the bar and the foo again<esc>'
|
||||
eq('The 1 and the bar and the 2 again', meths.nvim_get_current_line())
|
||||
eq('The 1 and the bar and the 2 again', api.nvim_get_current_line())
|
||||
|
||||
feed ':let x = "The foo is the one"<cr>'
|
||||
eq('The foo is the one', meths.nvim_eval 'x')
|
||||
eq('The foo is the one', api.nvim_eval 'x')
|
||||
end)
|
||||
|
||||
it('can define cmdline mode abbreviations with lua callbacks', function()
|
||||
@@ -1138,10 +1138,10 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
|
||||
]]
|
||||
|
||||
feed 'iThe foo and the bar and the foo again<esc>'
|
||||
eq('The foo and the bar and the foo again', meths.nvim_get_current_line())
|
||||
eq('The foo and the bar and the foo again', api.nvim_get_current_line())
|
||||
|
||||
feed ':let x = "The foo is the one"<cr>'
|
||||
eq('The 1 is the one', meths.nvim_eval 'x')
|
||||
eq('The 1 is the one', api.nvim_eval 'x')
|
||||
end)
|
||||
end)
|
||||
|
||||
@@ -1164,9 +1164,9 @@ describe('nvim_buf_set_keymap, nvim_buf_del_keymap', function()
|
||||
local function make_two_buffers(start_from_first)
|
||||
command('set hidden')
|
||||
|
||||
local first_buf = meths.nvim_call_function('bufnr', { '%' })
|
||||
local first_buf = api.nvim_call_function('bufnr', { '%' })
|
||||
command('new')
|
||||
local second_buf = meths.nvim_call_function('bufnr', { '%' })
|
||||
local second_buf = api.nvim_call_function('bufnr', { '%' })
|
||||
neq(second_buf, first_buf) -- sanity check
|
||||
|
||||
if start_from_first then
|
||||
@@ -1179,66 +1179,66 @@ describe('nvim_buf_set_keymap, nvim_buf_del_keymap', function()
|
||||
it('rejects negative bufnr values', function()
|
||||
eq(
|
||||
'Wrong type for argument 1 when calling nvim_buf_set_keymap, expecting Buffer',
|
||||
pcall_err(meths.nvim_buf_set_keymap, -1, '', 'lhs', 'rhs', {})
|
||||
pcall_err(api.nvim_buf_set_keymap, -1, '', 'lhs', 'rhs', {})
|
||||
)
|
||||
end)
|
||||
|
||||
it('can set mappings active in the current buffer but not others', function()
|
||||
local first, second = make_two_buffers(true)
|
||||
|
||||
meths.nvim_buf_set_keymap(0, '', 'lhs', 'irhs<Esc>', {})
|
||||
api.nvim_buf_set_keymap(0, '', 'lhs', 'irhs<Esc>', {})
|
||||
command('normal lhs')
|
||||
eq({ 'rhs' }, meths.nvim_buf_get_lines(0, 0, 1, 1))
|
||||
eq({ 'rhs' }, api.nvim_buf_get_lines(0, 0, 1, 1))
|
||||
|
||||
-- mapping should have no effect in new buffer
|
||||
switch_to_buf(second)
|
||||
command('normal lhs')
|
||||
eq({ '' }, meths.nvim_buf_get_lines(0, 0, 1, 1))
|
||||
eq({ '' }, api.nvim_buf_get_lines(0, 0, 1, 1))
|
||||
|
||||
-- mapping should remain active in old buffer
|
||||
switch_to_buf(first)
|
||||
command('normal ^lhs')
|
||||
eq({ 'rhsrhs' }, meths.nvim_buf_get_lines(0, 0, 1, 1))
|
||||
eq({ 'rhsrhs' }, api.nvim_buf_get_lines(0, 0, 1, 1))
|
||||
end)
|
||||
|
||||
it('can set local mappings in buffer other than current', function()
|
||||
local first = make_two_buffers(false)
|
||||
meths.nvim_buf_set_keymap(first, '', 'lhs', 'irhs<Esc>', {})
|
||||
api.nvim_buf_set_keymap(first, '', 'lhs', 'irhs<Esc>', {})
|
||||
|
||||
-- shouldn't do anything
|
||||
command('normal lhs')
|
||||
eq({ '' }, meths.nvim_buf_get_lines(0, 0, 1, 1))
|
||||
eq({ '' }, api.nvim_buf_get_lines(0, 0, 1, 1))
|
||||
|
||||
-- should take effect
|
||||
switch_to_buf(first)
|
||||
command('normal lhs')
|
||||
eq({ 'rhs' }, meths.nvim_buf_get_lines(0, 0, 1, 1))
|
||||
eq({ 'rhs' }, api.nvim_buf_get_lines(0, 0, 1, 1))
|
||||
end)
|
||||
|
||||
it('can disable mappings made in another buffer, inside that buffer', function()
|
||||
local first = make_two_buffers(false)
|
||||
meths.nvim_buf_set_keymap(first, '', 'lhs', 'irhs<Esc>', {})
|
||||
meths.nvim_buf_del_keymap(first, '', 'lhs')
|
||||
api.nvim_buf_set_keymap(first, '', 'lhs', 'irhs<Esc>', {})
|
||||
api.nvim_buf_del_keymap(first, '', 'lhs')
|
||||
switch_to_buf(first)
|
||||
|
||||
-- shouldn't do anything
|
||||
command('normal lhs')
|
||||
eq({ '' }, meths.nvim_buf_get_lines(0, 0, 1, 1))
|
||||
eq({ '' }, api.nvim_buf_get_lines(0, 0, 1, 1))
|
||||
end)
|
||||
|
||||
it("can't disable mappings given wrong buffer handle", function()
|
||||
local first, second = make_two_buffers(false)
|
||||
meths.nvim_buf_set_keymap(first, '', 'lhs', 'irhs<Esc>', {})
|
||||
eq('E31: No such mapping', pcall_err(meths.nvim_buf_del_keymap, second, '', 'lhs'))
|
||||
api.nvim_buf_set_keymap(first, '', 'lhs', 'irhs<Esc>', {})
|
||||
eq('E31: No such mapping', pcall_err(api.nvim_buf_del_keymap, second, '', 'lhs'))
|
||||
|
||||
-- should still work
|
||||
switch_to_buf(first)
|
||||
command('normal lhs')
|
||||
eq({ 'rhs' }, meths.nvim_buf_get_lines(0, 0, 1, 1))
|
||||
eq({ 'rhs' }, api.nvim_buf_get_lines(0, 0, 1, 1))
|
||||
end)
|
||||
|
||||
it('does not crash when setting mapping in a non-existing buffer #13541', function()
|
||||
pcall_err(meths.nvim_buf_set_keymap, 100, '', 'lsh', 'irhs<Esc>', {})
|
||||
pcall_err(api.nvim_buf_set_keymap, 100, '', 'lsh', 'irhs<Esc>', {})
|
||||
helpers.assert_alive()
|
||||
end)
|
||||
|
||||
@@ -1264,7 +1264,7 @@ describe('nvim_buf_set_keymap, nvim_buf_del_keymap', function()
|
||||
|
||||
feed('aa')
|
||||
|
||||
eq({ 'π<M-π>foo<' }, meths.nvim_buf_get_lines(0, 0, -1, false))
|
||||
eq({ 'π<M-π>foo<' }, api.nvim_buf_get_lines(0, 0, -1, false))
|
||||
end)
|
||||
|
||||
it('can make lua expr mappings without replacing keycodes', function()
|
||||
@@ -1274,7 +1274,7 @@ describe('nvim_buf_set_keymap, nvim_buf_del_keymap', function()
|
||||
|
||||
feed('iaa<esc>')
|
||||
|
||||
eq({ '<space>' }, meths.nvim_buf_get_lines(0, 0, -1, false))
|
||||
eq({ '<space>' }, api.nvim_buf_get_lines(0, 0, -1, false))
|
||||
end)
|
||||
|
||||
it('can overwrite lua mappings', function()
|
||||
|
||||
@@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')(after_each)
|
||||
|
||||
local clear = helpers.clear
|
||||
local eq = helpers.eq
|
||||
local funcs = helpers.funcs
|
||||
local fn = helpers.fn
|
||||
local neq = helpers.neq
|
||||
local nvim_argv = helpers.nvim_argv
|
||||
local request = helpers.request
|
||||
@@ -15,28 +15,28 @@ describe('API', function()
|
||||
|
||||
describe('nvim_get_proc_children', function()
|
||||
it('returns child process ids', function()
|
||||
local this_pid = funcs.getpid()
|
||||
local this_pid = fn.getpid()
|
||||
|
||||
-- Might be non-zero already (left-over from some other test?),
|
||||
-- but this is not what is tested here.
|
||||
local initial_children = request('nvim_get_proc_children', this_pid)
|
||||
|
||||
local job1 = funcs.jobstart(nvim_argv)
|
||||
local job1 = fn.jobstart(nvim_argv)
|
||||
retry(nil, nil, function()
|
||||
eq(#initial_children + 1, #request('nvim_get_proc_children', this_pid))
|
||||
end)
|
||||
|
||||
local job2 = funcs.jobstart(nvim_argv)
|
||||
local job2 = fn.jobstart(nvim_argv)
|
||||
retry(nil, nil, function()
|
||||
eq(#initial_children + 2, #request('nvim_get_proc_children', this_pid))
|
||||
end)
|
||||
|
||||
funcs.jobstop(job1)
|
||||
fn.jobstop(job1)
|
||||
retry(nil, nil, function()
|
||||
eq(#initial_children + 1, #request('nvim_get_proc_children', this_pid))
|
||||
end)
|
||||
|
||||
funcs.jobstop(job2)
|
||||
fn.jobstop(job2)
|
||||
retry(nil, nil, function()
|
||||
eq(#initial_children, #request('nvim_get_proc_children', this_pid))
|
||||
end)
|
||||
@@ -60,7 +60,7 @@ describe('API', function()
|
||||
|
||||
describe('nvim_get_proc', function()
|
||||
it('returns process info', function()
|
||||
local pid = funcs.getpid()
|
||||
local pid = fn.getpid()
|
||||
local pinfo = request('nvim_get_proc', pid)
|
||||
eq((is_os('win') and 'nvim.exe' or 'nvim'), pinfo.name)
|
||||
eq(pid, pinfo.pid)
|
||||
|
||||
@@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')(after_each)
|
||||
local assert_log = helpers.assert_log
|
||||
local eq, clear, eval, command, next_msg =
|
||||
helpers.eq, helpers.clear, helpers.eval, helpers.command, helpers.next_msg
|
||||
local meths = helpers.meths
|
||||
local api = helpers.api
|
||||
local exec_lua = helpers.exec_lua
|
||||
local retry = helpers.retry
|
||||
local assert_alive = helpers.assert_alive
|
||||
@@ -14,7 +14,7 @@ describe('notify', function()
|
||||
|
||||
before_each(function()
|
||||
clear()
|
||||
channel = meths.nvim_get_api_info()[1]
|
||||
channel = api.nvim_get_api_info()[1]
|
||||
end)
|
||||
|
||||
after_each(function()
|
||||
@@ -33,21 +33,21 @@ describe('notify', function()
|
||||
|
||||
describe('passing 0 as the channel id', function()
|
||||
it('sends the notification/args to all subscribed channels', function()
|
||||
meths.nvim_subscribe('event2')
|
||||
api.nvim_subscribe('event2')
|
||||
eval('rpcnotify(0, "event1", 1, 2, 3)')
|
||||
eval('rpcnotify(0, "event2", 4, 5, 6)')
|
||||
eval('rpcnotify(0, "event2", 7, 8, 9)')
|
||||
eq({ 'notification', 'event2', { 4, 5, 6 } }, next_msg())
|
||||
eq({ 'notification', 'event2', { 7, 8, 9 } }, next_msg())
|
||||
meths.nvim_unsubscribe('event2')
|
||||
meths.nvim_subscribe('event1')
|
||||
api.nvim_unsubscribe('event2')
|
||||
api.nvim_subscribe('event1')
|
||||
eval('rpcnotify(0, "event2", 10, 11, 12)')
|
||||
eval('rpcnotify(0, "event1", 13, 14, 15)')
|
||||
eq({ 'notification', 'event1', { 13, 14, 15 } }, next_msg())
|
||||
end)
|
||||
|
||||
it('does not crash for deeply nested variable', function()
|
||||
meths.nvim_set_var('l', {})
|
||||
api.nvim_set_var('l', {})
|
||||
local nest_level = 1000
|
||||
command(('call map(range(%u), "extend(g:, {\'l\': [g:l]})")'):format(nest_level - 1))
|
||||
eval('rpcnotify(' .. channel .. ', "event", g:l)')
|
||||
@@ -79,10 +79,10 @@ describe('notify', function()
|
||||
clear { env = {
|
||||
NVIM_LOG_FILE = testlog,
|
||||
} }
|
||||
meths.nvim_subscribe('event1')
|
||||
meths.nvim_unsubscribe('doesnotexist')
|
||||
api.nvim_subscribe('event1')
|
||||
api.nvim_unsubscribe('doesnotexist')
|
||||
assert_log("tried to unsubscribe unknown event 'doesnotexist'", testlog, 10)
|
||||
meths.nvim_unsubscribe('event1')
|
||||
api.nvim_unsubscribe('event1')
|
||||
assert_alive()
|
||||
end)
|
||||
|
||||
@@ -106,7 +106,7 @@ describe('notify', function()
|
||||
exec_lua([[ return {pcall(vim.rpcrequest, ..., 'nvim_eval', '1+1')}]], catchan)
|
||||
)
|
||||
retry(nil, 3000, function()
|
||||
eq({}, meths.nvim_get_chan_info(catchan))
|
||||
eq({}, api.nvim_get_chan_info(catchan))
|
||||
end) -- cat be dead :(
|
||||
end)
|
||||
end)
|
||||
|
||||
@@ -4,10 +4,10 @@ local helpers = require('test.functional.helpers')(after_each)
|
||||
|
||||
local clear, eval = helpers.clear, helpers.eval
|
||||
local eq, neq, run, stop = helpers.eq, helpers.neq, helpers.run, helpers.stop
|
||||
local nvim_prog, command, funcs = helpers.nvim_prog, helpers.command, helpers.funcs
|
||||
local nvim_prog, command, fn = helpers.nvim_prog, helpers.command, helpers.fn
|
||||
local source, next_msg = helpers.source, helpers.next_msg
|
||||
local ok = helpers.ok
|
||||
local meths = helpers.meths
|
||||
local api = helpers.api
|
||||
local spawn, merge_args = helpers.spawn, helpers.merge_args
|
||||
local set_session = helpers.set_session
|
||||
local pcall_err = helpers.pcall_err
|
||||
@@ -18,7 +18,7 @@ describe('server -> client', function()
|
||||
|
||||
before_each(function()
|
||||
clear()
|
||||
cid = meths.nvim_get_api_info()[1]
|
||||
cid = api.nvim_get_api_info()[1]
|
||||
end)
|
||||
|
||||
it('handles unexpected closed stream while preparing RPC response', function()
|
||||
@@ -77,15 +77,15 @@ describe('server -> client', function()
|
||||
describe('recursive call', function()
|
||||
it('works', function()
|
||||
local function on_setup()
|
||||
meths.nvim_set_var('result1', 0)
|
||||
meths.nvim_set_var('result2', 0)
|
||||
meths.nvim_set_var('result3', 0)
|
||||
meths.nvim_set_var('result4', 0)
|
||||
api.nvim_set_var('result1', 0)
|
||||
api.nvim_set_var('result2', 0)
|
||||
api.nvim_set_var('result3', 0)
|
||||
api.nvim_set_var('result4', 0)
|
||||
command('let g:result1 = rpcrequest(' .. cid .. ', "rcall", 2)')
|
||||
eq(4, meths.nvim_get_var('result1'))
|
||||
eq(8, meths.nvim_get_var('result2'))
|
||||
eq(16, meths.nvim_get_var('result3'))
|
||||
eq(32, meths.nvim_get_var('result4'))
|
||||
eq(4, api.nvim_get_var('result1'))
|
||||
eq(8, api.nvim_get_var('result2'))
|
||||
eq(16, api.nvim_get_var('result3'))
|
||||
eq(32, api.nvim_get_var('result4'))
|
||||
stop()
|
||||
end
|
||||
|
||||
@@ -113,12 +113,12 @@ describe('server -> client', function()
|
||||
it('does not delay notifications during pending request', function()
|
||||
local received = false
|
||||
local function on_setup()
|
||||
eq('retval', funcs.rpcrequest(cid, 'doit'))
|
||||
eq('retval', fn.rpcrequest(cid, 'doit'))
|
||||
stop()
|
||||
end
|
||||
local function on_request(method)
|
||||
if method == 'doit' then
|
||||
funcs.rpcnotify(cid, 'headsup')
|
||||
fn.rpcnotify(cid, 'headsup')
|
||||
eq(true, received)
|
||||
return 'retval'
|
||||
end
|
||||
@@ -231,8 +231,8 @@ describe('server -> client', function()
|
||||
describe('jobstart()', function()
|
||||
local jobid
|
||||
before_each(function()
|
||||
local channel = meths.nvim_get_api_info()[1]
|
||||
meths.nvim_set_var('channel', channel)
|
||||
local channel = api.nvim_get_api_info()[1]
|
||||
api.nvim_set_var('channel', channel)
|
||||
source([[
|
||||
function! s:OnEvent(id, data, event)
|
||||
call rpcnotify(g:channel, a:event, 0, a:data)
|
||||
@@ -244,7 +244,7 @@ describe('server -> client', function()
|
||||
\ 'rpc': v:true
|
||||
\ }
|
||||
]])
|
||||
meths.nvim_set_var('args', {
|
||||
api.nvim_set_var('args', {
|
||||
nvim_prog,
|
||||
'-ll',
|
||||
'test/functional/api/rpc_fixture.lua',
|
||||
@@ -256,7 +256,7 @@ describe('server -> client', function()
|
||||
end)
|
||||
|
||||
after_each(function()
|
||||
pcall(funcs.jobstop, jobid)
|
||||
pcall(fn.jobstop, jobid)
|
||||
end)
|
||||
|
||||
if helpers.skip(helpers.is_os('win')) then
|
||||
@@ -264,16 +264,16 @@ describe('server -> client', function()
|
||||
end
|
||||
|
||||
it('rpc and text stderr can be combined', function()
|
||||
local status, rv = pcall(funcs.rpcrequest, jobid, 'poll')
|
||||
local status, rv = pcall(fn.rpcrequest, jobid, 'poll')
|
||||
if not status then
|
||||
error(string.format('missing nvim Lua module? (%s)', rv))
|
||||
end
|
||||
eq('ok', rv)
|
||||
funcs.rpcnotify(jobid, 'ping')
|
||||
fn.rpcnotify(jobid, 'ping')
|
||||
eq({ 'notification', 'pong', {} }, next_msg())
|
||||
eq('done!', funcs.rpcrequest(jobid, 'write_stderr', 'fluff\n'))
|
||||
eq('done!', fn.rpcrequest(jobid, 'write_stderr', 'fluff\n'))
|
||||
eq({ 'notification', 'stderr', { 0, { 'fluff', '' } } }, next_msg())
|
||||
pcall(funcs.rpcrequest, jobid, 'exit')
|
||||
pcall(fn.rpcrequest, jobid, 'exit')
|
||||
eq({ 'notification', 'stderr', { 0, { '' } } }, next_msg())
|
||||
eq({ 'notification', 'exit', { 0, 0 } }, next_msg())
|
||||
end)
|
||||
@@ -282,29 +282,29 @@ describe('server -> client', function()
|
||||
describe('connecting to another (peer) nvim', function()
|
||||
local nvim_argv = merge_args(helpers.nvim_argv, { '--headless' })
|
||||
local function connect_test(server, mode, address)
|
||||
local serverpid = funcs.getpid()
|
||||
local serverpid = fn.getpid()
|
||||
local client = spawn(nvim_argv, false, nil, true)
|
||||
set_session(client)
|
||||
|
||||
local clientpid = funcs.getpid()
|
||||
local clientpid = fn.getpid()
|
||||
neq(serverpid, clientpid)
|
||||
local id = funcs.sockconnect(mode, address, { rpc = true })
|
||||
local id = fn.sockconnect(mode, address, { rpc = true })
|
||||
ok(id > 0)
|
||||
|
||||
funcs.rpcrequest(id, 'nvim_set_current_line', 'hello')
|
||||
local client_id = funcs.rpcrequest(id, 'nvim_get_api_info')[1]
|
||||
fn.rpcrequest(id, 'nvim_set_current_line', 'hello')
|
||||
local client_id = fn.rpcrequest(id, 'nvim_get_api_info')[1]
|
||||
|
||||
set_session(server)
|
||||
eq(serverpid, funcs.getpid())
|
||||
eq('hello', meths.nvim_get_current_line())
|
||||
eq(serverpid, fn.getpid())
|
||||
eq('hello', api.nvim_get_current_line())
|
||||
|
||||
-- method calls work both ways
|
||||
funcs.rpcrequest(client_id, 'nvim_set_current_line', 'howdy!')
|
||||
eq(id, funcs.rpcrequest(client_id, 'nvim_get_api_info')[1])
|
||||
fn.rpcrequest(client_id, 'nvim_set_current_line', 'howdy!')
|
||||
eq(id, fn.rpcrequest(client_id, 'nvim_get_api_info')[1])
|
||||
|
||||
set_session(client)
|
||||
eq(clientpid, funcs.getpid())
|
||||
eq('howdy!', meths.nvim_get_current_line())
|
||||
eq(clientpid, fn.getpid())
|
||||
eq('howdy!', api.nvim_get_current_line())
|
||||
|
||||
server:close()
|
||||
client:close()
|
||||
@@ -313,7 +313,7 @@ describe('server -> client', function()
|
||||
it('via named pipe', function()
|
||||
local server = spawn(nvim_argv)
|
||||
set_session(server)
|
||||
local address = funcs.serverlist()[1]
|
||||
local address = fn.serverlist()[1]
|
||||
local first = string.sub(address, 1, 1)
|
||||
ok(first == '/' or first == '\\')
|
||||
connect_test(server, 'pipe', address)
|
||||
@@ -322,7 +322,7 @@ describe('server -> client', function()
|
||||
it('via ipv4 address', function()
|
||||
local server = spawn(nvim_argv)
|
||||
set_session(server)
|
||||
local status, address = pcall(funcs.serverstart, '127.0.0.1:')
|
||||
local status, address = pcall(fn.serverstart, '127.0.0.1:')
|
||||
if not status then
|
||||
pending('no ipv4 stack')
|
||||
end
|
||||
@@ -333,7 +333,7 @@ describe('server -> client', function()
|
||||
it('via ipv6 address', function()
|
||||
local server = spawn(nvim_argv)
|
||||
set_session(server)
|
||||
local status, address = pcall(funcs.serverstart, '::1:')
|
||||
local status, address = pcall(fn.serverstart, '::1:')
|
||||
if not status then
|
||||
pending('no ipv6 stack')
|
||||
end
|
||||
@@ -344,7 +344,7 @@ describe('server -> client', function()
|
||||
it('via hostname', function()
|
||||
local server = spawn(nvim_argv)
|
||||
set_session(server)
|
||||
local address = funcs.serverstart('localhost:')
|
||||
local address = fn.serverstart('localhost:')
|
||||
eq('localhost:', string.sub(address, 1, 10))
|
||||
connect_test(server, 'tcp', address)
|
||||
end)
|
||||
@@ -352,12 +352,12 @@ describe('server -> client', function()
|
||||
it('does not crash on receiving UI events', function()
|
||||
local server = spawn(nvim_argv)
|
||||
set_session(server)
|
||||
local address = funcs.serverlist()[1]
|
||||
local address = fn.serverlist()[1]
|
||||
local client = spawn(nvim_argv, false, nil, true)
|
||||
set_session(client)
|
||||
|
||||
local id = funcs.sockconnect('pipe', address, { rpc = true })
|
||||
funcs.rpcrequest(id, 'nvim_ui_attach', 80, 24, {})
|
||||
local id = fn.sockconnect('pipe', address, { rpc = true })
|
||||
fn.rpcrequest(id, 'nvim_ui_attach', 80, 24, {})
|
||||
assert_alive()
|
||||
|
||||
server:close()
|
||||
@@ -367,18 +367,18 @@ describe('server -> client', function()
|
||||
|
||||
describe('connecting to its own pipe address', function()
|
||||
it('does not deadlock', function()
|
||||
local address = funcs.serverlist()[1]
|
||||
local address = fn.serverlist()[1]
|
||||
local first = string.sub(address, 1, 1)
|
||||
ok(first == '/' or first == '\\')
|
||||
local serverpid = funcs.getpid()
|
||||
local serverpid = fn.getpid()
|
||||
|
||||
local id = funcs.sockconnect('pipe', address, { rpc = true })
|
||||
local id = fn.sockconnect('pipe', address, { rpc = true })
|
||||
|
||||
funcs.rpcrequest(id, 'nvim_set_current_line', 'hello')
|
||||
eq('hello', meths.nvim_get_current_line())
|
||||
eq(serverpid, funcs.rpcrequest(id, 'nvim_eval', 'getpid()'))
|
||||
fn.rpcrequest(id, 'nvim_set_current_line', 'hello')
|
||||
eq('hello', api.nvim_get_current_line())
|
||||
eq(serverpid, fn.rpcrequest(id, 'nvim_eval', 'getpid()'))
|
||||
|
||||
eq(id, funcs.rpcrequest(id, 'nvim_get_api_info')[1])
|
||||
eq(id, fn.rpcrequest(id, 'nvim_get_api_info')[1])
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
local helpers = require('test.functional.helpers')(after_each)
|
||||
local clear, eq, ok = helpers.clear, helpers.eq, helpers.ok
|
||||
local meths = helpers.meths
|
||||
local funcs = helpers.funcs
|
||||
local api = helpers.api
|
||||
local fn = helpers.fn
|
||||
local request = helpers.request
|
||||
local NIL = vim.NIL
|
||||
local pcall_err = helpers.pcall_err
|
||||
@@ -14,33 +14,33 @@ describe('api/tabpage', function()
|
||||
it('works', function()
|
||||
helpers.command('tabnew')
|
||||
helpers.command('vsplit')
|
||||
local tab1, tab2 = unpack(meths.nvim_list_tabpages())
|
||||
local win1, win2, win3 = unpack(meths.nvim_list_wins())
|
||||
eq({ win1 }, meths.nvim_tabpage_list_wins(tab1))
|
||||
eq({ win2, win3 }, meths.nvim_tabpage_list_wins(tab2))
|
||||
eq(win2, meths.nvim_tabpage_get_win(tab2))
|
||||
meths.nvim_set_current_win(win3)
|
||||
eq(win3, meths.nvim_tabpage_get_win(tab2))
|
||||
local tab1, tab2 = unpack(api.nvim_list_tabpages())
|
||||
local win1, win2, win3 = unpack(api.nvim_list_wins())
|
||||
eq({ win1 }, api.nvim_tabpage_list_wins(tab1))
|
||||
eq({ win2, win3 }, api.nvim_tabpage_list_wins(tab2))
|
||||
eq(win2, api.nvim_tabpage_get_win(tab2))
|
||||
api.nvim_set_current_win(win3)
|
||||
eq(win3, api.nvim_tabpage_get_win(tab2))
|
||||
end)
|
||||
|
||||
it('validates args', function()
|
||||
eq('Invalid tabpage id: 23', pcall_err(meths.nvim_tabpage_list_wins, 23))
|
||||
eq('Invalid tabpage id: 23', pcall_err(api.nvim_tabpage_list_wins, 23))
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('{get,set,del}_var', function()
|
||||
it('works', function()
|
||||
meths.nvim_tabpage_set_var(0, 'lua', { 1, 2, { ['3'] = 1 } })
|
||||
eq({ 1, 2, { ['3'] = 1 } }, meths.nvim_tabpage_get_var(0, 'lua'))
|
||||
eq({ 1, 2, { ['3'] = 1 } }, meths.nvim_eval('t:lua'))
|
||||
eq(1, funcs.exists('t:lua'))
|
||||
meths.nvim_tabpage_del_var(0, 'lua')
|
||||
eq(0, funcs.exists('t:lua'))
|
||||
eq('Key not found: lua', pcall_err(meths.nvim_tabpage_del_var, 0, 'lua'))
|
||||
meths.nvim_tabpage_set_var(0, 'lua', 1)
|
||||
api.nvim_tabpage_set_var(0, 'lua', { 1, 2, { ['3'] = 1 } })
|
||||
eq({ 1, 2, { ['3'] = 1 } }, api.nvim_tabpage_get_var(0, 'lua'))
|
||||
eq({ 1, 2, { ['3'] = 1 } }, api.nvim_eval('t:lua'))
|
||||
eq(1, fn.exists('t:lua'))
|
||||
api.nvim_tabpage_del_var(0, 'lua')
|
||||
eq(0, fn.exists('t:lua'))
|
||||
eq('Key not found: lua', pcall_err(api.nvim_tabpage_del_var, 0, 'lua'))
|
||||
api.nvim_tabpage_set_var(0, 'lua', 1)
|
||||
command('lockvar t:lua')
|
||||
eq('Key is locked: lua', pcall_err(meths.nvim_tabpage_del_var, 0, 'lua'))
|
||||
eq('Key is locked: lua', pcall_err(meths.nvim_tabpage_set_var, 0, 'lua', 1))
|
||||
eq('Key is locked: lua', pcall_err(api.nvim_tabpage_del_var, 0, 'lua'))
|
||||
eq('Key is locked: lua', pcall_err(api.nvim_tabpage_set_var, 0, 'lua', 1))
|
||||
end)
|
||||
|
||||
it('tabpage_set_var returns the old value', function()
|
||||
@@ -61,28 +61,28 @@ describe('api/tabpage', function()
|
||||
|
||||
describe('get_number', function()
|
||||
it('works', function()
|
||||
local tabs = meths.nvim_list_tabpages()
|
||||
eq(1, meths.nvim_tabpage_get_number(tabs[1]))
|
||||
local tabs = api.nvim_list_tabpages()
|
||||
eq(1, api.nvim_tabpage_get_number(tabs[1]))
|
||||
|
||||
helpers.command('tabnew')
|
||||
local tab1, tab2 = unpack(meths.nvim_list_tabpages())
|
||||
eq(1, meths.nvim_tabpage_get_number(tab1))
|
||||
eq(2, meths.nvim_tabpage_get_number(tab2))
|
||||
local tab1, tab2 = unpack(api.nvim_list_tabpages())
|
||||
eq(1, api.nvim_tabpage_get_number(tab1))
|
||||
eq(2, api.nvim_tabpage_get_number(tab2))
|
||||
|
||||
helpers.command('-tabmove')
|
||||
eq(2, meths.nvim_tabpage_get_number(tab1))
|
||||
eq(1, meths.nvim_tabpage_get_number(tab2))
|
||||
eq(2, api.nvim_tabpage_get_number(tab1))
|
||||
eq(1, api.nvim_tabpage_get_number(tab2))
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('is_valid', function()
|
||||
it('works', function()
|
||||
helpers.command('tabnew')
|
||||
local tab = meths.nvim_list_tabpages()[2]
|
||||
meths.nvim_set_current_tabpage(tab)
|
||||
ok(meths.nvim_tabpage_is_valid(tab))
|
||||
local tab = api.nvim_list_tabpages()[2]
|
||||
api.nvim_set_current_tabpage(tab)
|
||||
ok(api.nvim_tabpage_is_valid(tab))
|
||||
helpers.command('tabclose')
|
||||
ok(not meths.nvim_tabpage_is_valid(tab))
|
||||
ok(not api.nvim_tabpage_is_valid(tab))
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
||||
@@ -6,7 +6,7 @@ local eq = helpers.eq
|
||||
local eval = helpers.eval
|
||||
local exec = helpers.exec
|
||||
local feed = helpers.feed
|
||||
local meths = helpers.meths
|
||||
local api = helpers.api
|
||||
local request = helpers.request
|
||||
local pcall_err = helpers.pcall_err
|
||||
|
||||
@@ -23,39 +23,39 @@ describe('nvim_ui_attach()', function()
|
||||
end)
|
||||
|
||||
it('validation', function()
|
||||
eq('No such UI option: foo', pcall_err(meths.nvim_ui_attach, 80, 24, { foo = { 'foo' } }))
|
||||
eq('No such UI option: foo', pcall_err(api.nvim_ui_attach, 80, 24, { foo = { 'foo' } }))
|
||||
|
||||
eq(
|
||||
"Invalid 'ext_linegrid': expected Boolean, got Array",
|
||||
pcall_err(meths.nvim_ui_attach, 80, 24, { ext_linegrid = {} })
|
||||
pcall_err(api.nvim_ui_attach, 80, 24, { ext_linegrid = {} })
|
||||
)
|
||||
eq(
|
||||
"Invalid 'override': expected Boolean, got Array",
|
||||
pcall_err(meths.nvim_ui_attach, 80, 24, { override = {} })
|
||||
pcall_err(api.nvim_ui_attach, 80, 24, { override = {} })
|
||||
)
|
||||
eq(
|
||||
"Invalid 'rgb': expected Boolean, got Array",
|
||||
pcall_err(meths.nvim_ui_attach, 80, 24, { rgb = {} })
|
||||
pcall_err(api.nvim_ui_attach, 80, 24, { rgb = {} })
|
||||
)
|
||||
eq(
|
||||
"Invalid 'term_name': expected String, got Boolean",
|
||||
pcall_err(meths.nvim_ui_attach, 80, 24, { term_name = true })
|
||||
pcall_err(api.nvim_ui_attach, 80, 24, { term_name = true })
|
||||
)
|
||||
eq(
|
||||
"Invalid 'term_colors': expected Integer, got Boolean",
|
||||
pcall_err(meths.nvim_ui_attach, 80, 24, { term_colors = true })
|
||||
pcall_err(api.nvim_ui_attach, 80, 24, { term_colors = true })
|
||||
)
|
||||
eq(
|
||||
"Invalid 'stdin_fd': expected Integer, got String",
|
||||
pcall_err(meths.nvim_ui_attach, 80, 24, { stdin_fd = 'foo' })
|
||||
pcall_err(api.nvim_ui_attach, 80, 24, { stdin_fd = 'foo' })
|
||||
)
|
||||
eq(
|
||||
"Invalid 'stdin_tty': expected Boolean, got String",
|
||||
pcall_err(meths.nvim_ui_attach, 80, 24, { stdin_tty = 'foo' })
|
||||
pcall_err(api.nvim_ui_attach, 80, 24, { stdin_tty = 'foo' })
|
||||
)
|
||||
eq(
|
||||
"Invalid 'stdout_tty': expected Boolean, got String",
|
||||
pcall_err(meths.nvim_ui_attach, 80, 24, { stdout_tty = 'foo' })
|
||||
pcall_err(api.nvim_ui_attach, 80, 24, { stdout_tty = 'foo' })
|
||||
)
|
||||
|
||||
eq('UI not attached to channel: 1', pcall_err(request, 'nvim_ui_try_resize', 40, 10))
|
||||
@@ -117,17 +117,17 @@ it('autocmds VimSuspend/VimResume #22041', function()
|
||||
end)
|
||||
eq({ 's', 'r', 's' }, eval('g:ev'))
|
||||
screen.suspended = false
|
||||
meths.nvim_input_mouse('move', '', '', 0, 0, 0)
|
||||
api.nvim_input_mouse('move', '', '', 0, 0, 0)
|
||||
eq({ 's', 'r', 's', 'r' }, eval('g:ev'))
|
||||
|
||||
feed('<C-Z><C-Z><C-Z>')
|
||||
screen:expect(function()
|
||||
eq(true, screen.suspended)
|
||||
end)
|
||||
meths.nvim_ui_set_focus(false)
|
||||
api.nvim_ui_set_focus(false)
|
||||
eq({ 's', 'r', 's', 'r', 's' }, eval('g:ev'))
|
||||
screen.suspended = false
|
||||
meths.nvim_ui_set_focus(true)
|
||||
api.nvim_ui_set_focus(true)
|
||||
eq({ 's', 'r', 's', 'r', 's', 'r' }, eval('g:ev'))
|
||||
|
||||
command('suspend | suspend | suspend')
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
local helpers = require('test.functional.helpers')(after_each)
|
||||
local clear, funcs, eq = helpers.clear, helpers.funcs, helpers.eq
|
||||
local call = helpers.call
|
||||
local meths = helpers.meths
|
||||
local clear, fn, eq = helpers.clear, helpers.fn, helpers.eq
|
||||
local api = helpers.api
|
||||
|
||||
local function read_mpack_file(fname)
|
||||
local fd = io.open(fname, 'rb')
|
||||
@@ -19,7 +18,7 @@ describe("api_info()['version']", function()
|
||||
before_each(clear)
|
||||
|
||||
it('returns API level', function()
|
||||
local version = call('api_info')['version']
|
||||
local version = fn.api_info()['version']
|
||||
local current = version['api_level']
|
||||
local compat = version['api_compatible']
|
||||
eq('number', type(current))
|
||||
@@ -28,7 +27,7 @@ describe("api_info()['version']", function()
|
||||
end)
|
||||
|
||||
it('returns Nvim version', function()
|
||||
local version = call('api_info')['version']
|
||||
local version = fn.api_info()['version']
|
||||
local major = version['major']
|
||||
local minor = version['minor']
|
||||
local patch = version['patch']
|
||||
@@ -38,10 +37,10 @@ describe("api_info()['version']", function()
|
||||
eq('number', type(minor))
|
||||
eq('number', type(patch))
|
||||
eq('boolean', type(prerelease))
|
||||
eq(1, funcs.has('nvim-' .. major .. '.' .. minor .. '.' .. patch))
|
||||
eq(0, funcs.has('nvim-' .. major .. '.' .. minor .. '.' .. (patch + 1)))
|
||||
eq(0, funcs.has('nvim-' .. major .. '.' .. (minor + 1) .. '.' .. patch))
|
||||
eq(0, funcs.has('nvim-' .. (major + 1) .. '.' .. minor .. '.' .. patch))
|
||||
eq(1, fn.has('nvim-' .. major .. '.' .. minor .. '.' .. patch))
|
||||
eq(0, fn.has('nvim-' .. major .. '.' .. minor .. '.' .. (patch + 1)))
|
||||
eq(0, fn.has('nvim-' .. major .. '.' .. (minor + 1) .. '.' .. patch))
|
||||
eq(0, fn.has('nvim-' .. (major + 1) .. '.' .. minor .. '.' .. patch))
|
||||
assert(build == nil or type(build) == 'string')
|
||||
end)
|
||||
end)
|
||||
@@ -90,14 +89,14 @@ describe('api metadata', function()
|
||||
end
|
||||
end
|
||||
|
||||
local api, compat, stable, api_level
|
||||
local api_info, compat, stable, api_level
|
||||
local old_api = {}
|
||||
setup(function()
|
||||
clear() -- Ensure a session before requesting api_info.
|
||||
api = meths.nvim_get_api_info()[2]
|
||||
compat = api.version.api_compatible
|
||||
api_level = api.version.api_level
|
||||
if api.version.api_prerelease then
|
||||
api_info = api.nvim_get_api_info()[2]
|
||||
compat = api_info.version.api_compatible
|
||||
api_level = api_info.version.api_level
|
||||
if api_info.version.api_prerelease then
|
||||
stable = api_level - 1
|
||||
else
|
||||
stable = api_level
|
||||
@@ -108,7 +107,7 @@ describe('api metadata', function()
|
||||
old_api[level] = read_mpack_file(path)
|
||||
if old_api[level] == nil then
|
||||
local errstr = 'missing metadata fixture for stable level ' .. level .. '. '
|
||||
if level == api_level and not api.version.api_prerelease then
|
||||
if level == api_level and not api_info.version.api_prerelease then
|
||||
errstr = (
|
||||
errstr
|
||||
.. 'If NVIM_API_CURRENT was bumped, '
|
||||
@@ -125,7 +124,7 @@ describe('api metadata', function()
|
||||
end)
|
||||
|
||||
it('functions are compatible with old metadata or have new level', function()
|
||||
local funcs_new = name_table(api.functions)
|
||||
local funcs_new = name_table(api_info.functions)
|
||||
local funcs_compat = {}
|
||||
for level = compat, stable do
|
||||
for _, f in ipairs(old_api[level].functions) do
|
||||
@@ -146,7 +145,7 @@ describe('api metadata', function()
|
||||
funcs_compat[level] = name_table(old_api[level].functions)
|
||||
end
|
||||
|
||||
for _, f in ipairs(api.functions) do
|
||||
for _, f in ipairs(api_info.functions) do
|
||||
if f.since <= stable then
|
||||
local f_old = funcs_compat[f.since][f.name]
|
||||
if f_old == nil then
|
||||
@@ -159,7 +158,7 @@ describe('api metadata', function()
|
||||
.. (stable + 1)
|
||||
.. '.'
|
||||
)
|
||||
if not api.version.api_prerelease then
|
||||
if not api_info.version.api_prerelease then
|
||||
errstr = (
|
||||
errstr
|
||||
.. ' Also bump NVIM_API_CURRENT and set '
|
||||
@@ -172,7 +171,7 @@ describe('api metadata', function()
|
||||
end
|
||||
end
|
||||
elseif f.since > api_level then
|
||||
if api.version.api_prerelease then
|
||||
if api_info.version.api_prerelease then
|
||||
error('New function ' .. f.name .. ' should use since value ' .. api_level)
|
||||
else
|
||||
error(
|
||||
@@ -188,7 +187,7 @@ describe('api metadata', function()
|
||||
end)
|
||||
|
||||
it('UI events are compatible with old metadata or have new level', function()
|
||||
local ui_events_new = name_table(api.ui_events)
|
||||
local ui_events_new = name_table(api_info.ui_events)
|
||||
local ui_events_compat = {}
|
||||
|
||||
-- UI events were formalized in level 3
|
||||
@@ -202,7 +201,7 @@ describe('api metadata', function()
|
||||
ui_events_compat[level] = name_table(old_api[level].ui_events)
|
||||
end
|
||||
|
||||
for _, e in ipairs(api.ui_events) do
|
||||
for _, e in ipairs(api_info.ui_events) do
|
||||
if e.since <= stable then
|
||||
local e_old = ui_events_compat[e.since][e.name]
|
||||
if e_old == nil then
|
||||
@@ -214,7 +213,7 @@ describe('api metadata', function()
|
||||
.. (stable + 1)
|
||||
.. '.'
|
||||
)
|
||||
if not api.version.api_prerelease then
|
||||
if not api_info.version.api_prerelease then
|
||||
errstr = (
|
||||
errstr
|
||||
.. ' Also bump NVIM_API_CURRENT and set '
|
||||
@@ -224,7 +223,7 @@ describe('api metadata', function()
|
||||
error(errstr)
|
||||
end
|
||||
elseif e.since > api_level then
|
||||
if api.version.api_prerelease then
|
||||
if api_info.version.api_prerelease then
|
||||
error('New UI event ' .. e.name .. ' should use since value ' .. api_level)
|
||||
else
|
||||
error(
|
||||
@@ -241,7 +240,7 @@ describe('api metadata', function()
|
||||
|
||||
it('ui_options are preserved from older levels', function()
|
||||
local available_options = {}
|
||||
for _, option in ipairs(api.ui_options) do
|
||||
for _, option in ipairs(api_info.ui_options) do
|
||||
available_options[option] = true
|
||||
end
|
||||
-- UI options were versioned from level 4
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user