aboutsummaryrefslogtreecommitdiff
path: root/test/functional/api/vim_spec.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/api/vim_spec.lua')
-rw-r--r--test/functional/api/vim_spec.lua1616
1 files changed, 802 insertions, 814 deletions
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua
index ba2042d585..aa3b4419cc 100644
--- a/test/functional/api/vim_spec.lua
+++ b/test/functional/api/vim_spec.lua
@@ -8,13 +8,13 @@ local assert_alive = helpers.assert_alive
local NIL = vim.NIL
local clear, eq, neq = helpers.clear, helpers.eq, helpers.neq
local command = helpers.command
-local command_output = helpers.meths.command_output
+local command_output = helpers.api.command_output
local exec = helpers.exec
local exec_capture = helpers.exec_capture
local eval = helpers.eval
local expect = helpers.expect
-local funcs = helpers.funcs
-local meths = helpers.meths
+local fn = helpers.fn
+local api = helpers.api
local matches = helpers.matches
local pesc = vim.pesc
local mkdir_p = helpers.mkdir_p
@@ -71,7 +71,7 @@ describe('API', function()
end)
it('handles errors in async requests', function()
- local error_types = meths.nvim_get_api_info()[2].error_types
+ local error_types = api.nvim_get_api_info()[2].error_types
nvim_async('bogus')
eq({
'notification',
@@ -83,7 +83,7 @@ describe('API', function()
end)
it('failed async request emits nvim_error_event', function()
- local error_types = meths.nvim_get_api_info()[2].error_types
+ local error_types = api.nvim_get_api_info()[2].error_types
nvim_async('command', 'bogus')
eq({
'notification',
@@ -98,37 +98,37 @@ describe('API', function()
command('split')
command('autocmd WinEnter * startinsert')
command('wincmd w')
- eq({ mode = 'i', blocking = false }, meths.nvim_get_mode())
+ eq({ mode = 'i', blocking = false }, api.nvim_get_mode())
end)
describe('nvim_exec2', function()
it('always returns table', function()
-- In built version this results into `vim.empty_dict()`
- eq({}, meths.nvim_exec2('echo "Hello"', {}))
- eq({}, meths.nvim_exec2('echo "Hello"', { output = false }))
- eq({ output = 'Hello' }, meths.nvim_exec2('echo "Hello"', { output = true }))
+ eq({}, api.nvim_exec2('echo "Hello"', {}))
+ eq({}, api.nvim_exec2('echo "Hello"', { output = false }))
+ eq({ output = 'Hello' }, api.nvim_exec2('echo "Hello"', { output = true }))
end)
it('default options', function()
-- Should be equivalent to { output = false }
- meths.nvim_exec2("let x0 = 'a'", {})
- eq('a', meths.nvim_get_var('x0'))
+ api.nvim_exec2("let x0 = 'a'", {})
+ eq('a', api.nvim_get_var('x0'))
end)
it('one-line input', function()
- meths.nvim_exec2("let x1 = 'a'", { output = false })
- eq('a', meths.nvim_get_var('x1'))
+ api.nvim_exec2("let x1 = 'a'", { output = false })
+ eq('a', api.nvim_get_var('x1'))
end)
it(':verbose set {option}?', function()
- meths.nvim_exec2('set nowrap', { output = false })
+ api.nvim_exec2('set nowrap', { output = false })
eq(
{ output = 'nowrap\n\tLast set from anonymous :source' },
- meths.nvim_exec2('verbose set wrap?', { output = true })
+ api.nvim_exec2('verbose set wrap?', { output = true })
)
-- Using script var to force creation of a script item
- meths.nvim_exec2(
+ api.nvim_exec2(
[[
let s:a = 1
set nowrap
@@ -137,39 +137,39 @@ describe('API', function()
)
eq(
{ output = 'nowrap\n\tLast set from anonymous :source (script id 1)' },
- meths.nvim_exec2('verbose set wrap?', { output = true })
+ api.nvim_exec2('verbose set wrap?', { output = true })
)
end)
it('multiline input', function()
-- Heredoc + empty lines.
- meths.nvim_exec2("let x2 = 'a'\n", { output = false })
- eq('a', meths.nvim_get_var('x2'))
- meths.nvim_exec2('lua <<EOF\n\n\n\ny=3\n\n\nEOF', { output = false })
- eq(3, meths.nvim_eval("luaeval('y')"))
+ api.nvim_exec2("let x2 = 'a'\n", { output = false })
+ eq('a', api.nvim_get_var('x2'))
+ api.nvim_exec2('lua <<EOF\n\n\n\ny=3\n\n\nEOF', { output = false })
+ eq(3, api.nvim_eval("luaeval('y')"))
- eq({}, meths.nvim_exec2('lua <<EOF\ny=3\nEOF', { output = false }))
- eq(3, meths.nvim_eval("luaeval('y')"))
+ eq({}, api.nvim_exec2('lua <<EOF\ny=3\nEOF', { output = false }))
+ eq(3, api.nvim_eval("luaeval('y')"))
-- Multiple statements
- meths.nvim_exec2('let x1=1\nlet x2=2\nlet x3=3\n', { output = false })
- eq(1, meths.nvim_eval('x1'))
- eq(2, meths.nvim_eval('x2'))
- eq(3, meths.nvim_eval('x3'))
+ api.nvim_exec2('let x1=1\nlet x2=2\nlet x3=3\n', { output = false })
+ eq(1, api.nvim_eval('x1'))
+ eq(2, api.nvim_eval('x2'))
+ eq(3, api.nvim_eval('x3'))
-- Functions
- meths.nvim_exec2('function Foo()\ncall setline(1,["xxx"])\nendfunction', { output = false })
- eq('', meths.nvim_get_current_line())
- meths.nvim_exec2('call Foo()', { output = false })
- eq('xxx', meths.nvim_get_current_line())
+ api.nvim_exec2('function Foo()\ncall setline(1,["xxx"])\nendfunction', { output = false })
+ eq('', api.nvim_get_current_line())
+ api.nvim_exec2('call Foo()', { output = false })
+ eq('xxx', api.nvim_get_current_line())
-- Autocmds
- meths.nvim_exec2('autocmd BufAdd * :let x1 = "Hello"', { output = false })
+ api.nvim_exec2('autocmd BufAdd * :let x1 = "Hello"', { output = false })
command('new foo')
eq('Hello', request('nvim_eval', 'g:x1'))
-- Line continuations
- meths.nvim_exec2(
+ api.nvim_exec2(
[[
let abc = #{
\ a: 1,
@@ -181,13 +181,13 @@ describe('API', function()
eq({ a = 1, c = 3 }, request('nvim_eval', 'g:abc'))
-- try no spaces before continuations to catch off-by-one error
- meths.nvim_exec2('let ab = #{\n\\a: 98,\n"\\ b: 2\n\\}', { output = false })
+ api.nvim_exec2('let ab = #{\n\\a: 98,\n"\\ b: 2\n\\}', { output = false })
eq({ a = 98 }, request('nvim_eval', 'g:ab'))
-- Script scope (s:)
eq(
{ output = 'ahoy! script-scoped varrrrr' },
- meths.nvim_exec2(
+ api.nvim_exec2(
[[
let s:pirate = 'script-scoped varrrrr'
function! s:avast_ye_hades(s) abort
@@ -201,7 +201,7 @@ describe('API', function()
eq(
{ output = "{'output': 'ahoy! script-scoped varrrrr'}" },
- meths.nvim_exec2(
+ api.nvim_exec2(
[[
let s:pirate = 'script-scoped varrrrr'
function! Avast_ye_hades(s) abort
@@ -229,7 +229,7 @@ describe('API', function()
-- Script items are created only on script var access
eq(
{ output = '1\n0' },
- meths.nvim_exec2(
+ api.nvim_exec2(
[[
echo expand("<SID>")->empty()
let s:a = 123
@@ -241,7 +241,7 @@ describe('API', function()
eq(
{ output = '1\n0' },
- meths.nvim_exec2(
+ api.nvim_exec2(
[[
echo expand("<SID>")->empty()
function s:a() abort
@@ -254,7 +254,7 @@ describe('API', function()
end)
it('non-ASCII input', function()
- meths.nvim_exec2(
+ api.nvim_exec2(
[=[
new
exe "normal! i ax \n Ax "
@@ -263,11 +263,11 @@ describe('API', function()
{ output = false }
)
command('1')
- eq(' --a1234-- ', meths.nvim_get_current_line())
+ eq(' --a1234-- ', api.nvim_get_current_line())
command('2')
- eq(' --A1234-- ', meths.nvim_get_current_line())
+ eq(' --A1234-- ', api.nvim_get_current_line())
- meths.nvim_exec2(
+ api.nvim_exec2(
[[
new
call setline(1,['xxx'])
@@ -276,7 +276,7 @@ describe('API', function()
]],
{ output = false }
)
- eq('ñxx', meths.nvim_get_current_line())
+ eq('ñxx', api.nvim_get_current_line())
end)
it('execution error', function()
@@ -284,7 +284,7 @@ describe('API', function()
'nvim_exec2(): Vim:E492: Not an editor command: bogus_command',
pcall_err(request, 'nvim_exec2', 'bogus_command', {})
)
- eq('', meths.nvim_eval('v:errmsg')) -- v:errmsg was not updated.
+ eq('', api.nvim_eval('v:errmsg')) -- v:errmsg was not updated.
eq('', eval('v:exception'))
eq(
@@ -319,7 +319,7 @@ describe('API', function()
write_file(fname, 'echo "hello"\n')
local sourcing_fname = tmpname()
write_file(sourcing_fname, 'call nvim_exec2("source ' .. fname .. '", {"output": v:false})\n')
- meths.nvim_exec2('set verbose=2', { output = false })
+ api.nvim_exec2('set verbose=2', { output = false })
local traceback_output = dedent([[
line 0: sourcing "%s"
line 0: sourcing "%s"
@@ -336,7 +336,7 @@ describe('API', function()
)
eq(
{ output = traceback_output },
- meths.nvim_exec2(
+ api.nvim_exec2(
'call nvim_exec2("source ' .. sourcing_fname .. '", {"output": v:false})',
{ output = true }
)
@@ -348,10 +348,10 @@ describe('API', function()
it('returns output', function()
eq(
{ output = 'this is spinal tap' },
- meths.nvim_exec2('lua <<EOF\n\n\nprint("this is spinal tap")\n\n\nEOF', { output = true })
+ api.nvim_exec2('lua <<EOF\n\n\nprint("this is spinal tap")\n\n\nEOF', { output = true })
)
- eq({ output = '' }, meths.nvim_exec2('echo', { output = true }))
- eq({ output = 'foo 42' }, meths.nvim_exec2('echo "foo" 42', { output = true }))
+ eq({ output = '' }, api.nvim_exec2('echo', { output = true }))
+ eq({ output = 'foo 42' }, api.nvim_exec2('echo "foo" 42', { output = true }))
end)
it('displays messages when opts.output=false', function()
@@ -360,7 +360,7 @@ describe('API', function()
screen:set_default_attr_ids({
[0] = { bold = true, foreground = Screen.colors.Blue },
})
- meths.nvim_exec2("echo 'hello'", { output = false })
+ api.nvim_exec2("echo 'hello'", { output = false })
screen:expect {
grid = [[
^ |
@@ -376,7 +376,7 @@ describe('API', function()
screen:set_default_attr_ids({
[0] = { bold = true, foreground = Screen.colors.Blue },
})
- meths.nvim_exec2("echo 'hello'", { output = true })
+ api.nvim_exec2("echo 'hello'", { output = true })
screen:expect {
grid = [[
^ |
@@ -421,7 +421,7 @@ describe('API', function()
local status, rv = pcall(command, 'bogus_command')
eq(false, status) -- nvim_command() failed.
eq('E492:', string.match(rv, 'E%d*:')) -- Vimscript error was returned.
- eq('', meths.nvim_eval('v:errmsg')) -- v:errmsg was not updated.
+ eq('', api.nvim_eval('v:errmsg')) -- v:errmsg was not updated.
eq('', eval('v:exception'))
end)
@@ -444,18 +444,18 @@ describe('API', function()
describe('nvim_command_output', function()
it('does not induce hit-enter prompt', function()
- meths.nvim_ui_attach(80, 20, {})
+ api.nvim_ui_attach(80, 20, {})
-- Induce a hit-enter prompt use nvim_input (non-blocking).
command('set cmdheight=1')
- meths.nvim_input([[:echo "hi\nhi2"<CR>]])
+ api.nvim_input([[:echo "hi\nhi2"<CR>]])
-- Verify hit-enter prompt.
- eq({ mode = 'r', blocking = true }, meths.nvim_get_mode())
- meths.nvim_input([[<C-c>]])
+ eq({ mode = 'r', blocking = true }, api.nvim_get_mode())
+ api.nvim_input([[<C-c>]])
-- Verify NO hit-enter prompt.
command_output([[echo "hi\nhi2"]])
- eq({ mode = 'n', blocking = false }, meths.nvim_get_mode())
+ eq({ mode = 'n', blocking = false }, api.nvim_get_mode())
end)
it('captures command output', function()
@@ -500,7 +500,7 @@ describe('API', function()
eq('E492: Not an editor command: bogus commannnd', string.match(rv, 'E%d*:.*'))
eq('', eval('v:errmsg')) -- v:errmsg was not updated.
-- Verify NO hit-enter prompt.
- eq({ mode = 'n', blocking = false }, meths.nvim_get_mode())
+ eq({ mode = 'n', blocking = false }, api.nvim_get_mode())
end)
it('Vimscript execution error: fails with specific error', function()
@@ -509,7 +509,7 @@ describe('API', function()
eq('E86: Buffer 42 does not exist', string.match(rv, 'E%d*:.*'))
eq('', eval('v:errmsg')) -- v:errmsg was not updated.
-- Verify NO hit-enter prompt.
- eq({ mode = 'n', blocking = false }, meths.nvim_get_mode())
+ eq({ mode = 'n', blocking = false }, api.nvim_get_mode())
end)
it('does not cause heap buffer overflow with large output', function()
@@ -521,12 +521,12 @@ describe('API', function()
it('works', function()
command('let g:v1 = "a"')
command('let g:v2 = [1, 2, {"v3": 3}]')
- eq({ v1 = 'a', v2 = { 1, 2, { v3 = 3 } } }, meths.nvim_eval('g:'))
+ eq({ v1 = 'a', v2 = { 1, 2, { v3 = 3 } } }, api.nvim_eval('g:'))
end)
it('handles NULL-initialized strings correctly', function()
- eq(1, meths.nvim_eval("matcharg(1) == ['', '']"))
- eq({ '', '' }, meths.nvim_eval('matcharg(1)'))
+ eq(1, api.nvim_eval("matcharg(1) == ['', '']"))
+ eq({ '', '' }, api.nvim_eval('matcharg(1)'))
end)
it('works under deprecated name', function()
@@ -541,10 +541,10 @@ describe('API', function()
describe('nvim_call_function', function()
it('works', function()
- meths.nvim_call_function('setqflist', { { { filename = 'something', lnum = 17 } }, 'r' })
- eq(17, meths.nvim_call_function('getqflist', {})[1].lnum)
- eq(17, meths.nvim_call_function('eval', { 17 }))
- eq('foo', meths.nvim_call_function('simplify', { 'this/./is//redundant/../../../foo' }))
+ api.nvim_call_function('setqflist', { { { filename = 'something', lnum = 17 } }, 'r' })
+ eq(17, api.nvim_call_function('getqflist', {})[1].lnum)
+ eq(17, api.nvim_call_function('eval', { 17 }))
+ eq('foo', api.nvim_call_function('simplify', { 'this/./is//redundant/../../../foo' }))
end)
it('Vimscript validation error: returns specific error, does NOT update v:errmsg', function()
@@ -619,18 +619,18 @@ describe('API', function()
]])
-- :help Dictionary-function
- eq('Hello, World!', meths.nvim_call_dict_function('g:test_dict_fn', 'F', { 'World' }))
+ eq('Hello, World!', api.nvim_call_dict_function('g:test_dict_fn', 'F', { 'World' }))
-- Funcref is sent as NIL over RPC.
- eq({ greeting = 'Hello', F = NIL }, meths.nvim_get_var('test_dict_fn'))
+ eq({ greeting = 'Hello', F = NIL }, api.nvim_get_var('test_dict_fn'))
-- :help numbered-function
- eq('Hi, Moon ...', meths.nvim_call_dict_function('g:test_dict_fn2', 'F2', { 'Moon' }))
+ eq('Hi, Moon ...', api.nvim_call_dict_function('g:test_dict_fn2', 'F2', { 'Moon' }))
-- Funcref is sent as NIL over RPC.
- eq({ greeting = 'Hi', F2 = NIL }, meths.nvim_get_var('test_dict_fn2'))
+ eq({ greeting = 'Hi', F2 = NIL }, api.nvim_get_var('test_dict_fn2'))
-- Function specified via RPC dict.
source('function! G() dict\n return "@".(self.result)."@"\nendfunction')
- eq('@it works@', meths.nvim_call_dict_function({ result = 'it works', G = 'G' }, 'G', {}))
+ eq('@it works@', api.nvim_call_dict_function({ result = 'it works', G = 'G' }, 'G', {}))
end)
it('validation', function()
@@ -675,8 +675,8 @@ describe('API', function()
local start_dir
before_each(function()
- funcs.mkdir('Xtestdir')
- start_dir = funcs.getcwd()
+ fn.mkdir('Xtestdir')
+ start_dir = fn.getcwd()
end)
after_each(function()
@@ -684,84 +684,84 @@ describe('API', function()
end)
it('works', function()
- meths.nvim_set_current_dir('Xtestdir')
- eq(funcs.getcwd(), start_dir .. helpers.get_pathsep() .. 'Xtestdir')
+ api.nvim_set_current_dir('Xtestdir')
+ eq(fn.getcwd(), start_dir .. helpers.get_pathsep() .. 'Xtestdir')
end)
it('sets previous directory', function()
- meths.nvim_set_current_dir('Xtestdir')
+ api.nvim_set_current_dir('Xtestdir')
command('cd -')
- eq(funcs.getcwd(), start_dir)
+ eq(fn.getcwd(), start_dir)
end)
end)
describe('nvim_exec_lua', function()
it('works', function()
- meths.nvim_exec_lua('vim.api.nvim_set_var("test", 3)', {})
- eq(3, meths.nvim_get_var('test'))
+ api.nvim_exec_lua('vim.api.nvim_set_var("test", 3)', {})
+ eq(3, api.nvim_get_var('test'))
- eq(17, meths.nvim_exec_lua('a, b = ...\nreturn a + b', { 10, 7 }))
+ eq(17, api.nvim_exec_lua('a, b = ...\nreturn a + b', { 10, 7 }))
- eq(NIL, meths.nvim_exec_lua('function xx(a,b)\nreturn a..b\nend', {}))
- eq('xy', meths.nvim_exec_lua('return xx(...)', { 'x', 'y' }))
+ eq(NIL, api.nvim_exec_lua('function xx(a,b)\nreturn a..b\nend', {}))
+ eq('xy', api.nvim_exec_lua('return xx(...)', { 'x', 'y' }))
-- Deprecated name: nvim_execute_lua.
- eq('xy', meths.nvim_execute_lua('return xx(...)', { 'x', 'y' }))
+ eq('xy', api.nvim_execute_lua('return xx(...)', { 'x', 'y' }))
end)
it('reports errors', function()
eq(
[[Error loading lua: [string "<nvim>"]:0: '=' expected near '+']],
- pcall_err(meths.nvim_exec_lua, 'a+*b', {})
+ pcall_err(api.nvim_exec_lua, 'a+*b', {})
)
eq(
[[Error loading lua: [string "<nvim>"]:0: unexpected symbol near '1']],
- pcall_err(meths.nvim_exec_lua, '1+2', {})
+ pcall_err(api.nvim_exec_lua, '1+2', {})
)
eq(
[[Error loading lua: [string "<nvim>"]:0: unexpected symbol]],
- pcall_err(meths.nvim_exec_lua, 'aa=bb\0', {})
+ pcall_err(api.nvim_exec_lua, 'aa=bb\0', {})
)
eq(
[[attempt to call global 'bork' (a nil value)]],
- pcall_err(meths.nvim_exec_lua, 'bork()', {})
+ pcall_err(api.nvim_exec_lua, 'bork()', {})
)
- eq('did\nthe\nfail', pcall_err(meths.nvim_exec_lua, 'error("did\\nthe\\nfail")', {}))
+ eq('did\nthe\nfail', pcall_err(api.nvim_exec_lua, 'error("did\\nthe\\nfail")', {}))
end)
it('uses native float values', function()
- eq(2.5, meths.nvim_exec_lua('return select(1, ...)', { 2.5 }))
- eq('2.5', meths.nvim_exec_lua('return vim.inspect(...)', { 2.5 }))
+ eq(2.5, api.nvim_exec_lua('return select(1, ...)', { 2.5 }))
+ eq('2.5', api.nvim_exec_lua('return vim.inspect(...)', { 2.5 }))
-- "special" float values are still accepted as return values.
- eq(2.5, meths.nvim_exec_lua("return vim.api.nvim_eval('2.5')", {}))
+ eq(2.5, api.nvim_exec_lua("return vim.api.nvim_eval('2.5')", {}))
eq(
'{\n [false] = 2.5,\n [true] = 3\n}',
- meths.nvim_exec_lua("return vim.inspect(vim.api.nvim_eval('2.5'))", {})
+ api.nvim_exec_lua("return vim.inspect(vim.api.nvim_eval('2.5'))", {})
)
end)
end)
describe('nvim_notify', function()
it('can notify a info message', function()
- meths.nvim_notify('hello world', 2, {})
+ api.nvim_notify('hello world', 2, {})
end)
it('can be overridden', function()
command('lua vim.notify = function(...) return 42 end')
- eq(42, meths.nvim_exec_lua("return vim.notify('Hello world')", {}))
- meths.nvim_notify('hello world', 4, {})
+ eq(42, api.nvim_exec_lua("return vim.notify('Hello world')", {}))
+ api.nvim_notify('hello world', 4, {})
end)
end)
describe('nvim_input', function()
it('Vimscript error: does NOT fail, updates v:errmsg', function()
- local status, _ = pcall(meths.nvim_input, ':call bogus_fn()<CR>')
- local v_errnum = string.match(meths.nvim_eval('v:errmsg'), 'E%d*:')
+ local status, _ = pcall(api.nvim_input, ':call bogus_fn()<CR>')
+ local v_errnum = string.match(api.nvim_eval('v:errmsg'), 'E%d*:')
eq(true, status) -- nvim_input() did not fail.
eq('E117:', v_errnum) -- v:errmsg was updated.
end)
@@ -779,23 +779,23 @@ describe('API', function()
end)
local function run_streamed_paste_tests()
it('stream: multiple chunks form one undo-block', function()
- meths.nvim_paste('1/chunk 1 (start)\n', true, 1)
- meths.nvim_paste('1/chunk 2 (end)\n', true, 3)
+ api.nvim_paste('1/chunk 1 (start)\n', true, 1)
+ api.nvim_paste('1/chunk 2 (end)\n', true, 3)
local expected1 = [[
1/chunk 1 (start)
1/chunk 2 (end)
]]
expect(expected1)
- meths.nvim_paste('2/chunk 1 (start)\n', true, 1)
- meths.nvim_paste('2/chunk 2\n', true, 2)
+ api.nvim_paste('2/chunk 1 (start)\n', true, 1)
+ api.nvim_paste('2/chunk 2\n', true, 2)
expect([[
1/chunk 1 (start)
1/chunk 2 (end)
2/chunk 1 (start)
2/chunk 2
]])
- meths.nvim_paste('2/chunk 3\n', true, 2)
- meths.nvim_paste('2/chunk 4 (end)\n', true, 3)
+ api.nvim_paste('2/chunk 3\n', true, 2)
+ api.nvim_paste('2/chunk 4 (end)\n', true, 3)
expect([[
1/chunk 1 (start)
1/chunk 2 (end)
@@ -811,10 +811,10 @@ describe('API', function()
-- If nvim_paste() calls :undojoin without making any changes, this makes it an error.
feed('afoo<Esc>u')
feed('i')
- meths.nvim_paste('aaaaaa', false, 1)
- meths.nvim_paste('bbbbbb', false, 2)
- meths.nvim_paste('cccccc', false, 2)
- meths.nvim_paste('dddddd', false, 3)
+ api.nvim_paste('aaaaaa', false, 1)
+ api.nvim_paste('bbbbbb', false, 2)
+ api.nvim_paste('cccccc', false, 2)
+ api.nvim_paste('dddddd', false, 3)
expect('aaaaaabbbbbbccccccdddddd')
feed('<Esc>u')
expect('')
@@ -830,17 +830,17 @@ describe('API', function()
expect('')
end)
it('pasting one line', function()
- meths.nvim_paste('aaaaaa', false, 1)
- meths.nvim_paste('bbbbbb', false, 2)
- meths.nvim_paste('cccccc', false, 2)
- meths.nvim_paste('dddddd', false, 3)
+ api.nvim_paste('aaaaaa', false, 1)
+ api.nvim_paste('bbbbbb', false, 2)
+ api.nvim_paste('cccccc', false, 2)
+ api.nvim_paste('dddddd', false, 3)
expect('aaaaaabbbbbbccccccdddddd')
end)
it('pasting multiple lines', function()
- meths.nvim_paste('aaaaaa\n', false, 1)
- meths.nvim_paste('bbbbbb\n', false, 2)
- meths.nvim_paste('cccccc\n', false, 2)
- meths.nvim_paste('dddddd', false, 3)
+ api.nvim_paste('aaaaaa\n', false, 1)
+ api.nvim_paste('bbbbbb\n', false, 2)
+ api.nvim_paste('cccccc\n', false, 2)
+ api.nvim_paste('dddddd', false, 3)
expect([[
aaaaaa
bbbbbb
@@ -860,17 +860,17 @@ describe('API', function()
expect('||')
end)
it('pasting one line', function()
- meths.nvim_paste('aaaaaa', false, 1)
- meths.nvim_paste('bbbbbb', false, 2)
- meths.nvim_paste('cccccc', false, 2)
- meths.nvim_paste('dddddd', false, 3)
+ api.nvim_paste('aaaaaa', false, 1)
+ api.nvim_paste('bbbbbb', false, 2)
+ api.nvim_paste('cccccc', false, 2)
+ api.nvim_paste('dddddd', false, 3)
expect('|aaaaaabbbbbbccccccdddddd|')
end)
it('pasting multiple lines', function()
- meths.nvim_paste('aaaaaa\n', false, 1)
- meths.nvim_paste('bbbbbb\n', false, 2)
- meths.nvim_paste('cccccc\n', false, 2)
- meths.nvim_paste('dddddd', false, 3)
+ api.nvim_paste('aaaaaa\n', false, 1)
+ api.nvim_paste('bbbbbb\n', false, 2)
+ api.nvim_paste('cccccc\n', false, 2)
+ api.nvim_paste('dddddd', false, 3)
expect([[
|aaaaaa
bbbbbb
@@ -890,17 +890,17 @@ describe('API', function()
expect('||')
end)
it('pasting one line', function()
- meths.nvim_paste('aaaaaa', false, 1)
- meths.nvim_paste('bbbbbb', false, 2)
- meths.nvim_paste('cccccc', false, 2)
- meths.nvim_paste('dddddd', false, 3)
+ api.nvim_paste('aaaaaa', false, 1)
+ api.nvim_paste('bbbbbb', false, 2)
+ api.nvim_paste('cccccc', false, 2)
+ api.nvim_paste('dddddd', false, 3)
expect('||aaaaaabbbbbbccccccdddddd')
end)
it('pasting multiple lines', function()
- meths.nvim_paste('aaaaaa\n', false, 1)
- meths.nvim_paste('bbbbbb\n', false, 2)
- meths.nvim_paste('cccccc\n', false, 2)
- meths.nvim_paste('dddddd', false, 3)
+ api.nvim_paste('aaaaaa\n', false, 1)
+ api.nvim_paste('bbbbbb\n', false, 2)
+ api.nvim_paste('cccccc\n', false, 2)
+ api.nvim_paste('dddddd', false, 3)
expect([[
||aaaaaa
bbbbbb
@@ -924,24 +924,24 @@ describe('API', function()
xxx|]])
end)
it('with non-empty chunks', function()
- meths.nvim_paste('aaaaaa', false, 1)
- meths.nvim_paste('bbbbbb', false, 2)
- meths.nvim_paste('cccccc', false, 2)
- meths.nvim_paste('dddddd', false, 3)
+ api.nvim_paste('aaaaaa', false, 1)
+ api.nvim_paste('bbbbbb', false, 2)
+ api.nvim_paste('cccccc', false, 2)
+ api.nvim_paste('dddddd', false, 3)
expect('|aaaaaabbbbbbccccccdddddd|')
end)
it('with empty first chunk', function()
- meths.nvim_paste('', false, 1)
- meths.nvim_paste('bbbbbb', false, 2)
- meths.nvim_paste('cccccc', false, 2)
- meths.nvim_paste('dddddd', false, 3)
+ api.nvim_paste('', false, 1)
+ api.nvim_paste('bbbbbb', false, 2)
+ api.nvim_paste('cccccc', false, 2)
+ api.nvim_paste('dddddd', false, 3)
expect('|bbbbbbccccccdddddd|')
end)
it('with all chunks empty', function()
- meths.nvim_paste('', false, 1)
- meths.nvim_paste('', false, 2)
- meths.nvim_paste('', false, 2)
- meths.nvim_paste('', false, 3)
+ api.nvim_paste('', false, 1)
+ api.nvim_paste('', false, 2)
+ api.nvim_paste('', false, 2)
+ api.nvim_paste('', false, 3)
expect('||')
end)
end)
@@ -959,17 +959,17 @@ describe('API', function()
xxx]])
end)
it('with non-empty chunks', function()
- meths.nvim_paste('aaaaaa', false, 1)
- meths.nvim_paste('bbbbbb', false, 2)
- meths.nvim_paste('cccccc', false, 2)
- meths.nvim_paste('dddddd', false, 3)
+ api.nvim_paste('aaaaaa', false, 1)
+ api.nvim_paste('bbbbbb', false, 2)
+ api.nvim_paste('cccccc', false, 2)
+ api.nvim_paste('dddddd', false, 3)
expect('||aaaaaabbbbbbccccccdddddd')
end)
it('with empty first chunk', function()
- meths.nvim_paste('', false, 1)
- meths.nvim_paste('bbbbbb', false, 2)
- meths.nvim_paste('cccccc', false, 2)
- meths.nvim_paste('dddddd', false, 3)
+ api.nvim_paste('', false, 1)
+ api.nvim_paste('bbbbbb', false, 2)
+ api.nvim_paste('cccccc', false, 2)
+ api.nvim_paste('dddddd', false, 3)
expect('||bbbbbbccccccdddddd')
end)
end)
@@ -987,17 +987,17 @@ describe('API', function()
xxx]])
end)
it('with non-empty chunks', function()
- meths.nvim_paste('aaaaaa', false, 1)
- meths.nvim_paste('bbbbbb', false, 2)
- meths.nvim_paste('cccccc', false, 2)
- meths.nvim_paste('dddddd', false, 3)
+ api.nvim_paste('aaaaaa', false, 1)
+ api.nvim_paste('bbbbbb', false, 2)
+ api.nvim_paste('cccccc', false, 2)
+ api.nvim_paste('dddddd', false, 3)
expect('||aaaaaabbbbbbccccccdddddd')
end)
it('with empty first chunk', function()
- meths.nvim_paste('', false, 1)
- meths.nvim_paste('bbbbbb', false, 2)
- meths.nvim_paste('cccccc', false, 2)
- meths.nvim_paste('dddddd', false, 3)
+ api.nvim_paste('', false, 1)
+ api.nvim_paste('bbbbbb', false, 2)
+ api.nvim_paste('cccccc', false, 2)
+ api.nvim_paste('dddddd', false, 3)
expect('||bbbbbbccccccdddddd')
end)
end)
@@ -1020,10 +1020,10 @@ describe('API', function()
feed('ggV')
end)
it('pasting text without final new line', function()
- meths.nvim_paste('aaaaaa\n', false, 1)
- meths.nvim_paste('bbbbbb\n', false, 2)
- meths.nvim_paste('cccccc\n', false, 2)
- meths.nvim_paste('dddddd', false, 3)
+ api.nvim_paste('aaaaaa\n', false, 1)
+ api.nvim_paste('bbbbbb\n', false, 2)
+ api.nvim_paste('cccccc\n', false, 2)
+ api.nvim_paste('dddddd', false, 3)
expect([[
aaaaaa
bbbbbb
@@ -1032,10 +1032,10 @@ describe('API', function()
123456789]])
end)
it('pasting text with final new line', function()
- meths.nvim_paste('aaaaaa\n', false, 1)
- meths.nvim_paste('bbbbbb\n', false, 2)
- meths.nvim_paste('cccccc\n', false, 2)
- meths.nvim_paste('dddddd\n', false, 3)
+ api.nvim_paste('aaaaaa\n', false, 1)
+ api.nvim_paste('bbbbbb\n', false, 2)
+ api.nvim_paste('cccccc\n', false, 2)
+ api.nvim_paste('dddddd\n', false, 3)
expect([[
aaaaaa
bbbbbb
@@ -1050,10 +1050,10 @@ describe('API', function()
feed('2ggV')
end)
it('pasting text without final new line', function()
- meths.nvim_paste('aaaaaa\n', false, 1)
- meths.nvim_paste('bbbbbb\n', false, 2)
- meths.nvim_paste('cccccc\n', false, 2)
- meths.nvim_paste('dddddd', false, 3)
+ api.nvim_paste('aaaaaa\n', false, 1)
+ api.nvim_paste('bbbbbb\n', false, 2)
+ api.nvim_paste('cccccc\n', false, 2)
+ api.nvim_paste('dddddd', false, 3)
expect([[
123456789
aaaaaa
@@ -1062,10 +1062,10 @@ describe('API', function()
dddddd123456789]])
end)
it('pasting text with final new line', function()
- meths.nvim_paste('aaaaaa\n', false, 1)
- meths.nvim_paste('bbbbbb\n', false, 2)
- meths.nvim_paste('cccccc\n', false, 2)
- meths.nvim_paste('dddddd\n', false, 3)
+ api.nvim_paste('aaaaaa\n', false, 1)
+ api.nvim_paste('bbbbbb\n', false, 2)
+ api.nvim_paste('cccccc\n', false, 2)
+ api.nvim_paste('dddddd\n', false, 3)
expect([[
123456789
aaaaaa
@@ -1080,10 +1080,10 @@ describe('API', function()
feed('3ggV')
end)
it('pasting text without final new line', function()
- meths.nvim_paste('aaaaaa\n', false, 1)
- meths.nvim_paste('bbbbbb\n', false, 2)
- meths.nvim_paste('cccccc\n', false, 2)
- meths.nvim_paste('dddddd', false, 3)
+ api.nvim_paste('aaaaaa\n', false, 1)
+ api.nvim_paste('bbbbbb\n', false, 2)
+ api.nvim_paste('cccccc\n', false, 2)
+ api.nvim_paste('dddddd', false, 3)
expect([[
123456789
987654321
@@ -1093,10 +1093,10 @@ describe('API', function()
dddddd]])
end)
it('pasting text with final new line', function()
- meths.nvim_paste('aaaaaa\n', false, 1)
- meths.nvim_paste('bbbbbb\n', false, 2)
- meths.nvim_paste('cccccc\n', false, 2)
- meths.nvim_paste('dddddd\n', false, 3)
+ api.nvim_paste('aaaaaa\n', false, 1)
+ api.nvim_paste('bbbbbb\n', false, 2)
+ api.nvim_paste('cccccc\n', false, 2)
+ api.nvim_paste('dddddd\n', false, 3)
expect([[
123456789
987654321
@@ -1112,10 +1112,10 @@ describe('API', function()
feed('ggVG')
end)
it('pasting text without final new line', function()
- meths.nvim_paste('aaaaaa\n', false, 1)
- meths.nvim_paste('bbbbbb\n', false, 2)
- meths.nvim_paste('cccccc\n', false, 2)
- meths.nvim_paste('dddddd', false, 3)
+ api.nvim_paste('aaaaaa\n', false, 1)
+ api.nvim_paste('bbbbbb\n', false, 2)
+ api.nvim_paste('cccccc\n', false, 2)
+ api.nvim_paste('dddddd', false, 3)
expect([[
aaaaaa
bbbbbb
@@ -1123,10 +1123,10 @@ describe('API', function()
dddddd]])
end)
it('pasting text with final new line', function()
- meths.nvim_paste('aaaaaa\n', false, 1)
- meths.nvim_paste('bbbbbb\n', false, 2)
- meths.nvim_paste('cccccc\n', false, 2)
- meths.nvim_paste('dddddd\n', false, 3)
+ api.nvim_paste('aaaaaa\n', false, 1)
+ api.nvim_paste('bbbbbb\n', false, 2)
+ api.nvim_paste('cccccc\n', false, 2)
+ api.nvim_paste('dddddd\n', false, 3)
expect([[
aaaaaa
bbbbbb
@@ -1148,71 +1148,71 @@ describe('API', function()
end)
it('non-streaming', function()
-- With final "\n".
- meths.nvim_paste('line 1\nline 2\nline 3\n', true, -1)
+ api.nvim_paste('line 1\nline 2\nline 3\n', true, -1)
expect([[
line 1
line 2
line 3
]])
- eq({ 0, 4, 1, 0 }, funcs.getpos('.')) -- Cursor follows the paste.
- eq(false, meths.nvim_get_option_value('paste', {}))
+ eq({ 0, 4, 1, 0 }, fn.getpos('.')) -- Cursor follows the paste.
+ eq(false, api.nvim_get_option_value('paste', {}))
command('%delete _')
-- Without final "\n".
- meths.nvim_paste('line 1\nline 2\nline 3', true, -1)
+ api.nvim_paste('line 1\nline 2\nline 3', true, -1)
expect([[
line 1
line 2
line 3]])
- eq({ 0, 3, 6, 0 }, funcs.getpos('.'))
+ eq({ 0, 3, 6, 0 }, fn.getpos('.'))
command('%delete _')
-- CRLF #10872
- meths.nvim_paste('line 1\r\nline 2\r\nline 3\r\n', true, -1)
+ api.nvim_paste('line 1\r\nline 2\r\nline 3\r\n', true, -1)
expect([[
line 1
line 2
line 3
]])
- eq({ 0, 4, 1, 0 }, funcs.getpos('.'))
+ eq({ 0, 4, 1, 0 }, fn.getpos('.'))
command('%delete _')
-- CRLF without final "\n".
- meths.nvim_paste('line 1\r\nline 2\r\nline 3\r', true, -1)
+ api.nvim_paste('line 1\r\nline 2\r\nline 3\r', true, -1)
expect([[
line 1
line 2
line 3
]])
- eq({ 0, 4, 1, 0 }, funcs.getpos('.'))
+ eq({ 0, 4, 1, 0 }, fn.getpos('.'))
command('%delete _')
-- CRLF without final "\r\n".
- meths.nvim_paste('line 1\r\nline 2\r\nline 3', true, -1)
+ api.nvim_paste('line 1\r\nline 2\r\nline 3', true, -1)
expect([[
line 1
line 2
line 3]])
- eq({ 0, 3, 6, 0 }, funcs.getpos('.'))
+ eq({ 0, 3, 6, 0 }, fn.getpos('.'))
command('%delete _')
-- Various other junk.
- meths.nvim_paste('line 1\r\n\r\rline 2\nline 3\rline 4\r', true, -1)
+ api.nvim_paste('line 1\r\n\r\rline 2\nline 3\rline 4\r', true, -1)
expect('line 1\n\n\nline 2\nline 3\nline 4\n')
- eq({ 0, 7, 1, 0 }, funcs.getpos('.'))
- eq(false, meths.nvim_get_option_value('paste', {}))
+ eq({ 0, 7, 1, 0 }, fn.getpos('.'))
+ eq(false, api.nvim_get_option_value('paste', {}))
end)
it('Replace-mode', function()
-- Within single line
- meths.nvim_put({ 'aabbccdd', 'eeffgghh', 'iijjkkll' }, 'c', true, false)
+ api.nvim_put({ 'aabbccdd', 'eeffgghh', 'iijjkkll' }, 'c', true, false)
command('normal l')
command('startreplace')
- meths.nvim_paste('123456', true, -1)
+ api.nvim_paste('123456', true, -1)
expect([[
a123456d
eeffgghh
iijjkkll]])
command('%delete _')
-- Across lines
- meths.nvim_put({ 'aabbccdd', 'eeffgghh', 'iijjkkll' }, 'c', true, false)
+ api.nvim_put({ 'aabbccdd', 'eeffgghh', 'iijjkkll' }, 'c', true, false)
command('normal l')
command('startreplace')
- meths.nvim_paste('123\n456', true, -1)
+ api.nvim_paste('123\n456', true, -1)
expect([[
a123
456d
@@ -1221,30 +1221,30 @@ describe('API', function()
end)
it('when searching in Visual mode', function()
feed('v/')
- meths.nvim_paste('aabbccdd', true, -1)
- eq('aabbccdd', funcs.getcmdline())
+ api.nvim_paste('aabbccdd', true, -1)
+ eq('aabbccdd', fn.getcmdline())
expect('')
end)
it('mappings are disabled in Cmdline mode', function()
command('cnoremap a b')
feed(':')
- meths.nvim_paste('a', true, -1)
- eq('a', funcs.getcmdline())
+ api.nvim_paste('a', true, -1)
+ eq('a', fn.getcmdline())
end)