diff options
| author | Lewis Russell <lewis6991@gmail.com> | 2024-01-12 13:11:28 +0000 |
|---|---|---|
| committer | Lewis Russell <lewis6991@gmail.com> | 2024-01-12 17:53:27 +0000 |
| commit | 4f81f506f96f8b5bfcf00e952ceb492d3ce9dc6e (patch) | |
| tree | 0cbb2cf8dac8b4f43109dc6f7a4051dfbea23f12 /test/functional/api/vim_spec.lua | |
| parent | c30f2e3182e3b50e7c03932027ac55edfc8ada4a (diff) | |
| download | rneovim-4f81f506f96f8b5bfcf00e952ceb492d3ce9dc6e.tar.gz rneovim-4f81f506f96f8b5bfcf00e952ceb492d3ce9dc6e.tar.bz2 rneovim-4f81f506f96f8b5bfcf00e952ceb492d3ce9dc6e.zip | |
test: normalise nvim bridge functions
- remove helpers.cur*meths
- remove helpers.nvim
Diffstat (limited to 'test/functional/api/vim_spec.lua')
| -rw-r--r-- | test/functional/api/vim_spec.lua | 934 |
1 files changed, 462 insertions, 472 deletions
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index 3fd1cdab1e..ba2042d585 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -6,8 +6,9 @@ local fmt = string.format local dedent = helpers.dedent local assert_alive = helpers.assert_alive local NIL = vim.NIL -local clear, nvim, eq, neq = helpers.clear, helpers.nvim, helpers.eq, helpers.neq +local clear, eq, neq = helpers.clear, helpers.eq, helpers.neq local command = helpers.command +local command_output = helpers.meths.command_output local exec = helpers.exec local exec_capture = helpers.exec_capture local eval = helpers.eval @@ -94,41 +95,40 @@ describe('API', function() end) it('does not set CA_COMMAND_BUSY #7254', function() - nvim('command', 'split') - nvim('command', 'autocmd WinEnter * startinsert') - nvim('command', 'wincmd w') - eq({ mode = 'i', blocking = false }, nvim('get_mode')) + command('split') + command('autocmd WinEnter * startinsert') + command('wincmd w') + eq({ mode = 'i', blocking = false }, meths.nvim_get_mode()) end) describe('nvim_exec2', function() it('always returns table', function() -- In built version this results into `vim.empty_dict()` - eq({}, nvim('exec2', 'echo "Hello"', {})) - eq({}, nvim('exec2', 'echo "Hello"', { output = false })) - eq({ output = 'Hello' }, nvim('exec2', 'echo "Hello"', { output = true })) + eq({}, meths.nvim_exec2('echo "Hello"', {})) + eq({}, meths.nvim_exec2('echo "Hello"', { output = false })) + eq({ output = 'Hello' }, meths.nvim_exec2('echo "Hello"', { output = true })) end) it('default options', function() -- Should be equivalent to { output = false } - nvim('exec2', "let x0 = 'a'", {}) - eq('a', nvim('get_var', 'x0')) + meths.nvim_exec2("let x0 = 'a'", {}) + eq('a', meths.nvim_get_var('x0')) end) it('one-line input', function() - nvim('exec2', "let x1 = 'a'", { output = false }) - eq('a', nvim('get_var', 'x1')) + meths.nvim_exec2("let x1 = 'a'", { output = false }) + eq('a', meths.nvim_get_var('x1')) end) it(':verbose set {option}?', function() - nvim('exec2', 'set nowrap', { output = false }) + meths.nvim_exec2('set nowrap', { output = false }) eq( { output = 'nowrap\n\tLast set from anonymous :source' }, - nvim('exec2', 'verbose set wrap?', { output = true }) + meths.nvim_exec2('verbose set wrap?', { output = true }) ) -- Using script var to force creation of a script item - nvim( - 'exec2', + meths.nvim_exec2( [[ let s:a = 1 set nowrap @@ -137,40 +137,39 @@ describe('API', function() ) eq( { output = 'nowrap\n\tLast set from anonymous :source (script id 1)' }, - nvim('exec2', 'verbose set wrap?', { output = true }) + meths.nvim_exec2('verbose set wrap?', { output = true }) ) end) it('multiline input', function() -- Heredoc + empty lines. - nvim('exec2', "let x2 = 'a'\n", { output = false }) - eq('a', nvim('get_var', 'x2')) - nvim('exec2', 'lua <<EOF\n\n\n\ny=3\n\n\nEOF', { output = false }) - eq(3, nvim('eval', "luaeval('y')")) + 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')")) - eq({}, nvim('exec2', 'lua <<EOF\ny=3\nEOF', { output = false })) - eq(3, nvim('eval', "luaeval('y')")) + eq({}, meths.nvim_exec2('lua <<EOF\ny=3\nEOF', { output = false })) + eq(3, meths.nvim_eval("luaeval('y')")) -- Multiple statements - nvim('exec2', 'let x1=1\nlet x2=2\nlet x3=3\n', { output = false }) - eq(1, nvim('eval', 'x1')) - eq(2, nvim('eval', 'x2')) - eq(3, nvim('eval', 'x3')) + 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')) -- Functions - nvim('exec2', 'function Foo()\ncall setline(1,["xxx"])\nendfunction', { output = false }) - eq('', nvim('get_current_line')) - nvim('exec2', 'call Foo()', { output = false }) - eq('xxx', nvim('get_current_line')) + 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()) -- Autocmds - nvim('exec2', 'autocmd BufAdd * :let x1 = "Hello"', { output = false }) - nvim('command', 'new foo') + meths.nvim_exec2('autocmd BufAdd * :let x1 = "Hello"', { output = false }) + command('new foo') eq('Hello', request('nvim_eval', 'g:x1')) -- Line continuations - nvim( - 'exec2', + meths.nvim_exec2( [[ let abc = #{ \ a: 1, @@ -182,14 +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 - nvim('exec2', 'let ab = #{\n\\a: 98,\n"\\ b: 2\n\\}', { output = false }) + meths.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' }, - nvim( - 'exec2', + meths.nvim_exec2( [[ let s:pirate = 'script-scoped varrrrr' function! s:avast_ye_hades(s) abort @@ -203,8 +201,7 @@ describe('API', function() eq( { output = "{'output': 'ahoy! script-scoped varrrrr'}" }, - nvim( - 'exec2', + meths.nvim_exec2( [[ let s:pirate = 'script-scoped varrrrr' function! Avast_ye_hades(s) abort @@ -232,8 +229,7 @@ describe('API', function() -- Script items are created only on script var access eq( { output = '1\n0' }, - nvim( - 'exec2', + meths.nvim_exec2( [[ echo expand("<SID>")->empty() let s:a = 123 @@ -245,8 +241,7 @@ describe('API', function() eq( { output = '1\n0' }, - nvim( - 'exec2', + meths.nvim_exec2( [[ echo expand("<SID>")->empty() function s:a() abort @@ -259,8 +254,7 @@ describe('API', function() end) it('non-ASCII input', function() - nvim( - 'exec2', + meths.nvim_exec2( [=[ new exe "normal! i ax \n Ax " @@ -268,13 +262,12 @@ describe('API', function() ]=], { output = false } ) - nvim('command', '1') - eq(' --a1234-- ', nvim('get_current_line')) - nvim('command', '2') - eq(' --A1234-- ', nvim('get_current_line')) + command('1') + eq(' --a1234-- ', meths.nvim_get_current_line()) + command('2') + eq(' --A1234-- ', meths.nvim_get_current_line()) - nvim( - 'exec2', + meths.nvim_exec2( [[ new call setline(1,['xxx']) @@ -283,7 +276,7 @@ describe('API', function() ]], { output = false } ) - eq('ñxx', nvim('get_current_line')) + eq('ñxx', meths.nvim_get_current_line()) end) it('execution error', function() @@ -291,7 +284,7 @@ describe('API', function() 'nvim_exec2(): Vim:E492: Not an editor command: bogus_command', pcall_err(request, 'nvim_exec2', 'bogus_command', {}) ) - eq('', nvim('eval', 'v:errmsg')) -- v:errmsg was not updated. + eq('', meths.nvim_eval('v:errmsg')) -- v:errmsg was not updated. eq('', eval('v:exception')) eq( @@ -355,10 +348,10 @@ describe('API', function() it('returns output', function() eq( { output = 'this is spinal tap' }, - nvim('exec2', 'lua <<EOF\n\n\nprint("this is spinal tap")\n\n\nEOF', { output = true }) + meths.nvim_exec2('lua <<EOF\n\n\nprint("this is spinal tap")\n\n\nEOF', { output = true }) ) - eq({ output = '' }, nvim('exec2', 'echo', { output = true })) - eq({ output = 'foo 42' }, nvim('exec2', 'echo "foo" 42', { output = true })) + eq({ output = '' }, meths.nvim_exec2('echo', { output = true })) + eq({ output = 'foo 42' }, meths.nvim_exec2('echo "foo" 42', { output = true })) end) it('displays messages when opts.output=false', function() @@ -410,10 +403,10 @@ describe('API', function() describe('nvim_command', function() it('works', function() local fname = tmpname() - nvim('command', 'new') - nvim('command', 'edit ' .. fname) - nvim('command', 'normal itesting\napi') - nvim('command', 'w') + command('new') + command('edit ' .. fname) + command('normal itesting\napi') + command('w') local f = assert(io.open(fname)) if is_os('win') then eq('testing\r\napi\r\n', f:read('*a')) @@ -425,15 +418,15 @@ describe('API', function() end) it('Vimscript validation error: fails with specific error', function() - local status, rv = pcall(nvim, 'command', 'bogus_command') + 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('', nvim('eval', 'v:errmsg')) -- v:errmsg was not updated. + eq('', meths.nvim_eval('v:errmsg')) -- v:errmsg was not updated. eq('', eval('v:exception')) end) it('Vimscript execution error: fails with specific error', function() - local status, rv = pcall(nvim, 'command', 'buffer 23487') + local status, rv = pcall(command, 'buffer 23487') eq(false, status) -- nvim_command() failed. eq('E86: Buffer 23487 does not exist', string.match(rv, 'E%d*:.*')) eq('', eval('v:errmsg')) -- v:errmsg was not updated. @@ -451,92 +444,89 @@ describe('API', function() describe('nvim_command_output', function() it('does not induce hit-enter prompt', function() - nvim('ui_attach', 80, 20, {}) + meths.nvim_ui_attach(80, 20, {}) -- Induce a hit-enter prompt use nvim_input (non-blocking). - nvim('command', 'set cmdheight=1') - nvim('input', [[:echo "hi\nhi2"<CR>]]) + command('set cmdheight=1') + meths.nvim_input([[:echo "hi\nhi2"<CR>]]) -- Verify hit-enter prompt. - eq({ mode = 'r', blocking = true }, nvim('get_mode')) - nvim('input', [[<C-c>]]) + eq({ mode = 'r', blocking = true }, meths.nvim_get_mode()) + meths.nvim_input([[<C-c>]]) -- Verify NO hit-enter prompt. - nvim('command_output', [[echo "hi\nhi2"]]) - eq({ mode = 'n', blocking = false }, nvim('get_mode')) + command_output([[echo "hi\nhi2"]]) + eq({ mode = 'n', blocking = false }, meths.nvim_get_mode()) end) it('captures command output', function() - eq('this is\nspinal tap', nvim('command_output', [[echo "this is\nspinal tap"]])) - eq('no line ending!', nvim('command_output', [[echon "no line ending!"]])) + eq('this is\nspinal tap', command_output([[echo "this is\nspinal tap"]])) + eq('no line ending!', command_output([[echon "no line ending!"]])) end) it('captures empty command output', function() - eq('', nvim('command_output', 'echo')) + eq('', command_output('echo')) end) it('captures single-char command output', function() - eq('x', nvim('command_output', 'echo "x"')) + eq('x', command_output('echo "x"')) end) it('captures multiple commands', function() - eq( - 'foo\n 1 %a "[No Name]" line 1', - nvim('command_output', 'echo "foo" | ls') - ) + eq('foo\n 1 %a "[No Name]" line 1', command_output('echo "foo" | ls')) end) it('captures nested execute()', function() eq( '\nnested1\nnested2\n 1 %a "[No Name]" line 1', - nvim('command_output', [[echo execute('echo "nested1\nnested2"') | ls]]) + command_output([[echo execute('echo "nested1\nnested2"') | ls]]) ) end) it('captures nested nvim_command_output()', function() eq( 'nested1\nnested2\n 1 %a "[No Name]" line 1', - nvim('command_output', [[echo nvim_command_output('echo "nested1\nnested2"') | ls]]) + command_output([[echo nvim_command_output('echo "nested1\nnested2"') | ls]]) ) end) it('returns shell |:!| output', function() local win_lf = is_os('win') and '\r' or '' - eq(':!echo foo\r\n\nfoo' .. win_lf .. '\n', nvim('command_output', [[!echo foo]])) + eq(':!echo foo\r\n\nfoo' .. win_lf .. '\n', command_output([[!echo foo]])) end) it('Vimscript validation error: fails with specific error', function() - local status, rv = pcall(nvim, 'command_output', 'bogus commannnd') + local status, rv = pcall(command_output, 'bogus commannnd') eq(false, status) -- nvim_command_output() failed. 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 }, nvim('get_mode')) + eq({ mode = 'n', blocking = false }, meths.nvim_get_mode()) end) it('Vimscript execution error: fails with specific error', function() - local status, rv = pcall(nvim, 'command_output', 'buffer 42') + local status, rv = pcall(command_output, 'buffer 42') eq(false, status) -- nvim_command_output() failed. 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 }, nvim('get_mode')) + eq({ mode = 'n', blocking = false }, meths.nvim_get_mode()) end) it('does not cause heap buffer overflow with large output', function() - eq(eval('string(range(1000000))'), nvim('command_output', 'echo range(1000000)')) + eq(eval('string(range(1000000))'), command_output('echo range(1000000)')) end) end) describe('nvim_eval', function() it('works', function() - nvim('command', 'let g:v1 = "a"') - nvim('command', 'let g:v2 = [1, 2, {"v3": 3}]') - eq({ v1 = 'a', v2 = { 1, 2, { v3 = 3 } } }, nvim('eval', 'g:')) + 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:')) end) it('handles NULL-initialized strings correctly', function() - eq(1, nvim('eval', "matcharg(1) == ['', '']")) - eq({ '', '' }, nvim('eval', 'matcharg(1)')) + eq(1, meths.nvim_eval("matcharg(1) == ['', '']")) + eq({ '', '' }, meths.nvim_eval('matcharg(1)')) end) it('works under deprecated name', function() @@ -551,10 +541,10 @@ describe('API', function() describe('nvim_call_function', function() it('works', function() - nvim('call_function', 'setqflist', { { { filename = 'something', lnum = 17 } }, 'r' }) - eq(17, nvim('call_function', 'getqflist', {})[1].lnum) - eq(17, nvim('call_function', 'eval', { 17 })) - eq('foo', nvim('call_function', 'simplify', { 'this/./is//redundant/../../../foo' })) + 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' })) end) it('Vimscript validation error: returns specific error, does NOT update v:errmsg', function() @@ -629,18 +619,18 @@ describe('API', function() ]]) -- :help Dictionary-function - eq('Hello, World!', nvim('call_dict_function', 'g:test_dict_fn', 'F', { 'World' })) + eq('Hello, World!', meths.nvim_call_dict_function('g:test_dict_fn', 'F', { 'World' })) -- Funcref is sent as NIL over RPC. - eq({ greeting = 'Hello', F = NIL }, nvim('get_var', 'test_dict_fn')) + eq({ greeting = 'Hello', F = NIL }, meths.nvim_get_var('test_dict_fn')) -- :help numbered-function - eq('Hi, Moon ...', nvim('call_dict_function', 'g:test_dict_fn2', 'F2', { 'Moon' })) + eq('Hi, Moon ...', meths.nvim_call_dict_function('g:test_dict_fn2', 'F2', { 'Moon' })) -- Funcref is sent as NIL over RPC. - eq({ greeting = 'Hi', F2 = NIL }, nvim('get_var', 'test_dict_fn2')) + eq({ greeting = 'Hi', F2 = NIL }, meths.nvim_get_var('test_dict_fn2')) -- Function specified via RPC dict. source('function! G() dict\n return "@".(self.result)."@"\nendfunction') - eq('@it works@', nvim('call_dict_function', { result = 'it works', G = 'G' }, 'G', {})) + eq('@it works@', meths.nvim_call_dict_function({ result = 'it works', G = 'G' }, 'G', {})) end) it('validation', function() @@ -758,20 +748,20 @@ describe('API', function() describe('nvim_notify', function() it('can notify a info message', function() - nvim('notify', 'hello world', 2, {}) + meths.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')", {})) - nvim('notify', 'hello world', 4, {}) + meths.nvim_notify('hello world', 4, {}) end) end) describe('nvim_input', function() it('Vimscript error: does NOT fail, updates v:errmsg', function() - local status, _ = pcall(nvim, 'input', ':call bogus_fn()<CR>') - local v_errnum = string.match(nvim('eval', 'v:errmsg'), 'E%d*:') + local status, _ = pcall(meths.nvim_input, ':call bogus_fn()<CR>') + local v_errnum = string.match(meths.nvim_eval('v:errmsg'), 'E%d*:') eq(true, status) -- nvim_input() did not fail. eq('E117:', v_errnum) -- v:errmsg was updated. end) @@ -789,23 +779,23 @@ describe('API', function() end) local function run_streamed_paste_tests() it('stream: multiple chunks form one undo-block', function() - nvim('paste', '1/chunk 1 (start)\n', true, 1) - nvim('paste', '1/chunk 2 (end)\n', true, 3) + meths.nvim_paste('1/chunk 1 (start)\n', true, 1) + meths.nvim_paste('1/chunk 2 (end)\n', true, 3) local expected1 = [[ 1/chunk 1 (start) 1/chunk 2 (end) ]] expect(expected1) - nvim('paste', '2/chunk 1 (start)\n', true, 1) - nvim('paste', '2/chunk 2\n', true, 2) + meths.nvim_paste('2/chunk 1 (start)\n', true, 1) + meths.nvim_paste('2/chunk 2\n', true, 2) expect([[ 1/chunk 1 (start) 1/chunk 2 (end) 2/chunk 1 (start) 2/chunk 2 ]]) - nvim('paste', '2/chunk 3\n', true, 2) - nvim('paste', '2/chunk 4 (end)\n', true, 3) + meths.nvim_paste('2/chunk 3\n', true, 2) + meths.nvim_paste('2/chunk 4 (end)\n', true, 3) expect([[ 1/chunk 1 (start) 1/chunk 2 (end) @@ -821,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') - nvim('paste', 'aaaaaa', false, 1) - nvim('paste', 'bbbbbb', false, 2) - nvim('paste', 'cccccc', false, 2) - nvim('paste', 'dddddd', false, 3) + meths.nvim_paste('aaaaaa', false, 1) + meths.nvim_paste('bbbbbb', false, 2) + meths.nvim_paste('cccccc', false, 2) + meths.nvim_paste('dddddd', false, 3) expect('aaaaaabbbbbbccccccdddddd') feed('<Esc>u') expect('') @@ -840,17 +830,17 @@ describe('API', function() expect('') end) it('pasting one line', function() - nvim('paste', 'aaaaaa', false, 1) - nvim('paste', 'bbbbbb', false, 2) - nvim('paste', 'cccccc', false, 2) - nvim('paste', 'dddddd', false, 3) + meths.nvim_paste('aaaaaa', false, 1) + meths.nvim_paste('bbbbbb', false, 2) + meths.nvim_paste('cccccc', false, 2) + meths.nvim_paste('dddddd', false, 3) expect('aaaaaabbbbbbccccccdddddd') end) it('pasting multiple lines', function() - nvim('paste', 'aaaaaa\n', false, 1) - nvim('paste', 'bbbbbb\n', false, 2) - nvim('paste', 'cccccc\n', false, 2) - nvim('paste', 'dddddd', false, 3) + 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) expect([[ aaaaaa bbbbbb @@ -870,17 +860,17 @@ describe('API', function() expect('||') end) it('pasting one line', function() - nvim('paste', 'aaaaaa', false, 1) - nvim('paste', 'bbbbbb', false, 2) - nvim('paste', 'cccccc', false, 2) - nvim('paste', 'dddddd', false, 3) + meths.nvim_paste('aaaaaa', false, 1) + meths.nvim_paste('bbbbbb', false, 2) + meths.nvim_paste('cccccc', false, 2) + meths.nvim_paste('dddddd', false, 3) expect('|aaaaaabbbbbbccccccdddddd|') end) it('pasting multiple lines', function() - nvim('paste', 'aaaaaa\n', false, 1) - nvim('paste', 'bbbbbb\n', false, 2) - nvim('paste', 'cccccc\n', false, 2) - nvim('paste', 'dddddd', false, 3) + 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) expect([[ |aaaaaa bbbbbb @@ -900,17 +890,17 @@ describe('API', function() expect('||') end) it('pasting one line', function() - nvim('paste', 'aaaaaa', false, 1) - nvim('paste', 'bbbbbb', false, 2) - nvim('paste', 'cccccc', false, 2) - nvim('paste', 'dddddd', false, 3) + meths.nvim_paste('aaaaaa', false, 1) + meths.nvim_paste('bbbbbb', false, 2) + meths.nvim_paste('cccccc', false, 2) + meths.nvim_paste('dddddd', false, 3) expect('||aaaaaabbbbbbccccccdddddd') end) it('pasting multiple lines', function() - nvim('paste', 'aaaaaa\n', false, 1) - nvim('paste', 'bbbbbb\n', false, 2) - nvim('paste', 'cccccc\n', false, 2) - nvim('paste', 'dddddd', false, 3) + 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) expect([[ ||aaaaaa bbbbbb @@ -934,24 +924,24 @@ describe('API', function() xxx|]]) end) it('with non-empty chunks', function() - nvim('paste', 'aaaaaa', false, 1) - nvim('paste', 'bbbbbb', false, 2) - nvim('paste', 'cccccc', false, 2) - nvim('paste', 'dddddd', false, 3) + meths.nvim_paste('aaaaaa', false, 1) + meths.nvim_paste('bbbbbb', false, 2) + meths.nvim_paste('cccccc', false, 2) + meths.nvim_paste('dddddd', false, 3) expect('|aaaaaabbbbbbccccccdddddd|') end) it('with empty first chunk', function() - nvim('paste', '', false, 1) - nvim('paste', 'bbbbbb', false, 2) - nvim('paste', 'cccccc', false, 2) - nvim('paste', 'dddddd', false, 3) + meths.nvim_paste('', false, 1) + meths.nvim_paste('bbbbbb', false, 2) + meths.nvim_paste('cccccc', false, 2) + meths.nvim_paste('dddddd', false, 3) expect('|bbbbbbccccccdddddd|') end) it('with all chunks empty', function() - nvim('paste', '', false, 1) - nvim('paste', '', false, 2) - nvim('paste', '', false, 2) - nvim('paste', '', false, 3) + meths.nvim_paste('', false, 1) + meths.nvim_paste('', false, 2) + meths.nvim_paste('', false, 2) + meths.nvim_paste('', false, 3) expect('||') end) end) @@ -969,17 +959,17 @@ describe('API', function() xxx]]) end) it('with non-empty chunks', function() - nvim('paste', 'aaaaaa', false, 1) - nvim('paste', 'bbbbbb', false, 2) - nvim('paste', 'cccccc', false, 2) - nvim('paste', 'dddddd', false, 3) + meths.nvim_paste('aaaaaa', false, 1) + meths.nvim_paste('bbbbbb', false, 2) + meths.nvim_paste('cccccc', false, 2) + meths.nvim_paste('dddddd', false, 3) expect('||aaaaaabbbbbbccccccdddddd') end) it('with empty first chunk', function() - nvim('paste', '', false, 1) - nvim('paste', 'bbbbbb', false, 2) - nvim('paste', 'cccccc', false, 2) - nvim('paste', 'dddddd', false, 3) + meths.nvim_paste('', false, 1) + meths.nvim_paste('bbbbbb', false, 2) + meths.nvim_paste('cccccc', false, 2) + meths.nvim_paste('dddddd', false, 3) expect('||bbbbbbccccccdddddd') end) end) @@ -997,17 +987,17 @@ describe('API', function() xxx]]) end) it('with non-empty chunks', function() - nvim('paste', 'aaaaaa', false, 1) - nvim('paste', 'bbbbbb', false, 2) - nvim('paste', 'cccccc', false, 2) - nvim('paste', 'dddddd', false, 3) + meths.nvim_paste('aaaaaa', false, 1) + meths.nvim_paste('bbbbbb', false, 2) + meths.nvim_paste('cccccc', false, 2) + meths.nvim_paste('dddddd', false, 3) expect('||aaaaaabbbbbbccccccdddddd') end) it('with empty first chunk', function() - nvim('paste', '', false, 1) - nvim('paste', 'bbbbbb', false, 2) - nvim('paste', 'cccccc', false, 2) - nvim('paste', 'dddddd', false, 3) + meths.nvim_paste('', false, 1) + meths.nvim_paste('bbbbbb', false, 2) + meths.nvim_paste('cccccc', false, 2) + meths.nvim_paste('dddddd', false, 3) expect('||bbbbbbccccccdddddd') end) end) @@ -1030,10 +1020,10 @@ describe('API', function() feed('ggV') end) it('pasting text without final new line', function() - nvim('paste', 'aaaaaa\n', false, 1) - nvim('paste', 'bbbbbb\n', false, 2) - nvim('paste', 'cccccc\n', false, 2) - nvim('paste', 'dddddd', false, 3) + 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) expect([[ aaaaaa bbbbbb @@ -1042,10 +1032,10 @@ describe('API', function() 123456789]]) end) it('pasting text with final new line', function() - nvim('paste', 'aaaaaa\n', false, 1) - nvim('paste', 'bbbbbb\n', false, 2) - nvim('paste', 'cccccc\n', false, 2) - nvim('paste', 'dddddd\n', false, 3) + 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) expect([[ aaaaaa bbbbbb @@ -1060,10 +1050,10 @@ describe('API', function() feed('2ggV') end) it('pasting text without final new line', function() - nvim('paste', 'aaaaaa\n', false, 1) - nvim('paste', 'bbbbbb\n', false, 2) - nvim('paste', 'cccccc\n', false, 2) - nvim('paste', 'dddddd', false, 3) + 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) expect([[ 123456789 aaaaaa @@ -1072,10 +1062,10 @@ describe('API', function() dddddd123456789]]) end) it('pasting text with final new line', function() - nvim('paste', 'aaaaaa\n', false, 1) - nvim('paste', 'bbbbbb\n', false, 2) - nvim('paste', 'cccccc\n', false, 2) - nvim('paste', 'dddddd\n', false, 3) + 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) expect([[ 123456789 aaaaaa @@ -1090,10 +1080,10 @@ describe('API', function() feed('3ggV') end) it('pasting text without final new line', function() - nvim('paste', 'aaaaaa\n', false, 1) - nvim('paste', 'bbbbbb\n', false, 2) - nvim('paste', 'cccccc\n', false, 2) - nvim('paste', 'dddddd', false, 3) + 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) expect([[ 123456789 987654321 @@ -1103,10 +1093,10 @@ describe('API', function() dddddd]]) end) it('pasting text with final new line', function() - nvim('paste', 'aaaaaa\n', false, 1) - nvim('paste', 'bbbbbb\n', false, 2) - nvim('paste', 'cccccc\n', false, 2) - nvim('paste', 'dddddd\n', false, 3) + 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) expect([[ 123456789 987654321 @@ -1122,10 +1112,10 @@ describe('API', function() feed('ggVG') end) it('pasting text without final new line', function() - nvim('paste', 'aaaaaa\n', false, 1) - nvim('paste', 'bbbbbb\n', false, 2) - nvim('paste', 'cccccc\n', false, 2) - nvim('paste', 'dddddd', false, 3) + 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) expect([[ aaaaaa bbbbbb @@ -1133,10 +1123,10 @@ describe('API', function() dddddd]]) end) it('pasting text with final new line', function() - nvim('paste', 'aaaaaa\n', false, 1) - nvim('paste', 'bbbbbb\n', false, 2) - nvim('paste', 'cccccc\n', false, 2) - nvim('paste', 'dddddd\n', false, 3) + 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) expect([[ aaaaaa bbbbbb @@ -1158,17 +1148,17 @@ describe('API', function() end) it('non-streaming', function() -- With final "\n". - nvim('paste', 'line 1\nline 2\nline 3\n', true, -1) + meths.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, nvim('get_option_value', 'paste', {})) + eq(false, meths.nvim_get_option_value('paste', {})) command('%delete _') -- Without final "\n". - nvim('paste', 'line 1\nline 2\nline 3', true, -1) + meths.nvim_paste('line 1\nline 2\nline 3', true, -1) expect([[ line 1 line 2 @@ -1176,7 +1166,7 @@ describe('API', function() eq({ 0, 3, 6, 0 }, funcs.getpos('.')) command('%delete _') -- CRLF #10872 - nvim('paste', 'line 1\r\nline 2\r\nline 3\r\n', true, -1) + meths.nvim_paste('line 1\r\nline 2\r\nline 3\r\n', true, -1) expect([[ line 1 line 2 @@ -1185,7 +1175,7 @@ describe('API', function() eq({ 0, 4, 1, 0 }, funcs.getpos('.')) command('%delete _') -- CRLF without final "\n". - nvim('paste', 'line 1\r\nline 2\r\nline 3\r', true, -1) + meths.nvim_paste('line 1\r\nline 2\r\nline 3\r', true, -1) expect([[ line 1 line 2 @@ -1194,7 +1184,7 @@ describe('API', function() eq({ 0, 4, 1, 0 }, funcs.getpos('.')) command('%delete _') -- CRLF without final "\r\n". - nvim('paste', 'line 1\r\nline 2\r\nline 3', true, -1) + meths.nvim_paste('line 1\r\nline 2\r\nline 3', true, -1) expect([[ line 1 line 2 @@ -1202,27 +1192,27 @@ describe('API', function() eq({ 0, 3, 6, 0 }, funcs.getpos('.')) command('%delete _') -- Various other junk. - nvim('paste', 'line 1\r\n\r\rline 2\nline 3\rline 4\r', true, -1) + meths.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, nvim('get_option_value', 'paste', {})) + eq(false, meths.nvim_get_option_value('paste', {})) end) it('Replace-mode', function() -- Within single line - nvim('put', { 'aabbccdd', 'eeffgghh', 'iijjkkll' }, 'c', true, false) + meths.nvim_put({ 'aabbccdd', 'eeffgghh', 'iijjkkll' }, 'c', true, false) command('normal l') command('startreplace') - nvim('paste', '123456', true, -1) + meths.nvim_paste('123456', true, -1) expect([[ a123456d eeffgghh iijjkkll]]) command('%delete _') -- Across lines - nvim('put', { 'aabbccdd', 'eeffgghh', 'iijjkkll' }, 'c', true, false) + meths.nvim_put({ 'aabbccdd', 'eeffgghh', 'iijjkkll' }, 'c', true, false) command('normal l') command('startreplace') - nvim('paste', '123\n456', true, -1) + meths.nvim_paste('123\n456', true, -1) expect([[ a123 456d @@ -1231,20 +1221,20 @@ describe('API', function() end) it('when searching in Visual mode', function() feed('v/') - nvim('paste', 'aabbccdd', true, -1) + meths.nvim_paste('aabbccdd', true, -1) eq('aabbccdd', funcs.getcmdline()) expect('') end) it('mappings are disabled in Cmdline mode', function() command('cnoremap a b') feed(':') - nvim('paste', 'a', true, -1) + meths.nvim_paste('a', true, -1) eq('a', funcs.getcmdline()) end) it('pasted text is saved in cmdline history when <CR> comes from mapping #20957', function() command('cnoremap <CR> <CR>') feed(':') - nvim('paste', 'echo', true, -1) + meths.nvim_paste('echo', true, -1) eq('', funcs.histget(':')) feed('<CR>') eq('echo', funcs.histget(':')) @@ -1253,8 +1243,8 @@ describe('API', function() local screen = Screen.new(20, 4) screen:attach() feed(':') - nvim('paste', 'Foo', true, 1) - nvim('paste', '', true, 3) + meths.nvim_paste('Foo', true, 1) + meths.nvim_paste('', true, 3) screen:expect([[ | ~ |*2 @@ -1265,7 +1255,7 @@ describe('API', function() local screen = Screen.new(20, 4) screen:attach() feed(':') - nvim('paste', 'normal! \023\022\006\027', true, -1) + meths.nvim_paste('normal! \023\022\006\027', true, -1) screen:expect([[ | ~ |