diff options
author | Lewis Russell <lewis6991@gmail.com> | 2024-01-12 12:44:54 +0000 |
---|---|---|
committer | Lewis Russell <lewis6991@gmail.com> | 2024-01-12 13:01:06 +0000 |
commit | c30f2e3182e3b50e7c03932027ac55edfc8ada4a (patch) | |
tree | edf0a76dba282d946f67fe70fff8c6cbe28e7a82 | |
parent | 284e0ad26dd9de90c3a813dd1b357a425eca6bad (diff) | |
download | rneovim-c30f2e3182e3b50e7c03932027ac55edfc8ada4a.tar.gz rneovim-c30f2e3182e3b50e7c03932027ac55edfc8ada4a.tar.bz2 rneovim-c30f2e3182e3b50e7c03932027ac55edfc8ada4a.zip |
test: typing for helpers.meths
141 files changed, 3340 insertions, 3135 deletions
diff --git a/test/functional/api/autocmd_spec.lua b/test/functional/api/autocmd_spec.lua index 1590ca2eda..79a524d9eb 100644 --- a/test/functional/api/autocmd_spec.lua +++ b/test/functional/api/autocmd_spec.lua @@ -17,7 +17,7 @@ describe('autocmd api', function() it('validation', function() eq( "Cannot use both 'callback' and 'command'", - pcall_err(meths.create_autocmd, 'BufReadPost', { + pcall_err(meths.nvim_create_autocmd, 'BufReadPost', { pattern = '*.py,*.pyi', command = "echo 'Should Have Errored", callback = 'NotAllowed', @@ -25,7 +25,7 @@ describe('autocmd api', function() ) eq( "Cannot use both 'pattern' and 'buffer' for the same autocmd", - pcall_err(meths.create_autocmd, 'FileType', { + pcall_err(meths.nvim_create_autocmd, 'FileType', { command = 'let g:called = g:called + 1', buffer = 0, pattern = '*.py', @@ -33,48 +33,48 @@ describe('autocmd api', function() ) eq( "Required: 'event'", - pcall_err(meths.create_autocmd, {}, { + pcall_err(meths.nvim_create_autocmd, {}, { command = 'ls', }) ) - eq("Required: 'command' or 'callback'", pcall_err(meths.create_autocmd, 'FileType', {})) + eq("Required: 'command' or 'callback'", pcall_err(meths.nvim_create_autocmd, 'FileType', {})) eq( "Invalid 'desc': expected String, got Integer", - pcall_err(meths.create_autocmd, 'FileType', { + pcall_err(meths.nvim_create_autocmd, 'FileType', { command = 'ls', desc = 42, }) ) eq( "Invalid 'callback': expected Lua function or Vim function name, got Integer", - pcall_err(meths.create_autocmd, 'FileType', { + pcall_err(meths.nvim_create_autocmd, 'FileType', { callback = 0, }) ) eq( "Invalid 'event' item: expected String, got Array", - pcall_err(meths.create_autocmd, { 'FileType', {} }, {}) + pcall_err(meths.nvim_create_autocmd, { 'FileType', {} }, {}) ) eq( "Invalid 'group': 0", - pcall_err(meths.create_autocmd, 'FileType', { + pcall_err(meths.nvim_create_autocmd, 'FileType', { group = 0, command = 'ls', }) ) - eq("Invalid 'event': 'foo'", pcall_err(meths.create_autocmd, 'foo', { command = '' })) + eq("Invalid 'event': 'foo'", pcall_err(meths.nvim_create_autocmd, 'foo', { command = '' })) eq( "Invalid 'event': 'VimEnter '", - pcall_err(meths.create_autocmd, 'VimEnter ', { command = '' }) + pcall_err(meths.nvim_create_autocmd, 'VimEnter ', { command = '' }) ) eq( "Invalid 'event': 'VimEnter foo'", - pcall_err(meths.create_autocmd, 'VimEnter foo', { command = '' }) + pcall_err(meths.nvim_create_autocmd, 'VimEnter foo', { command = '' }) ) eq( "Invalid 'event': 'BufAdd,BufDelete'", - pcall_err(meths.create_autocmd, 'BufAdd,BufDelete', { command = '' }) + pcall_err(meths.nvim_create_autocmd, 'BufAdd,BufDelete', { command = '' }) ) end) @@ -102,25 +102,25 @@ describe('autocmd api', function() end) it('allows passing buffer by key', function() - meths.set_var('called', 0) + meths.nvim_set_var('called', 0) - meths.create_autocmd('FileType', { + meths.nvim_create_autocmd('FileType', { command = 'let g:called = g:called + 1', buffer = 0, }) - meths.command 'set filetype=txt' - eq(1, meths.get_var('called')) + meths.nvim_command 'set filetype=txt' + eq(1, meths.nvim_get_var('called')) -- switch to a new buffer - meths.command 'new' - meths.command 'set filetype=python' + meths.nvim_command 'new' + meths.nvim_command 'set filetype=python' - eq(1, meths.get_var('called')) + eq(1, meths.nvim_get_var('called')) end) it('does not allow passing invalid buffers', function() - local ok, msg = pcall(meths.create_autocmd, 'FileType', { + local ok, msg = pcall(meths.nvim_create_autocmd, 'FileType', { command = 'let g:called = g:called + 1', buffer = -1, }) @@ -145,7 +145,7 @@ describe('autocmd api', function() end) it('allow passing pattern and <buffer> in same pattern', function() - local ok = pcall(meths.create_autocmd, 'BufReadPost', { + local ok = pcall(meths.nvim_create_autocmd, 'BufReadPost', { pattern = '*.py,<buffer>', command = "echo 'Should Not Error'", }) @@ -154,42 +154,42 @@ describe('autocmd api', function() end) it('should handle multiple values as comma separated list', function() - meths.create_autocmd('BufReadPost', { + meths.nvim_create_autocmd('BufReadPost', { pattern = '*.py,*.pyi', command = "echo 'Should Not Have Errored'", }) -- We should have one autocmd for *.py and one for *.pyi - eq(2, #meths.get_autocmds { event = 'BufReadPost' }) + eq(2, #meths.nvim_get_autocmds { event = 'BufReadPost' }) end) it('should handle multiple values as array', function() - meths.create_autocmd('BufReadPost', { + meths.nvim_create_autocmd('BufReadPost', { pattern = { '*.py', '*.pyi' }, command = "echo 'Should Not Have Errored'", }) -- We should have one autocmd for *.py and one for *.pyi - eq(2, #meths.get_autocmds { event = 'BufReadPost' }) + eq(2, #meths.nvim_get_autocmds { event = 'BufReadPost' }) end) describe('desc', function() it('can add description to one autocmd', function() local cmd = "echo 'Should Not Have Errored'" local desc = 'Can show description' - meths.create_autocmd('BufReadPost', { + meths.nvim_create_autocmd('BufReadPost', { pattern = '*.py', command = cmd, desc = desc, }) - eq(desc, meths.get_autocmds { event = 'BufReadPost' }[1].desc) - eq(cmd, meths.get_autocmds { event = 'BufReadPost' }[1].command) + eq(desc, meths.nvim_get_autocmds { event = 'BufReadPost' }[1].desc) + eq(cmd, meths.nvim_get_autocmds { event = 'BufReadPost' }[1].command) end) it('can add description to one autocmd that uses a callback', function() local desc = 'Can show description' - meths.set_var('desc', desc) + meths.nvim_set_var('desc', desc) local result = exec_lua([[ local callback = function() print 'Should Not Have Errored' end @@ -218,17 +218,17 @@ describe('autocmd api', function() }) ]]) - eq(nil, meths.get_autocmds({ event = 'BufReadPost' })[1].desc) + eq(nil, meths.nvim_get_autocmds({ event = 'BufReadPost' })[1].desc) end) it('can add description to multiple autocmd', function() - meths.create_autocmd('BufReadPost', { + meths.nvim_create_autocmd('BufReadPost', { pattern = { '*.py', '*.pyi' }, command = "echo 'Should Not Have Errored'", desc = 'Can show description', }) - local aus = meths.get_autocmds { event = 'BufReadPost' } + local aus = meths.nvim_get_autocmds { event = 'BufReadPost' } eq(2, #aus) eq('Can show description', aus[1].desc) eq('Can show description', aus[2].desc) @@ -237,19 +237,19 @@ describe('autocmd api', function() pending('script and verbose settings', function() it('marks API client', function() - meths.create_autocmd('BufReadPost', { + meths.nvim_create_autocmd('BufReadPost', { pattern = '*.py', command = "echo 'Should Not Have Errored'", desc = 'Can show description', }) - local aus = meths.get_autocmds { event = 'BufReadPost' } + local aus = meths.nvim_get_autocmds { event = 'BufReadPost' } eq(1, #aus, aus) end) end) it('removes an autocommand if the callback returns true', function() - meths.set_var('some_condition', false) + meths.nvim_set_var('some_condition', false) exec_lua [[ vim.api.nvim_create_autocmd("User", { @@ -261,21 +261,21 @@ describe('autocmd api', function() }) ]] - meths.exec_autocmds('User', { pattern = 'Test' }) + meths.nvim_exec_autocmds('User', { pattern = 'Test' }) - local aus = meths.get_autocmds({ event = 'User', pattern = 'Test' }) + local aus = meths.nvim_get_autocmds({ event = 'User', pattern = 'Test' }) local first = aus[1] eq(true, first.id > 0) - meths.set_var('some_condition', true) - meths.exec_autocmds('User', { pattern = 'Test' }) - eq({}, meths.get_autocmds({ event = 'User', pattern = 'Test' })) + meths.nvim_set_var('some_condition', true) + meths.nvim_exec_autocmds('User', { pattern = 'Test' }) + eq({}, meths.nvim_get_autocmds({ event = 'User', pattern = 'Test' })) end) it('receives an args table', function() - local group_id = meths.create_augroup('TestGroup', {}) + local group_id = meths.nvim_create_augroup('TestGroup', {}) -- Having an existing autocmd calling expand("<afile>") shouldn't change args #18964 - meths.create_autocmd('User', { + meths.nvim_create_autocmd('User', { group = 'TestGroup', pattern = 'Te*', command = 'call expand("<afile>")', @@ -291,7 +291,7 @@ describe('autocmd api', function() }) ]] - meths.exec_autocmds('User', { pattern = 'Test pattern' }) + meths.nvim_exec_autocmds('User', { pattern = 'Test pattern' }) eq({ id = autocmd_id, group = group_id, @@ -299,7 +299,7 @@ describe('autocmd api', function() match = 'Test pattern', file = 'Test pattern', buf = 1, - }, meths.get_var('autocmd_args')) + }, meths.nvim_get_var('autocmd_args')) -- Test without a group autocmd_id = exec_lua [[ @@ -311,7 +311,7 @@ describe('autocmd api', function() }) ]] - meths.exec_autocmds('User', { pattern = 'some_pat' }) + meths.nvim_exec_autocmds('User', { pattern = 'some_pat' }) eq({ id = autocmd_id, group = nil, @@ -319,7 +319,7 @@ describe('autocmd api', function() match = 'some_pat', file = 'some_pat', buf = 1, - }, meths.get_var('autocmd_args')) + }, meths.nvim_get_var('autocmd_args')) end) it('can receive arbitrary data', function() @@ -361,43 +361,43 @@ describe('autocmd api', function() it('validation', function() eq( "Invalid 'group': 9997999", - pcall_err(meths.get_autocmds, { + pcall_err(meths.nvim_get_autocmds, { group = 9997999, }) ) eq( "Invalid 'group': 'bogus'", - pcall_err(meths.get_autocmds, { + pcall_err(meths.nvim_get_autocmds, { group = 'bogus', }) ) eq( "Invalid 'group': 0", - pcall_err(meths.get_autocmds, { + pcall_err(meths.nvim_get_autocmds, { group = 0, }) ) eq( "Invalid 'group': expected String or Integer, got Array", - pcall_err(meths.get_autocmds, { + pcall_err(meths.nvim_get_autocmds, { group = {}, }) ) eq( "Invalid 'buffer': expected Integer or Array, got Boolean", - pcall_err(meths.get_autocmds, { + pcall_err(meths.nvim_get_autocmds, { buffer = true, }) ) eq( "Invalid 'event': expected String or Array", - pcall_err(meths.get_autocmds, { + pcall_err(meths.nvim_get_autocmds, { event = true, }) ) eq( "Invalid 'pattern': expected String or Array, got Boolean", - pcall_err(meths.get_autocmds, { + pcall_err(meths.nvim_get_autocmds, { pattern = true, }) ) @@ -408,7 +408,7 @@ describe('autocmd api', function() command [[au! InsertEnter]] command [[au InsertEnter * :echo "1"]] - local aus = meths.get_autocmds { event = 'InsertEnter' } + local aus = meths.nvim_get_autocmds { event = 'InsertEnter' } eq(1, #aus) end) @@ -417,7 +417,7 @@ describe('autocmd api', function() command [[au InsertEnter * :echo "1"]] command [[au InsertEnter * :echo "2"]] - local aus = meths.get_autocmds { event = 'InsertEnter' } + local aus = meths.nvim_get_autocmds { event = 'InsertEnter' } eq(2, #aus) end) @@ -426,8 +426,8 @@ describe('autocmd api', function() command [[au InsertEnter * :echo "1"]] command [[au InsertEnter * :echo "2"]] - local string_aus = meths.get_autocmds { event = 'InsertEnter' } - local array_aus = meths.get_autocmds { event = { 'InsertEnter' } } + local string_aus = meths.nvim_get_autocmds { event = 'InsertEnter' } + local array_aus = meths.nvim_get_autocmds { event = { 'InsertEnter' } } eq(string_aus, array_aus) end) @@ -437,7 +437,7 @@ describe('autocmd api', function() command [[au InsertEnter * :echo "1"]] command [[au InsertEnter * :echo "2"]] - local aus = meths.get_autocmds { event = { 'InsertEnter', 'InsertLeave' } } + local aus = meths.nvim_get_autocmds { event = { 'InsertEnter', 'InsertLeave' } } eq(2, #aus) end) @@ -451,7 +451,7 @@ describe('autocmd api', function() \ }) ]] - local aus = meths.get_autocmds { event = { 'InsertEnter', 'InsertLeave' } } + local aus = meths.nvim_get_autocmds { event = { 'InsertEnter', 'InsertLeave' } } local first = aus[1] eq(first.id, nil) @@ -459,8 +459,8 @@ describe('autocmd api', function() local second = aus[2] neq(second.id, nil) - meths.del_autocmd(second.id) - local new_aus = meths.get_autocmds { event = { 'InsertEnter', 'InsertLeave' } } + meths.nvim_del_autocmd(second.id) + local new_aus = meths.nvim_get_autocmds { event = { 'InsertEnter', 'InsertLeave' } } eq(1, #new_aus) eq(first, new_aus[1]) end) @@ -469,7 +469,7 @@ describe('autocmd api', function() command [[au! InsertEnter]] command [[au InsertEnter * :echo "1"]] - local aus = meths.get_autocmds { event = 'InsertEnter' } + local aus = meths.nvim_get_autocmds { event = 'InsertEnter' } eq({ { buflocal = false, @@ -487,7 +487,7 @@ describe('autocmd api', function() command [[au InsertEnter <buffer=1> :echo "1"]] command [[au InsertEnter <buffer=2> :echo "2"]] - local aus = meths.get_autocmds { event = 'InsertEnter', buffer = 0 } + local aus = meths.nvim_get_autocmds { event = 'InsertEnter', buffer = 0 } eq({ { buffer = 2, @@ -499,7 +499,7 @@ describe('autocmd api', function() }, }, aus) - aus = meths.get_autocmds { event = 'InsertEnter', buffer = 1 } + aus = meths.nvim_get_autocmds { event = 'InsertEnter', buffer = 1 } eq({ { buffer = 1, @@ -511,7 +511,7 @@ describe('autocmd api', function() }, }, aus) - aus = meths.get_autocmds { event = 'InsertEnter', buffer = { 1, 2 } } + aus = meths.nvim_get_autocmds { event = 'InsertEnter', buffer = { 1, 2 } } eq({ { buffer = 1, @@ -533,50 +533,50 @@ describe('autocmd api', function() eq( "Invalid 'buffer': expected Integer or Array, got String", - pcall_err(meths.get_autocmds, { event = 'InsertEnter', buffer = 'foo' }) + pcall_err(meths.nvim_get_autocmds, { event = 'InsertEnter', buffer = 'foo' }) ) eq( "Invalid 'buffer': expected Integer, got String", - pcall_err(meths.get_autocmds, { event = 'InsertEnter', buffer = { 'foo', 42 } }) + pcall_err(meths.nvim_get_autocmds, { event = 'InsertEnter', buffer = { 'foo', 42 } }) ) eq( 'Invalid buffer id: 42', - pcall_err(meths.get_autocmds, { event = 'InsertEnter', buffer = { 42 } }) + pcall_err(meths.nvim_get_autocmds, { event = 'InsertEnter', buffer = { 42 } }) ) local bufs = {} for _ = 1, 257 do - table.insert(bufs, meths.create_buf(true, false)) + table.insert(bufs, meths.nvim_create_buf(true, false)) end eq( 'Too many buffers (maximum of 256)', - pcall_err(meths.get_autocmds, { event = 'InsertEnter', buffer = bufs }) + pcall_err(meths.nvim_get_autocmds, { event = 'InsertEnter', buffer = bufs }) ) end) it('returns autocmds when group is specified by id', function() - local auid = meths.create_augroup('nvim_test_augroup', { clear = true }) - meths.create_autocmd('FileType', { group = auid, command = 'echo "1"' }) - meths.create_autocmd('FileType', { group = auid, command = 'echo "2"' }) + local auid = meths.nvim_create_augroup('nvim_test_augroup', { clear = true }) + meths.nvim_create_autocmd('FileType', { group = auid, command = 'echo "1"' }) + meths.nvim_create_autocmd('FileType', { group = auid, command = 'echo "2"' }) - local aus = meths.get_autocmds { group = auid } + local aus = meths.nvim_get_autocmds { group = auid } eq(2, #aus) - local aus2 = meths.get_autocmds { group = auid, event = 'InsertEnter' } + local aus2 = meths.nvim_get_autocmds { group = auid, event = 'InsertEnter' } eq(0, #aus2) end) it('returns autocmds when group is specified by name', function() local auname = 'nvim_test_augroup' - meths.create_augroup(auname, { clear = true }) - meths.create_autocmd('FileType', { group = auname, command = 'echo "1"' }) - meths.create_autocmd('FileType', { group = auname, command = 'echo "2"' }) + meths.nvim_create_augroup(auname, { clear = true }) + meths.nvim_create_autocmd('FileType', { group = auname, command = 'echo "1"' }) + meths.nvim_create_autocmd('FileType', { group = auname, command = 'echo "2"' }) - local aus = meths.get_autocmds { group = auname } + local aus = meths.nvim_get_autocmds { group = auname } eq(2, #aus) - local aus2 = meths.get_autocmds { group = auname, event = 'InsertEnter' } + local aus2 = meths.nvim_get_autocmds { group = auname, event = 'InsertEnter' } eq(0, #aus2) end) @@ -609,7 +609,7 @@ describe('autocmd api', function() it('can retrieve a callback from an autocmd', function() local content = 'I Am A Callback' - meths.set_var('content', content) + meths.nvim_set_var('content', content) local result = exec_lua([[ local cb = function() return vim.g.content end @@ -671,7 +671,7 @@ describe('autocmd api', function() end) it('returns all groups if no group is specified', function() - local aus = meths.get_autocmds { event = 'InsertEnter' } + local aus = meths.nvim_get_autocmds { event = 'InsertEnter' } if #aus ~= 4 then eq({}, aus) end @@ -680,7 +680,7 @@ describe('autocmd api', function() end) it('returns only the group specified', function() - local aus = meths.get_autocmds { + local aus = meths.nvim_get_autocmds { event = 'InsertEnter', group = 'GroupOne', } @@ -691,7 +691,7 @@ describe('autocmd api', function() end) it('returns only the group specified, multiple values', function() - local aus = meths.get_autocmds { + local aus = meths.nvim_get_autocmds { event = 'InsertEnter', group = 'GroupTwo', } @@ -706,7 +706,7 @@ describe('autocmd api', function() describe('groups: 2', function() it('raises error for undefined augroup name', function() - local success, code = unpack(meths.exec_lua( + local success, code = unpack(meths.nvim_exec_lua( [[ return {pcall(function() vim.api.nvim_create_autocmd("FileType", { @@ -724,7 +724,7 @@ describe('autocmd api', function() end) it('raises error for undefined augroup id', function() - local success, code = unpack(meths.exec_lua( + local success, code = unpack(meths.nvim_exec_lua( [[ return {pcall(function() -- Make sure the augroup is deleted @@ -745,7 +745,7 @@ describe('autocmd api', function() end) it('raises error for invalid group type', function() - local success, code = unpack(meths.exec_lua( + local success, code = unpack(meths.nvim_exec_lua( [[ return {pcall(function() vim.api.nvim_create_autocmd("FileType", { @@ -763,7 +763,7 @@ describe('autocmd api', function() end) it('raises error for invalid pattern array', function() - local success, code = unpack(meths.exec_lua( + local success, code = unpack(meths.nvim_exec_lua( [[ return {pcall(function() vim.api.nvim_create_autocmd("FileType", { @@ -792,7 +792,7 @@ describe('autocmd api', function() end) it('returns for literal match', function() - local aus = meths.get_autocmds { + local aus = meths.nvim_get_autocmds { event = 'InsertEnter', pattern = '*', } @@ -803,7 +803,7 @@ describe('autocmd api', function() it('returns for multiple matches', function() -- vim.api.nvim_get_autocmds - local aus = meths.get_autocmds { + local aus = meths.nvim_get_autocmds { event = 'InsertEnter', pattern = { '*.one', '*.two' }, } @@ -815,17 +815,17 @@ describe('autocmd api', function() end) it('should work for buffer autocmds', function() - local normalized_aus = meths.get_autocmds { + local normalized_aus = meths.nvim_get_autocmds { event = 'InsertEnter', pattern = '<buffer=1>', } - local raw_aus = meths.get_autocmds { + local raw_aus = meths.nvim_get_autocmds { event = 'InsertEnter', pattern = '<buffer>', } - local zero_aus = meths.get_autocmds { + local zero_aus = meths.nvim_get_autocmds { event = 'InsertEnter', pattern = '<buffer=0>', } @@ -841,110 +841,110 @@ describe('autocmd api', function() it('validation', function() eq( "Invalid 'group': 9997999", - pcall_err(meths.exec_autocmds, 'FileType', { + pcall_err(meths.nvim_exec_autocmds, 'FileType', { group = 9997999, }) ) eq( "Invalid 'group': 'bogus'", - pcall_err(meths.exec_autocmds, 'FileType', { + pcall_err(meths.nvim_exec_autocmds, 'FileType', { group = 'bogus', }) ) eq( "Invalid 'group': expected String or Integer, got Array", - pcall_err(meths.exec_autocmds, 'FileType', { + pcall_err(meths.nvim_exec_autocmds, 'FileType', { group = {}, }) ) eq( "Invalid 'group': 0", - pcall_err(meths.exec_autocmds, 'FileType', { + pcall_err(meths.nvim_exec_autocmds, 'FileType', { group = 0, }) ) eq( "Invalid 'buffer': expected Buffer, got Array", - pcall_err(meths.exec_autocmds, 'FileType', { + pcall_err(meths.nvim_exec_autocmds, 'FileType', { buffer = {}, }) ) eq( "Invalid 'event' item: expected String, got Array", - pcall_err(meths.exec_autocmds, { 'FileType', {} }, {}) + pcall_err(meths.nvim_exec_autocmds, { 'FileType', {} }, {}) ) end) it('can trigger builtin autocmds', function() - meths.set_var('autocmd_executed', false) + meths.nvim_set_var('autocmd_executed', false) - meths.create_autocmd('BufReadPost', { + meths.nvim_create_autocmd('BufReadPost', { pattern = '*', command = 'let g:autocmd_executed = v:true', }) - eq(false, meths.get_var('autocmd_executed')) - meths.exec_autocmds('BufReadPost', {}) - eq(true, meths.get_var('autocmd_executed')) + eq(false, meths.nvim_get_var('autocmd_executed')) + meths.nvim_exec_autocmds('BufReadPost', {}) + eq(true, meths.nvim_get_var('autocmd_executed')) end) it('can trigger multiple patterns', function() - meths.set_var('autocmd_executed', 0) + meths.nvim_set_var('autocmd_executed', 0) - meths.create_autocmd('BufReadPost', { + meths.nvim_create_autocmd('BufReadPost', { pattern = '*', command = 'let g:autocmd_executed += 1', }) - meths.exec_autocmds('BufReadPost', { pattern = { '*.lua', '*.vim' } }) - eq(2, meths.get_var('autocmd_executed')) + meths.nvim_exec_autocmds('BufReadPost', { pattern = { '*.lua', '*.vim' } }) + eq(2, meths.nvim_get_var('autocmd_executed')) - meths.create_autocmd('BufReadPre', { + meths.nvim_create_autocmd('BufReadPre', { pattern = { 'bar', 'foo' }, command = 'let g:autocmd_executed += 10', }) - meths.exec_autocmds('BufReadPre', { pattern = { 'foo', 'bar', 'baz', 'frederick' } }) - eq(22, meths.get_var('autocmd_executed')) + meths.nvim_exec_autocmds('BufReadPre', { pattern = { 'foo', 'bar', 'baz', 'frederick' } }) + eq(22, meths.nvim_get_var('autocmd_executed')) end) it('can pass the buffer', function() - meths.set_var('buffer_executed', -1) - eq(-1, meths.get_var('buffer_executed')) + meths.nvim_set_var('buffer_executed', -1) + eq(-1, meths.nvim_get_var('buffer_executed')) - meths.create_autocmd('BufLeave', { + meths.nvim_create_autocmd('BufLeave', { pattern = '*', command = 'let g:buffer_executed = +expand("<abuf>")', }) -- Doesn't execute for other non-matching events - meths.exec_autocmds('CursorHold', { buffer = 1 }) - eq(-1, meths.get_var('buffer_executed')) + meths.nvim_exec_autocmds('CursorHold', { buffer = 1 }) + eq(-1, meths.nvim_get_var('buffer_executed')) - meths.exec_autocmds('BufLeave', { buffer = 1 }) - eq(1, meths.get_var('buffer_executed')) + meths.nvim_exec_autocmds('BufLeave', { buffer = 1 }) + eq(1, meths.nvim_get_var('buffer_executed')) end) it('can pass the filename, pattern match', function() - meths.set_var('filename_executed', 'none') - eq('none', meths.get_var('filename_executed')) + meths.nvim_set_var('filename_executed', 'none') + eq('none', meths.nvim_get_var('filename_executed')) - meths.create_autocmd('BufEnter', { + meths.nvim_create_autocmd('BufEnter', { pattern = '*.py', command = 'let g:filename_executed = expand("<afile>")', }) -- Doesn't execute for other non-matching events - meths.exec_autocmds('CursorHold', { buffer = 1 }) - eq('none', meths.get_var('filename_executed')) + meths.nvim_exec_autocmds('CursorHold', { buffer = 1 }) + eq('none', meths.nvim_get_var('filename_executed')) - meths.command('edit __init__.py') - eq('__init__.py', meths.get_var('filename_executed')) + meths.nvim_command('edit __init__.py') + eq('__init__.py', meths.nvim_get_var('filename_executed')) end) it('cannot pass buf and fname', function() local ok = pcall( - meths.exec_autocmds, + meths.nvim_exec_autocmds, 'BufReadPre', { pattern = 'literally_cannot_error.rs', buffer = 1 } ) @@ -952,73 +952,73 @@ describe('autocmd api', function() end) it('can pass the filename, exact match', function() - meths.set_var('filename_executed', 'none') - eq('none', meths.get_var('filename_executed')) + meths.nvim_set_var('filename_executed', 'none') + eq('none', meths.nvim_get_var('filename_executed')) - meths.command('edit other_file.txt') - meths.command('edit __init__.py') - eq('none', meths.get_var('filename_executed')) + meths.nvim_command('edit other_file.txt') + meths.nvim_command('edit __init__.py') + eq('none', meths.nvim_get_var('filename_executed')) - meths.create_autocmd('CursorHoldI', { + meths.nvim_create_autocmd('CursorHoldI', { pattern = '__init__.py', command = 'let g:filename_executed = expand("<afile>")', }) -- Doesn't execute for other non-matching events - meths.exec_autocmds('CursorHoldI', { buffer = 1 }) - eq('none', meths.get_var('filename_executed')) + meths.nvim_exec_autocmds('CursorHoldI', { buffer = 1 }) + eq('none', meths.nvim_get_var('filename_executed')) - meths.exec_autocmds('CursorHoldI', { buffer = meths.get_current_buf() }) - eq('__init__.py', meths.get_var('filename_executed')) + meths.nvim_exec_autocmds('CursorHoldI', { buffer = meths.nvim_get_current_buf() }) + eq('__init__.py', meths.nvim_get_var('filename_executed')) -- Reset filename - meths.set_var('filename_executed', 'none') + meths.nvim_set_var('filename_executed', 'none') - meths.exec_autocmds('CursorHoldI', { pattern = '__init__.py' }) - eq('__init__.py', meths.get_var('filename_executed')) + meths.nvim_exec_autocmds('CursorHoldI', { pattern = '__init__.py' }) + eq('__init__.py', meths.nvim_get_var('filename_executed')) end) it('works with user autocmds', function() - meths.set_var('matched', 'none') + meths.nvim_set_var('matched', 'none') - meths.create_autocmd('User', { + meths.nvim_create_autocmd('User', { pattern = 'TestCommand', command = 'let g:matched = "matched"', }) - meths.exec_autocmds('User', { pattern = 'OtherCommand' }) - eq('none', meths.get_var('matched')) - meths.exec_autocmds('User', { pattern = 'TestCommand' }) - eq('matched', meths.get_var('matched')) + meths.nvim_exec_autocmds('User', { pattern = 'OtherCommand' }) + eq('none', meths.nvim_get_var('matched')) + meths.nvim_exec_autocmds('User', { pattern = 'TestCommand' }) + eq('matched', meths.nvim_get_var('matched')) end) it('can pass group by id', function() - meths.set_var('group_executed', false) + meths.nvim_set_var('group_executed', false) - local auid = meths.create_augroup('nvim_test_augroup', { clear = true }) - meths.create_autocmd('FileType', { + local auid = meths.nvim_create_augroup('nvim_test_augroup', { clear = true }) + meths.nvim_create_autocmd('FileType', { group = auid, command = 'let g:group_executed = v:true', }) - eq(false, meths.get_var('group_executed')) - meths.exec_autocmds('FileType', { group = auid }) - eq(true, meths.get_var('group_executed')) + eq(false, meths.nvim_get_var('group_executed')) + meths.nvim_exec_autocmds('FileType', { group = auid }) + eq(true, meths.nvim_get_var('group_executed')) end) it('can pass group by name', function() - meths.set_var('group_executed', false) + meths.nvim_set_var('group_executed', false) local auname = 'nvim_test_augroup' - meths.create_augroup(auname, { clear = true }) - meths.create_autocmd('FileType', { + meths.nvim_create_augroup(auname, { clear = true }) + meths.nvim_create_autocmd('FileType', { group = auname, command = 'let g:group_executed = v:true', }) - eq(false, meths.get_var('group_executed')) - meths.exec_autocmds('FileType', { group = auname }) - eq(true, meths.get_var('group_executed')) + eq(false, meths.nvim_get_var('group_executed')) + meths.nvim_exec_autocmds('FileType', { group = auname }) + eq(true, meths.nvim_get_var('group_executed')) end) end) @@ -1026,7 +1026,7 @@ describe('autocmd api', function() before_each(function() clear() - meths.set_var('executed', 0) + meths.nvim_set_var('executed', 0) end) local make_counting_autocmd = function(opts) @@ -1040,7 +1040,7 @@ describe('autocmd api', function() resulting.group = opts.group resulting.once = opts.once - meths.create_autocmd('FileType', resulting) + meths.nvim_create_autocmd('FileType', resulting) end local set_ft = function(ft) @@ -1049,12 +1049,12 @@ describe('autocmd api', function() end local get_executed_count = function() - return meths.get_var('executed') + return meths.nvim_get_var('executed') end it('can be added in a group', function() local augroup = 'TestGroup' - meths.create_augroup(augroup, { clear = true }) + meths.nvim_create_augroup(augroup, { clear = true }) make_counting_autocmd { group = augroup } set_ft('txt') @@ -1083,7 +1083,7 @@ describe('autocmd api', function() end) it('errors on unexpected keys', function() - local success, code = pcall(meths.create_autocmd, 'FileType', { + local success, code = pcall(meths.nvim_create_autocmd, 'FileType', { pattern = '*', not_a_valid_key = 'NotDefined', }) @@ -1190,8 +1190,8 @@ describe('autocmd api', function() it('groups can be cleared', function() local augroup = 'TestGroup' - meths.create_augroup(augroup, { clear = true }) - meths.create_autocmd('FileType', { + meths.nvim_create_augroup(augroup, { clear = true }) + meths.nvim_create_autocmd('FileType', { group = augroup, command = 'let g:executed = g:executed + 1', }) @@ -1200,8 +1200,8 @@ describe('autocmd api', function() set_ft('txt') eq(2, get_executed_count(), 'should only count twice') - meths.create_augroup(augroup, { clear = true }) - eq({}, meths.get_autocmds { group = augroup }) + meths.nvim_create_augroup(augroup, { clear = true }) + eq({}, meths.nvim_get_autocmds { group = augroup }) set_ft('txt') set_ft('txt') @@ -1210,22 +1210,22 @@ describe('autocmd api', function() it('can delete non-existent groups with pcall', function() eq(false, exec_lua [[return pcall(vim.api.nvim_del_augroup_by_name, 'noexist')]]) - eq('Vim:E367: No such group: "noexist"', pcall_err(meths.del_augroup_by_name, 'noexist')) + eq('Vim:E367: No such group: "noexist"', pcall_err(meths.nvim_del_augroup_by_name, 'noexist')) eq(false, exec_lua [[return pcall(vim.api.nvim_del_augroup_by_id, -12342)]]) - eq('Vim:E367: No such group: "--Deleted--"', pcall_err(meths.del_augroup_by_id, -12312)) + eq('Vim:E367: No such group: "--Deleted--"', pcall_err(meths.nvim_del_augroup_by_id, -12312)) eq(false, exec_lua [[return pcall(vim.api.nvim_del_augroup_by_id, 0)]]) - eq('Vim:E367: No such group: "[NULL]"', pcall_err(meths.del_augroup_by_id, 0)) + eq('Vim:E367: No such group: "[NULL]"', pcall_err(meths.nvim_del_augroup_by_id, 0)) eq(false, exec_lua [[return pcall(vim.api.nvim_del_augroup_by_id, 12342)]]) - eq('Vim:E367: No such group: "[NULL]"', pcall_err(meths.del_augroup_by_id, 12312)) + eq('Vim:E367: No such group: "[NULL]"', pcall_err(meths.nvim_del_augroup_by_id, 12312)) end) it('groups work with once', function() local augroup = 'TestGroup' - meths.create_augroup(augroup, { clear = true }) + meths.nvim_create_augroup(augroup, { clear = true }) make_counting_autocmd { group = augroup, once = true } set_ft('txt') @@ -1237,7 +1237,7 @@ describe('autocmd api', function() it('autocmds can be registered multiple times.', function() local augroup = 'TestGroup' - meths.create_augroup(augroup, { clear = true }) + meths.nvim_create_augroup(augroup, { clear = true }) make_counting_autocmd { group = augroup, once = false } make_counting_autocmd { group = augroup, once = false } make_counting_autocmd { group = augroup, once = false } @@ -1251,16 +1251,16 @@ describe('autocmd api', function() it('can be deleted', function() local augroup = 'WillBeDeleted' - meths.create_augroup(augroup, { clear = true }) - meths.create_autocmd({ 'FileType' }, { + meths.nvim_create_augroup(augroup, { clear = true }) + meths.nvim_create_autocmd({ 'FileType' }, { pattern = '*', command = "echo 'does not matter'", }) -- Clears the augroup from before, which erases the autocmd - meths.create_augroup(augroup, { clear = true }) + meths.nvim_create_augroup(augroup, { clear = true }) - local result = #meths.get_autocmds { group = augroup } + local result = #meths.nvim_get_autocmds { group = augroup } eq(0, result) end) @@ -1268,10 +1268,10 @@ describe('autocmd api', function() it('can be used for buffer local autocmds', function() local augroup = 'WillBeDeleted' - meths.set_var('value_set', false) + meths.nvim_set_var('value_set', false) - meths.create_augroup(augroup, { clear = true }) - meths.create_autocmd('FileType', { + meths.nvim_create_augroup(augroup, { clear = true }) + meths.nvim_create_autocmd('FileType', { pattern = '<buffer>', command = 'let g:value_set = v:true', }) @@ -1279,7 +1279,7 @@ describe('autocmd api', function() command 'new' command 'set filetype=python' - eq(false, meths.get_var('value_set')) + eq(false, meths.nvim_get_var('value_set')) end) it('can accept vimscript functions', function() @@ -1302,7 +1302,7 @@ describe('autocmd api', function() set filetype=txt ]] - eq(2, meths.get_var('vimscript_executed')) + eq(2, meths.nvim_get_var('vimscript_executed')) end) end) @@ -1314,11 +1314,11 @@ describe('autocmd api', function() command('augroup! TEMP_A') - eq(false, pcall(meths.get_autocmds, { group = 'TEMP_A' })) + eq(false, pcall(meths.nvim_get_autocmds, { group = 'TEMP_A' })) -- For some reason, augroup! doesn't clear the autocmds themselves, which is just wild -- but we managed to keep this behavior. - eq(1, #meths.get_autocmds { event = 'BufReadPost' }) + eq(1, #meths.nvim_get_autocmds { event = 'BufReadPost' }) end) it('legacy: remove augroups that have no autocmds', function() @@ -1327,8 +1327,8 @@ describe('autocmd api', function() command('augroup! TEMP_AB') - eq(false, pcall(meths.get_autocmds, { group = 'TEMP_AB' })) - eq(0, #meths.get_autocmds { event = 'BufReadPost' }) + eq(false, pcall(meths.nvim_get_autocmds, { group = 'TEMP_AB' })) + eq(0, #meths.nvim_get_autocmds { event = 'BufReadPost' }) end) it('legacy: multiple remove and add augroup', function() @@ -1340,7 +1340,7 @@ describe('autocmd api', function() command('augroup! TEMP_ABC') -- Should still have one autocmd :'( - local aus = meths.get_autocmds { event = 'BufReadPost' } + local aus = meths.nvim_get_autocmds { event = 'BufReadPost' } eq(1, #aus, aus) command('augroup TEMP_ABC') @@ -1349,13 +1349,13 @@ describe('autocmd api', function() command('augroup END') -- Should now have two autocmds :'( - aus = meths.get_autocmds { event = 'BufReadPost' } + aus = meths.nvim_get_autocmds { event = 'BufReadPost' } eq(2, #aus, aus) command('augroup! TEMP_ABC') - eq(false, pcall(meths.get_autocmds, { group = 'TEMP_ABC' })) - eq(2, #meths.get_autocmds { event = 'BufReadPost' }) + eq(false, pcall(meths.nvim_get_autocmds, { group = 'TEMP_ABC' })) + eq(2, #meths.nvim_get_autocmds { event = 'BufReadPost' }) end) it('api: should clear and not return any autocmds for delete groups by id', function() @@ -1363,13 +1363,13 @@ describe('autocmd api', function() command('autocmd! BufReadPost *.py :echo "Hello"') command('augroup END') - local augroup_id = meths.create_augroup('TEMP_ABCD', { clear = false }) - meths.del_augroup_by_id(augroup_id) + local augroup_id = meths.nvim_create_augroup('TEMP_ABCD', { clear = false }) + meths.nvim_del_augroup_by_id(augroup_id) -- For good reason, we kill all the autocmds from del_augroup, -- so now this works as expected - eq(false, pcall(meths.get_autocmds, { group = 'TEMP_ABCD' })) - eq(0, #meths.get_autocmds { event = 'BufReadPost' }) + eq(false, pcall(meths.nvim_get_autocmds, { group = 'TEMP_ABCD' })) + eq(0, #meths.nvim_get_autocmds { event = 'BufReadPost' }) end) it('api: should clear and not return any autocmds for delete groups by name', function() @@ -1377,12 +1377,12 @@ describe('autocmd api', function() command('autocmd! BufReadPost *.py :echo "Hello"') command('augroup END') - meths.del_augroup_by_name('TEMP_ABCDE') + meths.nvim_del_augroup_by_name('TEMP_ABCDE') -- For good reason, we kill all the autocmds from del_augroup, -- so now this works as expected - eq(false, pcall(meths.get_autocmds, { group = 'TEMP_ABCDE' })) - eq(0, #meths.get_autocmds { event = 'BufReadPost' }) + eq(false, pcall(meths.nvim_get_autocmds, { group = 'TEMP_ABCDE' })) + eq(0, #meths.nvim_get_autocmds { event = 'BufReadPost' }) end) end) @@ -1390,18 +1390,18 @@ describe('autocmd api', function() it('validation', function() eq( "Cannot use both 'pattern' and 'buffer'", - pcall_err(meths.clear_autocmds, { + pcall_err(meths.nvim_clear_autocmds, { pattern = '*', buffer = 42, }) ) eq( "Invalid 'event' item: expected String, got Array", - pcall_err(meths.clear_autocmds, { + pcall_err(meths.nvim_clear_autocmds, { event = { 'FileType', {} }, }) ) - eq("Invalid 'group': 0", pcall_err(meths.clear_autocmds, { group = 0 })) + eq("Invalid 'group': 0", pcall_err(meths.nvim_clear_autocmds, { group = 0 })) end) it('should clear based on event + pattern', function() @@ -1409,17 +1409,17 @@ describe('autocmd api', function() command('autocmd InsertEnter *.txt :echo "Text Files Are Cool"') local search = { event = 'InsertEnter', pattern = '*.txt' } - local before_delete = meths.get_autocmds(search) + local before_delete = meths.nvim_get_autocmds(search) eq(1, #before_delete) - local before_delete_all = meths.get_autocmds { event = search.event } + local before_delete_all = meths.nvim_get_autocmds { event = search.event } eq(2, #before_delete_all) - meths.clear_autocmds(search) - local after_delete = meths.get_autocmds(search) + meths.nvim_clear_autocmds(search) + local after_delete = meths.nvim_get_autocmds(search) eq(0, #after_delete) - local after_delete_all = meths.get_autocmds { event = search.event } + local after_delete_all = meths.nvim_get_autocmds { event = search.event } eq(1, #after_delete_all) end) @@ -1428,11 +1428,11 @@ describe('autocmd api', function() command('autocmd InsertEnter *.txt :echo "Text Files Are Cool"') local search = { event = 'InsertEnter' } - local before_delete = meths.get_autocmds(search) + local before_delete = meths.nvim_get_autocmds(search) eq(2, #before_delete) - meths.clear_autocmds(search) - local after_delete = meths.get_autocmds(search) + meths.nvim_clear_autocmds(search) + local after_delete = meths.nvim_get_autocmds(search) eq(0, #after_delete) end) @@ -1443,16 +1443,18 @@ describe('autocmd api', function() command('autocmd InsertLeave *.TestPat2 :echo "Leave 2"') local search = { pattern = '*.TestPat1' } - local before_delete = meths.get_autocmds(search) + local before_delete = meths.nvim_get_autocmds(search) eq(2, #before_delete) - local before_delete_events = meths.get_autocmds { event = { 'InsertEnter', 'InsertLeave' } } + local before_delete_events = + meths.nvim_get_autocmds { event = { 'InsertEnter', 'InsertLeave' } } eq(4, #before_delete_events) - meths.clear_autocmds(search) - local after_delete = meths.get_autocmds(search) + meths.nvim_clear_autocmds(search) + local after_delete = meths.nvim_get_autocmds(search) eq(0, #after_delete) - local after_delete_events = meths.get_autocmds { event = { 'InsertEnter', 'InsertLeave' } } + local after_delete_events = + meths.nvim_get_autocmds { event = { 'InsertEnter', 'InsertLeave' } } eq(2, #after_delete_events) end) @@ -1462,11 +1464,11 @@ describe('autocmd api', function() command('autocmd InsertEnter *.TestPat1 :echo "Enter Pattern"') local search = { event = 'InsertEnter' } - local before_delete = meths.get_autocmds(search) + local before_delete = meths.nvim_get_autocmds(search) eq(2, #before_delete) - meths.clear_autocmds { buffer = 0 } - local after_delete = meths.get_autocmds(search) + meths.nvim_clear_autocmds { buffer = 0 } + local after_delete = meths.nvim_get_autocmds(search) eq(1, #after_delete) eq('*.TestPat1', after_delete[1].pattern) end) @@ -1479,17 +1481,17 @@ describe('autocmd api', function() command('augroup END') local search = { event = 'InsertEnter', group = 'TestNvimClearAutocmds' } - local before_delete = meths.get_autocmds(search) + local before_delete = meths.nvim_get_autocmds(search) eq(2, #before_delete) -- Doesn't clear without passing group. - meths.clear_autocmds { buffer = 0 } - local without_group = meths.get_autocmds(search) + meths.nvim_clear_autocmds { buffer = 0 } + local without_group = meths.nvim_get_autocmds(search) eq(2, #without_group) -- Doesn't clear with passing group. - meths.clear_autocmds { buffer = 0, group = search.group } - local with_group = meths.get_autocmds(search) + meths.nvim_clear_autocmds { buffer = 0, group = search.group } + local with_group = meths.nvim_get_autocmds(search) eq(1, #with_group) end) end) diff --git a/test/functional/api/buffer_spec.lua b/test/functional/api/buffer_spec.lua index 0dd01b7299..c71853b574 100644 --- a/test/functional/api/buffer_spec.lua +++ b/test/functional/api/buffer_spec.lua @@ -42,9 +42,9 @@ describe('api/buf', function() end) it("doesn't crash just after set undolevels=1 #24894", function() - local buf = meths.create_buf(false, true) - meths.buf_set_option(buf, 'undolevels', -1) - meths.buf_set_lines(buf, 0, 1, false, {}) + local buf = meths.nvim_create_buf(false, true) + meths.nvim_buf_set_option(buf, 'undolevels', -1) + meths.nvim_buf_set_lines(buf, 0, 1, false, {}) assert_alive() end) @@ -85,35 +85,41 @@ describe('api/buf', function() end) it('cursor position is maintained in non-current window', function() - meths.buf_set_lines(0, 0, -1, 1, { 'line1', 'line2', 'line3', 'line4' }) - meths.win_set_cursor(0, { 3, 2 }) - local win = meths.get_current_win() - local buf = meths.get_current_buf() + meths.nvim_buf_set_lines(0, 0, -1, 1, { 'line1', 'line2', 'line3', 'line4' }) + meths.nvim_win_set_cursor(0, { 3, 2 }) + local win = meths.nvim_get_current_win() + local buf = meths.nvim_get_current_buf() command('new') - meths.buf_set_lines(buf, 1, 2, 1, { 'line5', 'line6' }) - eq({ 'line1', 'line5', 'line6', 'line3', 'line4' }, meths.buf_get_lines(buf, 0, -1, true)) - eq({ 4, 2 }, meths.win_get_cursor(win)) + meths.nvim_buf_set_lines(buf, 1, 2, 1, { 'line5', 'line6' }) + eq( + { 'line1', 'line5', 'line6', 'line3', 'line4' }, + meths.nvim_buf_get_lines(buf, 0, -1, true) + ) + eq({ 4, 2 }, meths.nvim_win_get_cursor(win)) end) it('cursor position is maintained in TWO non-current windows', function() - meths.buf_set_lines(0, 0, -1, 1, { 'line1', 'line2', 'line3', 'line4' }) - meths.win_set_cursor(0, { 3, 2 }) - local win = meths.get_current_win() - local buf = meths.get_current_buf() + meths.nvim_buf_set_lines(0, 0, -1, 1, { 'line1', 'line2', 'line3', 'line4' }) + meths.nvim_win_set_cursor(0, { 3, 2 }) + local win = meths.nvim_get_current_win() + local buf = meths.nvim_get_current_buf() command('split') - meths.win_set_cursor(0, { 4, 2 }) - local win2 = meths.get_current_win() + meths.nvim_win_set_cursor(0, { 4, 2 }) + local win2 = meths.nvim_get_current_win() -- set current window to third one with another buffer command('new') - meths.buf_set_lines(buf, 1, 2, 1, { 'line5', 'line6' }) - eq({ 'line1', 'line5', 'line6', 'line3', 'line4' }, meths.buf_get_lines(buf, 0, -1, true)) - eq({ 4, 2 }, meths.win_get_cursor(win)) - eq({ 5, 2 }, meths.win_get_cursor(win2)) + meths.nvim_buf_set_lines(buf, 1, 2, 1, { 'line5', 'line6' }) + eq( + { 'line1', 'line5', 'line6', 'line3', 'line4' }, + meths.nvim_buf_get_lines(buf, 0, -1, true) + ) + eq({ 4, 2 }, meths.nvim_win_get_cursor(win)) + eq({ 5, 2 }, meths.nvim_win_get_cursor(win2)) end) it('line_count has defined behaviour for unloaded buffers', function() @@ -156,16 +162,22 @@ describe('api/buf', function() [3] = { reverse = true }, } screen:attach() - meths.buf_set_lines(0, 0, -1, 1, { 'aaa', 'bbb', 'ccc', 'ddd', 'www', 'xxx', 'yyy', 'zzz' }) - meths.set_option_value('modified', false, {}) + meths.nvim_buf_set_lines( + 0, + 0, + -1, + 1, + { 'aaa', 'bbb', 'ccc', 'ddd', 'www', 'xxx', 'yyy', 'zzz' } + ) + meths.nvim_set_option_value('modified', false, {}) end) it('of current window', function() - local win = meths.get_current_win() - local buf = meths.get_current_buf() + local win = meths.nvim_get_current_win() + local buf = meths.nvim_get_current_buf() command('new | wincmd w') - meths.win_set_cursor(win, { 8, 0 }) + meths.nvim_win_set_cursor(win, { 8, 0 }) screen:expect { grid = [[ @@ -181,7 +193,7 @@ describe('api/buf', function() ]], } - meths.buf_set_lines(buf, 0, 2, true, { 'aaabbb' }) + meths.nvim_buf_set_lines(buf, 0, 2, true, { 'aaabbb' }) screen:expect { grid = [[ | @@ -197,7 +209,7 @@ describe('api/buf', function() } -- replacing topline keeps it the topline - meths.buf_set_lines(buf, 3, 4, true, { 'wwweeee' }) + meths.nvim_buf_set_lines(buf, 3, 4, true, { 'wwweeee' }) screen:expect { grid = [[ | @@ -213,7 +225,7 @@ describe('api/buf', function() } -- inserting just before topline does not scroll up if cursor would be moved - meths.buf_set_lines(buf, 3, 3, true, { 'mmm' }) + meths.nvim_buf_set_lines(buf, 3, 3, true, { 'mmm' }) screen:expect { grid = [[ | @@ -229,7 +241,7 @@ describe('api/buf', function() unchanged = true, } - meths.win_set_cursor(0, { 7, 0 }) + meths.nvim_win_set_cursor(0, { 7, 0 }) screen:expect { grid = [[ | @@ -244,7 +256,7 @@ describe('api/buf', function() ]], } - meths.buf_set_lines(buf, 4, 4, true, { 'mmmeeeee' }) + meths.nvim_buf_set_lines(buf, 4, 4, true, { 'mmmeeeee' }) screen:expect { grid = [[ | @@ -261,11 +273,11 @@ describe('api/buf', function() end) it('of non-current window', function() - local win = meths.get_current_win() - local buf = meths.get_current_buf() + local win = meths.nvim_get_current_win() + local buf = meths.nvim_get_current_buf() command('new') - meths.win_set_cursor(win, { 8, 0 }) + meths.nvim_win_set_cursor(win, { 8, 0 }) screen:expect { grid = [[ @@ -281,7 +293,7 @@ describe('api/buf', function() ]], } - meths.buf_set_lines(buf, 0, 2, true, { 'aaabbb' }) + meths.nvim_buf_set_lines(buf, 0, 2, true, { 'aaabbb' }) screen:expect { grid = [[ ^ | @@ -297,7 +309,7 @@ describe('api/buf', function() } -- replacing topline keeps it the topline - meths.buf_set_lines(buf, 3, 4, true, { 'wwweeee' }) + meths.nvim_buf_set_lines(buf, 3, 4, true, { 'wwweeee' }) screen:expect { grid = [[ ^ | @@ -313,7 +325,7 @@ describe('api/buf', function() } -- inserting just before topline scrolls up - meths.buf_set_lines(buf, 3, 3, true, { 'mmm' }) + meths.nvim_buf_set_lines(buf, 3, 3, true, { 'mmm' }) screen:expect { grid = [[ ^ | @@ -330,12 +342,12 @@ describe('api/buf', function() end) it('of split windows with same buffer', function() - local win = meths.get_current_win() - local buf = meths.get_current_buf() + local win = meths.nvim_get_current_win() + local buf = meths.nvim_get_current_buf() command('split') - meths.win_set_cursor(win, { 8, 0 }) - meths.win_set_cursor(0, { 1, 0 }) + meths.nvim_win_set_cursor(win, { 8, 0 }) + meths.nvim_win_set_cursor(0, { 1, 0 }) screen:expect { grid = [[ @@ -353,7 +365,7 @@ describe('api/buf', function() | ]], } - meths.buf_set_lines(buf, 0, 2, true, { 'aaabbb' }) + meths.nvim_buf_set_lines(buf, 0, 2, true, { 'aaabbb' }) screen:expect { grid = [[ @@ -373,7 +385,7 @@ describe('api/buf', function() } -- replacing topline keeps it the topline - meths.buf_set_lines(buf, 3, 4, true, { 'wwweeee' }) + meths.nvim_buf_set_lines(buf, 3, 4, true, { 'wwweeee' }) screen:expect { grid = [[ ^aaabbb | @@ -392,7 +404,7 @@ describe('api/buf', function() } -- inserting just before topline scrolls up - meths.buf_set_lines(buf, 3, 3, true, { 'mmm' }) + meths.nvim_buf_set_lines(buf, 3, 3, true, { 'mmm' }) screen:expect { grid = [[ ^aaabbb | @@ -413,15 +425,15 @@ describe('api/buf', function() end) it('handles clearing out non-current buffer #24911', function() - local buf = meths.get_current_buf() - meths.buf_set_lines(buf, 0, -1, true, { 'aaa', 'bbb', 'ccc' }) + local buf = meths.nvim_get_current_buf() + meths.nvim_buf_set_lines(buf, 0, -1, true, { 'aaa', 'bbb', 'ccc' }) command('new') - meths.buf_set_lines(0, 0, -1, true, { 'xxx', 'yyy', 'zzz' }) + meths.nvim_buf_set_lines(0, 0, -1, true, { 'xxx', 'yyy', 'zzz' }) - meths.buf_set_lines(buf, 0, -1, true, {}) - eq({ 'xxx', 'yyy', 'zzz' }, meths.buf_get_lines(0, 0, -1, true)) - eq({ '' }, meths.buf_get_lines(buf, 0, -1, true)) + meths.nvim_buf_set_lines(buf, 0, -1, true, {}) + eq({ 'xxx', 'yyy', 'zzz' }, meths.nvim_buf_get_lines(0, 0, -1, true)) + eq({ '' }, meths.nvim_buf_get_lines(buf, 0, -1, true)) end) end) @@ -676,7 +688,7 @@ describe('api/buf', function() Who would win? A real window with proper text]]) - local buf = api.meths.create_buf(false, true) + local buf = api.meths.nvim_create_buf(false, true) screen:expect([[ Who would win? | A real window | @@ -685,7 +697,7 @@ describe('api/buf', function() | ]]) - api.meths.buf_set_lines(buf, 0, -1, true, { 'or some', 'scratchy text' }) + api.meths.nvim_buf_set_lines(buf, 0, -1, true, { 'or some', 'scratchy text' }) feed('i') -- provoke redraw screen:expect([[ Who would win? | @@ -701,22 +713,22 @@ describe('api/buf', function() visible buffer line 1 line 2 ]]) - local hiddenbuf = api.meths.create_buf(false, true) + local hiddenbuf = api.meths.nvim_create_buf(false, true) command('vsplit') command('vsplit') feed('<c-w>l<c-w>l<c-w>l') eq(3, funcs.winnr()) feed('<c-w>h') eq(2, funcs.winnr()) - api.meths.buf_set_lines(hiddenbuf, 0, -1, true, { 'hidden buffer line 1', 'line 2' }) + api.meths.nvim_buf_set_lines(hiddenbuf, 0, -1, true, { 'hidden buffer line 1', 'line 2' }) feed('<c-w>p') eq(3, funcs.winnr()) end) it('set_lines on unloaded buffer #8659 #22670', function() local bufnr = curbuf('get_number') - meths.buf_set_lines(bufnr, 0, -1, false, { 'a', 'b', 'c' }) - meths.buf_set_name(bufnr, 'set_lines') + meths.nvim_buf_set_lines(bufnr, 0, -1, false, { 'a', 'b', 'c' }) + meths.nvim_buf_set_name(bufnr, 'set_lines') finally(function() os.remove('set_lines') end) @@ -724,8 +736,8 @@ describe('api/buf', function() command('new') command('bunload! ' .. bufnr) local new_bufnr = funcs.bufnr('set_lines', true) - meths.buf_set_lines(new_bufnr, 0, -1, false, {}) - eq({ '' }, meths.buf_get_lines(new_bufnr, 0, -1, false)) + meths.nvim_buf_set_lines(new_bufnr, 0, -1, false, {}) + eq({ '' }, meths.nvim_buf_get_lines(new_bufnr, 0, -1, false)) end) end) @@ -822,18 +834,18 @@ describe('api/buf', function() hello world!]]) -- position the cursor on `!` - meths.win_set_cursor(0, { 1, 11 }) + meths.nvim_win_set_cursor(0, { 1, 11 }) - local win = meths.get_current_win() - local buf = meths.get_current_buf() + local win = meths.nvim_get_current_win() + local buf = meths.nvim_get_current_buf() command('new') -- replace 'world' with 'foo' - meths.buf_set_text(buf, 0, 6, 0, 11, { 'foo' }) - eq({ 'hello foo!' }, meths.buf_get_lines(buf, 0, -1, true)) + meths.nvim_buf_set_text(buf, 0, 6, 0, 11, { 'foo' }) + eq({ 'hello foo!' }, meths.nvim_buf_get_lines(buf, 0, -1, true)) -- cursor should be moved left by two columns (replacement is shorter by 2 chars) - eq({ 1, 9 }, meths.win_get_cursor(win)) + eq({ 1, 9 }, meths.nvim_win_get_cursor(win)) end) it('updates the cursor position in TWO non-current windows', function() @@ -841,24 +853,24 @@ describe('api/buf', function() hello world!]]) -- position the cursor on `!` - meths.win_set_cursor(0, { 1, 11 }) - local win = meths.get_current_win() - local buf = meths.get_current_buf() + meths.nvim_win_set_cursor(0, { 1, 11 }) + local win = meths.nvim_get_current_win() + local buf = meths.nvim_get_current_buf() command('split') - local win2 = meths.get_current_win() + local win2 = meths.nvim_get_current_win() -- position the cursor on `w` - meths.win_set_cursor(0, { 1, 6 }) + meths.nvim_win_set_cursor(0, { 1, 6 }) command('new') -- replace 'hello' with 'foo' - meths.buf_set_text(buf, 0, 0, 0, 5, { 'foo' }) - eq({ 'foo world!' }, meths.buf_get_lines(buf, 0, -1, true)) + meths.nvim_buf_set_text(buf, 0, 0, 0, 5, { 'foo' }) + eq({ 'foo world!' }, meths.nvim_buf_get_lines(buf, 0, -1, true)) -- both cursors should be moved left by two columns (replacement is shorter by 2 chars) - eq({ 1, 9 }, meths.win_get_cursor(win)) - eq({ 1, 4 }, meths.win_get_cursor(win2)) + eq({ 1, 9 }, meths.nvim_win_get_cursor(win)) + eq({ 1, 4 }, meths.nvim_win_get_cursor(win2)) end) describe('when text is being added right at cursor position #22526', function() @@ -1693,7 +1705,7 @@ describe('api/buf', function() it('no heap-use-after-free when called consecutively #19643', function() set_text(0, 0, 0, 0, { 'one', '', '', 'two' }) eq({ 'one', '', '', 'two' }, get_lines(0, 4, true)) - meths.win_set_cursor(0, { 1, 0 }) + meths.nvim_win_set_cursor(0, { 1, 0 }) exec_lua([[ vim.api.nvim_buf_set_text(0, 0, 3, 1, 0, {''}) vim.api.nvim_buf_set_text(0, 0, 3, 1, 0, {''}) @@ -1711,16 +1723,22 @@ describe('api/buf', function() [3] = { reverse = true }, } screen:attach() - meths.buf_set_lines(0, 0, -1, 1, { 'aaa', 'bbb', 'ccc', 'ddd', 'www', 'xxx', 'yyy', 'zzz' }) - meths.set_option_value('modified', false, {}) + meths.nvim_buf_set_lines( + 0, + 0, + -1, + 1, + { 'aaa', 'bbb', 'ccc', 'ddd', 'www', 'xxx', 'yyy', 'zzz' } + ) + meths.nvim_set_option_value('modified', false, {}) end) it('of current window', function() - local win = meths.get_current_win() - local buf = meths.get_current_buf() + local win = meths.nvim_get_current_win() + local buf = meths.nvim_get_current_buf() command('new | wincmd w') - meths.win_set_cursor(win, { 8, 0 }) + meths.nvim_win_set_cursor(win, { 8, 0 }) screen:expect { grid = [[ @@ -1735,7 +1753,7 @@ describe('api/buf', function() | ]], } - meths.buf_set_text(buf, 0, 3, 1, 0, { 'X' }) + meths.nvim_buf_set_text(buf, 0, 3, 1, 0, { 'X' }) screen:expect { grid = [[ @@ -1753,11 +1771,11 @@ describe('api/buf', function() end) it('of non-current window', function() - local win = meths.get_current_win() - local buf = meths.get_current_buf() + local win = meths.nvim_get_current_win() + local buf = meths.nvim_get_current_buf() command('new') - meths.win_set_cursor(win, { 8, 0 }) + meths.nvim_win_set_cursor(win, { 8, 0 }) screen:expect { grid = [[ @@ -1773,7 +1791,7 @@ describe('api/buf', function() ]], } - meths.buf_set_text(buf, 0, 3, 1, 0, { 'X' }) + meths.nvim_buf_set_text(buf, 0, 3, 1, 0, { 'X' }) screen:expect { grid = [[ ^ | @@ -1790,12 +1808,12 @@ describe('api/buf', function() end) it('of split windows with same buffer', function() - local win = meths.get_current_win() - local buf = meths.get_current_buf() + local win = meths.nvim_get_current_win() + local buf = meths.nvim_get_current_buf() command('split') - meths.win_set_cursor(win, { 8, 0 }) - meths.win_set_cursor(0, { 1, 1 }) + meths.nvim_win_set_cursor(win, { 8, 0 }) + meths.nvim_win_set_cursor(0, { 1, 1 }) screen:expect { grid = [[ @@ -1813,7 +1831,7 @@ describe('api/buf', function() | ]], } - meths.buf_set_text(buf, 0, 3, 1, 0, { 'X' }) + meths.nvim_buf_set_text(buf, 0, 3, 1, 0, { 'X' }) screen:expect { grid = [[ @@ -1861,7 +1879,7 @@ describe('api/buf', function() eq('Index out of bounds', pcall_err(get_text, 0, 0, 3, 0, {})) eq('Index out of bounds', pcall_err(get_text, 0, 0, -4, 0, {})) -- no ml_get errors should happen #19017 - eq('', meths.get_vvar('errmsg')) + eq('', meths.nvim_get_vvar('errmsg')) end) it('errors when start is greater than end', function() @@ -1884,19 +1902,19 @@ describe('api/buf', function() eq('Index out of bounds', pcall_err(get_offset, 6)) eq('Index out of bounds', pcall_err(get_offset, -1)) - meths.set_option_value('eol', false, {}) - meths.set_option_value('fixeol', false, {}) + meths.nvim_set_option_value('eol', false, {}) + meths.nvim_set_option_value('fixeol', false, {}) eq(28, get_offset(5)) -- fileformat is ignored - meths.set_option_value('fileformat', 'dos', {}) + meths.nvim_set_option_value('fileformat', 'dos', {}) eq(0, get_offset(0)) eq(6, get_offset(1)) eq(15, get_offset(2)) eq(16, get_offset(3)) eq(24, get_offset(4)) eq(28, get_offset(5)) - meths.set_option_value('eol', true, {}) + meths.nvim_set_option_value('eol', true, {}) eq(29, get_offset(5)) command('set hidden') @@ -2077,7 +2095,7 @@ describe('api/buf', function() eq(false, pcall(curbufmeths.set_mark, 'fail', 1, 0, {})) end) it('fails when invalid buffer number is used', function() - eq(false, pcall(meths.buf_set_mark, 99, 'a', 1, 1, {})) + eq(false, pcall(meths.nvim_buf_set_mark, 99, 'a', 1, 1, {})) end) end) @@ -2095,7 +2113,7 @@ describe('api/buf', function() eq({ 0, 0 }, curbufmeths.get_mark('Z')) end) it('returns false in marks not set in this buffer', function() - local abuf = meths.create_buf(false, true) + local abuf = meths.nvim_create_buf(false, true) bufmeths.set_lines(abuf, -1, -1, true, { 'a', 'bit of', 'text' }) bufmeths.set_mark(abuf, 'A', 2, 2, {}) eq(false, curbufmeths.del_mark('A')) @@ -2112,7 +2130,7 @@ describe('api/buf', function() eq(false, pcall(curbufmeths.del_mark, 'fail')) end) it('fails when invalid buffer number is used', function() - eq(false, pcall(meths.buf_del_mark, 99, 'a')) + eq(false, pcall(meths.nvim_buf_del_mark, 99, 'a')) end) end) end) diff --git a/test/functional/api/command_spec.lua b/test/functional/api/command_spec.lua index 6486b58db9..f1e3c5155d 100644 --- a/test/functional/api/command_spec.lua +++ b/test/functional/api/command_spec.lua @@ -51,24 +51,24 @@ describe('nvim_get_commands', function() before_each(clear) it('gets empty list if no commands were defined', function() - eq({}, meths.get_commands({ builtin = false })) + eq({}, meths.nvim_get_commands({ builtin = false })) end) it('validation', function() - eq('builtin=true not implemented', pcall_err(meths.get_commands, { builtin = true })) - eq("Invalid key: 'foo'", pcall_err(meths.get_commands, { foo = 'blah' })) + 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' })) end) it('gets global user-defined commands', function() -- Define a command. command('command -nargs=1 Hello echo "Hello World"') - eq({ Hello = cmd_dict }, meths.get_commands({ builtin = false })) + eq({ Hello = cmd_dict }, meths.nvim_get_commands({ builtin = false })) -- Define another command. command('command -nargs=? Pwd pwd') - eq({ Hello = cmd_dict, Pwd = cmd_dict2 }, meths.get_commands({ builtin = false })) + eq({ Hello = cmd_dict, Pwd = cmd_dict2 }, meths.nvim_get_commands({ builtin = false })) -- Delete a command. command('delcommand Pwd') - eq({ Hello = cmd_dict }, meths.get_commands({ builtin = false })) + eq({ Hello = cmd_dict }, meths.nvim_get_commands({ builtin = false })) end) it('gets buffer-local user-defined commands', function() @@ -171,9 +171,9 @@ describe('nvim_get_commands', function() let s:foo = 1 command -complete=custom,ListUsers -nargs=+ Finger !finger <args> ]]) - eq({ Finger = cmd1 }, meths.get_commands({ builtin = false })) + eq({ Finger = cmd1 }, meths.nvim_get_commands({ builtin = false })) command('command -nargs=1 -complete=dir -addr=arguments -count=10 TestCmd pwd <args>') - eq({ Finger = cmd1, TestCmd = cmd0 }, meths.get_commands({ builtin = false })) + eq({ Finger = cmd1, TestCmd = cmd0 }, meths.nvim_get_commands({ builtin = false })) source([[ function! s:foo() abort @@ -193,7 +193,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.get_commands({ builtin = false }) + meths.nvim_get_commands({ builtin = false }) ) end) end) @@ -202,9 +202,9 @@ describe('nvim_create_user_command', function() before_each(clear) it('works with strings', function() - meths.create_user_command('SomeCommand', 'let g:command_fired = <args>', { nargs = 1 }) - meths.command('SomeCommand 42') - eq(42, meths.eval('g:command_fired')) + meths.nvim_create_user_command('SomeCommand', 'let g:command_fired = <args>', { nargs = 1 }) + meths.nvim_command('SomeCommand 42') + eq(42, meths.nvim_eval('g:command_fired')) end) it('works with Lua functions', function() @@ -646,11 +646,11 @@ describe('nvim_create_user_command', function() end) it('can define buffer-local commands', function() - local bufnr = meths.create_buf(false, false) + local bufnr = meths.nvim_create_buf(false, false) bufmeths.create_user_command(bufnr, 'Hello', '', {}) - matches('Not an editor command: Hello', pcall_err(meths.command, 'Hello')) - meths.set_current_buf(bufnr) - meths.command('Hello') + matches('Not an editor command: Hello', pcall_err(meths.nvim_command, 'Hello')) + meths.nvim_set_current_buf(bufnr) + meths.nvim_command('Hello') assert_alive() end) @@ -731,28 +731,28 @@ describe('nvim_create_user_command', function() vim.api.nvim_cmd({ cmd = 'echo', args = { '&verbose' }, mods = opts.smods }, {}) end, {}) ]] - eq('3', meths.cmd({ cmd = 'MyEcho', mods = { verbose = 3 } }, { output = true })) + eq('3', meths.nvim_cmd({ cmd = 'MyEcho', mods = { verbose = 3 } }, { output = true })) - eq(1, #meths.list_tabpages()) + eq(1, #meths.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.cmd({ cmd = 'MySplit' }, {}) - eq(1, #meths.list_tabpages()) - eq(2, #meths.list_wins()) - meths.cmd({ cmd = 'MySplit', mods = { tab = 1 } }, {}) - eq(2, #meths.list_tabpages()) + 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.cmd({ cmd = 'MySplit', mods = { tab = 1 } }, {}) - eq(3, #meths.list_tabpages()) + meths.nvim_cmd({ cmd = 'MySplit', mods = { tab = 1 } }, {}) + eq(3, #meths.nvim_list_tabpages()) eq(2, funcs.tabpagenr()) - meths.cmd({ cmd = 'MySplit', mods = { tab = 3 } }, {}) - eq(4, #meths.list_tabpages()) + meths.nvim_cmd({ cmd = 'MySplit', mods = { tab = 3 } }, {}) + eq(4, #meths.nvim_list_tabpages()) eq(4, funcs.tabpagenr()) - meths.cmd({ cmd = 'MySplit', mods = { tab = 0 } }, {}) - eq(5, #meths.list_tabpages()) + meths.nvim_cmd({ cmd = 'MySplit', mods = { tab = 0 } }, {}) + eq(5, #meths.nvim_list_tabpages()) eq(1, funcs.tabpagenr()) end) end) @@ -761,16 +761,16 @@ describe('nvim_del_user_command', function() before_each(clear) it('can delete global commands', function() - meths.create_user_command('Hello', 'echo "Hi"', {}) - meths.command('Hello') - meths.del_user_command('Hello') - matches('Not an editor command: Hello', pcall_err(meths.command, 'Hello')) + meths.nvim_create_user_command('Hello', 'echo "Hi"', {}) + meths.nvim_command('Hello') + meths.nvim_del_user_command('Hello') + matches('Not an editor command: Hello', pcall_err(meths.nvim_command, 'Hello')) end) it('can delete buffer-local commands', function() bufmeths.create_user_command(0, 'Hello', 'echo "Hi"', {}) - meths.command('Hello') + meths.nvim_command('Hello') bufmeths.del_user_command(0, 'Hello') - matches('Not an editor command: Hello', pcall_err(meths.command, 'Hello')) + matches('Not an editor command: Hello', pcall_err(meths.nvim_command, 'Hello')) end) end) diff --git a/test/functional/api/extmark_spec.lua b/test/functional/api/extmark_spec.lua index 0594f36d0e..83fc5aa47f 100644 --- a/test/functional/api/extmark_spec.lua +++ b/test/functional/api/extmark_spec.lua @@ -1472,7 +1472,7 @@ describe('API/extmarks', function() it('in read-only buffer', function() command('view! runtime/doc/help.txt') - eq(true, meths.get_option_value('ro', {})) + eq(true, meths.nvim_get_option_value('ro', {})) local id = set_extmark(ns, 0, 0, 2) eq({ { id, 0, 2 } }, get_extmarks(ns, 0, -1)) end) @@ -1512,7 +1512,7 @@ describe('API/extmarks', function() curbufmeths.set_text(0, 0, 0, 17, {}) -- handles set_text correctly as well - eq({ { 1, 0, 0 }, { 2, 0, 0 } }, meths.buf_get_extmarks(0, ns, 0, -1, {})) + eq({ { 1, 0, 0 }, { 2, 0, 0 } }, meths.nvim_buf_get_extmarks(0, ns, 0, -1, {})) curbufmeths.set_text(0, 0, 0, 0, { 'asdfasdf' }) eq({ { 1, 0, 0 }, { 2, 0, 8 } }, curbufmeths.get_extmarks(ns, 0, -1, {})) @@ -1520,7 +1520,7 @@ describe('API/extmarks', function() -- handles pasting exec([[let @a='asdfasdf']]) feed([["ap]]) - eq({ { 1, 0, 0 }, { 2, 0, 8 } }, meths.buf_get_extmarks(0, ns, 0, -1, {})) + eq({ { 1, 0, 0 }, { 2, 0, 8 } }, meths.nvim_buf_get_extmarks(0, ns, 0, -1, {})) end) it('can accept "end_row" or "end_line" #16548', function() @@ -1547,7 +1547,7 @@ describe('API/extmarks', function() it('in prompt buffer', function() feed('dd') local id = set_extmark(ns, marks[1], 0, 0, {}) - meths.set_option_value('buftype', 'prompt', {}) + meths.nvim_set_option_value('buftype', 'prompt', {}) feed('i<esc>') eq({ { id, 0, 2 } }, get_extmarks(ns, 0, -1)) end) @@ -1695,7 +1695,7 @@ describe('API/extmarks', function() screen = Screen.new(40, 6) screen:attach() feed('dd6iaaa bbb ccc<CR><ESC>gg') - meths.set_option_value('signcolumn', 'auto:2', {}) + meths.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 diff --git a/test/functional/api/highlight_spec.lua b/test/functional/api/highlight_spec.lua index fe9e2a7727..07ce9d0c54 100644 --- a/test/functional/api/highlight_spec.lua +++ b/test/functional/api/highlight_spec.lua @@ -59,7 +59,7 @@ describe('API: highlight', function() eq(expected_rgb, nvim('get_hl_by_id', hl_id, true)) -- Test invalid id. - eq('Invalid highlight id: 30000', pcall_err(meths.get_hl_by_id, 30000, false)) + eq('Invalid highlight id: 30000', pcall_err(meths.nvim_get_hl_by_id, 30000, false)) -- Test all highlight properties. command('hi NewHighlight gui=underline,bold,italic,reverse,strikethrough,altfont,nocombine') @@ -72,30 +72,30 @@ describe('API: highlight', function() -- Test nil argument. eq( 'Wrong type for argument 1 when calling nvim_get_hl_by_id, expecting Integer', - pcall_err(meths.get_hl_by_id, { nil }, false) + pcall_err(meths.nvim_get_hl_by_id, { nil }, false) ) -- Test 0 argument. - eq('Invalid highlight id: 0', pcall_err(meths.get_hl_by_id, 0, false)) + eq('Invalid highlight id: 0', pcall_err(meths.nvim_get_hl_by_id, 0, false)) -- Test -1 argument. - eq('Invalid highlight id: -1', pcall_err(meths.get_hl_by_id, -1, false)) + eq('Invalid highlight id: -1', pcall_err(meths.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.get_hl_by_id(hl_id, false)) + eq({ foreground = 10 }, meths.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.get_hl_by_id(hl_id, false)) + eq({ background = 13 }, meths.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.get_hl_by_id(hl_id, false)) + eq({ foreground = 10, background = 13 }, meths.nvim_get_hl_by_id(hl_id, false)) end) it('nvim_get_hl_by_name', function() @@ -114,28 +114,28 @@ describe('API: highlight', function() -- Test invalid name. eq( "Invalid highlight name: 'unknown_highlight'", - pcall_err(meths.get_hl_by_name, 'unknown_highlight', false) + pcall_err(meths.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.get_hl_by_name, { nil }, false) + pcall_err(meths.nvim_get_hl_by_name, { nil }, false) ) -- Test empty string argument. - eq('Invalid highlight name', pcall_err(meths.get_hl_by_name, '', false)) + eq('Invalid highlight name', pcall_err(meths.nvim_get_hl_by_name, '', false)) -- Test "standout" attribute. #8054 - eq({ underline = true }, meths.get_hl_by_name('cursorline', 0)) + eq({ underline = true }, meths.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.get_hl_by_name('cursorline', 0)) + eq({ underline = true, standout = true }, meths.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.set_hl(0, 'Normal', { ctermfg = 17, ctermbg = 213 }) - meths.set_hl(0, 'NotNormal', { ctermfg = 17, ctermbg = 213, nocombine = true }) + meths.nvim_set_hl(0, 'Normal', { ctermfg = 17, ctermbg = 213 }) + meths.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 }, nvim('get_hl_by_name', 'Normal', false)) eq( @@ -146,31 +146,34 @@ describe('API: highlight', function() 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.get_hl_by_name, 'Shrubbery', true)) + eq( + "Invalid highlight name: 'Shrubbery'", + pcall_err(meths.nvim_get_hl_by_name, 'Shrubbery', true) + ) eq(0, funcs.hlID('Shrubbery')) - local hl_id = meths.get_hl_id_by_name('Shrubbery') + local hl_id = meths.nvim_get_hl_id_by_name('Shrubbery') ok(hl_id > 0) eq(hl_id, funcs.hlID('Shrubbery')) command('hi Shrubbery guifg=#888888 guibg=#888888') eq( { foreground = tonumber('0x888888'), background = tonumber('0x888888') }, - meths.get_hl_by_id(hl_id, true) + meths.nvim_get_hl_by_id(hl_id, true) ) eq( { foreground = tonumber('0x888888'), background = tonumber('0x888888') }, - meths.get_hl_by_name('Shrubbery', true) + meths.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.set_option_value, 'undofile', false, { buf = 1 }) + local err, _ = pcall(meths.nvim_set_option_value, 'undofile', false, { buf = 1 }) eq(true, err) - err, _ = pcall(meths.set_option_value, 'undolevels', -1, { buf = 1 }) + err, _ = pcall(meths.nvim_set_option_value, 'undolevels', -1, { buf = 1 }) eq(true, err) - err, _ = pcall(meths.buf_add_highlight, 1, -1, 'Question', 0, 0, -1) + err, _ = pcall(meths.nvim_buf_add_highlight, 1, -1, 'Question', 0, 0, -1) eq(true, err) assert_alive() end) @@ -241,8 +244,8 @@ describe('API: set highlight', function() } local function get_ns() - local ns = meths.create_namespace('Test_set_hl') - meths.set_hl_ns(ns) + local ns = meths.nvim_create_namespace('Test_set_hl') + meths.nvim_set_hl_ns(ns) return ns end @@ -251,51 +254,51 @@ describe('API: set highlight', function() it('validation', function() eq( "Invalid 'blend': out of range", - pcall_err(meths.set_hl, 0, 'Test_hl3', { fg = '#FF00FF', blend = 999 }) + pcall_err(meths.nvim_set_hl, 0, 'Test_hl3', { fg = '#FF00FF', blend = 999 }) ) eq( "Invalid 'blend': expected Integer, got Array", - pcall_err(meths.set_hl, 0, 'Test_hl3', { fg = '#FF00FF', blend = {} }) + pcall_err(meths.nvim_set_hl, 0, 'Test_hl3', { fg = '#FF00FF', blend = {} }) ) end) it('can set gui highlight', function() local ns = get_ns() - meths.set_hl(ns, 'Test_hl', highlight1) - eq(highlight1, meths.get_hl_by_name('Test_hl', true)) + meths.nvim_set_hl(ns, 'Test_hl', highlight1) + eq(highlight1, meths.nvim_get_hl_by_name('Test_hl', true)) end) it('can set cterm highlight', function() local ns = get_ns() - meths.set_hl(ns, 'Test_hl', highlight2_config) - eq(highlight2_result, meths.get_hl_by_name('Test_hl', false)) + meths.nvim_set_hl(ns, 'Test_hl', highlight2_config) + eq(highlight2_result, meths.nvim_get_hl_by_name('Test_hl', false)) end) it('can set empty cterm attr', function() local ns = get_ns() - meths.set_hl(ns, 'Test_hl', { cterm = {} }) - eq({}, meths.get_hl_by_name('Test_hl', false)) + meths.nvim_set_hl(ns, 'Test_hl', { cterm = {} }) + eq({}, meths.nvim_get_hl_by_name('Test_hl', false)) end) it('cterm attr defaults to gui attr', function() local ns = get_ns() - meths.set_hl(ns, 'Test_hl', highlight1) + meths.nvim_set_hl(ns, 'Test_hl', highlight1) eq({ bold = true, italic = true, - }, meths.get_hl_by_name('Test_hl', false)) + }, meths.nvim_get_hl_by_name('Test_hl', false)) end) it('can overwrite attr for cterm', function() local ns = get_ns() - meths.set_hl(ns, 'Test_hl', highlight3_config) - eq(highlight3_result_gui, meths.get_hl_by_name('Test_hl', true)) - eq(highlight3_result_cterm, meths.get_hl_by_name('Test_hl', false)) + 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)) end) it('only allows one underline attribute #22371', function() local ns = get_ns() - meths.set_hl(ns, 'Test_hl', { + meths.nvim_set_hl(ns, 'Test_hl', { underdouble = true, underdotted = true, cterm = { @@ -303,21 +306,21 @@ describe('API: set highlight', function() undercurl = true, }, }) - eq({ undercurl = true }, meths.get_hl_by_name('Test_hl', false)) - eq({ underdotted = true }, meths.get_hl_by_name('Test_hl', 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)) end) it('can set a highlight in the global namespace', function() - meths.set_hl(0, 'Test_hl', highlight2_config) + meths.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.set_hl(0, 'Test_hl', { background = highlight_color.bg }) + meths.nvim_set_hl(0, 'Test_hl', { background = highlight_color.bg }) eq('Test_hl xxx guibg=#0032aa', exec_capture('highlight Test_hl')) - meths.set_hl(0, 'Test_hl2', highlight3_config) + meths.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') @@ -325,58 +328,64 @@ describe('API: set highlight', function() -- Colors are stored with the name they are defined, but -- with canonical casing - meths.set_hl(0, 'Test_hl3', { bg = 'reD', fg = 'bLue' }) + meths.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.set_hl(0, 'Test_hl3', { bg = 'red', fg = 'blue' }) + meths.nvim_set_hl(0, 'Test_hl3', { bg = 'red', fg = 'blue' }) eq('Test_hl3 xxx guifg=Blue guibg=Red', exec_capture('highlight Test_hl3')) - meths.set_hl(0, 'Test_hl3', { bg = 'red' }) + meths.nvim_set_hl(0, 'Test_hl3', { bg = 'red' }) eq('Test_hl3 xxx guibg=Red', exec_capture('highlight Test_hl3')) - meths.set_hl(0, 'Test_hl3', { ctermbg = 9, ctermfg = 12 }) + meths.nvim_set_hl(0, 'Test_hl3', { ctermbg = 9, ctermfg = 12 }) eq('Test_hl3 xxx ctermfg=12 ctermbg=9', exec_capture('highlight Test_hl3')) - meths.set_hl(0, 'Test_hl3', { ctermbg = 'red', ctermfg = 'blue' }) + meths.nvim_set_hl(0, 'Test_hl3', { ctermbg = 'red', ctermfg = 'blue' }) eq('Test_hl3 xxx ctermfg=12 ctermbg=9', exec_capture('highlight Test_hl3')) - meths.set_hl(0, 'Test_hl3', { ctermbg = 9 }) + meths.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.set_hl, 0, 'Test_hl3', { fg = 'redd' })) + eq( + "Invalid highlight color: 'redd'", + pcall_err(meths.nvim_set_hl, 0, 'Test_hl3', { fg = 'redd' }) + ) eq( "Invalid highlight color: 'bleu'", - pcall_err(meths.set_hl, 0, 'Test_hl3', { ctermfg = 'bleu' }) + pcall_err(meths.nvim_set_hl, 0, 'Test_hl3', { ctermfg = 'bleu' }) ) - meths.set_hl(0, 'Test_hl3', { fg = '#FF00FF' }) + meths.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.set_hl, 0, 'Test_hl3', { ctermfg = '#FF00FF' }) + pcall_err(meths.nvim_set_hl, 0, 'Test_hl3', { ctermfg = '#FF00FF' }) ) for _, fg_val in ipairs { nil, 'NONE', 'nOnE', '', -1 } do - meths.set_hl(0, 'Test_hl3', { fg = fg_val }) + meths.nvim_set_hl(0, 'Test_hl3', { fg = fg_val }) eq('Test_hl3 xxx cleared', exec_capture('highlight Test_hl3')) end - meths.set_hl(0, 'Test_hl3', { fg = '#FF00FF', blend = 50 }) + meths.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.set_hl(0, 'Normal', { fg = '#000083', bg = '#0000F3' }) + meths.nvim_set_hl(0, 'Normal', { fg = '#000083', bg = '#0000F3' }) eq({ foreground = 131, background = 243 }, 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.set_hl, 0, 'foo bar', { bold = true })) + eq( + "Invalid highlight name: 'foo bar'", + pcall_err(meths.nvim_set_hl, 0, 'foo bar', { bold = true }) + ) assert_alive() end) end) @@ -443,14 +452,14 @@ describe('API: get highlight', function() local function get_ns() -- Test namespace filtering behavior - local ns2 = meths.create_namespace('Another_namespace') - meths.set_hl(ns2, 'Test_hl', { ctermfg = 23 }) - meths.set_hl(ns2, 'Test_another_hl', { link = 'Test_hl' }) - meths.set_hl(ns2, 'Test_hl_link', { link = 'Test_another_hl' }) - meths.set_hl(ns2, 'Test_another_hl_link', { link = 'Test_hl_link' }) + 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 ns = meths.create_namespace('Test_set_hl') - meths.set_hl_ns(ns) + local ns = meths.nvim_create_namespace('Test_set_hl') + meths.nvim_set_hl_ns(ns) return ns end @@ -458,23 +467,26 @@ describe('API: get highlight', function() before_each(clear) it('validation', function() - eq("Invalid 'name': expected String, got Integer", pcall_err(meths.get_hl, 0, { name = 177 })) - eq('Highlight id out of bounds', pcall_err(meths.get_hl, 0, { name = 'Test set hl' })) + eq( + "Invalid 'name': expected String, got Integer", + pcall_err(meths.nvim_get_hl, 0, { name = 177 }) + ) + eq('Highlight id out of bounds', pcall_err(meths.nvim_get_hl, 0, { name = 'Test set hl' })) end) it('nvim_get_hl with create flag', function() eq({}, nvim('get_hl', 0, { name = 'Foo', create = false })) eq(0, funcs.hlexists('Foo')) - meths.get_hl(0, { name = 'Bar', create = true }) + meths.nvim_get_hl(0, { name = 'Bar', create = true }) eq(1, funcs.hlexists('Bar')) - meths.get_hl(0, { name = 'FooBar' }) + meths.nvim_get_hl(0, { name = 'FooBar' }) eq(1, funcs.hlexists('FooBar')) end) it('can get all highlights in current namespace', function() local ns = get_ns() - meths.set_hl(ns, 'Test_hl', { bg = '#B4BEFE' }) - meths.set_hl(ns, 'Test_hl_link', { link = 'Test_hl' }) + meths.nvim_set_hl(ns, 'Test_hl', { bg = '#B4BEFE' }) + meths.nvim_set_hl(ns, 'Test_hl_link', { link = 'Test_hl' }) eq({ Test_hl = { bg = 11845374, @@ -482,42 +494,42 @@ describe('API: get highlight', function() Test_hl_link = { link = 'Test_hl', }, - }, meths.get_hl(ns, {})) + }, meths.nvim_get_hl(ns, {})) end) it('can get gui highlight', function() local ns = get_ns() - meths.set_hl(ns, 'Test_hl', highlight1) - eq(highlight1, meths.get_hl(ns, { name = 'Test_hl' })) + meths.nvim_set_hl(ns, 'Test_hl', highlight1) + eq(highlight1, meths.nvim_get_hl(ns, { name = 'Test_hl' })) end) it('can get cterm highlight', function() local ns = get_ns() - meths.set_hl(ns, 'Test_hl', highlight2) - eq(highlight2, meths.get_hl(ns, { name = 'Test_hl' })) + meths.nvim_set_hl(ns, 'Test_hl', highlight2) + eq(highlight2, meths.nvim_get_hl(ns, { name = 'Test_hl' })) end) it('can get empty cterm attr', function() local ns = get_ns() - meths.set_hl(ns, 'Test_hl', { cterm = {} }) - eq({}, meths.get_hl(ns, { name = 'Test_hl' })) + meths.nvim_set_hl(ns, 'Test_hl', { cterm = {} }) + eq({}, meths.nvim_get_hl(ns, { name = 'Test_hl' })) end) it('cterm attr defaults to gui attr', function() local ns = get_ns() - meths.set_hl(ns, 'Test_hl', highlight1) - eq(highlight1, meths.get_hl(ns, { name = 'Test_hl' })) + meths.nvim_set_hl(ns, 'Test_hl', highlight1) + eq(highlight1, meths.nvim_get_hl(ns, { name = 'Test_hl' })) end) it('can overwrite attr for cterm', function() local ns = get_ns() - meths.set_hl(ns, 'Test_hl', highlight3_config) - eq(highlight3_result, meths.get_hl(ns, { name = 'Test_hl' })) + meths.nvim_set_hl(ns, 'Test_hl', highlight3_config) + eq(highlight3_result, meths.nvim_get_hl(ns, { name = 'Test_hl' })) end) it('only allows one underline attribute #22371', function() local ns = get_ns() - meths.set_hl(ns, 'Test_hl', { + meths.nvim_set_hl(ns, 'Test_hl', { underdouble = true, underdotted = true, cterm = { @@ -525,32 +537,35 @@ describe('API: get highlight', function() undercurl = true, }, }) - eq({ underdotted = true, cterm = { undercurl = true } }, meths.get_hl(ns, { name = 'Test_hl' })) + eq( + { underdotted = true, cterm = { undercurl = true } }, + meths.nvim_get_hl(ns, { name = 'Test_hl' }) + ) end) it('can get a highlight in the global namespace', function() - meths.set_hl(0, 'Test_hl', highlight2) - eq(highlight2, meths.get_hl(0, { name = 'Test_hl' })) + meths.nvim_set_hl(0, 'Test_hl', highlight2) + eq(highlight2, meths.nvim_get_hl(0, { name = 'Test_hl' })) - meths.set_hl(0, 'Test_hl', { background = highlight_color.bg }) + meths.nvim_set_hl(0, 'Test_hl', { background = highlight_color.bg }) eq({ bg = 12970, - }, meths.get_hl(0, { name = 'Test_hl' })) + }, meths.nvim_get_hl(0, { name = 'Test_hl' })) - meths.set_hl(0, 'Test_hl2', highlight3_config) - eq(highlight3_result, meths.get_hl(0, { name = 'Test_hl2' })) + meths.nvim_set_hl(0, 'Test_hl2', highlight3_config) + eq(highlight3_result, meths.nvim_get_hl(0, { name = 'Test_hl2' })) -- Colors are stored with the name they are defined, but -- with canonical casing - meths.set_hl(0, 'Test_hl3', { bg = 'reD', fg = 'bLue' }) + meths.nvim_set_hl(0, 'Test_hl3', { bg = 'reD', fg = 'bLue' }) eq({ bg = 16711680, fg = 255, - }, meths.get_hl(0, { name = 'Test_hl3' })) + }, meths.nvim_get_hl(0, { name = 'Test_hl3' })) end) it('nvim_get_hl by id', function() - local hl_id = meths.get_hl_id_by_name('NewHighlight') + local hl_id = meths.nvim_get_hl_id_by_name('NewHighlight') command( 'hi NewHighlight cterm=underline ctermbg=green guifg=red guibg=yellow guisp=blue gui=bold' @@ -562,14 +577,14 @@ describe('API: get highlight', function() bold = true, ctermbg = 10, cterm = { underline = true }, - }, meths.get_hl(0, { id = hl_id })) + }, meths.nvim_get_hl(0, { id = hl_id })) -- Test 0 argument - eq('Highlight id out of bounds', pcall_err(meths.get_hl, 0, { id = 0 })) + eq('Highlight id out of bounds', pcall_err(meths.nvim_get_hl, 0, { id = 0 })) eq( "Invalid 'id': expected Integer, got String", - pcall_err(meths.get_hl, 0, { id = 'Test_set_hl' }) + pcall_err(meths.nvim_get_hl, 0, { id = 'Test_set_hl' }) ) -- Test all highlight properties. @@ -587,7 +602,7 @@ describe('API: get highlight', function() underline = true, ctermbg = 10, cterm = { underline = true }, - }, meths.get_hl(0, { id = hl_id })) + }, meths.nvim_get_hl(0, { id = hl_id })) -- Test undercurl command('hi NewHighlight gui=undercurl') @@ -598,16 +613,16 @@ describe('API: get highlight', function() undercurl = true, ctermbg = 10, cterm = { underline = true }, - }, meths.get_hl(0, { id = hl_id })) + }, meths.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.get_hl(0, { name = 'String' })) - eq({ link = 'String' }, meths.get_hl(0, { name = '@string' })) - eq({ fg = 10937249 }, meths.get_hl(0, { name = '@string.cpp', link = false })) + 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 })) end) it('can get all attributes for a linked group', function() @@ -616,55 +631,55 @@ describe('API: get highlight', function() command('hi! link Foo Bar') eq( { link = 'Bar', fg = tonumber('00ff00', 16), bold = true, underline = true }, - meths.get_hl(0, { name = 'Foo', link = true }) + meths.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.set_hl(0, 'Foo', hl) - eq(hl, meths.get_hl(0, { name = 'Foo', link = true })) + meths.nvim_set_hl(0, 'Foo', hl) + eq(hl, meths.nvim_get_hl(0, { name = 'Foo', link = true })) end) it("doesn't contain unset groups", function() - local id = meths.get_hl_id_by_name '@foobar.hubbabubba' + local id = meths.nvim_get_hl_id_by_name '@foobar.hubbabubba' ok(id > 0) - local data = meths.get_hl(0, {}) + local data = meths.nvim_get_hl(0, {}) eq(nil, data['@foobar.hubbabubba']) eq(nil, data['@foobar']) command 'hi @foobar.hubbabubba gui=bold' - data = meths.get_hl(0, {}) + data = meths.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.get_hl(0, {}) + data = meths.nvim_get_hl(0, {}) eq({}, data['@foobar.hubbabubba']) eq(nil, data['@foobar']) end) it('should return default flag', function() - meths.set_hl(0, 'Tried', { fg = '#00ff00', default = true }) - eq({ fg = tonumber('00ff00', 16), default = true }, meths.get_hl(0, { name = 'Tried' })) + meths.nvim_set_hl(0, 'Tried', { fg = '#00ff00', default = true }) + eq({ fg = tonumber('00ff00', 16), default = true }, meths.nvim_get_hl(0, { name = 'Tried' })) end) it('should not output empty gui and cterm #23474', function() - meths.set_hl(0, 'Foo', { default = true }) - meths.set_hl(0, 'Bar', { default = true, fg = '#ffffff' }) - meths.set_hl(0, 'FooBar', { default = true, fg = '#ffffff', cterm = { bold = true } }) - meths.set_hl( + 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( 0, 'FooBarA', { default = true, fg = '#ffffff', cterm = { bold = true, italic = true } } ) eq('Foo xxx cleared', exec_capture('highlight Foo')) - eq({ default = true }, meths.get_hl(0, { name = 'Foo' })) + eq({ default = true }, meths.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')) @@ -673,27 +688,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.set_hl(0, 'Foo', { fg = white }) - meths.set_hl(0, 'Foo', { fg = green, force = true }) - eq({ fg = green }, meths.get_hl(0, { name = 'Foo' })) - meths.set_hl(0, 'Bar', { link = 'Comment', default = true }) - meths.set_hl(0, 'Bar', { link = 'Foo', default = true, force = true }) - eq({ link = 'Foo', default = true }, meths.get_hl(0, { name = 'Bar' })) + 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' })) end) end) describe('API: set/get highlight namespace', function() it('set/get highlight namespace', function() - eq(0, meths.get_hl_ns({})) - local ns = meths.create_namespace('') - meths.set_hl_ns(ns) - eq(ns, meths.get_hl_ns({})) + 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({})) end) it('set/get window highlight namespace', function() - eq(-1, meths.get_hl_ns({ winid = 0 })) - local ns = meths.create_namespace('') - meths.win_set_hl_ns(0, ns) - eq(ns, meths.get_hl_ns({ winid = 0 })) + 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 })) end) end) diff --git a/test/functional/api/keymap_spec.lua b/test/functional/api/keymap_spec.lua index 789ad28544..f633c96a7c 100644 --- a/test/functional/api/keymap_spec.lua +++ b/test/functional/api/keymap_spec.lua @@ -57,7 +57,7 @@ describe('nvim_get_keymap', function() } it('returns empty list when no map', function() - eq({}, meths.get_keymap('n')) + eq({}, meths.nvim_get_keymap('n')) end) it('returns list of all applicable mappings', function() @@ -66,8 +66,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.get_keymap('n')) - eq({ funcs.maparg('foo', 'n', false, true) }, meths.get_keymap('n')) + eq({ foo_bar_map_table }, meths.nvim_get_keymap('n')) + eq({ funcs.maparg('foo', 'n', false, true) }, meths.nvim_get_keymap('n')) -- Add another mapping command('nnoremap foo_longer bar_longer') @@ -76,11 +76,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.get_keymap('n')) + eq({ foolong_bar_map_table, foo_bar_map_table }, meths.nvim_get_keymap('n')) -- Remove a mapping command('unmap foo_longer') - eq({ foo_bar_map_table }, meths.get_keymap('n')) + eq({ foo_bar_map_table }, meths.nvim_get_keymap('n')) end) it('works for other modes', function() @@ -94,7 +94,7 @@ describe('nvim_get_keymap', function() insert_table['mode'] = 'i' insert_table['mode_bits'] = 0x10 - eq({ insert_table }, meths.get_keymap('i')) + eq({ insert_table }, meths.nvim_get_keymap('i')) end) it('considers scope', function() @@ -111,7 +111,7 @@ describe('nvim_get_keymap', function() command('nnoremap <buffer> foo bar') -- The buffer mapping should not show up - eq({ foolong_bar_map_table }, meths.get_keymap('n')) + eq({ foolong_bar_map_table }, meths.nvim_get_keymap('n')) eq({ buffer_table }, curbufmeths.get_keymap('n')) end) @@ -123,7 +123,7 @@ describe('nvim_get_keymap', function() command('nnoremap <buffer> foo bar') - eq({ foo_bar_map_table }, meths.get_keymap('n')) + eq({ foo_bar_map_table }, meths.nvim_get_keymap('n')) eq({ buffer_table }, curbufmeths.get_keymap('n')) end) @@ -143,15 +143,15 @@ describe('nvim_get_keymap', function() -- Final buffer will have buffer mappings local buffer_table = shallowcopy(foo_bar_map_table) buffer_table['buffer'] = final_buffer - eq({ buffer_table }, meths.buf_get_keymap(final_buffer, 'n')) - eq({ buffer_table }, meths.buf_get_keymap(0, 'n')) + eq({ buffer_table }, meths.nvim_buf_get_keymap(final_buffer, 'n')) + eq({ buffer_table }, meths.nvim_buf_get_keymap(0, 'n')) command('buffer ' .. original_buffer) eq(original_buffer, curbufmeths.get_number()) -- Original buffer won't have any mappings - eq({}, meths.get_keymap('n')) + eq({}, meths.nvim_get_keymap('n')) eq({}, curbufmeths.get_keymap('n')) - eq({ buffer_table }, meths.buf_get_keymap(final_buffer, 'n')) + eq({ buffer_table }, meths.nvim_buf_get_keymap(final_buffer, 'n')) end) -- Test toggle switches for basic options @@ -191,7 +191,7 @@ describe('nvim_get_keymap', function() function() make_new_windows(new_windows) command(map .. ' ' .. option_token .. ' foo bar') - local result = meths.get_keymap(mode)[1][option] + local result = meths.nvim_get_keymap(mode)[1][option] eq(global_on_result, result) end ) @@ -228,7 +228,7 @@ describe('nvim_get_keymap', function() function() make_new_windows(new_windows) command(map .. ' baz bat') - local result = meths.get_keymap(mode)[1][option] + local result = meths.nvim_get_keymap(mode)[1][option] eq(global_off_result, result) end ) @@ -277,9 +277,9 @@ describe('nvim_get_keymap', function() nnoremap fizz :call <SID>maparg_test_function()<CR> ]]) - local sid_result = meths.get_keymap('n')[1]['sid'] + local sid_result = meths.nvim_get_keymap('n')[1]['sid'] eq(1, sid_result) - eq('testing', meths.call_function('<SNR>' .. sid_result .. '_maparg_test_function', {})) + eq('testing', meths.nvim_call_function('<SNR>' .. sid_result .. '_maparg_test_function', {})) end) it('returns script numbers for buffer maps', function() @@ -292,13 +292,13 @@ describe('nvim_get_keymap', function() ]]) local sid_result = curbufmeths.get_keymap('n')[1]['sid'] eq(1, sid_result) - eq('testing', meths.call_function('<SNR>' .. sid_result .. '_maparg_test_function', {})) + eq('testing', meths.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.get_keymap('n')[1]['lhs']) - eq(':let g:maparg_test_var = 1<CR>', meths.get_keymap('n')[1]['rhs']) + eq('<F12>', meths.nvim_get_keymap('n')[1]['lhs']) + eq(':let g:maparg_test_var = 1<CR>', meths.nvim_get_keymap('n')[1]['rhs']) end) it('works correctly despite various &cpo settings', function() @@ -341,7 +341,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.get_keymap(...) + local ret = meths.nvim_get_keymap(...) for _, item in ipairs(ret) do item.lhsraw = nil item.lhsrawalt = nil @@ -392,7 +392,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.get_keymap('n')) + eq({ space_table }, meths.nvim_get_keymap('n')) end) it('can handle lua mappings', function() @@ -421,7 +421,7 @@ describe('nvim_get_keymap', function() ]]) eq(3, exec_lua([[return GlobalCount]])) - local mapargs = meths.get_keymap('n') + local mapargs = meths.nvim_get_keymap('n') mapargs[1].callback = nil eq({ lhs = 'asdf', @@ -442,7 +442,7 @@ describe('nvim_get_keymap', function() end) it('can handle map descriptions', function() - meths.set_keymap('n', 'lhs', 'rhs', { desc = 'map description' }) + meths.nvim_set_keymap('n', 'lhs', 'rhs', { desc = 'map description' }) eq({ lhs = 'lhs', lhsraw = 'lhs', @@ -460,7 +460,7 @@ describe('nvim_get_keymap', function() noremap = 0, lnum = 0, desc = 'map description', - }, meths.get_keymap('n')[1]) + }, meths.nvim_get_keymap('n')[1]) end) end) @@ -522,9 +522,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.set_keymap, '', '', 'rhs', {})) - eq('Invalid (empty) LHS', pcall_err(meths.set_keymap, '', '', '', {})) - eq('Invalid (empty) LHS', pcall_err(meths.del_keymap, '', '')) + 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, '', '')) end) it('error if LHS longer than MAXMAPLEN', function() @@ -536,16 +536,19 @@ describe('nvim_set_keymap, nvim_del_keymap', function() end -- exactly 50 chars should be fine - meths.set_keymap('', lhs, 'rhs', {}) + meths.nvim_set_keymap('', lhs, 'rhs', {}) -- del_keymap should unmap successfully - meths.del_keymap('', lhs) + meths.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.set_keymap, '', lhs, 'rhs', {})) - eq('LHS exceeds maximum map length: ' .. lhs, pcall_err(meths.del_keymap, '', lhs)) + eq( + 'LHS exceeds maximum map length: ' .. lhs, + pcall_err(meths.nvim_set_keymap, '', lhs, 'rhs', {}) + ) + eq('LHS exceeds maximum map length: ' .. lhs, pcall_err(meths.nvim_del_keymap, '', lhs)) end) it('does not throw errors when rhs is longer than MAXMAPLEN', function() @@ -555,56 +558,65 @@ describe('nvim_set_keymap, nvim_del_keymap', function() rhs = rhs .. (i % 10) end rhs = rhs .. '1' - meths.set_keymap('', 'lhs', rhs, {}) + meths.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.set_keymap, ' ', 'lhs', 'rhs', {})) - eq('Invalid mode shortname: "m"', pcall_err(meths.set_keymap, 'm', 'lhs', 'rhs', {})) - eq('Invalid mode shortname: "?"', pcall_err(meths.set_keymap, '?', 'lhs', 'rhs', {})) - eq('Invalid mode shortname: "y"', pcall_err(meths.set_keymap, 'y', 'lhs', 'rhs', {})) - eq('Invalid mode shortname: "p"', pcall_err(meths.set_keymap, 'p', 'lhs', 'rhs', {})) - eq('Invalid mode shortname: "a"', pcall_err(meths.set_keymap, 'a', 'lhs', 'rhs', {})) - eq('Invalid mode shortname: "oa"', pcall_err(meths.set_keymap, 'oa', 'lhs', 'rhs', {})) - eq('Invalid mode shortname: "!o"', pcall_err(meths.set_keymap, '!o', 'lhs', 'rhs', {})) - eq('Invalid mode shortname: "!i"', pcall_err(meths.set_keymap, '!i', 'lhs', 'rhs', {})) - eq('Invalid mode shortname: "!!"', pcall_err(meths.set_keymap, '!!', 'lhs', 'rhs', {})) - eq('Invalid mode shortname: "map"', pcall_err(meths.set_keymap, 'map', 'lhs', 'rhs', {})) - eq('Invalid mode shortname: "vmap"', pcall_err(meths.set_keymap, 'vmap', 'lhs', 'rhs', {})) + 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: "xnoremap"', - pcall_err(meths.set_keymap, 'xnoremap', 'lhs', 'rhs', {}) + pcall_err(meths.nvim_set_keymap, 'xnoremap', 'lhs', 'rhs', {}) ) - eq('Invalid mode shortname: " "', pcall_err(meths.del_keymap, ' ', 'lhs')) - eq('Invalid mode shortname: "m"', pcall_err(meths.del_keymap, 'm', 'lhs')) - eq('Invalid mode shortname: "?"', pcall_err(meths.del_keymap, '?', 'lhs')) - eq('Invalid mode shortname: "y"', pcall_err(meths.del_keymap, 'y', 'lhs')) - eq('Invalid mode shortname: "p"', pcall_err(meths.del_keymap, 'p', 'lhs')) - eq('Invalid mode shortname: "a"', pcall_err(meths.del_keymap, 'a', 'lhs')) - eq('Invalid mode shortname: "oa"', pcall_err(meths.del_keymap, 'oa', 'lhs')) - eq('Invalid mode shortname: "!o"', pcall_err(meths.del_keymap, '!o', 'lhs')) - eq('Invalid mode shortname: "!i"', pcall_err(meths.del_keymap, '!i', 'lhs')) - eq('Invalid mode shortname: "!!"', pcall_err(meths.del_keymap, '!!', 'lhs')) - eq('Invalid mode shortname: "map"', pcall_err(meths.del_keymap, 'map', 'lhs')) - eq('Invalid mode shortname: "vmap"', pcall_err(meths.del_keymap, 'vmap', 'lhs')) - eq('Invalid mode shortname: "xnoremap"', pcall_err(meths.del_keymap, 'xnoremap', 'lhs')) + 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')) end) it('error on invalid optnames', function() - eq("Invalid key: 'silentt'", pcall_err(meths.set_keymap, 'n', 'lhs', 'rhs', { silentt = true })) - eq("Invalid key: 'sidd'", pcall_err(meths.set_keymap, 'n', 'lhs', 'rhs', { sidd = false })) - eq("Invalid key: 'nowaiT'", pcall_err(meths.set_keymap, 'n', 'lhs', 'rhs', { nowaiT = false })) + eq( + "Invalid key: 'silentt'", + pcall_err(meths.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: 'nowaiT'", + pcall_err(meths.nvim_set_keymap, 'n', 'lhs', 'rhs', { nowaiT = false }) + ) end) it('error on <buffer> option key', function() - eq("Invalid key: 'buffer'", pcall_err(meths.set_keymap, 'n', 'lhs', 'rhs', { buffer = true })) + eq( + "Invalid key: 'buffer'", + pcall_err(meths.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.set_keymap, 'n', 'lhs', 'rhs', { replace_keycodes = true }) + pcall_err(meths.nvim_set_keymap, 'n', 'lhs', 'rhs', { replace_keycodes = true }) ) end) @@ -614,45 +626,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.set_keymap, 'n', 'lhs', 'rhs', opts)) + eq(opt .. ' is not a boolean', pcall_err(meths.nvim_set_keymap, 'n', 'lhs', 'rhs', opts)) end) end -- Perform tests of basic functionality it('sets ordinary mappings', function() - meths.set_keymap('n', 'lhs', 'rhs', {}) + meths.nvim_set_keymap('n', 'lhs', 'rhs', {}) eq(generate_mapargs('n', 'lhs', 'rhs'), get_mapargs('n', 'lhs')) - meths.set_keymap('v', 'lhs', 'rhs', {}) + meths.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.set_keymap('n', ' lhs', 'rhs', {}) + meths.nvim_set_keymap('n', ' lhs', 'rhs', {}) eq(generate_mapargs('n', '<Space><Space><Space>lhs', 'rhs'), get_mapargs('n', ' lhs')) - meths.set_keymap('n', 'lhs ', 'rhs', {}) + meths.nvim_set_keymap('n', 'lhs ', 'rhs', {}) eq(generate_mapargs('n', 'lhs<Space><Space><Space><Space>', 'rhs'), get_mapargs('n', 'lhs ')) - meths.set_keymap('v', ' lhs ', '\trhs\t\f', {}) + meths.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.set_keymap('x', 'lhs', 'rhs', { noremap = true }) + meths.nvim_set_keymap('x', 'lhs', 'rhs', { noremap = true }) eq(generate_mapargs('x', 'lhs', 'rhs', { noremap = true }), get_mapargs('x', 'lhs')) - meths.set_keymap('t', 'lhs', 'rhs', { noremap = true }) + meths.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.set_keymap('v', 'lhs', 'rhs', {}) - meths.del_keymap('v', 'lhs') + meths.nvim_set_keymap('v', 'lhs', 'rhs', {}) + meths.nvim_del_keymap('v', 'lhs') eq({}, get_mapargs('v', 'lhs')) - meths.set_keymap('t', 'lhs', 'rhs', { noremap = true }) - meths.del_keymap('t', 'lhs') + meths.nvim_set_keymap('t', 'lhs', 'rhs', { noremap = true }) + meths.nvim_del_keymap('t', 'lhs') eq({}, get_mapargs('t', 'lhs')) end) @@ -660,8 +672,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.set_keymap(name, 'lhs', 'rhs', {}) - meths.del_keymap(name, 'lhs') + meths.nvim_set_keymap(name, 'lhs', 'rhs', {}) + meths.nvim_del_keymap(name, 'lhs') eq({}, get_mapargs(name, 'lhs')) end end) @@ -671,46 +683,46 @@ 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.set_keymap(mapmode, lhs, rhs, {}) + meths.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.set_keymap('n', '\n\r\n', 'rhs', {}) + meths.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.set_keymap('i', 'lhs', '<Nop>', {}) + meths.nvim_set_keymap('i', 'lhs', '<Nop>', {}) command('normal ilhs') eq({ '' }, curbufmeths.get_lines(0, -1, 0)) -- imap to <Nop> does nothing eq(generate_mapargs('i', 'lhs', '<Nop>', {}), get_mapargs('i', 'lhs')) -- also test for case insensitivity - meths.set_keymap('i', 'lhs', '<nOp>', {}) + meths.nvim_set_keymap('i', 'lhs', '<nOp>', {}) command('normal ilhs') eq({ '' }, curbufmeths.get_lines(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.set_keymap('i', 'lhs', '<NOP>', {}) + meths.nvim_set_keymap('i', 'lhs', '<NOP>', {}) command('normal ilhs') eq({ '' }, curbufmeths.get_lines(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.set_keymap('i', 'lhs', '\022', {}) + meths.nvim_set_keymap('i', 'lhs', '\022', {}) command('normal ilhs') eq({ '' }, curbufmeths.get_lines(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.set_keymap('i', 'lhs', '', {}) + meths.nvim_set_keymap('i', 'lhs', '', {}) command('normal ilhs') eq({ '' }, curbufmeths.get_lines(0, -1, 0)) eq(generate_mapargs('i', 'lhs', '', {}), get_mapargs('i', 'lhs')) @@ -720,8 +732,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.set_keymap('i', '<M-">', 'foo', {}) - meths.del_keymap('i', '<M-">') + meths.nvim_set_keymap('i', '<M-">', 'foo', {}) + meths.nvim_del_keymap('i', '<M-">') eq({}, get_mapargs('i', '<M-">')) end) @@ -736,13 +748,13 @@ describe('nvim_set_keymap, nvim_del_keymap', function() ) it('throws appropriate error messages when setting <unique> maps', function() - meths.set_keymap('l', 'lhs', 'rhs', {}) + meths.nvim_set_keymap('l', 'lhs', 'rhs', {}) eq( 'E227: mapping already exists for lhs', - pcall_err(meths.set_keymap, 'l', 'lhs', 'rhs', { unique = true }) + pcall_err(meths.nvim_set_keymap, 'l', 'lhs', 'rhs', { unique = true }) ) -- different mapmode, no error should be thrown - meths.set_keymap('t', 'lhs', 'rhs', { unique = true }) + meths.nvim_set_keymap('t', 'lhs', 'rhs', { unique = true }) end) it('can set <expr> mappings whose RHS change dynamically', function() @@ -753,12 +765,12 @@ describe('nvim_set_keymap, nvim_del_keymap', function() return g:flip endfunction ]]) - eq(1, meths.call_function('FlipFlop', {})) - eq(0, meths.call_function('FlipFlop', {})) - eq(1, meths.call_function('FlipFlop', {})) - eq(0, meths.call_function('FlipFlop', {})) + 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', {})) - meths.set_keymap('i', 'lhs', 'FlipFlop()', { expr = true }) + meths.nvim_set_keymap('i', 'lhs', 'FlipFlop()', { expr = true }) command('normal ilhs') eq({ '1' }, curbufmeths.get_lines(0, -1, 0)) @@ -769,8 +781,8 @@ describe('nvim_set_keymap, nvim_del_keymap', function() end) it('can set mappings that do trigger other mappings', function() - meths.set_keymap('i', 'mhs', 'rhs', {}) - meths.set_keymap('i', 'lhs', 'mhs', {}) + meths.nvim_set_keymap('i', 'mhs', 'rhs', {}) + meths.nvim_set_keymap('i', 'lhs', 'mhs', {}) command('normal imhs') eq({ 'rhs' }, curbufmeths.get_lines(0, -1, 0)) @@ -782,8 +794,8 @@ describe('nvim_set_keymap, nvim_del_keymap', function() end) it("can set noremap mappings that don't trigger other mappings", function() - meths.set_keymap('i', 'mhs', 'rhs', {}) - meths.set_keymap('i', 'lhs', 'mhs', { noremap = true }) + meths.nvim_set_keymap('i', 'mhs', 'rhs', {}) + meths.nvim_set_keymap('i', 'lhs', 'mhs', { noremap = true }) command('normal imhs') eq({ 'rhs' }, curbufmeths.get_lines(0, -1, 0)) @@ -795,8 +807,8 @@ describe('nvim_set_keymap, nvim_del_keymap', function() end) it('can set nowait mappings that fire without waiting', function() - meths.set_keymap('i', '123456', 'longer', {}) - meths.set_keymap('i', '123', 'shorter', { nowait = true }) + meths.nvim_set_keymap('i', '123456', 'longer', {}) + meths.nvim_set_keymap('i', '123', 'shorter', { nowait = true }) -- feed keys one at a time; if all keys arrive atomically, the longer -- mapping will trigger @@ -812,22 +824,22 @@ describe('nvim_set_keymap, nvim_del_keymap', function() 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.set_keymap(mapmode, 'lhs', 'rhs', {}) + meths.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.del_keymap(mapmode, 'lhs') + meths.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.set_keymap(mapmode, 'lhs', 'rhs', { noremap = true }) + meths.nvim_set_keymap(mapmode, 'lhs', 'rhs', { noremap = true }) eq(generate_mapargs(mapmode, 'lhs', 'rhs', { noremap = true }), get_mapargs(mapmode, 'lhs')) - meths.del_keymap(mapmode, 'lhs') + meths.nvim_del_keymap(mapmode, 'lhs') eq({}, get_mapargs(mapmode, 'lhs')) end) end @@ -839,12 +851,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.set_keymap(mapmode, 'lhs', 'rhs', { [maparg] = true }) + meths.nvim_set_keymap(mapmode, 'lhs', 'rhs', { [maparg] = true }) eq( generate_mapargs(mapmode, 'lhs', 'rhs', { [maparg] = true }), get_mapargs(mapmode, 'lhs') ) - meths.del_keymap(mapmode, 'lhs') + meths.nvim_del_keymap(mapmode, 'lhs') eq({}, get_mapargs(mapmode, 'lhs')) end) it( @@ -854,9 +866,9 @@ describe('nvim_set_keymap, nvim_del_keymap', function() .. maparg .. ', whose value is false', function() - meths.set_keymap(mapmode, 'lhs', 'rhs', { [maparg] = false }) + meths.nvim_set_keymap(mapmode, 'lhs', 'rhs', { [maparg] = false }) eq(generate_mapargs(mapmode, 'lhs', 'rhs'), get_mapargs(mapmode, 'lhs')) - meths.del_keymap(mapmode, 'lhs') + meths.nvim_del_keymap(mapmode, 'lhs') eq({}, get_mapargs(mapmode, 'lhs')) end ) @@ -876,9 +888,9 @@ describe('nvim_set_keymap, nvim_del_keymap', function() .. opt3, function() local opts = { [opt1] = true, [opt2] = false, [opt3] = true } - meths.set_keymap(mapmode, 'lhs', 'rhs', opts) + meths.nvim_set_keymap(mapmode, 'lhs', 'rhs', opts) eq(generate_mapargs(mapmode, 'lhs', 'rhs', opts), get_mapargs(mapmode, 'lhs')) - meths.del_keymap(mapmode, 'lhs') + meths.nvim_del_keymap(mapmode, 'lhs') eq({}, get_mapargs(mapmode, 'lhs')) end ) @@ -958,7 +970,7 @@ describe('nvim_set_keymap, nvim_del_keymap', function() feed('aa') - eq({ 'π<M-π>foo<' }, meths.buf_get_lines(0, 0, -1, false)) + eq({ 'π<M-π>foo<' }, meths.nvim_buf_get_lines(0, 0, -1, false)) end) it('can make lua expr mappings without replacing keycodes', function() @@ -968,7 +980,7 @@ describe('nvim_set_keymap, nvim_del_keymap', function() feed('iaa<esc>') - eq({ '<space>' }, meths.buf_get_lines(0, 0, -1, false)) + eq({ '<space>' }, meths.nvim_buf_get_lines(0, 0, -1, false)) end) it('lua expr mapping returning nil is equivalent to returning an empty string', function() @@ -978,7 +990,7 @@ describe('nvim_set_keymap, nvim_del_keymap', function() feed('iaa<esc>') - eq({ '' }, meths.buf_get_lines(0, 0, -1, false)) + eq({ '' }, meths.nvim_buf_get_lines(0, 0, -1, false)) end) it('does not reset pum in lua mapping', function() @@ -1081,7 +1093,7 @@ describe('nvim_set_keymap, nvim_del_keymap', function() end) it('can set descriptions on mappings', function() - meths.set_keymap('n', 'lhs', 'rhs', { desc = 'map description' }) + meths.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) @@ -1096,10 +1108,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.get_current_line()) + eq('The 1 and the bar and the 2 again', meths.nvim_get_current_line()) feed ':let x = "The foo is the one"<cr>' - eq('The 3 is the one', meths.eval 'x') + eq('The 3 is the one', meths.nvim_eval 'x') end) it('can define insert mode abbreviations with lua callbacks', function() @@ -1112,10 +1124,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.get_current_line()) + eq('The 1 and the bar and the 2 again', meths.nvim_get_current_line()) feed ':let x = "The foo is the one"<cr>' - eq('The foo is the one', meths.eval 'x') + eq('The foo is the one', meths.nvim_eval 'x') end) it('can define cmdline mode abbreviations with lua callbacks', function() @@ -1128,10 +1140,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.get_current_line()) + eq('The foo and the bar and the foo again', meths.nvim_get_current_line()) feed ':let x = "The foo is the one"<cr>' - eq('The 1 is the one', meths.eval 'x') + eq('The 1 is the one', meths.nvim_eval 'x') end) end) @@ -1154,9 +1166,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.call_function('bufnr', { '%' }) + local first_buf = meths.nvim_call_function('bufnr', { '%' }) command('new') - local second_buf = meths.call_function('bufnr', { '%' }) + local second_buf = meths.nvim_call_function('bufnr', { '%' }) neq(second_buf, first_buf) -- sanity check if start_from_first then @@ -1254,7 +1266,7 @@ describe('nvim_buf_set_keymap, nvim_buf_del_keymap', function() feed('aa') - eq({ 'π<M-π>foo<' }, meths.buf_get_lines(0, 0, -1, false)) + eq({ 'π<M-π>foo<' }, meths.nvim_buf_get_lines(0, 0, -1, false)) end) it('can make lua expr mappings without replacing keycodes', function() @@ -1264,7 +1276,7 @@ describe('nvim_buf_set_keymap, nvim_buf_del_keymap', function() feed('iaa<esc>') - eq({ '<space>' }, meths.buf_get_lines(0, 0, -1, false)) + eq({ '<space>' }, meths.nvim_buf_get_lines(0, 0, -1, false)) end) it('can overwrite lua mappings', function() diff --git a/test/functional/api/server_notifications_spec.lua b/test/functional/api/server_notifications_spec.lua index d75bfd5324..3fc7b9986a 100644 --- a/test/functional/api/server_notifications_spec.lua +++ b/test/functional/api/server_notifications_spec.lua @@ -47,9 +47,11 @@ describe('notify', function() end) it('does not crash for deeply nested variable', function() - meths.set_var('l', {}) + meths.nvim_set_var('l', {}) local nest_level = 1000 - meths.command(('call map(range(%u), "extend(g:, {\'l\': [g:l]})")'):format(nest_level - 1)) + meths.nvim_command( + ('call map(range(%u), "extend(g:, {\'l\': [g:l]})")'):format(nest_level - 1) + ) eval('rpcnotify(' .. channel .. ', "event", g:l)') local msg = next_msg() eq('notification', msg[1]) @@ -106,7 +108,7 @@ describe('notify', function() exec_lua([[ return {pcall(vim.rpcrequest, ..., 'nvim_eval', '1+1')}]], catchan) ) retry(nil, 3000, function() - eq({}, meths.get_chan_info(catchan)) + eq({}, meths.nvim_get_chan_info(catchan)) end) -- cat be dead :( end) end) diff --git a/test/functional/api/server_requests_spec.lua b/test/functional/api/server_requests_spec.lua index 421e0b5c9a..6878ac0218 100644 --- a/test/functional/api/server_requests_spec.lua +++ b/test/functional/api/server_requests_spec.lua @@ -244,7 +244,7 @@ describe('server -> client', function() \ 'rpc': v:true \ } ]]) - meths.set_var('args', { + meths.nvim_set_var('args', { nvim_prog, '-ll', 'test/functional/api/rpc_fixture.lua', @@ -296,7 +296,7 @@ describe('server -> client', function() set_session(server) eq(serverpid, funcs.getpid()) - eq('hello', meths.get_current_line()) + eq('hello', meths.nvim_get_current_line()) -- method calls work both ways funcs.rpcrequest(client_id, 'nvim_set_current_line', 'howdy!') @@ -304,7 +304,7 @@ describe('server -> client', function() set_session(client) eq(clientpid, funcs.getpid()) - eq('howdy!', meths.get_current_line()) + eq('howdy!', meths.nvim_get_current_line()) server:close() client:close() @@ -375,7 +375,7 @@ describe('server -> client', function() local id = funcs.sockconnect('pipe', address, { rpc = true }) funcs.rpcrequest(id, 'nvim_set_current_line', 'hello') - eq('hello', meths.get_current_line()) + eq('hello', meths.nvim_get_current_line()) eq(serverpid, funcs.rpcrequest(id, 'nvim_eval', 'getpid()')) eq(id, funcs.rpcrequest(id, 'nvim_get_api_info')[1]) diff --git a/test/functional/api/ui_spec.lua b/test/functional/api/ui_spec.lua index dafbbe550f..e74a35e97e 100644 --- a/test/functional/api/ui_spec.lua +++ b/test/functional/api/ui_spec.lua @@ -23,39 +23,39 @@ describe('nvim_ui_attach()', function() end) it('validation', function() - eq('No such UI option: foo', pcall_err(meths.ui_attach, 80, 24, { foo = { 'foo' } })) + eq('No such UI option: foo', pcall_err(meths.nvim_ui_attach, 80, 24, { foo = { 'foo' } })) eq( "Invalid 'ext_linegrid': expected Boolean, got Array", - pcall_err(meths.ui_attach, 80, 24, { ext_linegrid = {} }) + pcall_err(meths.nvim_ui_attach, 80, 24, { ext_linegrid = {} }) ) eq( "Invalid 'override': expected Boolean, got Array", - pcall_err(meths.ui_attach, 80, 24, { override = {} }) + pcall_err(meths.nvim_ui_attach, 80, 24, { override = {} }) ) eq( "Invalid 'rgb': expected Boolean, got Array", - pcall_err(meths.ui_attach, 80, 24, { rgb = {} }) + pcall_err(meths.nvim_ui_attach, 80, 24, { rgb = {} }) ) eq( "Invalid 'term_name': expected String, got Boolean", - pcall_err(meths.ui_attach, 80, 24, { term_name = true }) + pcall_err(meths.nvim_ui_attach, 80, 24, { term_name = true }) ) eq( "Invalid 'term_colors': expected Integer, got Boolean", - pcall_err(meths.ui_attach, 80, 24, { term_colors = true }) + pcall_err(meths.nvim_ui_attach, 80, 24, { term_colors = true }) ) eq( "Invalid 'stdin_fd': expected Integer, got String", - pcall_err(meths.ui_attach, 80, 24, { stdin_fd = 'foo' }) + pcall_err(meths.nvim_ui_attach, 80, 24, { stdin_fd = 'foo' }) ) eq( "Invalid 'stdin_tty': expected Boolean, got String", - pcall_err(meths.ui_attach, 80, 24, { stdin_tty = 'foo' }) + pcall_err(meths.nvim_ui_attach, 80, 24, { stdin_tty = 'foo' }) ) eq( "Invalid 'stdout_tty': expected Boolean, got String", - pcall_err(meths.ui_attach, 80, 24, { stdout_tty = 'foo' }) + pcall_err(meths.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.input_mouse('move', '', '', 0, 0, 0) + meths.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.ui_set_focus(false) + meths.nvim_ui_set_focus(false) eq({ 's', 'r', 's', 'r', 's' }, eval('g:ev')) screen.suspended = false - meths.ui_set_focus(true) + meths.nvim_ui_set_focus(true) eq({ 's', 'r', 's', 'r', 's', 'r' }, eval('g:ev')) command('suspend | suspend | suspend') diff --git a/test/functional/api/version_spec.lua b/test/functional/api/version_spec.lua index 41f8fccab9..fefafb8f98 100644 --- a/test/functional/api/version_spec.lua +++ b/test/functional/api/version_spec.lua @@ -94,7 +94,7 @@ describe('api metadata', function() local old_api = {} setup(function() clear() -- Ensure a session before requesting api_info. - api = meths.get_api_info()[2] + api = meths.nvim_get_api_info()[2] compat = api.version.api_compatible api_level = api.version.api_level if api.version.api_prerelease then diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index 13b80f4486..3fd1cdab1e 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -70,7 +70,7 @@ describe('API', function() end) it('handles errors in async requests', function() - local error_types = meths.get_api_info()[2].error_types + local error_types = meths.nvim_get_api_info()[2].error_types nvim_async('bogus') eq({ 'notification', @@ -82,7 +82,7 @@ describe('API', function() end) it('failed async request emits nvim_error_event', function() - local error_types = meths.get_api_info()[2].error_types + local error_types = meths.nvim_get_api_info()[2].error_types nvim_async('command', 'bogus') eq({ 'notification', @@ -326,7 +326,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.exec2('set verbose=2', { output = false }) + meths.nvim_exec2('set verbose=2', { output = false }) local traceback_output = dedent([[ line 0: sourcing "%s" line 0: sourcing "%s" @@ -343,7 +343,7 @@ describe('API', function() ) eq( { output = traceback_output }, - meths.exec2( + meths.nvim_exec2( 'call nvim_exec2("source ' .. sourcing_fname .. '", {"output": v:false})', { output = true } ) @@ -367,7 +367,7 @@ describe('API', function() screen:set_default_attr_ids({ [0] = { bold = true, foreground = Screen.colors.Blue }, }) - meths.exec2("echo 'hello'", { output = false }) + meths.nvim_exec2("echo 'hello'", { output = false }) screen:expect { grid = [[ ^ | @@ -383,7 +383,7 @@ describe('API', function() screen:set_default_attr_ids({ [0] = { bold = true, foreground = Screen.colors.Blue }, }) - meths.exec2("echo 'hello'", { output = true }) + meths.nvim_exec2("echo 'hello'", { output = true }) screen:expect { grid = [[ ^ | @@ -694,12 +694,12 @@ describe('API', function() end) it('works', function() - meths.set_current_dir('Xtestdir') + meths.nvim_set_current_dir('Xtestdir') eq(funcs.getcwd(), start_dir .. helpers.get_pathsep() .. 'Xtestdir') end) it('sets previous directory', function() - meths.set_current_dir('Xtestdir') + meths.nvim_set_current_dir('Xtestdir') command('cd -') eq(funcs.getcwd(), start_dir) end) @@ -707,48 +707,51 @@ describe('API', function() describe('nvim_exec_lua', function() it('works', function() - meths.exec_lua('vim.api.nvim_set_var("test", 3)', {}) - eq(3, meths.get_var('test')) + meths.nvim_exec_lua('vim.api.nvim_set_var("test", 3)', {}) + eq(3, meths.nvim_get_var('test')) - eq(17, meths.exec_lua('a, b = ...\nreturn a + b', { 10, 7 })) + eq(17, meths.nvim_exec_lua('a, b = ...\nreturn a + b', { 10, 7 })) - eq(NIL, meths.exec_lua('function xx(a,b)\nreturn a..b\nend', {})) - eq('xy', meths.exec_lua('return xx(...)', { 'x', 'y' })) + eq(NIL, meths.nvim_exec_lua('function xx(a,b)\nreturn a..b\nend', {})) + eq('xy', meths.nvim_exec_lua('return xx(...)', { 'x', 'y' })) -- Deprecated name: nvim_execute_lua. - eq('xy', meths.execute_lua('return xx(...)', { 'x', 'y' })) + eq('xy', meths.nvim_execute_lua('return xx(...)', { 'x', 'y' })) end) it('reports errors', function() eq( [[Error loading lua: [string "<nvim>"]:0: '=' expected near '+']], - pcall_err(meths.exec_lua, 'a+*b', {}) + pcall_err(meths.nvim_exec_lua, 'a+*b', {}) ) eq( [[Error loading lua: [string "<nvim>"]:0: unexpected symbol near '1']], - pcall_err(meths.exec_lua, '1+2', {}) + pcall_err(meths.nvim_exec_lua, '1+2', {}) ) eq( [[Error loading lua: [string "<nvim>"]:0: unexpected symbol]], - pcall_err(meths.exec_lua, 'aa=bb\0', {}) + pcall_err(meths.nvim_exec_lua, 'aa=bb\0', {}) ) - eq([[attempt to call global 'bork' (a nil value)]], pcall_err(meths.exec_lua, 'bork()', {})) + eq( + [[attempt to call global 'bork' (a nil value)]], + pcall_err(meths.nvim_exec_lua, 'bork()', {}) + ) - eq('did\nthe\nfail', pcall_err(meths.exec_lua, 'error("did\\nthe\\nfail")', {})) + eq('did\nthe\nfail', pcall_err(meths.nvim_exec_lua, 'error("did\\nthe\\nfail")', {})) end) it('uses native float values', function() - eq(2.5, meths.exec_lua('return select(1, ...)', { 2.5 })) - eq('2.5', meths.exec_lua('return vim.inspect(...)', { 2.5 })) + eq(2.5, meths.nvim_exec_lua('return select(1, ...)', { 2.5 })) + eq('2.5', meths.nvim_exec_lua('return vim.inspect(...)', { 2.5 })) -- "special" float values are still accepted as return values. - eq(2.5, meths.exec_lua("return vim.api.nvim_eval('2.5')", {})) + eq(2.5, meths.nvim_exec_lua("return vim.api.nvim_eval('2.5')", {})) eq( '{\n [false] = 2.5,\n [true] = 3\n}', - meths.exec_lua("return vim.inspect(vim.api.nvim_eval('2.5'))", {}) + meths.nvim_exec_lua("return vim.inspect(vim.api.nvim_eval('2.5'))", {}) ) end) end) @@ -760,7 +763,7 @@ describe('API', function() it('can be overridden', function() command('lua vim.notify = function(...) return 42 end') - eq(42, meths.exec_lua("return vim.notify('Hello world')", {})) + eq(42, meths.nvim_exec_lua("return vim.notify('Hello world')", {})) nvim('notify', 'hello world', 4, {}) end) end) @@ -1368,7 +1371,7 @@ describe('API', function() it('allows block width', function() -- behave consistently with setreg(); support "\022{NUM}" return by getregtype() - meths.put({ 'line 1', 'line 2', 'line 3' }, 'l', false, false) + meths.nvim_put({ 'line 1', 'line 2', 'line 3' }, 'l', false, false) expect([[ line 1 line 2 @@ -1376,21 +1379,21 @@ describe('API', function() ]]) -- larger width create spaces - meths.put({ 'a', 'bc' }, 'b3', false, false) + meths.nvim_put({ 'a', 'bc' }, 'b3', false, false) expect([[ a line 1 bc line 2 line 3 ]]) -- smaller width is ignored - meths.put({ 'xxx', 'yyy' }, '\0221', false, true) + meths.nvim_put({ 'xxx', 'yyy' }, '\0221', false, true) expect([[ xxxa line 1 yyybc line 2 line 3 ]]) - eq("Invalid 'type': 'bx'", pcall_err(meths.put, { 'xxx', 'yyy' }, 'bx', false, true)) - eq("Invalid 'type': 'b3x'", pcall_err(meths.put, { 'xxx', 'yyy' }, 'b3x', false, true)) + eq("Invalid 'type': 'bx'", pcall_err(meths.nvim_put, { 'xxx', 'yyy' }, 'bx', false, true)) + eq("Invalid 'type': 'b3x'", pcall_err(meths.nvim_put, { 'xxx', 'yyy' }, 'b3x', false, true)) end) end) @@ -1417,8 +1420,8 @@ describe('API', function() describe('set/get/del variables', function() it('validation', function() - eq('Key not found: bogus', pcall_err(meths.get_var, 'bogus')) - eq('Key not found: bogus', pcall_err(meths.del_var, 'bogus')) + eq('Key not found: bogus', pcall_err(meths.nvim_get_var, 'bogus')) + eq('Key not found: bogus', pcall_err(meths.nvim_del_var, 'bogus')) end) it('nvim_get_var, nvim_set_var, nvim_del_var', function() @@ -1426,10 +1429,10 @@ describe('API', function() eq({ 1, 2, { ['3'] = 1 } }, nvim('get_var', 'lua')) eq({ 1, 2, { ['3'] = 1 } }, nvim('eval', 'g:lua')) eq(1, funcs.exists('g:lua')) - meths.del_var('lua') + meths.nvim_del_var('lua') eq(0, funcs.exists('g:lua')) - eq('Key not found: lua', pcall_err(meths.del_var, 'lua')) - meths.set_var('lua', 1) + eq('Key not found: lua', pcall_err(meths.nvim_del_var, 'lua')) + meths.nvim_set_var('lua', 1) -- Empty keys are allowed in Vim dicts (and msgpack). nvim('set_var', 'dict_empty_key', { [''] = 'empty key' }) @@ -1437,8 +1440,8 @@ describe('API', function() -- Set locked g: var. command('lockvar lua') - eq('Key is locked: lua', pcall_err(meths.del_var, 'lua')) - eq('Key is locked: lua', pcall_err(meths.set_var, 'lua', 1)) + eq('Key is locked: lua', pcall_err(meths.nvim_del_var, 'lua')) + eq('Key is locked: lua', pcall_err(meths.nvim_set_var, 'lua', 1)) exec([[ function Test() @@ -1448,8 +1451,8 @@ describe('API', function() let g:Unknown_func = function('Test') let g:Unknown_script_func = function('s:Test') ]]) - eq(NIL, meths.get_var('Unknown_func')) - eq(NIL, meths.get_var('Unknown_script_func')) + eq(NIL, meths.nvim_get_var('Unknown_func')) + eq(NIL, meths.nvim_get_var('Unknown_script_func')) -- Check if autoload works properly local pathsep = helpers.get_pathsep() @@ -1461,37 +1464,40 @@ describe('API', function() write_file(autoload_file, [[let testload#value = 2]]) clear { args_rm = { '-u' }, env = { XDG_CONFIG_HOME = xconfig, XDG_DATA_HOME = xdata } } - eq(2, meths.get_var('testload#value')) + eq(2, meths.nvim_get_var('testload#value')) rmdir('Xhome') end) it('nvim_get_vvar, nvim_set_vvar', function() eq('Key is read-only: count', pcall_err(request, 'nvim_set_vvar', 'count', 42)) eq('Dictionary is locked', pcall_err(request, 'nvim_set_vvar', 'nosuchvar', 42)) - meths.set_vvar('errmsg', 'set by API') - eq('set by API', meths.get_vvar('errmsg')) - meths.set_vvar('errmsg', 42) + meths.nvim_set_vvar('errmsg', 'set by API') + eq('set by API', meths.nvim_get_vvar('errmsg')) + meths.nvim_set_vvar('errmsg', 42) eq('42', eval('v:errmsg')) - meths.set_vvar('oldfiles', { 'one', 'two' }) + meths.nvim_set_vvar('oldfiles', { 'one', 'two' }) eq({ 'one', 'two' }, eval('v:oldfiles')) - meths.set_vvar('oldfiles', {}) + meths.nvim_set_vvar('oldfiles', {}) eq({}, eval('v:oldfiles')) - eq('Setting v:oldfiles to value with wrong type', pcall_err(meths.set_vvar, 'oldfiles', 'a')) + eq( + 'Setting v:oldfiles to value with wrong type', + pcall_err(meths.nvim_set_vvar, 'oldfiles', 'a') + ) eq({}, eval('v:oldfiles')) feed('i foo foo foo<Esc>0/foo<CR>') - eq({ 1, 1 }, meths.win_get_cursor(0)) + eq({ 1, 1 }, meths.nvim_win_get_cursor(0)) eq(1, eval('v:searchforward')) feed('n') - eq({ 1, 5 }, meths.win_get_cursor(0)) - meths.set_vvar('searchforward', 0) + eq({ 1, 5 }, meths.nvim_win_get_cursor(0)) + meths.nvim_set_vvar('searchforward', 0) eq(0, eval('v:searchforward')) feed('n') - eq({ 1, 1 }, meths.win_get_cursor(0)) - meths.set_vvar('searchforward', 1) + eq({ 1, 1 }, meths.nvim_win_get_cursor(0)) + meths.nvim_set_vvar('searchforward', 1) eq(1, eval('v:searchforward')) feed('n') - eq({ 1, 5 }, meths.win_get_cursor(0)) + eq({ 1, 5 }, meths.nvim_win_get_cursor(0)) local screen = Screen.new(60, 3) screen:set_default_attr_ids({ @@ -1507,7 +1513,7 @@ describe('API', function() | ]], } - meths.set_vvar('hlsearch', 0) + meths.nvim_set_vvar('hlsearch', 0) eq(0, eval('v:hlsearch')) screen:expect { grid = [[ @@ -1516,7 +1522,7 @@ describe('API', function() | ]], } - meths.set_vvar('hlsearch', 1) + meths.nvim_set_vvar('hlsearch', 1) eq(1, eval('v:hlsearch')) screen:expect { grid = [[ @@ -1900,7 +1906,7 @@ describe('API', function() 1, }, NIL, - }, meths.call_atomic(req)) + }, meths.nvim_call_atomic(req)) eq({ mode = 'r', blocking = true }, nvim('get_mode')) end) it('during insert-mode map-pending, returns blocking=true #6166', function() @@ -2004,24 +2010,24 @@ describe('API', function() it('does not interrupt Insert mode i_CTRL-O #10035', function() feed('iHello World<c-o>') - eq({ mode = 'niI', blocking = false }, meths.get_mode()) -- fast event + eq({ mode = 'niI', blocking = false }, meths.nvim_get_mode()) -- fast event eq(2, eval('1+1')) -- causes K_EVENT key - eq({ mode = 'niI', blocking = false }, meths.get_mode()) -- still in ctrl-o mode + eq({ mode = 'niI', blocking = false }, meths.nvim_get_mode()) -- still in ctrl-o mode feed('dd') - eq({ mode = 'i', blocking = false }, meths.get_mode()) -- left ctrl-o mode + eq({ mode = 'i', blocking = false }, meths.nvim_get_mode()) -- left ctrl-o mode expect('') -- executed the command end) it('does not interrupt Select mode v_CTRL-O #15688', function() feed('iHello World<esc>gh<c-o>') - eq({ mode = 'vs', blocking = false }, meths.get_mode()) -- fast event - eq({ mode = 'vs', blocking = false }, meths.get_mode()) -- again #15288 + eq({ mode = 'vs', blocking = false }, meths.nvim_get_mode()) -- fast event + eq({ mode = 'vs', blocking = false }, meths.nvim_get_mode()) -- again #15288 eq(2, eval('1+1')) -- causes K_EVENT key - eq({ mode = 'vs', blocking = false }, meths.get_mode()) -- still in ctrl-o mode + eq({ mode = 'vs', blocking = false }, meths.nvim_get_mode()) -- still in ctrl-o mode feed('^') - eq({ mode = 's', blocking = false }, meths.get_mode()) -- left ctrl-o mode + eq({ mode = 's', blocking = false }, meths.nvim_get_mode()) -- left ctrl-o mode feed('h') - eq({ mode = 'i', blocking = false }, meths.get_mode()) -- entered insert mode + eq({ mode = 'i', blocking = false }, meths.nvim_get_mode()) -- entered insert mode expect('h') -- selection is the whole line and is replaced end) @@ -2176,13 +2182,13 @@ describe('API', function() -- then `return str` in vim_replace_termcodes body will make Neovim free -- `str.data` twice: once when freeing arguments, then when freeing return -- value. - eq('', meths.replace_termcodes('', true, true, true)) + eq('', meths.nvim_replace_termcodes('', true, true, true)) end) -- Not exactly the case, as nvim_replace_termcodes() escapes K_SPECIAL in Unicode it('translates the result of keytrans() on string with 0x80 byte back', function() local s = 'ff\128\253\097tt' - eq(s, meths.replace_termcodes(funcs.keytrans(s), true, true, true)) + eq(s, meths.nvim_replace_termcodes(funcs.keytrans(s), true, true, true)) end) end) @@ -2244,7 +2250,7 @@ describe('API', function() silent! call nvim_out_write("\n") redir END ]]) - eq('\naaa\n' .. ('a'):rep(5002) .. '\naaa', meths.get_var('out')) + eq('\naaa\n' .. ('a'):rep(5002) .. '\naaa', meths.nvim_get_var('out')) end) it('blank line in message', function() @@ -2430,18 +2436,18 @@ describe('API', function() } it('returns {} for invalid channel', function() - eq({}, meths.get_chan_info(0)) - eq({}, meths.get_chan_info(-1)) + eq({}, meths.nvim_get_chan_info(0)) + eq({}, meths.nvim_get_chan_info(-1)) -- more preallocated numbers might be added, try something high - eq({}, meths.get_chan_info(10)) + eq({}, meths.nvim_get_chan_info(10)) end) it('stream=stdio channel', function() - eq({ [1] = testinfo, [2] = stderr }, meths.list_chans()) - eq(testinfo, meths.get_chan_info(1)) - eq(stderr, meths.get_chan_info(2)) + eq({ [1] = testinfo, [2] = stderr }, meths.nvim_list_chans()) + eq(testinfo, meths.nvim_get_chan_info(1)) + eq(stderr, meths.nvim_get_chan_info(2)) - meths.set_client_info( + meths.nvim_set_client_info( 'functionaltests', { major = 0, minor = 3, patch = 17 }, 'ui', @@ -2460,9 +2466,9 @@ describe('API', function() attributes = { license = 'Apache2' }, }, } - eq({ info = info }, meths.get_var('info_event')) - eq({ [1] = info, [2] = stderr }, meths.list_chans()) - eq(info, meths.get_chan_info(1)) + eq({ info = info }, meths.nvim_get_var('info_event')) + eq({ [1] = info, [2] = stderr }, meths.nvim_list_chans()) + eq(info, meths.nvim_get_chan_info(1)) end) it('stream=job channel', function() @@ -2475,9 +2481,9 @@ describe('API', function() mode = 'rpc', client = {}, } - eq({ info = info }, meths.get_var('opened_event')) - eq({ [1] = testinfo, [2] = stderr, [3] = info }, meths.list_chans()) - eq(info, meths.get_chan_info(3)) + eq({ info = info }, meths.nvim_get_var('opened_event')) + eq({ [1] = testinfo, [2] = stderr, [3] = info }, meths.nvim_list_chans()) + eq(info, meths.nvim_get_chan_info(3)) eval( 'rpcrequest(3, "nvim_set_client_info", "amazing-cat", {}, "remote",' .. '{"nvim_command":{"n_args":1}},' -- and so on @@ -2496,8 +2502,8 @@ describe('API', function() attributes = { description = 'The Amazing Cat' }, }, } - eq({ info = info }, meths.get_var('info_event')) - eq({ [1] = testinfo, [2] = stderr, [3] = info }, meths.list_chans()) + eq({ info = info }, meths.nvim_get_var('info_event')) + eq({ [1] = testinfo, [2] = stderr, [3] = info }, meths.nvim_list_chans()) eq( "Vim:Error invoking 'nvim_set_current_buf' on channel 3 (amazing-cat):\nWrong type for argument 1 when calling nvim_set_current_buf, expecting Buffer", @@ -2507,8 +2513,8 @@ describe('API', function() it('stream=job :terminal channel', function() command(':terminal') - eq({ id = 1 }, meths.get_current_buf()) - eq(3, meths.get_option_value('channel', { buf = 1 })) + eq({ id = 1 }, meths.nvim_get_current_buf()) + eq(3, meths.nvim_get_option_value('channel', { buf = 1 })) local info = { stream = 'job', @@ -2518,15 +2524,15 @@ describe('API', function() buffer = 1, pty = '?', } - local event = meths.get_var('opened_event') + local event = meths.nvim_get_var('opened_event') if not is_os('win') then info.pty = event.info.pty neq(nil, string.match(info.pty, '^/dev/')) end eq({ info = info }, event) info.buffer = { id = 1 } - eq({ [1] = testinfo, [2] = stderr, [3] = info }, meths.list_chans()) - eq(info, meths.get_chan_info(3)) + eq({ [1] = testinfo, [2] = stderr, [3] = info }, meths.nvim_list_chans()) + eq(info, meths.nvim_get_chan_info(3)) -- :terminal with args + running process. command('enew') @@ -2566,13 +2572,13 @@ describe('API', function() describe('nvim_call_atomic', function() it('works', function() - meths.buf_set_lines(0, 0, -1, true, { 'first' }) + meths.nvim_buf_set_lines(0, 0, -1, true, { 'first' }) local req = { { 'nvim_get_current_line', {} }, { 'nvim_set_current_line', { 'second' } }, } - eq({ { 'first', NIL }, NIL }, meths.call_atomic(req)) - eq({ 'second' }, meths.buf_get_lines(0, 0, -1, true)) + eq({ { 'first', NIL }, NIL }, meths.nvim_call_atomic(req)) + eq({ 'second' }, meths.nvim_buf_get_lines(0, 0, -1, true)) end) it('allows multiple return values', function() @@ -2582,11 +2588,11 @@ describe('API', function() { 'nvim_get_var', { 'avar' } }, { 'nvim_get_var', { 'bvar' } }, } - eq({ { NIL, NIL, true, 'string' }, NIL }, meths.call_atomic(req)) + eq({ { NIL, NIL, true, 'string' }, NIL }, meths.nvim_call_atomic(req)) end) it('is aborted by errors in call', function() - local error_types = meths.get_api_info()[2].error_types + local error_types = meths.nvim_get_api_info()[2].error_types local req = { { 'nvim_set_var', { 'one', 1 } }, { 'nvim_buf_set_lines', {} }, @@ -2599,9 +2605,9 @@ describe('API', function() error_types.Exception.id, 'Wrong number of arguments: expecting 5 but got 0', }, - }, meths.call_atomic(req)) - eq(1, meths.get_var('one')) - eq(false, pcall(meths.get_var, 'two')) + }, meths.nvim_call_atomic(req)) + eq(1, meths.nvim_get_var('one')) + eq(false, pcall(meths.nvim_get_var, 'two')) -- still returns all previous successful calls req = { @@ -2613,7 +2619,7 @@ describe('API', function() } eq( { { NIL, NIL, 5 }, { 3, error_types.Validation.id, 'Index out of bounds' } }, - meths.call_atomic(req) + meths.nvim_call_atomic(req) ) req = { @@ -2622,9 +2628,9 @@ describe('API', function() } eq( { {}, { 0, error_types.Exception.id, 'Invalid method: i_am_not_a_method' } }, - meths.call_atomic(req) + meths.nvim_call_atomic(req) ) - eq(5, meths.get_var('avar')) + eq(5, meths.nvim_get_var('avar')) end) it('validation', function() @@ -2633,25 +2639,28 @@ describe('API', function() { 'nvim_set_var' }, { 'nvim_set_var', { 'avar', 2 } }, } - eq("Invalid 'calls' item: expected 2-item Array", pcall_err(meths.call_atomic, req)) + eq("Invalid 'calls' item: expected 2-item Array", pcall_err(meths.nvim_call_atomic, req)) -- call before was done, but not after - eq(1, meths.get_var('avar')) + eq(1, meths.nvim_get_var('avar')) req = { { 'nvim_set_var', { 'bvar', { 2, 3 } } }, 12, } - eq("Invalid 'calls' item: expected Array, got Integer", pcall_err(meths.call_atomic, req)) - eq({ 2, 3 }, meths.get_var('bvar')) + eq( + "Invalid 'calls' item: expected Array, got Integer", + pcall_err(meths.nvim_call_atomic, req) + ) + eq({ 2, 3 }, meths.nvim_get_var('bvar')) req = { { 'nvim_set_current_line', 'little line' }, { 'nvim_set_var', { 'avar', 3 } }, } - eq('Invalid call args: expected Array, got String', pcall_err(meths.call_atomic, req)) + eq('Invalid call args: expected Array, got String', pcall_err(meths.nvim_call_atomic, req)) -- call before was done, but not after - eq(1, meths.get_var('avar')) - eq({ '' }, meths.buf_get_lines(0, 0, -1, true)) + eq(1, meths.nvim_get_var('avar')) + eq({ '' }, meths.nvim_buf_get_lines(0, 0, -1, true)) end) end) @@ -2665,36 +2674,36 @@ describe('API', function() rmdir 'Xtest' end) before_each(function() - meths.set_current_dir 'Xtest' + meths.nvim_set_current_dir 'Xtest' end) it('returns nothing with empty &runtimepath', function() - meths.set_option_value('runtimepath', '', {}) - eq({}, meths.list_runtime_paths()) + meths.nvim_set_option_value('runtimepath', '', {}) + eq({}, meths.nvim_list_runtime_paths()) end) it('returns single runtimepath', function() - meths.set_option_value('runtimepath', 'a', {}) - eq({ 'a' }, meths.list_runtime_paths()) + meths.nvim_set_option_value('runtimepath', 'a', {}) + eq({ 'a' }, meths.nvim_list_runtime_paths()) end) it('returns two runtimepaths', function() - meths.set_option_value('runtimepath', 'a,b', {}) - eq({ 'a', 'b' }, meths.list_runtime_paths()) + meths.nvim_set_option_value('runtimepath', 'a,b', {}) + eq({ 'a', 'b' }, meths.nvim_list_runtime_paths()) end) it('returns empty strings when appropriate', function() - meths.set_option_value('runtimepath', 'a,,b', {}) - eq({ 'a', '', 'b' }, meths.list_runtime_paths()) - meths.set_option_value('runtimepath', ',a,b', {}) - eq({ '', 'a', 'b' }, meths.list_runtime_paths()) + meths.nvim_set_option_value('runtimepath', 'a,,b', {}) + eq({ 'a', '', 'b' }, meths.nvim_list_runtime_paths()) + meths.nvim_set_option_value('runtimepath', ',a,b', {}) + eq({ '', 'a', 'b' }, meths.nvim_list_runtime_paths()) -- Trailing "," is ignored. Use ",," if you really really want CWD. - meths.set_option_value('runtimepath', 'a,b,', {}) - eq({ 'a', 'b' }, meths.list_runtime_paths()) - meths.set_option_value('runtimepath', 'a,b,,', {}) - eq({ 'a', 'b', '' }, meths.list_runtime_paths()) + meths.nvim_set_option_value('runtimepath', 'a,b,', {}) + eq({ 'a', 'b' }, meths.nvim_list_runtime_paths()) + meths.nvim_set_option_value('runtimepath', 'a,b,,', {}) + eq({ 'a', 'b', '' }, meths.nvim_list_runtime_paths()) end) it('truncates too long paths', function() local long_path = ('/a'):rep(8192) - meths.set_option_value('runtimepath', long_path, {}) - local paths_list = meths.list_runtime_paths() + meths.nvim_set_option_value('runtimepath', long_path, {}) + local paths_list = meths.nvim_list_runtime_paths() eq({}, paths_list) end) end) @@ -2723,7 +2732,7 @@ describe('API', function() describe('nvim_parse_expression', function() before_each(function() - meths.set_option_value('isident', '', {}) + meths.nvim_set_option_value('isident', '', {}) end) local function simplify_east_api_node(line, east_api_node) @@ -2856,7 +2865,7 @@ describe('API', function() nz_flags_exps = nz_flags_exps or {} for _, flags in ipairs(opts.flags) do local err, msg = pcall(function() - local east_api = meths.parse_expression(str, FLAGS_TO_STR[flags], true) + local east_api = meths.nvim_parse_expression(str, FLAGS_TO_STR[flags], true) local east_hl = east_api.highlight east_api.highlight = nil local ast = simplify_east_api(str, east_api) @@ -2980,33 +2989,33 @@ describe('API', function() describe('nvim_create_namespace', function() it('works', function() - eq({}, meths.get_namespaces()) - eq(1, meths.create_namespace('ns-1')) - eq(2, meths.create_namespace('ns-2')) - eq(1, meths.create_namespace('ns-1')) - eq({ ['ns-1'] = 1, ['ns-2'] = 2 }, meths.get_namespaces()) - eq(3, meths.create_namespace('')) - eq(4, meths.create_namespace('')) - eq({ ['ns-1'] = 1, ['ns-2'] = 2 }, meths.get_namespaces()) + eq({}, meths.nvim_get_namespaces()) + eq(1, meths.nvim_create_namespace('ns-1')) + eq(2, meths.nvim_create_namespace('ns-2')) + eq(1, meths.nvim_create_namespace('ns-1')) + eq({ ['ns-1'] = 1, ['ns-2'] = 2 }, meths.nvim_get_namespaces()) + eq(3, meths.nvim_create_namespace('')) + eq(4, meths.nvim_create_namespace('')) + eq({ ['ns-1'] = 1, ['ns-2'] = 2 }, meths.nvim_get_namespaces()) end) end) describe('nvim_create_buf', function() it('works', function() - eq({ id = 2 }, meths.create_buf(true, false)) - eq({ id = 3 }, meths.create_buf(false, false)) + eq({ id = 2 }, meths.nvim_create_buf(true, false)) + eq({ id = 3 }, meths.nvim_create_buf(false, false)) eq( ' 1 %a "[No Name]" line 1\n' .. ' 2 h "[No Name]" line 0', - meths.command_output('ls') + meths.nvim_command_output('ls') ) -- current buffer didn't change - eq({ id = 1 }, meths.get_current_buf()) + eq({ id = 1 }, meths.nvim_get_current_buf()) local screen = Screen.new(20, 4) screen:attach() - meths.buf_set_lines(2, 0, -1, true, { 'some text' }) - meths.set_current_buf(2) + meths.nvim_buf_set_lines(2, 0, -1, true, { 'some text' }) + meths.nvim_set_current_buf(2) screen:expect( [[ ^some text | @@ -3020,43 +3029,43 @@ describe('API', function() end) it('can change buftype before visiting', function() - meths.set_option_value('hidden', false, {}) - eq({ id = 2 }, meths.create_buf(true, false)) - meths.set_option_value('buftype', 'nofile', { buf = 2 }) - meths.buf_set_lines(2, 0, -1, true, { 'test text' }) + meths.nvim_set_option_value('hidden', false, {}) + eq({ id = 2 }, meths.nvim_create_buf(true, false)) + meths.nvim_set_option_value('buftype', 'nofile', { buf = 2 }) + meths.nvim_buf_set_lines(2, 0, -1, true, { 'test text' }) command('split | buffer 2') - eq({ id = 2 }, meths.get_current_buf()) + eq({ id = 2 }, meths.nvim_get_current_buf()) -- if the buf_set_option("buftype") didn't work, this would error out. command('close') - eq({ id = 1 }, meths.get_current_buf()) + eq({ id = 1 }, meths.nvim_get_current_buf()) end) it('does not trigger BufEnter, BufWinEnter', function() command('let g:fired = v:false') command('au BufEnter,BufWinEnter * let g:fired = v:true') - eq({ id = 2 }, meths.create_buf(true, false)) - meths.buf_set_lines(2, 0, -1, true, { 'test', 'text' }) + eq({ id = 2 }, meths.nvim_create_buf(true, false)) + meths.nvim_buf_set_lines(2, 0, -1, true, { 'test', 'text' }) eq(false, eval('g:fired')) end) it('TextChanged and TextChangedI do not trigger without changes', function() - local buf = meths.create_buf(true, false) + local buf = meths.nvim_create_buf(true, false) command([[let g:changed = '']]) - meths.create_autocmd({ 'TextChanged', 'TextChangedI' }, { + meths.nvim_create_autocmd({ 'TextChanged', 'TextChangedI' }, { buffer = buf, command = 'let g:changed ..= mode()', }) - meths.set_current_buf(buf) + meths.nvim_set_current_buf(buf) feed('i') - eq('', meths.get_var('changed')) + eq('', meths.nvim_get_var('changed')) end) it('scratch-buffer', function() - eq({ id = 2 }, meths.create_buf(false, true)) - eq({ id = 3 }, meths.create_buf(true, true)) - eq({ id = 4 }, meths.create_buf(true, true)) + eq({ id = 2 }, meths.nvim_create_buf(false, true)) + eq({ id = 3 }, meths.nvim_create_buf(true, true)) + eq({ id = 4 }, meths.nvim_create_buf(true, true)) local scratch_bufs = { 2, 3, 4 } eq( ' 1 %a "[No Name]" line 1\n' @@ -3065,7 +3074,7 @@ describe('API', function() exec_capture('ls') ) -- current buffer didn't change - eq({ id = 1 }, meths.get_current_buf()) + eq({ id = 1 }, meths.nvim_get_current_buf()) local screen = Screen.new(20, 4) screen:set_default_attr_ids({ @@ -3077,27 +3086,27 @@ describe('API', function() -- Editing a scratch-buffer does NOT change its properties. -- local edited_buf = 2 - meths.buf_set_lines(edited_buf, 0, -1, true, { 'some text' }) + meths.nvim_buf_set_lines(edited_buf, 0, -1, true, { 'some text' }) for _, b in ipairs(scratch_bufs) do - eq('nofile', meths.get_option_value('buftype', { buf = b })) - eq('hide', meths.get_option_value('bufhidden', { buf = b })) - eq(false, meths.get_option_value('swapfile', { buf = b })) - eq(false, meths.get_option_value('modeline', { buf = b })) + eq('nofile', meths.nvim_get_option_value('buftype', { buf = b })) + eq('hide', meths.nvim_get_option_value('bufhidden', { buf = b })) + eq(false, meths.nvim_get_option_value('swapfile', { buf = b })) + eq(false, meths.nvim_get_option_value('modeline', { buf = b })) end -- -- Visiting a scratch-buffer DOES NOT change its properties. -- - meths.set_current_buf(edited_buf) + meths.nvim_set_current_buf(edited_buf) screen:expect([[ ^some text | {1:~ }|*2 | ]]) - eq('nofile', meths.get_option_value('buftype', { buf = edited_buf })) - eq('hide', meths.get_option_value('bufhidden', { buf = edited_buf })) - eq(false, meths.get_option_value('swapfile', { buf = edited_buf })) - eq(false, meths.get_option_value('modeline', { buf = edited_buf })) + eq('nofile', meths.nvim_get_option_value('buftype', { buf = edited_buf })) + eq('hide', meths.nvim_get_option_value('bufhidden', { buf = edited_buf })) + eq(false, meths.nvim_get_option_value('swapfile', { buf = edited_buf })) + eq(false, meths.nvim_get_option_value('modeline', { buf = edited_buf })) -- Scratch buffer can be wiped without error. command('bwipe') @@ -3119,11 +3128,11 @@ describe('API', function() describe('nvim_get_runtime_file', function() local p = helpers.alter_slashes it('can find files', function() - eq({}, meths.get_runtime_file('bork.borkbork', false)) - eq({}, meths.get_runtime_file('bork.borkbork', true)) - eq(1, #meths.get_runtime_file('autoload/msgpack.vim', false)) - eq(1, #meths.get_runtime_file('autoload/msgpack.vim', true)) - local val = meths.get_runtime_file('autoload/remote/*.vim', true) + eq({}, meths.nvim_get_runtime_file('bork.borkbork', false)) + eq({}, meths.nvim_get_runtime_file('bork.borkbork', true)) + eq(1, #meths.nvim_get_runtime_file('autoload/msgpack.vim', false)) + eq(1, #meths.nvim_get_runtime_file('autoload/msgpack.vim', true)) + local val = meths.nvim_get_runtime_file('autoload/remote/*.vim', true) eq(2, #val) if endswith(val[1], 'define.vim') then ok(endswith(val[1], p 'autoload/remote/define.vim')) @@ -3132,37 +3141,37 @@ describe('API', function() ok(endswith(val[1], p 'autoload/remote/host.vim')) ok(endswith(val[2], p 'autoload/remote/define.vim')) end - val = meths.get_runtime_file('autoload/remote/*.vim', false) + val = meths.nvim_get_runtime_file('autoload/remote/*.vim', false) eq(1, #val) ok( endswith(val[1], p 'autoload/remote/define.vim') or endswith(val[1], p 'autoload/remote/host.vim') ) - val = meths.get_runtime_file('lua', true) + val = meths.nvim_get_runtime_file('lua', true) eq(1, #val) ok(endswith(val[1], p 'lua')) - val = meths.get_runtime_file('lua/vim', true) + val = meths.nvim_get_runtime_file('lua/vim', true) eq(1, #val) ok(endswith(val[1], p 'lua/vim')) end) it('can find directories', function() - local val = meths.get_runtime_file('lua/', true) + local val = meths.nvim_get_runtime_file('lua/', true) eq(1, #val) ok(endswith(val[1], p 'lua/')) - val = meths.get_runtime_file('lua/vim/', true) + val = meths.nvim_get_runtime_file('lua/vim/', true) eq(1, #val) ok(endswith(val[1], p 'lua/vim/')) - eq({}, meths.get_runtime_file('foobarlang/', true)) + eq({}, meths.nvim_get_runtime_file('foobarlang/', true)) end) it('can handle bad patterns', function() skip(is_os('win')) - eq('Vim:E220: Missing }.', pcall_err(meths.get_runtime_file, '{', false)) + eq('Vim:E220: Missing }.', pcall_err(meths.nvim_get_runtime_file, '{', false)) eq( 'Vim(echo):E5555: API call: Vim:E220: Missing }.', @@ -3173,25 +3182,25 @@ describe('API', function() describe('nvim_get_all_options_info', function() it('should have key value pairs of option names', function() - local options_info = meths.get_all_options_info() + local options_info = meths.nvim_get_all_options_info() neq(nil, options_info.listchars) neq(nil, options_info.tabstop) - eq(meths.get_option_info 'winhighlight', options_info.winhighlight) + eq(meths.nvim_get_option_info 'winhighlight', options_info.winhighlight) end) it('should not crash when echoed', function() - meths.exec2('echo nvim_get_all_options_info()', { output = true }) + meths.nvim_exec2('echo nvim_get_all_options_info()', { output = true }) end) end) describe('nvim_get_option_info', function() it('should error for unknown options', function() - eq("Invalid option (not found): 'bogus'", pcall_err(meths.get_option_info, 'bogus')) + eq("Invalid option (not found): 'bogus'", pcall_err(meths.nvim_get_option_info, 'bogus')) end) it('should return the same options for short and long name', function() - eq(meths.get_option_info 'winhl', meths.get_option_info 'winhighlight') + eq(meths.nvim_get_option_info 'winhl', meths.nvim_get_option_info 'winhighlight') end) it('should have information about window options', function() @@ -3209,7 +3218,7 @@ describe('API', function() shortname = 'winhl', type = 'string', was_set = false, - }, meths.get_option_info 'winhl') + }, meths.nvim_get_option_info 'winhl') end) it('should have information about buffer options', function() @@ -3227,13 +3236,13 @@ describe('API', function() shortname = 'ft', type = 'string', was_set = false, - }, meths.get_option_info 'filetype') + }, meths.nvim_get_option_info 'filetype') end) it('should have information about global options', function() -- precondition: the option was changed from its default -- in test setup. - eq(false, meths.get_option_value('showcmd', {})) + eq(false, meths.nvim_get_option_value('showcmd', {})) eq({ allows_duplicates = true, @@ -3249,9 +3258,9 @@ describe('API', function() shortname = 'sc', type = 'boolean', was_set = true, - }, meths.get_option_info 'showcmd') + }, meths.nvim_get_option_info 'showcmd') - meths.set_option_value('showcmd', true, {}) + meths.nvim_set_option_value('showcmd', true, {}) eq({ allows_duplicates = true, @@ -3267,7 +3276,7 @@ describe('API', function() shortname = 'sc', type = 'boolean', was_set = true, - }, meths.get_option_info 'showcmd') + }, meths.nvim_get_option_info 'showcmd') end) end) @@ -3294,18 +3303,18 @@ describe('API', function() ) exec_lua 'vim.cmd.vsplit()' - meths.create_buf(false, false) + meths.nvim_create_buf(false, false) - bufs = meths.list_bufs() - wins = meths.list_wins() + bufs = meths.nvim_list_bufs() + wins = meths.nvim_list_wins() - meths.win_set_buf(wins[1].id, bufs[1].id) - meths.win_set_buf(wins[2].id, bufs[2].id) + meths.nvim_win_set_buf(wins[1].id, bufs[1].id) + meths.nvim_win_set_buf(wins[2].id, bufs[2].id) - meths.set_current_win(wins[2].id) - meths.exec('source ' .. fname, false) + meths.nvim_set_current_win(wins[2].id) + meths.nvim_exec('source ' .. fname, false) - meths.set_current_win(wins[1].id) + meths.nvim_set_current_win(wins[1].id) end) after_each(function() @@ -3313,9 +3322,9 @@ describe('API', function() end) it('should return option information', function() - eq(meths.get_option_info('dictionary'), meths.get_option_info2('dictionary', {})) -- buffer - eq(meths.get_option_info('fillchars'), meths.get_option_info2('fillchars', {})) -- window - eq(meths.get_option_info('completeopt'), meths.get_option_info2('completeopt', {})) -- global + eq(meths.nvim_get_option_info('dictionary'), meths.nvim_get_option_info2('dictionary', {})) -- buffer + eq(meths.nvim_get_option_info('fillchars'), meths.nvim_get_option_info2('fillchars', {})) -- window + eq(meths.nvim_get_option_info('completeopt'), meths.nvim_get_option_info2('completeopt', {})) -- global end) describe('last set', function() @@ -3347,21 +3356,21 @@ describe('API', function() for _, t in pairs(tests) do it(t.desc, function() -- Switch to the target buffer/window so that curbuf/curwin are used. - meths.set_current_win(wins[2].id) - local info = meths.get_option_info2(unpack(t.args)) + meths.nvim_set_current_win(wins[2].id) + local info = meths.nvim_get_option_info2(unpack(t.args)) eq(t.linenr, info.last_set_linenr) eq(t.sid, info.last_set_sid) end) end it('is provided for cross-buffer requests', function() - local info = meths.get_option_info2('formatprg', { buf = bufs[2].id }) + local info = meths.nvim_get_option_info2('formatprg', { buf = bufs[2].id }) eq(2, info.last_set_linenr) eq(1, info.last_set_sid) end) it('is provided for cross-window requests', function() - local info = meths.get_option_info2('listchars', { win = wins[2].id }) + local info = meths.nvim_get_option_info2('listchars', { win = wins[2].id }) eq(6, info.last_set_linenr) eq(1, info.last_set_sid) end) @@ -3466,11 +3475,15 @@ describe('API', function() end) it('can batch process sequences', function() - local b = meths.create_buf(true, true) - meths.open_win(b, false, { width = 79, height = 31, row = 1, col = 1, relative = 'editor' }) - local t = meths.open_term(b, {}) + local b = meths.nvim_create_buf(true, true) + meths.nvim_open_win( + b, + false, + { width = 79, height = 31, row = 1, col = 1, relative = 'editor' } + ) + local t = meths.nvim_open_term(b, {}) - meths.chan_send(t, io.open('test/functional/fixtures/smile2.cat', 'r'):read('*a')) + meths.nvim_chan_send(t, io.open('test/functional/fixtures/smile2.cat', 'r'):read('*a')) screen:expect { grid = [[ ^ | @@ -3576,50 +3589,56 @@ describe('API', function() describe('nvim_del_mark', function() it('works', function() - local buf = meths.create_buf(false, true) - meths.buf_set_lines(buf, -1, -1, true, { 'a', 'bit of', 'text' }) - eq(true, meths.buf_set_mark(buf, 'F', 2, 2, {})) - eq(true, meths.del_mark('F')) - eq({ 0, 0 }, meths.buf_get_mark(buf, 'F')) + local buf = meths.nvim_create_buf(false, true) + meths.nvim_buf_set_lines(buf, -1, -1, true, { 'a', 'bit of', 'text' }) + eq(true, meths.nvim_buf_set_mark(buf, 'F', 2, 2, {})) + eq(true, meths.nvim_del_mark('F')) + eq({ 0, 0 }, meths.nvim_buf_get_mark(buf, 'F')) end) it('validation', function() - eq("Invalid mark name (must be file/uppercase): 'f'", pcall_err(meths.del_mark, 'f')) - eq("Invalid mark name (must be file/uppercase): '!'", pcall_err(meths.del_mark, '!')) - eq("Invalid mark name (must be a single char): 'fail'", pcall_err(meths.del_mark, 'fail')) + eq("Invalid mark name (must be file/uppercase): 'f'", pcall_err(meths.nvim_del_mark, 'f')) + eq("Invalid mark name (must be file/uppercase): '!'", pcall_err(meths.nvim_del_mark, '!')) + eq( + "Invalid mark name (must be a single char): 'fail'", + pcall_err(meths.nvim_del_mark, 'fail') + ) end) end) describe('nvim_get_mark', function() it('works', function() - local buf = meths.create_buf(false, true) - meths.buf_set_lines(buf, -1, -1, true, { 'a', 'bit of', 'text' }) - meths.buf_set_mark(buf, 'F', 2, 2, {}) - meths.buf_set_name(buf, 'mybuf') - local mark = meths.get_mark('F', {}) + local buf = meths.nvim_create_buf(false, true) + meths.nvim_buf_set_lines(buf, -1, -1, true, { 'a', 'bit of', 'text' }) + meths.nvim_buf_set_mark(buf, 'F', 2, 2, {}) + meths.nvim_buf_set_name(buf, 'mybuf') + local mark = meths.nvim_get_mark('F', {}) -- Compare the path tail only assert(string.find(mark[4], 'mybuf$')) eq({ 2, 2, buf.id, mark[4] }, mark) end) it('validation', function() - eq("Invalid mark name (must be file/uppercase): 'f'", pcall_err(meths.get_mark, 'f', {})) - eq("Invalid mark name (must be file/uppercase): '!'", pcall_err(meths.get_mark, '!', {})) - eq("Invalid mark name (must be a single char): 'fail'", pcall_err(meths.get_mark, 'fail', {})) + eq("Invalid mark name (must be file/uppercase): 'f'", pcall_err(meths.nvim_get_mark, 'f', {})) + eq("Invalid mark name (must be file/uppercase): '!'", pcall_err(meths.nvim_get_mark, '!', {})) + eq( + "Invalid mark name (must be a single char): 'fail'", + pcall_err(meths.nvim_get_mark, 'fail', {}) + ) end) it('returns the expected when mark is not set', function() - eq(true, meths.del_mark('A')) - eq({ 0, 0, 0, '' }, meths.get_mark('A', {})) + eq(true, meths.nvim_del_mark('A')) + eq({ 0, 0, 0, '' }, meths.nvim_get_mark('A', {})) end) it('works with deleted buffers', function() local fname = tmpname() write_file(fname, 'a\nbit of\text') nvim('command', 'edit ' .. fname) - local buf = meths.get_current_buf() + local buf = meths.nvim_get_current_buf() - meths.buf_set_mark(buf, 'F', 2, 2, {}) + meths.nvim_buf_set_mark(buf, 'F', 2, 2, {}) nvim('command', 'new') -- Create new buf to avoid :bd failing nvim('command', 'bd! ' .. buf.id) os.remove(fname) - local mark = meths.get_mark('F', {}) + local mark = meths.nvim_get_mark('F', {}) -- To avoid comparing relative vs absolute path local mfname = mark[4] local tail_patt = [[[\/][^\/]*$]] @@ -3633,72 +3652,72 @@ describe('API', function() eq({ str = '%StatusLineStringWithHighlights', width = 31, - }, meths.eval_statusline('%%StatusLineString%#WarningMsg#WithHighlights', {})) + }, meths.nvim_eval_statusline('%%StatusLineString%#WarningMsg#WithHighlights', {})) end) it("doesn't exceed maxwidth", function() eq({ str = 'Should be trun>', width = 15, - }, meths.eval_statusline('Should be truncated%<', { maxwidth = 15 })) + }, meths.nvim_eval_statusline('Should be truncated%<', { maxwidth = 15 })) end) it('supports ASCII fillchar', function() eq( { str = 'a~~~b', width = 5 }, - meths.eval_statusline('a%=b', { fillchar = '~', maxwidth = 5 }) + meths.nvim_eval_statusline('a%=b', { fillchar = '~', maxwidth = 5 }) ) end) it('supports single-width multibyte fillchar', function() eq( { str = 'a━━━b', width = 5 }, - meths.eval_statusline('a%=b', { fillchar = '━', maxwidth = 5 }) + meths.nvim_eval_statusline('a%=b', { fillchar = '━', maxwidth = 5 }) ) end) it('treats double-width fillchar as single-width', function() eq( { str = 'a哦哦哦b', width = 5 }, - meths.eval_statusline('a%=b', { fillchar = '哦', maxwidth = 5 }) + meths.nvim_eval_statusline('a%=b', { fillchar = '哦', maxwidth = 5 }) ) end) it('treats control character fillchar as single-width', function() eq( { str = 'a\031\031\031b', width = 5 }, - meths.eval_statusline('a%=b', { fillchar = '\031', maxwidth = 5 }) + meths.nvim_eval_statusline('a%=b', { fillchar = '\031', maxwidth = 5 }) ) end) it('rejects multiple-character fillchar', function() eq( "Invalid 'fillchar': expected single character", - pcall_err(meths.eval_statusline, '', { fillchar = 'aa' }) + pcall_err(meths.nvim_eval_statusline, '', { fillchar = 'aa' }) ) end) it('rejects empty string fillchar', function() eq( "Invalid 'fillchar': expected single character", - pcall_err(meths.eval_statusline, '', { fillchar = '' }) + pcall_err(meths.nvim_eval_statusline, '', { fillchar = '' }) ) end) it('rejects non-string fillchar', function() eq( "Invalid 'fillchar': expected String, got Integer", - pcall_err(meths.eval_statusline, '', { fillchar = 1 }) + pcall_err(meths.nvim_eval_statusline, '', { fillchar = 1 }) ) end) it('rejects invalid string', function() - eq('E539: Illegal character <}>', pcall_err(meths.eval_statusline, '%{%}', {})) + eq('E539: Illegal character <}>', pcall_err(meths.nvim_eval_statusline, '%{%}', {})) end) it('supports various items', function() - eq({ str = '0', width = 1 }, meths.eval_statusline('%l', { maxwidth = 5 })) + eq({ str = '0', width = 1 }, meths.nvim_eval_statusline('%l', { maxwidth = 5 })) command('set readonly') - eq({ str = '[RO]', width = 4 }, meths.eval_statusline('%r', { maxwidth = 5 })) + eq({ str = '[RO]', width = 4 }, meths.nvim_eval_statusline('%r', { maxwidth = 5 })) local screen = Screen.new(80, 24) screen:attach() command('set showcmd') feed('1234') screen:expect({ any = '1234' }) - eq({ str = '1234', width = 4 }, meths.eval_statusline('%S', { maxwidth = 5 })) + eq({ str = '1234', width = 4 }, meths.nvim_eval_statusline('%S', { maxwidth = 5 })) feed('56') screen:expect({ any = '123456' }) - eq({ str = '<3456', width = 5 }, meths.eval_statusline('%S', { maxwidth = 5 })) + eq({ str = '<3456', width = 5 }, meths.nvim_eval_statusline('%S', { maxwidth = 5 })) end) describe('highlight parsing', function() it('works', function() @@ -3711,7 +3730,7 @@ describe('API', function() { start = 24, group = 'User1' }, }, }, - meths.eval_statusline( + meths.nvim_eval_statusline( '%#WarningMsg#TextWithWarningHighlight%1*TextWithUserHighlight', { highlights = true } ) @@ -3724,7 +3743,7 @@ describe('API', function() highlights = { { start = 0, group = 'StatusLine' }, }, - }, meths.eval_statusline('TextWithNoHighlight', { highlights = true })) + }, meths.nvim_eval_statusline('TextWithNoHighlight', { highlights = true })) end) it('works with inactive statusline', function() command('split') @@ -3738,9 +3757,9 @@ describe('API', function() { start = 19, group = 'WarningMsg' }, }, }, - meths.eval_statusline( + meths.nvim_eval_statusline( 'TextWithNoHighlight%#WarningMsg#TextWithWarningHighlight', - { winid = meths.list_wins()[2].id, highlights = true } + { winid = meths.nvim_list_wins()[2].id, highlights = true } ) ) end) @@ -3754,7 +3773,7 @@ describe('API', function() { start = 19, group = 'WarningMsg' }, }, }, - meths.eval_statusline( + meths.nvim_eval_statusline( 'TextWithNoHighlight%#WarningMsg#TextWithWarningHighlight', { use_tabline = true, highlights = true } ) @@ -3770,7 +3789,7 @@ describe('API', function() { start = 19, group = 'WarningMsg' }, }, }, - meths.eval_statusline( + meths.nvim_eval_statusline( 'TextWithNoHighlight%#WarningMsg#TextWithWarningHighlight', { use_winbar = true, highlights = true } ) @@ -3798,25 +3817,31 @@ describe('API', function() { group = 'ErrorMsg', start = 8 }, { group = 'Normal', start = 10 }, }, - }, meths.eval_statusline('%C%s%=%l ', { use_statuscol_lnum = 4, highlights = true })) - eq({ - str = '3 ', - width = 2, - highlights = { - { group = 'LineNr', start = 0 }, - { group = 'ErrorMsg', start = 1 }, - }, - }, meths.eval_statusline( - '%l%#ErrorMsg# ', - { use_statuscol_lnum = 3, highlights = true } + }, meths.nvim_eval_statusline( + '%C%s%=%l ', + { use_statuscol_lnum = 4, highlights = true } )) + eq( + { + str = '3 ', + width = 2, + highlights = { + { group = 'LineNr', start = 0 }, + { group = 'ErrorMsg', start = 1 }, + }, + }, + meths.nvim_eval_statusline( + '%l%#ErrorMsg# ', + { use_statuscol_lnum = 3, highlights = true } + ) + ) end) it('no memory leak with click functions', function() - meths.eval_statusline('%@ClickFunc@StatusLineStringWithClickFunc%T', {}) + meths.nvim_eval_statusline('%@ClickFunc@StatusLineStringWithClickFunc%T', {}) eq({ str = 'StatusLineStringWithClickFunc', width = 29, - }, meths.eval_statusline('%@ClickFunc@StatusLineStringWithClickFunc%T', {})) + }, meths.nvim_eval_statusline('%@ClickFunc@StatusLineStringWithClickFunc%T', {})) end) end) end) @@ -3859,7 +3884,7 @@ describe('API', function() verbose = -1, vertical = false, }, - }, meths.parse_cmd('echo foo', {})) + }, meths.nvim_parse_cmd('echo foo', {})) end) it('works with ranges', function() eq({ @@ -3899,7 +3924,7 @@ describe('API', function() verbose = -1, vertical = false, }, - }, meths.parse_cmd('4,6s/math.random/math.max/', {})) + }, meths.nvim_parse_cmd('4,6s/math.random/math.max/', {})) end) it('works with count', function() eq({ @@ -3940,7 +3965,7 @@ describe('API', function() verbose = -1, vertical = false, }, - }, meths.parse_cmd('buffer 1', {})) + }, meths.nvim_parse_cmd('buffer 1', {})) end) it('works with register', function() eq({ @@ -3981,7 +4006,7 @@ describe('API', function() verbose = -1, vertical = false, }, - }, meths.parse_cmd('put +', {})) + }, meths.nvim_parse_cmd('put +', {})) eq({ cmd = 'put', args = {}, @@ -4020,7 +4045,7 @@ describe('API', function() verbose = -1, vertical = false, }, - }, meths.parse_cmd('put', {})) + }, meths.nvim_parse_cmd('put', {})) end) it('works with range, count and register', function() eq({ @@ -4062,7 +4087,7 @@ describe('API', function() verbose = -1, vertical = false, }, - }, meths.parse_cmd('1,3delete * 5', {})) + }, meths.nvim_parse_cmd('1,3delete * 5', {})) end) it('works with bang', function() eq({ @@ -4102,91 +4127,97 @@ describe('API', function() verbose = -1, vertical = false, }, - }, meths.parse_cmd('w!', {})) + }, meths.nvim_parse_cmd('w!', {})) end) it('works with modifiers', function() - eq({ - cmd = 'split', - args = { 'foo.txt' }, - bang = false, - range = {}, - addr = '?', - magic = { - file = true, - bar = true, - }, - nargs = '?', - nextcmd = '', - mods = { - browse = false, - confirm = false, - emsg_silent = true, - filter = { - pattern = 'foo', - force = false, + eq( + { + cmd = 'split', + args = { 'foo.txt' }, + bang = false, + range = {}, + addr = '?', + magic = { + file = true, + bar = true, + }, + nargs = '?', + nextcmd = '', + mods = { + browse = false, + confirm = false, + emsg_silent = true, + filter = { + pattern = 'foo', + force = false, + }, + hide = false, + horizontal = true, + keepalt = false, + keepjumps = false, + keepmarks = false, + keeppatterns = false, + lockmarks = false, + noautocmd = false, + noswapfile = false, + sandbox = false, + silent = true, + split = 'topleft', + tab = 1, + unsilent = false, + verbose = 15, + vertical = false, }, - hide = false, - horizontal = true, - keepalt = false, - keepjumps = false, - keepmarks = false, - keeppatterns = false, - lockmarks = false, - noautocmd = false, - noswapfile = false, - sandbox = false, - silent = true, - split = 'topleft', - tab = 1, - unsilent = false, - verbose = 15, - vertical = false, - }, - }, meths.parse_cmd( - '15verbose silent! horizontal topleft tab filter /foo/ split foo.txt', - {} - )) - eq({ - cmd = 'split', - args = { 'foo.txt' }, - bang = false, - range = {}, - addr = '?', - magic = { - file = true, - bar = true, }, - nargs = '?', - nextcmd = '', - mods = { - browse = false, - confirm = true, - emsg_silent = false, - filter = { - pattern = 'foo', - force = true, + meths.nvim_parse_cmd( + '15verbose silent! horizontal topleft tab filter /foo/ split foo.txt', + {} + ) + ) + eq( + { + cmd = 'split', + args = { 'foo.txt' }, + bang = false, + range = {}, + addr = '?', + magic = { + file = true, + bar = true, + }, + nargs = '?', + nextcmd = '', + mods = { + browse = false, + confirm = true, + emsg_silent = false, + filter = { + pattern = 'foo', + force = true, + }, + hide = false, + horizontal = false, + keepalt = false, + keepjumps = false, + keepmarks = false, + keeppatterns = false, + lockmarks = false, + noautocmd = false, + noswapfile = false, + sandbox = false, + silent = false, + split = 'botright', + tab = 0, + unsilent = true, + verbose = 0, + vertical = false, }, - hide = false, - horizontal = false, - keepalt = false, - keepjumps = false, - keepmarks = false, - keeppatterns = false, - lockmarks = false, - noautocmd = false, - noswapfile = false, - sandbox = false, - silent = false, - split = 'botright', - tab = 0, - unsilent = true, - verbose = 0, - vertical = false, }, - }, meths.parse_cmd( - '0verbose unsilent botright 0tab confirm filter! /foo/ split foo.txt', - {} - )) + meths.nvim_parse_cmd( + '0verbose unsilent botright 0tab confirm filter! /foo/ split foo.txt', + {} + ) + ) end) it('works with user commands', function() command('command -bang -nargs=+ -range -addr=lines MyCommand echo foo') @@ -4227,7 +4258,7 @@ describe('API', function() verbose = -1, vertical = false, }, - }, meths.parse_cmd('4,6MyCommand! test it', {})) + }, meths.nvim_parse_cmd('4,6MyCommand! test it', {})) end) it('works for commands separated by bar', function() eq({ @@ -4267,7 +4298,7 @@ describe('API', function() verbose = -1, vertical = false, }, - }, meths.parse_cmd('argadd a.txt | argadd b.txt', {})) + }, meths.nvim_parse_cmd('argadd a.txt | argadd b.txt', {})) end) it('works for nargs=1', function() command('command -nargs=1 MyCommand echo <q-args>') @@ -4307,28 +4338,28 @@ describe('API', function() verbose = -1, vertical = false, }, - }, meths.parse_cmd('MyCommand test it', {})) + }, meths.nvim_parse_cmd('MyCommand test it', {})) end) it('validates command', function() - eq('Error while parsing command line', pcall_err(meths.parse_cmd, '', {})) - eq('Error while parsing command line', pcall_err(meths.parse_cmd, '" foo', {})) + eq('Error while parsing command line', pcall_err(meths.nvim_parse_cmd, '', {})) + eq('Error while parsing command line', pcall_err(meths.nvim_parse_cmd, '" foo', {})) eq( 'Error while parsing command line: E492: Not an editor command: Fubar', - pcall_err(meths.parse_cmd, 'Fubar', {}) + pcall_err(meths.nvim_parse_cmd, 'Fubar', {}) ) command('command! Fubar echo foo') eq( 'Error while parsing command line: E477: No ! allowed', - pcall_err(meths.parse_cmd, 'Fubar!', {}) + pcall_err(meths.nvim_parse_cmd, 'Fubar!', {}) ) eq( 'Error while parsing command line: E481: No range allowed', - pcall_err(meths.parse_cmd, '4,6Fubar', {}) + pcall_err(meths.nvim_parse_cmd, '4,6Fubar', {}) ) command('command! Foobar echo foo') eq( 'Error while parsing command line: E464: Ambiguous use of user-defined command', - pcall_err(meths.parse_cmd, 'F', {}) + pcall_err(meths.nvim_parse_cmd, 'F', {}) ) end) it('does not interfere with printing line in Ex mode #19400', function() @@ -4350,7 +4381,7 @@ describe('API', function() Entering Ex mode. Type "visual" to go to Normal mode. | :1^ | ]]) - eq('Error while parsing command line', pcall_err(meths.parse_cmd, '', {})) + eq('Error while parsing command line', pcall_err(meths.nvim_parse_cmd, '', {})) feed('<CR>') screen:expect([[ foo | @@ -4363,8 +4394,8 @@ describe('API', function() ]]) end) it('does not move cursor or change search history/pattern #19878 #19890', function() - meths.buf_set_lines(0, 0, -1, true, { 'foo', 'bar', 'foo', 'bar' }) - eq({ 1, 0 }, meths.win_get_cursor(0)) + meths.nvim_buf_set_lines(0, 0, -1, true, { 'foo', 'bar', 'foo', 'bar' }) + eq({ 1, 0 }, meths.nvim_win_get_cursor(0)) eq('', funcs.getreg('/')) eq('', funcs.histget('search')) feed(':') -- call the API in cmdline mode to test whether it changes search history @@ -4405,15 +4436,15 @@ describe('API', function() verbose = -1, vertical = false, }, - }, meths.parse_cmd('+2;/bar/normal! x', {})) - eq({ 1, 0 }, meths.win_get_cursor(0)) + }, meths.nvim_parse_cmd('+2;/bar/normal! x', {})) + eq({ 1, 0 }, meths.nvim_win_get_cursor(0)) eq('', funcs.getreg('/')) eq('', funcs.histget('search')) end) it('result can be used directly by nvim_cmd #20051', function() - eq('foo', meths.cmd(meths.parse_cmd('echo "foo"', {}), { output = true })) - meths.cmd(meths.parse_cmd('set cursorline', {}), {}) - eq(true, meths.get_option_value('cursorline', {})) + eq('foo', meths.nvim_cmd(meths.nvim_parse_cmd('echo "foo"', {}), { output = true })) + meths.nvim_cmd(meths.nvim_parse_cmd('set cursorline', {}), {}) + eq(true, meths.nvim_get_option_value('cursorline', {})) end) it('no side-effects (error messages) in pcall() #20339', function() eq( @@ -4426,80 +4457,86 @@ describe('API', function() describe('nvim_cmd', function() it('works', function() - meths.cmd({ cmd = 'set', args = { 'cursorline' } }, {}) - eq(true, meths.get_option_value('cursorline', {})) + meths.nvim_cmd({ cmd = 'set', args = { 'cursorline' } }, {}) + eq(true, meths.nvim_get_option_value('cursorline', {})) end) it('validation', function() - eq("Invalid 'cmd': expected non-empty String", pcall_err(meths.cmd, { cmd = '' }, {})) - eq("Invalid 'cmd': expected String, got Array", pcall_err(meths.cmd, { cmd = {} }, {})) + eq("Invalid 'cmd': expected non-empty String", pcall_err(meths.nvim_cmd, { cmd = '' }, {})) + eq("Invalid 'cmd': expected String, got Array", pcall_err(meths.nvim_cmd, { cmd = {} }, {})) eq( "Invalid 'args': expected Array, got Boolean", - pcall_err(meths.cmd, { cmd = 'set', args = true }, {}) + pcall_err(meths.nvim_cmd, { cmd = 'set', args = true }, {}) ) eq( 'Invalid command arg: expected non-whitespace', - pcall_err(meths.cmd, { cmd = 'set', args = { ' ' } }, {}) + pcall_err(meths.nvim_cmd, { cmd = 'set', args = { ' ' } }, {}) ) eq( 'Invalid command arg: expected valid type, got Array', - pcall_err(meths.cmd, { cmd = 'set', args = { {} } }, {}) + pcall_err(meths.nvim_cmd, { cmd = 'set', args = { {} } }, {}) + ) + eq( + 'Wrong number of arguments', + pcall_err(meths.nvim_cmd, { cmd = 'aboveleft', args = {} }, {}) ) - eq('Wrong number of arguments', pcall_err(meths.cmd, { cmd = 'aboveleft', args = {} }, {})) eq( 'Command cannot accept bang: print', - pcall_err(meths.cmd, { cmd = 'print', args = {}, bang = true }, {}) + pcall_err(meths.nvim_cmd, { cmd = 'print', args = {}, bang = true }, {}) ) eq( 'Command cannot accept range: set', - pcall_err(meths.cmd, { cmd = 'set', args = {}, range = { 1 } }, {}) + pcall_err(meths.nvim_cmd, { cmd = 'set', args = {}, range = { 1 } }, {}) ) eq( "Invalid 'range': expected Array, got Boolean", - pcall_err(meths.cmd, { cmd = 'print', args = {}, range = true }, {}) + pcall_err(meths.nvim_cmd, { cmd = 'print', args = {}, range = true }, {}) ) eq( "Invalid 'range': expected <=2 elements", - pcall_err(meths.cmd, { cmd = 'print', args = {}, range = { 1, 2, 3, 4 } }, {}) + pcall_err(meths.nvim_cmd, { cmd = 'print', args = {}, range = { 1, 2, 3, 4 } }, {}) ) eq( 'Invalid range element: expected non-negative Integer', - pcall_err(meths.cmd, { cmd = 'print', args = {}, range = { -1 } }, {}) + pcall_err(meths.nvim_cmd, { cmd = 'print', args = {}, range = { -1 } }, {}) ) eq( 'Command cannot accept count: set', - pcall_err(meths.cmd, { cmd = 'set', args = {}, count = 1 }, {}) + pcall_err(meths.nvim_cmd, { cmd = 'set', args = {}, count = 1 }, {}) ) eq( "Invalid 'count': expected Integer, got Boolean", - pcall_err(meths.cmd, { cmd = 'print', args = {}, count = true }, {}) + pcall_err(meths.nvim_cmd, { cmd = 'print', args = {}, count = true }, {}) ) eq( "Invalid 'count': expected non-negative Integer", - pcall_err(meths.cmd, { cmd = 'print', args = {}, count = -1 }, {}) + pcall_err(meths.nvim_cmd, { cmd = 'print', args = {}, count = -1 }, {}) ) eq( 'Command cannot accept register: set', - pcall_err(meths.cmd, { cmd = 'set', args = {}, reg = 'x' }, {}) + pcall_err(meths.nvim_cmd, { cmd = 'set', args = {}, reg = 'x' }, {}) + ) + eq( + 'Cannot use register "=', + pcall_err(meths.nvim_cmd, { cmd = 'put', args = {}, reg = '=' }, {}) ) - eq('Cannot use register "=', pcall_err(meths.cmd, { cmd = 'put', args = {}, reg = '=' }, {})) eq( "Invalid 'reg': expected single character, got xx", - pcall_err(meths.cmd, { cmd = 'put', args = {}, reg = 'xx' }, {}) + pcall_err(meths.nvim_cmd, { cmd = 'put', args = {}, reg = 'xx' }, {}) ) -- #20681 - eq('Invalid command: "win_getid"', pcall_err(meths.cmd, { cmd = 'win_getid' }, {})) - eq('Invalid command: "echo "hi""', pcall_err(meths.cmd, { cmd = 'echo "hi"' }, {})) + eq('Invalid command: "win_getid"', pcall_err(meths.nvim_cmd, { cmd = 'win_getid' }, {})) + eq('Invalid command: "echo "hi""', pcall_err(meths.nvim_cmd, { cmd = 'echo "hi"' }, {})) eq('Invalid command: "win_getid"', pcall_err(exec_lua, [[return vim.cmd.win_getid{}]])) -- Lua call allows empty {} for dict item. eq('', exec_lua([[return vim.cmd{ cmd = "set", args = {}, magic = {} }]])) eq('', exec_lua([[return vim.cmd{ cmd = "set", args = {}, mods = {} }]])) - eq('', meths.cmd({ cmd = 'set', args = {}, magic = {} }, {})) + eq('', meths.nvim_cmd({ cmd = 'set', args = {}, magic = {} }, {})) -- Lua call does not allow non-empty list-like {} for dict item. eq( @@ -4517,11 +4554,11 @@ describe('API', function() end) it('captures output', function() - eq('foo', meths.cmd({ cmd = 'echo', args = { '"foo"' } }, { output = true })) + eq('foo', meths.nvim_cmd({ cmd = 'echo', args = { '"foo"' } }, { output = true })) end) it('sets correct script context', function() - meths.cmd({ cmd = 'set', args = { 'cursorline' } }, {}) + meths.nvim_cmd({ cmd = 'set', args = { 'cursorline' } }, {}) local str = exec_capture([[verbose set cursorline?]]) neq(nil, str:find('cursorline\n\tLast set from API client %(channel id %d+%)')) end) @@ -4536,7 +4573,7 @@ describe('API', function() line5 line6 ]] - meths.cmd({ cmd = 'del', range = { 2, 4 } }, {}) + meths.nvim_cmd({ cmd = 'del', range = { 2, 4 } }, {}) expect [[ line1 you didn't expect this @@ -4554,7 +4591,7 @@ describe('API', function() line5 line6 ]] - meths.cmd({ cmd = 'del', range = { 2 }, count = 4 }, {}) + meths.nvim_cmd({ cmd = 'del', range = { 2 }, count = 4 }, {}) expect [[ line1 line5 @@ -4571,7 +4608,7 @@ describe('API', function() line5 line6 ]] - meths.cmd({ cmd = 'del', range = { 2, 4 }, reg = 'a' }, {}) + meths.nvim_cmd({ cmd = 'del', range = { 2, 4 }, reg = 'a' }, {}) command('1put a') expect [[ line1 @@ -4584,26 +4621,29 @@ describe('API', function() ]] end) it('works with bang', function() - meths.create_user_command('Foo', 'echo "<bang>"', { bang = true }) - eq('!', meths.cmd({ cmd = 'Foo', bang = true }, { output = true })) - eq('', meths.cmd({ cmd = 'Foo', bang = false }, { output = true })) + meths.nvim_create_user_command('Foo', 'echo "<bang>"', { bang = true }) + eq('!', meths.nvim_cmd({ cmd = 'Foo', bang = true }, { output = true })) + eq('', meths.nvim_cmd({ cmd = 'Foo', bang = false }, { output = true })) end) it('works with modifiers', function() -- with silent = true output is still captured eq( '1', - meths.cmd({ cmd = 'echomsg', args = { '1' }, mods = { silent = true } }, { output = true }) + meths.nvim_cmd( + { cmd = 'echomsg', args = { '1' }, mods = { silent = true } }, + { output = true } + ) ) -- but message isn't added to message history - eq('', meths.cmd({ cmd = 'messages' }, { output = true })) + eq('', meths.nvim_cmd({ cmd = 'messages' }, { output = true })) - meths.create_user_command('Foo', 'set verbose', {}) - eq(' verbose=1', meths.cmd({ cmd = 'Foo', mods = { verbose = 1 } }, { output = true })) + meths.nvim_create_user_command('Foo', 'set verbose', {}) + eq(' verbose=1', meths.nvim_cmd({ cmd = 'Foo', mods = { verbose = 1 } }, { output = true })) - meths.create_user_command('Mods', "echo '<mods>'", {}) + meths.nvim_create_user_command('Mods', "echo '<mods>'", {}) eq( 'keepmarks keeppatterns silent 3verbose aboveleft horizontal', - meths.cmd({ + meths.nvim_cmd({ cmd = 'Mods', mods = { horizontal = true, @@ -4615,19 +4655,19 @@ describe('API', function() }, }, { output = true }) ) - eq(0, meths.get_option_value('verbose', {})) + eq(0, meths.nvim_get_option_value('verbose', {})) command('edit foo.txt | edit bar.txt') eq( ' 1 #h "foo.txt" line 1', - meths.cmd( + meths.nvim_cmd( { cmd = 'buffers', mods = { filter = { pattern = 'foo', force = false } } }, { output = true } ) ) eq( ' 2 %a "bar.txt" line 1', - meths.cmd( + meths.nvim_cmd( { cmd = 'buffers', mods = { filter = { pattern = 'foo', force = true } } }, { output = true } ) @@ -4635,10 +4675,10 @@ describe('API', function() -- with emsg_silent = true error is suppressed feed([[:lua vim.api.nvim_cmd({ cmd = 'call', mods = { emsg_silent = true } }, {})<CR>]]) - eq('', meths.cmd({ cmd = 'messages' }, { output = true })) + eq('', meths.nvim_cmd({ cmd = 'messages' }, { output = true })) -- error from the next command typed is not suppressed #21420 feed(':call<CR><CR>') - eq('E471: Argument required', meths.cmd({ cmd = 'messages' }, { output = true })) + eq('E471: Argument required', meths.nvim_cmd({ cmd = 'messages' }, { output = true })) end) it('works with magic.file', function() exec_lua([[ @@ -4648,7 +4688,10 @@ describe('API', function() ]]) eq( uv.cwd(), - meths.cmd({ cmd = 'Foo', args = { '%:p:h' }, magic = { file = true } }, { output = true }) + meths.nvim_cmd( + { cmd = 'Foo', args = { '%:p:h' }, magic = { file = true } }, + { output = true } + ) ) end) it('splits arguments correctly', function() @@ -4657,24 +4700,24 @@ describe('API', function() echo a:000 endfunction ]]) - meths.create_user_command('Foo', 'call FooFunc(<f-args>)', { nargs = '+' }) + meths.nvim_create_user_command('Foo', 'call FooFunc(<f-args>)', { nargs = '+' }) eq( [=[['a quick', 'brown fox', 'jumps over the', 'lazy dog']]=], - meths.cmd( + meths.nvim_cmd( { cmd = 'Foo', args = { 'a quick', 'brown fox', 'jumps over the', 'lazy dog' } }, { output = true } ) ) eq( [=[['test \ \\ \"""\', 'more\ tests\" ']]=], - meths.cmd( + meths.nvim_cmd( { cmd = 'Foo', args = { [[test \ \\ \"""\]], [[more\ tests\" ]] } }, { output = true } ) ) end) it('splits arguments correctly for Lua callback', function() - meths.exec_lua( + meths.nvim_exec_lua( [[ local function FooFunc(opts) vim.print(opts.fargs) @@ -4686,14 +4729,14 @@ describe('API', function() ) eq( [[{ "a quick", "brown fox", "jumps over the", "lazy dog" }]], - meths.cmd( + meths.nvim_cmd( { cmd = 'Foo', args = { 'a quick', 'brown fox', 'jumps over the', 'lazy dog' } }, { output = true } ) ) eq( [[{ 'test \\ \\\\ \\"""\\', 'more\\ tests\\" ' }]], - meths.cmd( + meths.nvim_cmd( { cmd = 'Foo', args = { [[test \ \\ \"""\]], [[more\ tests\" ]] } }, { output = true } ) @@ -4701,13 +4744,13 @@ describe('API', function() end) it('works with buffer names', function() command('edit foo.txt | edit bar.txt') - meths.cmd({ cmd = 'buffer', args = { 'foo.txt' } }, {}) - eq('foo.txt', funcs.fnamemodify(meths.buf_get_name(0), ':t')) - meths.cmd({ cmd = 'buffer', args = { 'bar.txt' } }, {}) - eq('bar.txt', funcs.fnamemodify(meths.buf_get_name(0), ':t')) + meths.nvim_cmd({ cmd = 'buffer', args = { 'foo.txt' } }, {}) + eq('foo.txt', funcs.fnamemodify(meths.nvim_buf_get_name(0), ':t')) + meths.nvim_cmd({ cmd = 'buffer', args = { 'bar.txt' } }, {}) + eq('bar.txt', funcs.fnamemodify(meths.nvim_buf_get_name(0), ':t')) end) it('triggers CmdUndefined event if command is not found', function() - meths.exec_lua( + meths.nvim_exec_lua( [[ vim.api.nvim_create_autocmd("CmdUndefined", { pattern = "Foo", @@ -4718,17 +4761,17 @@ describe('API', function() ]], {} ) - eq('foo', meths.cmd({ cmd = 'Foo' }, { output = true })) + eq('foo', meths.nvim_cmd({ cmd = 'Foo' }, { output = true })) end) it('errors if command is not implemented', function() - eq('Command not implemented: winpos', pcall_err(meths.cmd, { cmd = 'winpos' }, {})) + eq('Command not implemented: winpos', pcall_err(meths.nvim_cmd, { cmd = 'winpos' }, {})) end) it('works with empty arguments list', function() - meths.cmd({ cmd = 'update' }, {}) - meths.cmd({ cmd = 'buffer', count = 0 }, {}) + meths.nvim_cmd({ cmd = 'update' }, {}) + meths.nvim_cmd({ cmd = 'buffer', count = 0 }, {}) end) it("doesn't suppress errors when used in keymapping", function() - meths.exec_lua( + meths.nvim_exec_lua( [[ vim.keymap.set("n", "[l", function() vim.api.nvim_cmd({ cmd = "echo", args = {"foo"} }, {}) end) @@ -4739,31 +4782,31 @@ describe('API', function() neq(nil, string.find(eval('v:errmsg'), 'E5108:')) end) it('handles 0 range #19608', function() - meths.buf_set_lines(0, 0, -1, false, { 'aa' }) - meths.cmd({ cmd = 'delete', range = { 0 } }, {}) + meths.nvim_buf_set_lines(0, 0, -1, false, { 'aa' }) + meths.nvim_cmd({ cmd = 'delete', range = { 0 } }, {}) command('undo') - eq({ 'aa' }, meths.buf_get_lines(0, 0, 1, false)) + eq({ 'aa' }, meths.nvim_buf_get_lines(0, 0, 1, false)) assert_alive() end) it('supports filename expansion', function() - meths.cmd({ cmd = 'argadd', args = { '%:p:h:t', '%:p:h:t' } }, {}) + meths.nvim_cmd({ cmd = 'argadd', args = { '%:p:h:t', '%:p:h:t' } }, {}) local arg = funcs.expand('%:p:h:t') eq({ arg, arg }, funcs.argv()) end) it("'make' command works when argument count isn't 1 #19696", function() command('set makeprg=echo') command('set shellquote=') - matches('^:!echo ', meths.cmd({ cmd = 'make' }, { output = true })) + matches('^:!echo ', meths.nvim_cmd({ cmd = 'make' }, { output = true })) assert_alive() matches( '^:!echo foo bar', - meths.cmd({ cmd = 'make', args = { 'foo', 'bar' } }, { output = true }) + meths.nvim_cmd({ cmd = 'make', args = { 'foo', 'bar' } }, { output = true }) ) assert_alive() local arg_pesc = pesc(funcs.expand('%:p:h:t')) matches( ('^:!echo %s %s'):format(arg_pesc, arg_pesc), - meths.cmd({ cmd = 'make', args = { '%:p:h:t', '%:p:h:t' } }, { output = true }) + meths.nvim_cmd({ cmd = 'make', args = { '%:p:h:t', '%:p:h:t' } }, { output = true }) ) assert_alive() end) @@ -4773,7 +4816,7 @@ describe('API', function() screen:set_default_attr_ids({ [0] = { bold = true, foreground = Screen.colors.Blue }, }) - meths.cmd({ cmd = 'echo', args = { [['hello']] } }, { output = true }) + meths.nvim_cmd({ cmd = 'echo', args = { [['hello']] } }, { output = true }) screen:expect { grid = [[ ^ | @@ -4796,29 +4839,29 @@ describe('API', function() } end) it('works with non-String args', function() - eq('2', meths.cmd({ cmd = 'echo', args = { 2 } }, { output = true })) - eq('1', meths.cmd({ cmd = 'echo', args = { true } }, { output = true })) + eq('2', meths.nvim_cmd({ cmd = 'echo', args = { 2 } }, { output = true })) + eq('1', meths.nvim_cmd({ cmd = 'echo', args = { true } }, { output = true })) end) describe('first argument as count', function() it('works', function() command('vsplit | enew') - meths.cmd({ cmd = 'bdelete', args = { meths.get_current_buf() } }, {}) - eq(1, meths.get_current_buf().id) + meths.nvim_cmd({ cmd = 'bdelete', args = { meths.nvim_get_current_buf() } }, {}) + eq(1, meths.nvim_get_current_buf().id) end) it('works with :sleep using milliseconds', function() local start = uv.now() - meths.cmd({ cmd = 'sleep', args = { '100m' } }, {}) + meths.nvim_cmd({ cmd = 'sleep', args = { '100m' } }, {}) ok(uv.now() - start <= 300) end) end) it(':call with unknown function does not crash #26289', function() eq( 'Vim:E117: Unknown function: UnknownFunc', - pcall_err(meths.cmd, { cmd = 'call', args = { 'UnknownFunc()' } }, {}) + pcall_err(meths.nvim_cmd, { cmd = 'call', args = { 'UnknownFunc()' } }, {}) ) end) it(':throw does not crash #24556', function() - eq('42', pcall_err(meths.cmd, { cmd = 'throw', args = { '42' } }, {})) + eq('42', pcall_err(meths.nvim_cmd, { cmd = 'throw', args = { '42' } }, {})) end) it('can use :return #24556', function() exec([[ @@ -4829,8 +4872,8 @@ describe('API', function() endfunc let g:result = Foo() ]]) - eq('before', meths.get_var('pos')) - eq({ 1, 2, 3 }, meths.get_var('result')) + eq('before', meths.nvim_get_var('pos')) + eq({ 1, 2, 3 }, meths.nvim_get_var('result')) end) end) end) diff --git a/test/functional/api/window_spec.lua b/test/functional/api/window_spec.lua index 2516e96be2..9542272447 100644 --- a/test/functional/api/window_spec.lua +++ b/test/functional/api/window_spec.lua @@ -53,9 +53,9 @@ describe('API/win', function() end) it('disallowed in cmdwin if win={old_}curwin or buf=curbuf', function() - local new_buf = meths.create_buf(true, true) - local old_win = meths.get_current_win() - local new_win = meths.open_win(new_buf, false, { + local new_buf = meths.nvim_create_buf(true, true) + local old_win = meths.nvim_get_current_win() + local new_win = meths.nvim_open_win(new_buf, false, { relative = 'editor', row = 10, col = 10, @@ -65,20 +65,20 @@ describe('API/win', function() feed('q:') eq( 'E11: Invalid in command-line window; <CR> executes, CTRL-C quits', - pcall_err(meths.win_set_buf, 0, new_buf) + pcall_err(meths.nvim_win_set_buf, 0, new_buf) ) eq( 'E11: Invalid in command-line window; <CR> executes, CTRL-C quits', - pcall_err(meths.win_set_buf, old_win, new_buf) + pcall_err(meths.nvim_win_set_buf, old_win, new_buf) ) eq( 'E11: Invalid in command-line window; <CR> executes, CTRL-C quits', - pcall_err(meths.win_set_buf, new_win, 0) + pcall_err(meths.nvim_win_set_buf, new_win, 0) ) - local next_buf = meths.create_buf(true, true) - meths.win_set_buf(new_win, next_buf) - eq(next_buf, meths.win_get_buf(new_win)) + local next_buf = meths.nvim_create_buf(true, true) + meths.nvim_win_set_buf(new_win, next_buf) + eq(next_buf, meths.nvim_win_get_buf(new_win)) end) end) @@ -94,7 +94,7 @@ describe('API/win', function() end) it('does not leak memory when using invalid window ID with invalid pos', function() - eq('Invalid window id: 1', pcall_err(meths.win_set_cursor, 1, { 'b\na' })) + eq('Invalid window id: 1', pcall_err(meths.nvim_win_set_cursor, 1, { 'b\na' })) end) it('updates the screen, and also when the window is unfocused', function() @@ -334,7 +334,7 @@ describe('API/win', function() call nvim_win_set_height(w, 5) ]]) feed('l') - eq('', meths.get_vvar('errmsg')) + eq('', meths.nvim_get_vvar('errmsg')) end) end) @@ -365,7 +365,7 @@ describe('API/win', function() call nvim_win_set_width(w, 5) ]]) feed('l') - eq('', meths.get_vvar('errmsg')) + eq('', meths.nvim_get_vvar('errmsg')) end) end) @@ -501,48 +501,48 @@ describe('API/win', function() describe('close', function() it('can close current window', function() - local oldwin = meths.get_current_win() + local oldwin = meths.nvim_get_current_win() command('split') - local newwin = meths.get_current_win() - meths.win_close(newwin, false) - eq({ oldwin }, meths.list_wins()) + local newwin = meths.nvim_get_current_win() + meths.nvim_win_close(newwin, false) + eq({ oldwin }, meths.nvim_list_wins()) end) it('can close noncurrent window', function() - local oldwin = meths.get_current_win() + local oldwin = meths.nvim_get_current_win() command('split') - local newwin = meths.get_current_win() - meths.win_close(oldwin, false) - eq({ newwin }, meths.list_wins()) + local newwin = meths.nvim_get_current_win() + meths.nvim_win_close(oldwin, false) + eq({ newwin }, meths.nvim_list_wins()) end) it("handles changed buffer when 'hidden' is unset", function() command('set nohidden') - local oldwin = meths.get_current_win() + local oldwin = meths.nvim_get_current_win() insert('text') command('new') - local newwin = meths.get_current_win() + local newwin = meths.nvim_get_current_win() eq( 'Vim:E37: No write since last change (add ! to override)', - pcall_err(meths.win_close, oldwin, false) + pcall_err(meths.nvim_win_close, oldwin, false) ) - eq({ newwin, oldwin }, meths.list_wins()) + eq({ newwin, oldwin }, meths.nvim_list_wins()) end) it('handles changed buffer with force', function() - local oldwin = meths.get_current_win() + local oldwin = meths.nvim_get_current_win() insert('text') command('new') - local newwin = meths.get_current_win() - meths.win_close(oldwin, true) - eq({ newwin }, meths.list_wins()) + local newwin = meths.nvim_get_current_win() + meths.nvim_win_close(oldwin, true) + eq({ newwin }, meths.nvim_list_wins()) end) it('in cmdline-window #9767', function() command('split') - eq(2, #meths.list_wins()) - local oldwin = meths.get_current_win() - local otherwin = meths.open_win(0, false, { + eq(2, #meths.nvim_list_wins()) + local oldwin = meths.nvim_get_current_win() + local otherwin = meths.nvim_open_win(0, false, { relative = 'editor', row = 10, col = 10, @@ -551,19 +551,19 @@ describe('API/win', function() }) -- Open cmdline-window. feed('q:') - eq(4, #meths.list_wins()) + eq(4, #meths.nvim_list_wins()) eq(':', funcs.getcmdwintype()) -- Not allowed to close previous window from cmdline-window. eq( 'E11: Invalid in command-line window; <CR> executes, CTRL-C quits', - pcall_err(meths.win_close, oldwin, true) + pcall_err(meths.nvim_win_close, oldwin, true) ) -- Closing other windows is fine. - meths.win_close(otherwin, true) - eq(false, meths.win_is_valid(otherwin)) + meths.nvim_win_close(otherwin, true) + eq(false, meths.nvim_win_is_valid(otherwin)) -- Close cmdline-window. - meths.win_close(0, true) - eq(2, #meths.list_wins()) + meths.nvim_win_close(0, true) + eq(2, #meths.nvim_list_wins()) eq('', funcs.getcmdwintype()) end) @@ -572,7 +572,7 @@ describe('API/win', function() command('botright split') local prevwin = curwin().id eq(2, eval('tabpagenr()')) - local win = meths.open_win(0, true, { + local win = meths.nvim_open_win(0, true, { relative = 'editor', row = 10, col = 10, @@ -582,67 +582,67 @@ describe('API/win', function() local tab = eval('tabpagenr()') command('tabprevious') eq(1, eval('tabpagenr()')) - meths.win_close(win, false) + meths.nvim_win_close(win, false) - eq(prevwin, meths.tabpage_get_win(tab).id) + eq(prevwin, meths.nvim_tabpage_get_win(tab).id) assert_alive() end) end) describe('hide', function() it('can hide current window', function() - local oldwin = meths.get_current_win() + local oldwin = meths.nvim_get_current_win() command('split') - local newwin = meths.get_current_win() - meths.win_hide(newwin) - eq({ oldwin }, meths.list_wins()) + local newwin = meths.nvim_get_current_win() + meths.nvim_win_hide(newwin) + eq({ oldwin }, meths.nvim_list_wins()) end) it('can hide noncurrent window', function() - local oldwin = meths.get_current_win() + local oldwin = meths.nvim_get_current_win() command('split') - local newwin = meths.get_current_win() - meths.win_hide(oldwin) - eq({ newwin }, meths.list_wins()) + local newwin = meths.nvim_get_current_win() + meths.nvim_win_hide(oldwin) + eq({ newwin }, meths.nvim_list_wins()) end) it('does not close the buffer', function() - local oldwin = meths.get_current_win() - local oldbuf = meths.get_current_buf() - local buf = meths.create_buf(true, false) - local newwin = meths.open_win(buf, true, { + local oldwin = meths.nvim_get_current_win() + local oldbuf = meths.nvim_get_current_buf() + local buf = meths.nvim_create_buf(true, false) + local newwin = meths.nvim_open_win(buf, true, { relative = 'win', row = 3, col = 3, width = 12, height = 3, }) - meths.win_hide(newwin) - eq({ oldwin }, meths.list_wins()) - eq({ oldbuf, buf }, meths.list_bufs()) + meths.nvim_win_hide(newwin) + eq({ oldwin }, meths.nvim_list_wins()) + eq({ oldbuf, buf }, meths.nvim_list_bufs()) end) it('deletes the buffer when bufhidden=wipe', function() - local oldwin = meths.get_current_win() - local oldbuf = meths.get_current_buf() - local buf = meths.create_buf(true, false).id - local newwin = meths.open_win(buf, true, { + local oldwin = meths.nvim_get_current_win() + local oldbuf = meths.nvim_get_current_buf() + local buf = meths.nvim_create_buf(true, false).id + local newwin = meths.nvim_open_win(buf, true, { relative = 'win', row = 3, col = 3, width = 12, height = 3, }) - meths.set_option_value('bufhidden', 'wipe', { buf = buf }) - meths.win_hide(newwin) - eq({ oldwin }, meths.list_wins()) - eq({ oldbuf }, meths.list_bufs()) + meths.nvim_set_option_value('bufhidden', 'wipe', { buf = buf }) + meths.nvim_win_hide(newwin) + eq({ oldwin }, meths.nvim_list_wins()) + eq({ oldbuf }, meths.nvim_list_bufs()) end) it('in the cmdwin', function() feed('q:') -- Can close the cmdwin. - meths.win_hide(0) + meths.nvim_win_hide(0) eq('', funcs.getcmdwintype()) - local old_win = meths.get_current_win() - local other_win = meths.open_win(0, false, { + local old_win = meths.nvim_get_current_win() + local other_win = meths.nvim_open_win(0, false, { relative = 'win', row = 3, col = 3, @@ -653,24 +653,24 @@ describe('API/win', function() -- Cannot close the previous window. eq( 'E11: Invalid in command-line window; <CR> executes, CTRL-C quits', - pcall_err(meths.win_hide, old_win) + pcall_err(meths.nvim_win_hide, old_win) ) -- Can close other windows. - meths.win_hide(other_win) - eq(false, meths.win_is_valid(other_win)) + meths.nvim_win_hide(other_win) + eq(false, meths.nvim_win_is_valid(other_win)) end) end) describe('text_height', function() it('validation', function() - local X = meths.get_vvar('maxcol') + local X = meths.nvim_get_vvar('maxcol') insert([[ aaa bbb ccc ddd eee]]) - eq('Invalid window id: 23', pcall_err(meths.win_text_height, 23, {})) + eq('Invalid window id: 23', pcall_err(meths.nvim_win_text_height, 23, {})) eq('Line index out of bounds', pcall_err(curwinmeths.text_height, { start_row = 5 })) eq('Line index out of bounds', pcall_err(curwinmeths.text_height, { start_row = -6 })) eq('Line index out of bounds', pcall_err(curwinmeths.text_height, { end_row = 5 })) @@ -713,7 +713,7 @@ describe('API/win', function() end) it('with two diff windows', function() - local X = meths.get_vvar('maxcol') + local X = meths.nvim_get_vvar('maxcol') local screen = Screen.new(45, 22) screen:set_default_attr_ids({ [0] = { foreground = Screen.colors.Blue1, bold = true }, @@ -775,70 +775,88 @@ describe('API/win', function() | ]], } - eq({ all = 20, fill = 5 }, meths.win_text_height(1000, {})) - eq({ all = 20, fill = 5 }, meths.win_text_height(1001, {})) - eq({ all = 20, fill = 5 }, meths.win_text_height(1000, { start_row = 0 })) - eq({ all = 20, fill = 5 }, meths.win_text_height(1001, { start_row = 0 })) - eq({ all = 15, fill = 0 }, meths.win_text_height(1000, { end_row = -1 })) - eq({ all = 15, fill = 0 }, meths.win_text_height(1000, { end_row = 40 })) - eq({ all = 20, fill = 5 }, meths.win_text_height(1001, { end_row = -1 })) - eq({ all = 20, fill = 5 }, meths.win_text_height(1001, { end_row = 40 })) - eq({ all = 10, fill = 5 }, meths.win_text_height(1000, { start_row = 23 })) - eq({ all = 13, fill = 3 }, meths.win_text_height(1001, { start_row = 18 })) - eq({ all = 11, fill = 0 }, meths.win_text_height(1000, { end_row = 23 })) - eq({ all = 11, fill = 5 }, meths.win_text_height(1001, { end_row = 18 })) - eq({ all = 11, fill = 0 }, meths.win_text_height(1000, { start_row = 3, end_row = 39 })) - eq({ all = 11, fill = 3 }, meths.win_text_height(1001, { start_row = 1, end_row = 34 })) - eq({ all = 9, fill = 0 }, meths.win_text_height(1000, { start_row = 4, end_row = 38 })) - eq({ all = 9, fill = 3 }, meths.win_text_height(1001, { start_row = 2, end_row = 33 })) - eq({ all = 9, fill = 0 }, meths.win_text_height(1000, { start_row = 5, end_row = 37 })) - eq({ all = 9, fill = 3 }, meths.win_text_height(1001, { start_row = 3, end_row = 32 })) - eq({ all = 9, fill = 0 }, meths.win_text_height(1000, { start_row = 17, end_row = 25 })) - eq({ all = 9, fill = 3 }, meths.win_text_height(1001, { start_row = 15, end_row = 20 })) - eq({ all = 7, fill = 0 }, meths.win_text_height(1000, { start_row = 18, end_row = 24 })) - eq({ all = 7, fill = 3 }, meths.win_text_height(1001, { start_row = 16, end_row = 19 })) - eq({ all = 6, fill = 5 }, meths.win_text_height(1000, { start_row = -1 })) - eq({ all = 5, fill = 5 }, meths.win_text_height(1000, { start_row = -1, start_vcol = X })) + eq({ all = 20, fill = 5 }, meths.nvim_win_text_height(1000, {})) + eq({ all = 20, fill = 5 }, meths.nvim_win_text_height(1001, {})) + eq({ all = 20, fill = 5 }, meths.nvim_win_text_height(1000, { start_row = 0 })) + eq({ all = 20, fill = 5 }, meths.nvim_win_text_height(1001, { start_row = 0 })) + eq({ all = 15, fill = 0 }, meths.nvim_win_text_height(1000, { end_row = -1 })) + eq({ all = 15, fill = 0 }, meths.nvim_win_text_height(1000, { end_row = 40 })) + eq({ all = 20, fill = 5 }, meths.nvim_win_text_height(1001, { end_row = -1 })) + eq({ all = 20, fill = 5 }, meths.nvim_win_text_height(1001, { end_row = 40 })) + eq({ all = 10, fill = 5 }, meths.nvim_win_text_height(1000, { start_row = 23 })) + eq({ all = 13, fill = 3 }, meths.nvim_win_text_height(1001, { start_row = 18 })) + eq({ all = 11, fill = 0 }, meths.nvim_win_text_height(1000, { end_row = 23 })) + eq({ all = 11, fill = 5 }, meths.nvim_win_text_height(1001, { end_row = 18 })) + eq({ all = 11, fill = 0 }, meths.nvim_win_text_height(1000, { start_row = 3, end_row = 39 })) + eq({ all = 11, fill = 3 }, meths.nvim_win_text_height(1001, { start_row = 1, end_row = 34 })) + eq({ all = 9, fill = 0 }, meths.nvim_win_text_height(1000, { start_row = 4, end_row = 38 })) + eq({ all = 9, fill = 3 }, meths.nvim_win_text_height(1001, { start_row = 2, end_row = 33 })) + eq({ all = 9, fill = 0 }, meths.nvim_win_text_height(1000, { start_row = 5, end_row = 37 })) + eq({ all = 9, fill = 3 }, meths.nvim_win_text_height(1001, { start_row = 3, end_row = 32 })) + eq({ all = 9, fill = 0 }, meths.nvim_win_text_height(1000, { start_row = 17, end_row = 25 })) + eq({ all = 9, fill = 3 }, meths.nvim_win_text_height(1001, { start_row = 15, end_row = 20 })) + eq({ all = 7, fill = 0 }, meths.nvim_win_text_height(1000, { start_row = 18, end_row = 24 })) + eq({ all = 7, fill = 3 }, meths.nvim_win_text_height(1001, { start_row = 16, end_row = 19 })) + eq({ all = 6, fill = 5 }, meths.nvim_win_text_height(1000, { start_row = -1 })) + eq( + { all = 5, fill = 5 }, + meths.nvim_win_text_height(1000, { start_row = -1, start_vcol = X }) + ) eq( { all = 0, fill = 0 }, - meths.win_text_height(1000, { start_row = -1, start_vcol = X, end_row = -1 }) + meths.nvim_win_text_height(1000, { start_row = -1, start_vcol = X, end_row = -1 }) ) eq( { all = 0, fill = 0 }, - meths.win_text_height(1000, { start_row = -1, start_vcol = X, end_row = -1, end_vcol = X }) + meths.nvim_win_text_height( + 1000, + { start_row = -1, start_vcol = X, end_row = -1, end_vcol = X } + ) ) eq( { all = 1, fill = 0 }, - meths.win_text_height(1000, { start_row = -1, start_vcol = 0, end_row = -1, end_vcol = X }) + meths.nvim_win_text_height( + 1000, + { start_row = -1, start_vcol = 0, end_row = -1, end_vcol = X } + ) ) - eq({ all = 3, fill = 2 }, meths.win_text_height(1001, { end_row = 0 })) - eq({ all = 2, fill = 2 }, meths.win_text_height(1001, { end_row = 0, end_vcol = 0 })) + eq({ all = 3, fill = 2 }, meths.nvim_win_text_height(1001, { end_row = 0 })) + eq({ all = 2, fill = 2 }, meths.nvim_win_text_height(1001, { end_row = 0, end_vcol = 0 })) eq( { all = 2, fill = 2 }, - meths.win_text_height(1001, { start_row = 0, end_row = 0, end_vcol = 0 }) + meths.nvim_win_text_height(1001, { start_row = 0, end_row = 0, end_vcol = 0 }) ) eq( { all = 0, fill = 0 }, - meths.win_text_height(1001, { start_row = 0, start_vcol = 0, end_row = 0, end_vcol = 0 }) + meths.nvim_win_text_height( + 1001, + { start_row = 0, start_vcol = 0, end_row = 0, end_vcol = 0 } + ) ) eq( { all = 1, fill = 0 }, - meths.win_text_height(1001, { start_row = 0, start_vcol = 0, end_row = 0, end_vcol = X }) + meths.nvim_win_text_height( + 1001, + { start_row = 0, start_vcol = 0, end_row = 0, end_vcol = X } + ) ) - eq({ all = 11, fill = 5 }, meths.win_text_height(1001, { end_row = 18 })) + eq({ all = 11, fill = 5 }, meths.nvim_win_text_height(1001, { end_row = 18 })) eq( { all = 9, fill = 3 }, - meths.win_text_height(1001, { start_row = 0, start_vcol = 0, end_row = 18 }) + meths.nvim_win_text_height(1001, { start_row = 0, start_vcol = 0, end_row = 18 }) ) - eq({ all = 10, fill = 5 }, meths.win_text_height(1001, { end_row = 18, end_vcol = 0 })) + eq({ all = 10, fill = 5 }, meths.nvim_win_text_height(1001, { end_row = 18, end_vcol = 0 })) eq( { all = 8, fill = 3 }, - meths.win_text_height(1001, { start_row = 0, start_vcol = 0, end_row = 18, end_vcol = 0 }) + meths.nvim_win_text_height( + 1001, + { start_row = 0, start_vcol = 0, end_row = 18, end_vcol = 0 } + ) ) end) it('with wrapped lines', function() - local X = meths.get_vvar('maxcol') + local X = meths.nvim_get_vvar('maxcol') local screen = Screen.new(45, 22) screen:set_default_attr_ids({ [0] = { foreground = Screen.colors.Blue1, bold = true }, @@ -850,15 +868,15 @@ describe('API/win', function() set number cpoptions+=n call setline(1, repeat([repeat('foobar-', 36)], 3)) ]]) - local ns = meths.create_namespace('') - meths.buf_set_extmark( + local ns = meths.nvim_create_namespace('') + meths.nvim_buf_set_extmark( 0, ns, 1, 100, { virt_text = { { ('?'):rep(15), 'Search' } }, virt_text_pos = 'inline' } ) - meths.buf_set_extmark( + meths.nvim_buf_set_extmark( 0, ns, 2, @@ -898,113 +916,155 @@ describe('API/win', function() | ]], } - eq({ all = 21, fill = 0 }, meths.win_text_height(0, {})) - eq({ all = 6, fill = 0 }, meths.win_text_height(0, { start_row = 0, end_row = 0 })) - eq({ all = 7, fill = 0 }, meths.win_text_height(0, { start_row = 1, end_row = 1 })) - eq({ all = 8, fill = 0 }, meths.win_text_height(0, { start_row = 2, end_row = 2 })) + eq({ all = 21, fill = 0 }, meths.nvim_win_text_height(0, {})) + eq({ all = 6, fill = 0 }, meths.nvim_win_text_height(0, { start_row = 0, end_row = 0 })) + eq({ all = 7, fill = 0 }, meths.nvim_win_text_height(0, { start_row = 1, end_row = 1 })) + eq({ all = 8, fill = 0 }, meths.nvim_win_text_height(0, { start_row = 2, end_row = 2 })) eq( { all = 0, fill = 0 }, - meths.win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 0 }) + meths.nvim_win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 0 }) ) eq( { all = 1, fill = 0 }, - meths.win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 41 }) + meths.nvim_win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 41 }) ) eq( { all = 2, fill = 0 }, - meths.win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 42 }) + meths.nvim_win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 42 }) ) eq( { all = 2, fill = 0 }, - meths.win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 86 }) + meths.nvim_win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 86 }) ) eq( { all = 3, fill = 0 }, - meths.win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 87 }) + meths.nvim_win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 87 }) ) eq( { all = 6, fill = 0 }, - meths.win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 266 }) + meths.nvim_win_text_height( + 0, + { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 266 } + ) ) eq( { all = 7, fill = 0 }, - meths.win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 267 }) + meths.nvim_win_text_height( + 0, + { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 267 } + ) ) eq( { all = 7, fill = 0 }, - meths.win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 311 }) + meths.nvim_win_text_height( + 0, + { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 311 } + ) ) eq( { all = 7, fill = 0 }, - meths.win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 312 }) + meths.nvim_win_text_height( + 0, + { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 312 } + ) ) eq( { all = 7, fill = 0 }, - meths.win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = X }) + meths.nvim_win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = X }) ) eq( { all = 7, fill = 0 }, - meths.win_text_height(0, { start_row = 1, start_vcol = 40, end_row = 1, end_vcol = X }) + meths.nvim_win_text_height(0, { start_row = 1, start_vcol = 40, end_row = 1, end_vcol = X }) ) eq( { all = 6, fill = 0 }, - meths.win_text_height(0, { start_row = 1, start_vcol = 41, end_row = 1, end_vcol = X }) + meths.nvim_win_text_height(0, { start_row = 1, start_vcol = 41, end_row = 1, end_vcol = X }) ) eq( { all = 6, fill = 0 }, - meths.win_text_height(0, { start_row = 1, start_vcol = 85, end_row = 1, end_vcol = X }) + meths.nvim_win_text_height(0, { start_row = 1, start_vcol = 85, end_row = 1, end_vcol = X }) ) eq( { all = 5, fill = 0 }, - meths.win_text_height(0, { start_row = 1, start_vcol = 86, end_row = 1, end_vcol = X }) + meths.nvim_win_text_height(0, { start_row = 1, start_vcol = 86, end_row = 1, end_vcol = X }) ) eq( { all = 2, fill = 0 }, - meths.win_text_height(0, { start_row = 1, start_vcol = 265, end_row = 1, end_vcol = X }) + meths.nvim_win_text_height( + 0, + { start_row = 1, start_vcol = 265, end_row = 1, end_vcol = X } + ) ) eq( { all = 1, fill = 0 }, - meths.win_text_height(0, { start_row = 1, start_vcol = 266, end_row = 1, end_vcol = X }) + meths.nvim_win_text_height( + 0, + { start_row = 1, start_vcol = 266, end_row = 1, end_vcol = X } + ) ) eq( { all = 1, fill = 0 }, - meths.win_text_height(0, { start_row = 1, start_vcol = 310, end_row = 1, end_vcol = X }) + meths.nvim_win_text_height( + 0, + { start_row = 1, start_vcol = 310, end_row = 1, end_vcol = X } + ) ) eq( { all = 0, fill = 0 }, - meths.win_text_height(0, { start_row = 1, start_vcol = 311, end_row = 1, end_vcol = X }) + meths.nvim_win_text_height( + 0, + { start_row = 1, start_vcol = 311, end_row = 1, end_vcol = X } + ) ) eq( { all = 1, fill = 0 }, - meths.win_text_height(0, { start_row = 1, start_vcol = 86, end_row = 1, end_vcol = 131 }) + meths.nvim_win_text_height( + 0, + { start_row = 1, start_vcol = 86, end_row = 1, end_vcol = 131 } + ) ) eq( { all = 1, fill = 0 }, - meths.win_text_height(0, { start_row = 1, start_vcol = 221, end_row = 1, end_vcol = 266 }) + meths.nvim_win_text_height( + 0, + { start_row = 1, start_vcol = 221, end_row = 1, end_vcol = 266 } + ) ) - eq({ all = 18, fill = 0 }, meths.win_text_height(0, { start_row = 0, start_vcol = 131 })) - eq({ all = 19, fill = 0 }, meths.win_text_height(0, { start_row = 0, start_vcol = 130 })) - eq({ all = 20, fill = 0 }, meths.win_text_height(0, { end_row = 2, end_vcol = 311 })) - eq({ all = 21, fill = 0 }, meths.win_text_height(0, { end_row = 2, end_vcol = 312 })) + eq({ all = 18, fill = 0 }, meths.nvim_win_text_height(0, { start_row = 0, start_vcol = 131 })) + eq({ all = 19, fill = 0 }, meths.nvim_win_text_height(0, { start_row = 0, start_vcol = 130 })) + eq({ all = 20, fill = 0 }, meths.nvim_win_text_height(0, { end_row = 2, end_vcol = 311 })) + eq({ all = 21, fill = 0 }, meths.nvim_win_text_height(0, { end_row = 2, end_vcol = 312 })) eq( { all = 17, fill = 0 }, - meths.win_text_height(0, { start_row = 0, start_vcol = 131, end_row = 2, end_vcol = 311 }) + meths.nvim_win_text_height( + 0, + { start_row = 0, start_vcol = 131, end_row = 2, end_vcol = 311 } + ) ) eq( { all = 19, fill = 0 }, - meths.win_text_height(0, { start_row = 0, start_vcol = 130, end_row = 2, end_vcol = 312 }) + meths.nvim_win_text_height( + 0, + { start_row = 0, start_vcol = 130, end_row = 2, end_vcol = 312 } + ) ) - eq({ all = 16, fill = 0 }, meths.win_text_height(0, { start_row = 0, start_vcol = 221 })) - eq({ all = 17, fill = 0 }, meths.win_text_height(0, { start_row = 0, start_vcol = 220 })) - eq({ all = 14, fill = 0 }, meths.win_text_height(0, { end_row = 2, end_vcol = 41 })) - eq({ all = 15, fill = 0 }, meths.win_text_height(0, { end_row = 2, end_vcol = 42 })) + eq({ all = 16, fill = 0 }, meths.nvim_win_text_height(0, { start_row = 0, start_vcol = 221 })) + eq({ all = 17, fill = 0 }, meths.nvim_win_text_height(0, { start_row = 0, start_vcol = 220 })) + eq({ all = 14, fill = 0 }, meths.nvim_win_text_height(0, { end_row = 2, end_vcol = 41 })) + eq({ all = 15, fill = 0 }, meths.nvim_win_text_height(0, { end_row = 2, end_vcol = 42 })) eq( { all = 9, fill = 0 }, - meths.win_text_height(0, { start_row = 0, start_vcol = 221, end_row = 2, end_vcol = 41 }) + meths.nvim_win_text_height( + 0, + { start_row = 0, start_vcol = 221, end_row = 2, end_vcol = 41 } + ) ) eq( { all = 11, fill = 0 }, - meths.win_text_height(0, { start_row = 0, start_vcol = 220, end_row = 2, end_vcol = 42 }) + meths.nvim_win_text_height( + 0, + { start_row = 0, start_vcol = 220, end_row = 2, end_vcol = 42 } + ) ) end) end) @@ -1012,7 +1072,7 @@ describe('API/win', function() describe('open_win', function() it('noautocmd option works', function() command('autocmd BufEnter,BufLeave,BufWinEnter * let g:fired = 1') - meths.open_win(meths.create_buf(true, true), true, { + meths.nvim_open_win(meths.nvim_create_buf(true, true), true, { relative = 'win', row = 3, col = 3, @@ -1021,7 +1081,7 @@ describe('API/win', function() noautocmd = true, }) eq(0, funcs.exists('g:fired')) - meths.open_win(meths.create_buf(true, true), true, { + meths.nvim_open_win(meths.nvim_create_buf(true, true), true, { relative = 'win', row = 3, col = 3, @@ -1032,11 +1092,11 @@ describe('API/win', function() end) it('disallowed in cmdwin if enter=true or buf=curbuf', function() - local new_buf = meths.create_buf(true, true) + local new_buf = meths.nvim_create_buf(true, true) feed('q:') eq( 'E11: Invalid in command-line window; <CR> executes, CTRL-C quits', - pcall_err(meths.open_win, new_buf, true, { + pcall_err(meths.nvim_open_win, new_buf, true, { relative = 'editor', row = 5, col = 5, @@ -1046,7 +1106,7 @@ describe('API/win', function() ) eq( 'E11: Invalid in command-line window; <CR> executes, CTRL-C quits', - pcall_err(meths.open_win, 0, false, { + pcall_err(meths.nvim_open_win, 0, false, { relative = 'editor', row = 5, col = 5, @@ -1057,7 +1117,7 @@ describe('API/win', function() eq( new_buf, - meths.win_get_buf(meths.open_win(new_buf, false, { + meths.nvim_win_get_buf(meths.nvim_open_win(new_buf, false, { relative = 'editor', row = 5, col = 5, @@ -1068,10 +1128,10 @@ describe('API/win', function() end) it('aborts if buffer is invalid', function() - local wins_before = meths.list_wins() + local wins_before = meths.nvim_list_wins() eq( 'Invalid buffer id: 1337', - pcall_err(meths.open_win, 1337, false, { + pcall_err(meths.nvim_open_win, 1337, false, { relative = 'editor', row = 5, col = 5, @@ -1079,14 +1139,14 @@ describe('API/win', function() height = 5, }) ) - eq(wins_before, meths.list_wins()) + eq(wins_before, meths.nvim_list_wins()) end) end) describe('get_config', function() it('includes border', function() local b = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h' } - local win = meths.open_win(0, true, { + local win = meths.nvim_open_win(0, true, { relative = 'win', row = 3, col = 3, @@ -1095,7 +1155,7 @@ describe('API/win', function() border = b, }) - local cfg = meths.win_get_config(win) + local cfg = meths.nvim_win_get_config(win) eq(b, cfg.border) end) @@ -1110,7 +1170,7 @@ describe('API/win', function() { 'g', 'Constant' }, { 'h', 'PreProc' }, } - local win = meths.open_win(0, true, { + local win = meths.nvim_open_win(0, true, { relative = 'win', row = 3, col = 3, @@ -1119,14 +1179,14 @@ describe('API/win', function() border = b, }) - local cfg = meths.win_get_config(win) + local cfg = meths.nvim_win_get_config(win) eq(b, cfg.border) end) it('includes title and footer', function() local title = { { 'A', { 'StatusLine', 'TabLine' } }, { 'B' }, { 'C', 'WinBar' } } local footer = { { 'A', 'WinBar' }, { 'B' }, { 'C', { 'StatusLine', 'TabLine' } } } - local win = meths.open_win(0, true, { + local win = meths.nvim_open_win(0, true, { relative = 'win', row = 3, col = 3, @@ -1137,7 +1197,7 @@ describe('API/win', function() footer = footer, }) - local cfg = meths.win_get_config(win) + local cfg = meths.nvim_win_get_config(win) eq(title, cfg.title) eq(footer, cfg.footer) end) @@ -1145,7 +1205,7 @@ describe('API/win', function() describe('set_config', function() it('no crash with invalid title', function() - local win = meths.open_win(0, true, { + local win = meths.nvim_open_win(0, true, { width = 10, height = 10, relative = 'editor', @@ -1156,14 +1216,14 @@ describe('API/win', function() }) eq( 'title/footer cannot be an empty array', - pcall_err(meths.win_set_config, win, { title = {} }) + pcall_err(meths.nvim_win_set_config, win, { title = {} }) ) command('redraw!') assert_alive() end) it('no crash with invalid footer', function() - local win = meths.open_win(0, true, { + local win = meths.nvim_open_win(0, true, { width = 10, height = 10, relative = 'editor', @@ -1174,7 +1234,7 @@ describe('API/win', function() }) eq( 'title/footer cannot be an empty array', - pcall_err(meths.win_set_config, win, { footer = {} }) + pcall_err(meths.nvim_win_set_config, win, { footer = {} }) ) command('redraw!') assert_alive() diff --git a/test/functional/autocmd/autocmd_oldtest_spec.lua b/test/functional/autocmd/autocmd_oldtest_spec.lua index 62f87bfd97..fb566e27c3 100644 --- a/test/functional/autocmd/autocmd_oldtest_spec.lua +++ b/test/functional/autocmd/autocmd_oldtest_spec.lua @@ -23,7 +23,7 @@ describe('oldtests', function() ]] eq(3, #exec_lines('au vimBarTest')) - eq(1, #meths.get_autocmds({ group = 'vimBarTest' })) + eq(1, #meths.nvim_get_autocmds({ group = 'vimBarTest' })) end it('should recognize a bar before the {event}', function() @@ -31,7 +31,7 @@ describe('oldtests', function() add_an_autocmd() exec [[ augroup vimBarTest | au! | augroup END ]] eq(1, #exec_lines('au vimBarTest')) - eq({}, meths.get_autocmds({ group = 'vimBarTest' })) + eq({}, meths.nvim_get_autocmds({ group = 'vimBarTest' })) -- Sad spacing add_an_autocmd() @@ -74,7 +74,7 @@ describe('oldtests', function() funcs.writefile(funcs.split(content, '\n'), fname) funcs.delete('Xout') - funcs.system(string.format('%s --clean -N -S %s', meths.get_vvar('progpath'), fname)) + funcs.system(string.format('%s --clean -N -S %s', meths.nvim_get_vvar('progpath'), fname)) eq(1, funcs.filereadable('Xout')) funcs.delete('Xxx1') diff --git a/test/functional/autocmd/autocmd_spec.lua b/test/functional/autocmd/autocmd_spec.lua index 2ae6277bd9..5088ef8031 100644 --- a/test/functional/autocmd/autocmd_spec.lua +++ b/test/functional/autocmd/autocmd_spec.lua @@ -143,7 +143,7 @@ describe('autocmd', function() describe('BufLeave autocommand', function() it('can wipe out the buffer created by :edit which triggered autocmd', function() - meths.set_option_value('hidden', true, {}) + meths.nvim_set_option_value('hidden', true, {}) curbufmeths.set_lines(0, 1, false, { 'start of test file xx', 'end of test file xx', @@ -416,7 +416,11 @@ describe('autocmd', function() end) it('gives E814 when there are other floating windows', function() - meths.open_win(0, true, { width = 10, height = 10, relative = 'editor', row = 10, col = 10 }) + meths.nvim_open_win( + 0, + true, + { width = 10, height = 10, relative = 'editor', row = 10, col = 10 } + ) eq( 'BufAdd Autocommands for "Xa.txt": Vim(close):E814: Cannot close window, only autocmd window would remain', pcall_err(command, 'doautoall BufAdd') @@ -512,15 +516,15 @@ describe('autocmd', function() command('autocmd ChanOpen * let v:event.info.id = 0') funcs.jobstart({ 'cat' }) retry(nil, nil, function() - eq('E46: Cannot change read-only variable "v:event.info"', meths.get_vvar('errmsg')) + eq('E46: Cannot change read-only variable "v:event.info"', meths.nvim_get_vvar('errmsg')) end) end) it('during ChanOpen event', function() command('autocmd ChanInfo * let v:event.info.id = 0') - meths.set_client_info('foo', {}, 'remote', {}, {}) + meths.nvim_set_client_info('foo', {}, 'remote', {}, {}) retry(nil, nil, function() - eq('E46: Cannot change read-only variable "v:event.info"', meths.get_vvar('errmsg')) + eq('E46: Cannot change read-only variable "v:event.info"', meths.nvim_get_vvar('errmsg')) end) end) @@ -574,7 +578,7 @@ describe('autocmd', function() call assert_fails('au WinNew * ++once ++once echo bad', 'E983:') ]] - meths.set_var('did_split', 0) + meths.nvim_set_var('did_split', 0) source [[ augroup Testing @@ -586,11 +590,11 @@ describe('autocmd', function() split ]] - eq(2, meths.get_var('did_split')) + eq(2, meths.nvim_get_var('did_split')) eq(1, funcs.exists('#WinNew')) -- Now with once - meths.set_var('did_split', 0) + meths.nvim_set_var('did_split', 0) source [[ augroup Testing @@ -602,7 +606,7 @@ describe('autocmd', function() split ]] - eq(1, meths.get_var('did_split')) + eq(1, meths.nvim_get_var('did_split')) eq(0, funcs.exists('#WinNew')) -- call assert_fails('au WinNew * ++once ++once echo bad', 'E983:') @@ -619,7 +623,7 @@ describe('autocmd', function() it('should have autocmds in filetypedetect group', function() source [[filetype on]] - neq({}, meths.get_autocmds { group = 'filetypedetect' }) + neq({}, meths.nvim_get_autocmds { group = 'filetypedetect' }) end) it('should allow comma-separated patterns', function() @@ -631,7 +635,7 @@ describe('autocmd', function() augroup END ]] - eq(4, #meths.get_autocmds { event = 'BufReadCmd', group = 'TestingPatterns' }) + eq(4, #meths.nvim_get_autocmds { event = 'BufReadCmd', group = 'TestingPatterns' }) end) end) diff --git a/test/functional/autocmd/cmdline_spec.lua b/test/functional/autocmd/cmdline_spec.lua index 3502721ee0..11a320910c 100644 --- a/test/functional/autocmd/cmdline_spec.lua +++ b/test/functional/autocmd/cmdline_spec.lua @@ -14,8 +14,8 @@ describe('cmdline autocommands', function() local channel before_each(function() clear() - channel = meths.get_api_info()[1] - meths.set_var('channel', channel) + channel = meths.nvim_get_api_info()[1] + meths.nvim_set_var('channel', channel) command("autocmd CmdlineEnter * call rpcnotify(g:channel, 'CmdlineEnter', v:event)") command("autocmd CmdlineLeave * call rpcnotify(g:channel, 'CmdlineLeave', v:event)") command("autocmd CmdWinEnter * call rpcnotify(g:channel, 'CmdWinEnter', v:event)") diff --git a/test/functional/autocmd/cursorhold_spec.lua b/test/functional/autocmd/cursorhold_spec.lua index 67ccf86ea4..58c50c9922 100644 --- a/test/functional/autocmd/cursorhold_spec.lua +++ b/test/functional/autocmd/cursorhold_spec.lua @@ -26,47 +26,47 @@ describe('CursorHold', function() -- if testing with small 'updatetime' fails, double its value and test again retry(10, nil, function() ut = ut * 2 - meths.set_option_value('updatetime', ut, {}) + meths.nvim_set_option_value('updatetime', ut, {}) feed('0') -- reset did_cursorhold - meths.set_var('cursorhold', 0) + meths.nvim_set_var('cursorhold', 0) sleep(ut / 4) fn() - eq(0, meths.get_var('cursorhold')) + eq(0, meths.nvim_get_var('cursorhold')) sleep(ut / 2) fn() - eq(0, meths.get_var('cursorhold')) + eq(0, meths.nvim_get_var('cursorhold')) sleep(ut / 2) - eq(early, meths.get_var('cursorhold')) + eq(early, meths.nvim_get_var('cursorhold')) sleep(ut / 4 * 3) - eq(1, meths.get_var('cursorhold')) + eq(1, meths.nvim_get_var('cursorhold')) end) end - local ignore_key = meths.replace_termcodes('<Ignore>', true, true, true) + local ignore_key = meths.nvim_replace_termcodes('<Ignore>', true, true, true) test_cursorhold(function() end, 1) test_cursorhold(function() feed('') end, 1) test_cursorhold(function() - meths.feedkeys('', 'n', true) + meths.nvim_feedkeys('', 'n', true) end, 1) test_cursorhold(function() feed('<Ignore>') end, 0) test_cursorhold(function() - meths.feedkeys(ignore_key, 'n', true) + meths.nvim_feedkeys(ignore_key, 'n', true) end, 0) end) it("reducing 'updatetime' while waiting for CursorHold #20241", function() - meths.set_option_value('updatetime', 10000, {}) + meths.nvim_set_option_value('updatetime', 10000, {}) feed('0') -- reset did_cursorhold - meths.set_var('cursorhold', 0) + meths.nvim_set_var('cursorhold', 0) sleep(50) - eq(0, meths.get_var('cursorhold')) - meths.set_option_value('updatetime', 20, {}) + eq(0, meths.nvim_get_var('cursorhold')) + meths.nvim_set_option_value('updatetime', 20, {}) sleep(10) - eq(1, meths.get_var('cursorhold')) + eq(1, meths.nvim_get_var('cursorhold')) end) end) @@ -85,7 +85,7 @@ describe('CursorHoldI', function() feed('ifoo') retry(5, nil, function() sleep(1) - eq(1, meths.get_var('cursorhold')) + eq(1, meths.nvim_get_var('cursorhold')) end) end) end) diff --git a/test/functional/autocmd/cursormoved_spec.lua b/test/functional/autocmd/cursormoved_spec.lua index 3ab5c3b9b1..0fa5ab296c 100644 --- a/test/functional/autocmd/cursormoved_spec.lua +++ b/test/functional/autocmd/cursormoved_spec.lua @@ -41,9 +41,9 @@ describe('CursorMoved', function() vsplit foo autocmd CursorMoved * let g:cursormoved += 1 ]]) - meths.buf_set_lines(eval('g:buf'), 0, -1, true, { 'aaa' }) + meths.nvim_buf_set_lines(eval('g:buf'), 0, -1, true, { 'aaa' }) eq(0, eval('g:cursormoved')) - eq({ 'aaa' }, meths.buf_get_lines(eval('g:buf'), 0, -1, true)) + eq({ 'aaa' }, meths.nvim_buf_get_lines(eval('g:buf'), 0, -1, true)) eq(0, eval('g:cursormoved')) end) diff --git a/test/functional/autocmd/safestate_spec.lua b/test/functional/autocmd/safestate_spec.lua index 73693749e4..867f845e48 100644 --- a/test/functional/autocmd/safestate_spec.lua +++ b/test/functional/autocmd/safestate_spec.lua @@ -18,40 +18,40 @@ describe('SafeState autocommand', function() it('with pending operator', function() feed('d') create_autocmd() - eq(0, meths.get_var('safe')) + eq(0, meths.nvim_get_var('safe')) feed('d') - eq(1, meths.get_var('safe')) + eq(1, meths.nvim_get_var('safe')) end) it('with specified register', function() feed('"r') create_autocmd() - eq(0, meths.get_var('safe')) + eq(0, meths.nvim_get_var('safe')) feed('x') - eq(1, meths.get_var('safe')) + eq(1, meths.nvim_get_var('safe')) end) it('with i_CTRL-O', function() feed('i<C-O>') create_autocmd() - eq(0, meths.get_var('safe')) + eq(0, meths.nvim_get_var('safe')) feed('x') - eq(1, meths.get_var('safe')) + eq(1, meths.nvim_get_var('safe')) end) it('with Insert mode completion', function() feed('i<C-X><C-V>') create_autocmd() - eq(0, meths.get_var('safe')) + eq(0, meths.nvim_get_var('safe')) feed('<C-X><C-Z>') - eq(1, meths.get_var('safe')) + eq(1, meths.nvim_get_var('safe')) end) it('with Cmdline completion', function() feed(':<Tab>') create_autocmd() - eq(0, meths.get_var('safe')) + eq(0, meths.nvim_get_var('safe')) feed('<C-E>') - eq(1, meths.get_var('safe')) + eq(1, meths.nvim_get_var('safe')) end) end) diff --git a/test/functional/autocmd/termxx_spec.lua b/test/functional/autocmd/termxx_spec.lua index dd79de4c37..caa7209de1 100644 --- a/test/functional/autocmd/termxx_spec.lua +++ b/test/functional/autocmd/termxx_spec.lua @@ -204,7 +204,7 @@ describe('autocmd TextChangedT', function() command('autocmd TextChangedT * ++once let g:called = 1') thelpers.feed_data('a') retry(nil, nil, function() - eq(1, meths.get_var('called')) + eq(1, meths.nvim_get_var('called')) end) end) @@ -212,6 +212,9 @@ describe('autocmd TextChangedT', function() command([[autocmd TextChangedT * call nvim_input('<CR>') | bwipe!]]) thelpers.feed_data('a') screen:expect({ any = 'E937: ' }) - matches('^E937: Attempt to delete a buffer that is in use: term://', meths.get_vvar('errmsg')) + matches( + '^E937: Attempt to delete a buffer that is in use: term://', + meths.nvim_get_vvar('errmsg') + ) end) end) diff --git a/test/functional/autocmd/win_scrolled_resized_spec.lua b/test/functional/autocmd/win_scrolled_resized_spec.lua index 6f61ad7902..67cb84de5b 100644 --- a/test/functional/autocmd/win_scrolled_resized_spec.lua +++ b/test/functional/autocmd/win_scrolled_resized_spec.lua @@ -45,7 +45,7 @@ describe('WinScrolled', function() local win_id before_each(function() - win_id = meths.get_current_win().id + win_id = meths.nvim_get_current_win().id command(string.format('autocmd WinScrolled %d let g:matched = v:true', win_id)) exec([[ let g:scrolled = 0 @@ -64,7 +64,7 @@ describe('WinScrolled', function() it('is triggered by scrolling vertically', function() local lines = { '123', '123' } - meths.buf_set_lines(0, 0, -1, true, lines) + meths.nvim_buf_set_lines(0, 0, -1, true, lines) eq(0, eval('g:scrolled')) feed('<C-E>') @@ -84,10 +84,10 @@ describe('WinScrolled', function() it('is triggered by scrolling horizontally', function() command('set nowrap') - local width = meths.win_get_width(0) + local width = meths.nvim_win_get_width(0) local line = '123' .. ('*'):rep(width * 2) local lines = { line, line } - meths.buf_set_lines(0, 0, -1, true, lines) + meths.nvim_buf_set_lines(0, 0, -1, true, lines) eq(0, eval('g:scrolled')) feed('zl') @@ -108,8 +108,8 @@ describe('WinScrolled', function() it('is triggered by horizontal scrolling from cursor move', function() command('set nowrap') local lines = { '', '', 'Foo' } - meths.buf_set_lines(0, 0, -1, true, lines) - meths.win_set_cursor(0, { 3, 0 }) + meths.nvim_buf_set_lines(0, 0, -1, true, lines) + meths.nvim_win_set_cursor(0, { 3, 0 }) eq(0, eval('g:scrolled')) feed('zl') @@ -143,10 +143,10 @@ describe('WinScrolled', function() -- oldtest: Test_WinScrolled_long_wrapped() it('is triggered by scrolling on a long wrapped line #19968', function() - local height = meths.win_get_height(0) - local width = meths.win_get_width(0) - meths.buf_set_lines(0, 0, -1, true, { ('foo'):rep(height * width) }) - meths.win_set_cursor(0, { 1, height * width - 1 }) + local height = meths.nvim_win_get_height(0) + local width = meths.nvim_win_get_width(0) + meths.nvim_buf_set_lines(0, 0, -1, true, { ('foo'):rep(height * width) }) + meths.nvim_win_set_cursor(0, { 1, height * width - 1 }) eq(0, eval('g:scrolled')) feed('gj') @@ -168,12 +168,12 @@ describe('WinScrolled', function() end) it('is triggered when the window scrolls in Insert mode', function() - local height = meths.win_get_height(0) + local height = meths.nvim_win_get_height(0) local lines = {} for i = 1, height * 2 do lines[i] = tostring(i) end - meths.buf_set_lines(0, 0, -1, true, lines) + meths.nvim_buf_set_lines(0, 0, -1, true, lines) feed('M') eq(0, eval('g:scrolled')) @@ -220,12 +220,12 @@ describe('WinScrolled', function() eq(0, eval('g:scrolled')) -- With the upper split focused, send a scroll-down event to the unfocused one. - meths.input_mouse('wheel', 'down', '', 0, 6, 0) + meths.nvim_input_mouse('wheel', 'down', '', 0, 6, 0) eq(1, eval('g:scrolled')) -- Again, but this time while we're in insert mode. feed('i') - meths.input_mouse('wheel', 'down', '', 0, 6, 0) + meths.nvim_input_mouse('wheel', 'down', '', 0, 6, 0) feed('<Esc>') eq(2, eval('g:scrolled')) end) @@ -296,15 +296,15 @@ describe('WinScrolled', function() ]]) eq(0, eval('g:scrolled')) - local buf = meths.create_buf(true, true) - meths.buf_set_lines( + local buf = meths.nvim_create_buf(true, true) + meths.nvim_buf_set_lines( buf, 0, -1, false, { '@', 'b', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n' } ) - local win = meths.open_win(buf, false, { + local win = meths.nvim_open_win(buf, false, { height = 5, width = 10, col = 0, @@ -317,7 +317,7 @@ describe('WinScrolled', function() -- WinScrolled should not be triggered when creating a new floating window eq(0, eval('g:scrolled')) - meths.input_mouse('wheel', 'down', '', 0, 3, 3) + meths.nvim_input_mouse('wheel', 'down', '', 0, 3, 3) eq(1, eval('g:scrolled')) eq(winid_str, eval('g:amatch')) eq({ @@ -325,7 +325,7 @@ describe('WinScrolled', function() [winid_str] = { leftcol = 0, topline = 3, topfill = 0, width = 0, height = 0, skipcol = 0 }, }, eval('g:v_event')) - meths.input_mouse('wheel', 'up', '', 0, 3, 3) + meths.nvim_input_mouse('wheel', 'up', '', 0, 3, 3) eq(2, eval('g:scrolled')) eq(tostring(win.id), eval('g:amatch')) eq({ diff --git a/test/functional/core/channels_spec.lua b/test/functional/core/channels_spec.lua index 570dda0730..566b8e4250 100644 --- a/test/functional/core/channels_spec.lua +++ b/test/functional/core/channels_spec.lua @@ -38,7 +38,7 @@ describe('channels', function() set_session(client) source(init) - meths.set_var('address', address) + meths.nvim_set_var('address', address) command("let g:id = sockconnect('pipe', address, {'on_data':'OnEvent'})") local id = eval('g:id') ok(id > 0) @@ -46,7 +46,7 @@ describe('channels', function() command("call chansend(g:id, msgpackdump([[2,'nvim_set_var',['code',23]]]))") set_session(server) retry(nil, 1000, function() - eq(23, meths.get_var('code')) + eq(23, meths.nvim_get_var('code')) end) set_session(client) @@ -67,8 +67,8 @@ describe('channels', function() \ 'on_exit': function('OnEvent'), \ } ]]) - meths.set_var('nvim_prog', nvim_prog) - meths.set_var( + meths.nvim_set_var('nvim_prog', nvim_prog) + meths.nvim_set_var( 'code', [[ function! OnEvent(id, data, event) dict @@ -117,8 +117,8 @@ describe('channels', function() \ 'on_exit': function('OnEvent'), \ } ]]) - meths.set_var('nvim_prog', nvim_prog) - meths.set_var( + meths.nvim_set_var('nvim_prog', nvim_prog) + meths.nvim_set_var( 'code', [[ function! OnStdin(id, data, event) dict @@ -165,8 +165,8 @@ describe('channels', function() \ 'pty': v:true, \ } ]]) - meths.set_var('nvim_prog', nvim_prog) - meths.set_var( + meths.nvim_set_var('nvim_prog', nvim_prog) + meths.nvim_set_var( 'code', [[ function! OnEvent(id, data, event) dict @@ -220,8 +220,8 @@ describe('channels', function() \ 'rpc': v:true, \ } ]]) - meths.set_var('nvim_prog', nvim_prog) - meths.set_var( + meths.nvim_set_var('nvim_prog', nvim_prog) + meths.nvim_set_var( 'code', [[ let id = stdioopen({'rpc':v:true}) diff --git a/test/functional/core/fileio_spec.lua b/test/functional/core/fileio_spec.lua index 6b821869ee..229d127b6d 100644 --- a/test/functional/core/fileio_spec.lua +++ b/test/functional/core/fileio_spec.lua @@ -409,14 +409,14 @@ describe('tmpdir', function() funcs.tempname() funcs.tempname() funcs.tempname() - eq('', meths.get_vvar('errmsg')) + eq('', meths.nvim_get_vvar('errmsg')) rm_tmpdir() funcs.tempname() funcs.tempname() funcs.tempname() - eq('E5431: tempdir disappeared (2 times)', meths.get_vvar('errmsg')) + eq('E5431: tempdir disappeared (2 times)', meths.nvim_get_vvar('errmsg')) rm_tmpdir() - eq('E5431: tempdir disappeared (3 times)', meths.get_vvar('errmsg')) + eq('E5431: tempdir disappeared (3 times)', meths.nvim_get_vvar('errmsg')) end) it('$NVIM_APPNAME relative path', function() diff --git a/test/functional/core/job_spec.lua b/test/functional/core/job_spec.lua index e1baa6f48f..5d5be2851b 100644 --- a/test/functional/core/job_spec.lua +++ b/test/functional/core/job_spec.lua @@ -403,11 +403,11 @@ describe('jobs', function() it('can get the pid value using getpid', function() nvim('command', "let j = jobstart(['cat', '-'], g:job_opts)") local pid = eval('jobpid(j)') - neq(NIL, meths.get_proc(pid)) + neq(NIL, meths.nvim_get_proc(pid)) nvim('command', 'call jobstop(j)') eq({ 'notification', 'stdout', { 0, { '' } } }, next_msg()) eq({ 'notification', 'exit', { 0, 143 } }, next_msg()) - eq(NIL, meths.get_proc(pid)) + eq(NIL, meths.nvim_get_proc(pid)) end) it('disposed on Nvim exit', function() @@ -417,9 +417,9 @@ describe('jobs', function() "let g:j = jobstart(has('win32') ? ['ping', '-n', '1001', '127.0.0.1'] : ['sleep', '1000'], g:job_opts)" ) local pid = eval('jobpid(g:j)') - neq(NIL, meths.get_proc(pid)) + neq(NIL, meths.nvim_get_proc(pid)) clear() - eq(NIL, meths.get_proc(pid)) + eq(NIL, meths.nvim_get_proc(pid)) end) it('can survive the exit of nvim with "detach"', function() @@ -429,9 +429,9 @@ describe('jobs', function() "let g:j = jobstart(has('win32') ? ['ping', '-n', '1001', '127.0.0.1'] : ['sleep', '1000'], g:job_opts)" ) local pid = eval('jobpid(g:j)') - neq(NIL, meths.get_proc(pid)) + neq(NIL, meths.nvim_get_proc(pid)) clear() - neq(NIL, meths.get_proc(pid)) + neq(NIL, meths.nvim_get_proc(pid)) -- clean up after ourselves eq(0, os_kill(pid)) end) @@ -948,7 +948,7 @@ describe('jobs', function() ]], } feed('<CR>') - funcs.jobstop(meths.get_var('id')) + funcs.jobstop(meths.nvim_get_var('id')) end) end) @@ -1066,7 +1066,7 @@ describe('jobs', function() local children if is_os('win') then local status, result = pcall(retry, nil, nil, function() - children = meths.get_proc_children(ppid) + children = meths.nvim_get_proc_children(ppid) -- On Windows conhost.exe may exist, and -- e.g. vctip.exe might appear. #10783 ok(#children >= 3 and #children <= 5) @@ -1078,13 +1078,13 @@ describe('jobs', function() end else retry(nil, nil, function() - children = meths.get_proc_children(ppid) + children = meths.nvim_get_proc_children(ppid) eq(3, #children) end) end -- Assert that nvim_get_proc() sees the children. for _, child_pid in ipairs(children) do - local info = meths.get_proc(child_pid) + local info = meths.nvim_get_proc(child_pid) -- eq((is_os('win') and 'nvim.exe' or 'nvim'), info.name) eq(ppid, info.ppid) end @@ -1093,7 +1093,7 @@ describe('jobs', function() -- Assert that the children were killed. retry(nil, nil, function() for _, child_pid in ipairs(children) do - eq(NIL, meths.get_proc(child_pid)) + eq(NIL, meths.nvim_get_proc(child_pid)) end end) end) @@ -1129,7 +1129,7 @@ describe('jobs', function() local j local function send(str) -- check no nvim_chan_free double free with pty job (#14198) - meths.chan_send(j, str) + meths.nvim_chan_send(j, str) end before_each(function() diff --git a/test/functional/core/spellfile_spec.lua b/test/functional/core/spellfile_spec.lua index 60cdf88fe3..0e2d71ef14 100644 --- a/test/functional/core/spellfile_spec.lua +++ b/test/functional/core/spellfile_spec.lua @@ -24,7 +24,7 @@ describe('spellfile', function() -- │ ┌ Spell file version (#VIMSPELLVERSION) local spellheader = 'VIMspell\050' it('errors out when prefcond section is truncated', function() - meths.set_option_value('runtimepath', testdir, {}) + meths.nvim_set_option_value('runtimepath', testdir, {}) -- stylua: ignore write_file(testdir .. '/spell/en.ascii.spl', -- ┌ Section identifier (#SN_PREFCOND) @@ -35,11 +35,11 @@ describe('spellfile', function() -- │ ┌ Condition length (1 byte) -- │ │ ┌ Condition regex (missing!) .. '\000\001\001') - meths.set_option_value('spelllang', 'en', {}) + meths.nvim_set_option_value('spelllang', 'en', {}) eq('Vim(set):E758: Truncated spell file', exc_exec('set spell')) end) it('errors out when prefcond regexp contains NUL byte', function() - meths.set_option_value('runtimepath', testdir, {}) + meths.nvim_set_option_value('runtimepath', testdir, {}) -- stylua: ignore write_file(testdir .. '/spell/en.ascii.spl', -- ┌ Section identifier (#SN_PREFCOND) @@ -55,11 +55,11 @@ describe('spellfile', function() -- │ ┌ KWORDTREE tree length (4 bytes) -- │ │ ┌ PREFIXTREE tree length .. '\000\000\000\000\000\000\000\000\000\000\000\000') - meths.set_option_value('spelllang', 'en', {}) + meths.nvim_set_option_value('spelllang', 'en', {}) eq('Vim(set):E759: Format error in spell file', exc_exec('set spell')) end) it('errors out when region contains NUL byte', function() - meths.set_option_value('runtimepath', testdir, {}) + meths.nvim_set_option_value('runtimepath', testdir, {}) -- stylua: ignore write_file(testdir .. '/spell/en.ascii.spl', -- ┌ Section identifier (#SN_REGION) @@ -72,11 +72,11 @@ describe('spellfile', function() -- │ ┌ KWORDTREE tree length (4 bytes) -- │ │ ┌ PREFIXTREE tree length .. '\000\000\000\000\000\000\000\000\000\000\000\000') - meths.set_option_value('spelllang', 'en', {}) + meths.nvim_set_option_value('spelllang', 'en', {}) eq('Vim(set):E759: Format error in spell file', exc_exec('set spell')) end) it('errors out when SAL section contains NUL byte', function() - meths.set_option_value('runtimepath', testdir, {}) + meths.nvim_set_option_value('runtimepath', testdir, {}) -- stylua: ignore write_file(testdir .. '/spell/en.ascii.spl', -- ┌ Section identifier (#SN_SAL) @@ -96,13 +96,13 @@ describe('spellfile', function() -- │ ┌ KWORDTREE tree length (4 bytes) -- │ │ ┌ PREFIXTREE tree length .. '\000\000\000\000\000\000\000\000\000\000\000\000') - meths.set_option_value('spelllang', 'en', {}) + meths.nvim_set_option_value('spelllang', 'en', {}) eq('Vim(set):E759: Format error in spell file', exc_exec('set spell')) end) it('errors out when spell header contains NUL bytes', function() - meths.set_option_value('runtimepath', testdir, {}) + meths.nvim_set_option_value('runtimepath', testdir, {}) write_file(testdir .. '/spell/en.ascii.spl', spellheader:sub(1, -3) .. '\000\000') - meths.set_option_value('spelllang', 'en', {}) + meths.nvim_set_option_value('spelllang', 'en', {}) eq('Vim(set):E757: This does not look like a spell file', exc_exec('set spell')) end) end) diff --git a/test/functional/core/startup_spec.lua b/test/functional/core/startup_spec.lua index 5d2da8f5e0..39d38a47a5 100644 --- a/test/functional/core/startup_spec.lua +++ b/test/functional/core/startup_spec.lua @@ -38,7 +38,7 @@ describe('startup', function() clear() ok( string.find( - alter_slashes(meths.get_option_value('runtimepath', {})), + alter_slashes(meths.nvim_get_option_value('runtimepath', {})), funcs.stdpath('config'), 1, true @@ -47,7 +47,7 @@ describe('startup', function() clear('--clean') ok( string.find( - alter_slashes(meths.get_option_value('runtimepath', {})), + alter_slashes(meths.nvim_get_option_value('runtimepath', {})), funcs.stdpath('config'), 1, true @@ -737,11 +737,11 @@ describe('startup', function() os.remove('Xdiff.vim') end) clear { args = { '-u', 'Xdiff.vim', '-d', 'Xdiff.vim', 'Xdiff.vim' } } - eq(true, meths.get_option_value('diff', { win = funcs.win_getid(1) })) - eq(true, meths.get_option_value('diff', { win = funcs.win_getid(2) })) + eq(true, meths.nvim_get_option_value('diff', { win = funcs.win_getid(1) })) + eq(true, meths.nvim_get_option_value('diff', { win = funcs.win_getid(2) })) local float_win = funcs.win_getid(3) - eq('editor', meths.win_get_config(float_win).relative) - eq(false, meths.get_option_value('diff', { win = float_win })) + eq('editor', meths.nvim_win_get_config(float_win).relative) + eq(false, meths.nvim_get_option_value('diff', { win = float_win })) end) it('does not crash if --embed is given twice', function() @@ -870,7 +870,7 @@ describe('startup', function() exec_lua [[ return _G.test_loadorder ]] ) - local rtp = meths.get_option_value('rtp', {}) + local rtp = meths.nvim_get_option_value('rtp', {}) ok( startswith( rtp, @@ -963,9 +963,9 @@ describe('startup', function() os.remove('Xtab2.noft') end) clear({ args = { '-p', 'Xtab1.noft', 'Xtab2.noft' } }) - eq(81, meths.win_get_width(0)) + eq(81, meths.nvim_win_get_width(0)) command('tabnext') - eq(81, meths.win_get_width(0)) + eq(81, meths.nvim_win_get_width(0)) end) end) diff --git a/test/functional/editor/K_spec.lua b/test/functional/editor/K_spec.lua index 1107de7984..bb7bcb7ca6 100644 --- a/test/functional/editor/K_spec.lua +++ b/test/functional/editor/K_spec.lua @@ -61,9 +61,9 @@ describe('K', function() end) it('empty string falls back to :help #19298', function() - meths.set_option_value('keywordprg', '', {}) - meths.buf_set_lines(0, 0, -1, true, { 'doesnotexist' }) + meths.nvim_set_option_value('keywordprg', '', {}) + meths.nvim_buf_set_lines(0, 0, -1, true, { 'doesnotexist' }) feed('K') - eq('E149: Sorry, no help for doesnotexist', meths.get_vvar('errmsg')) + eq('E149: Sorry, no help for doesnotexist', meths.nvim_get_vvar('errmsg')) end) end) diff --git a/test/functional/editor/completion_spec.lua b/test/functional/editor/completion_spec.lua index c13222bd7a..2e1d36202d 100644 --- a/test/functional/editor/completion_spec.lua +++ b/test/functional/editor/completion_spec.lua @@ -883,8 +883,8 @@ describe('completion', function() return '' endfunction ]]) - meths.set_option_value('completeopt', 'menuone,noselect', {}) - meths.set_var('_complist', { + meths.nvim_set_option_value('completeopt', 'menuone,noselect', {}) + meths.nvim_set_var('_complist', { { word = 0, abbr = 1, diff --git a/test/functional/editor/macro_spec.lua b/test/functional/editor/macro_spec.lua index 421bd3ebb8..ceaa01344c 100644 --- a/test/functional/editor/macro_spec.lua +++ b/test/functional/editor/macro_spec.lua @@ -139,7 +139,7 @@ describe('immediately after a macro has finished executing,', function() it('if the macro does not end with a <Nop> mapping', function() feed('@asq') -- "q" from "s" mapping should start recording a macro instead of being no-op - eq({ mode = 'n', blocking = false }, meths.get_mode()) + eq({ mode = 'n', blocking = false }, meths.nvim_get_mode()) expect('') eq('', eval('@a')) end) @@ -147,7 +147,7 @@ describe('immediately after a macro has finished executing,', function() it('if the macro ends with a <Nop> mapping', function() command('nnoremap 0 <Nop>') feed('@asq') -- "q" from "s" mapping should start recording a macro instead of being no-op - eq({ mode = 'n', blocking = false }, meths.get_mode()) + eq({ mode = 'n', blocking = false }, meths.nvim_get_mode()) expect('') eq('', eval('@a')) end) diff --git a/test/functional/editor/mark_spec.lua b/test/functional/editor/mark_spec.lua index 67d8cc58ad..266b5194ee 100644 --- a/test/functional/editor/mark_spec.lua +++ b/test/functional/editor/mark_spec.lua @@ -10,7 +10,7 @@ local feed = helpers.feed local write_file = helpers.write_file local pcall_err = helpers.pcall_err local cursor = function() - return helpers.meths.win_get_cursor(0) + return helpers.meths.nvim_win_get_cursor(0) end describe('named marks', function() @@ -105,7 +105,7 @@ describe('named marks', function() feed('mA') command('next') feed("'A") - eq(1, meths.get_current_buf().id) + eq(1, meths.nvim_get_current_buf().id) eq({ 2, 0 }, cursor()) end) @@ -118,7 +118,7 @@ describe('named marks', function() feed('mA') command('next') feed('`A') - eq(1, meths.get_current_buf().id) + eq(1, meths.nvim_get_current_buf().id) eq({ 2, 2 }, cursor()) end) @@ -131,7 +131,7 @@ describe('named marks', function() feed('mA') command('next') feed("g'A") - eq(1, meths.get_current_buf().id) + eq(1, meths.nvim_get_current_buf().id) eq({ 2, 0 }, cursor()) end) @@ -144,7 +144,7 @@ describe('named marks', function() feed('mA') command('next') feed('g`A') - eq(1, meths.get_current_buf().id) + eq(1, meths.nvim_get_current_buf().id) eq({ 2, 2 }, cursor()) end) @@ -158,7 +158,7 @@ describe('named marks', function() feed('mA') command('next') command("'A") - eq(1, meths.get_current_buf().id) + eq(1, meths.nvim_get_current_buf().id) eq({ 2, 0 }, cursor()) end) @@ -303,24 +303,24 @@ describe('named marks', function() end) it("getting '{ '} '( ') does not move cursor", function() - meths.buf_set_lines(0, 0, 0, true, { 'aaaaa', 'bbbbb', 'ccccc', 'ddddd', 'eeeee' }) - meths.win_set_cursor(0, { 2, 0 }) + meths.nvim_buf_set_lines(0, 0, 0, true, { 'aaaaa', 'bbbbb', 'ccccc', 'ddddd', 'eeeee' }) + meths.nvim_win_set_cursor(0, { 2, 0 }) funcs.getpos("'{") - eq({ 2, 0 }, meths.win_get_cursor(0)) + eq({ 2, 0 }, meths.nvim_win_get_cursor(0)) funcs.getpos("'}") - eq({ 2, 0 }, meths.win_get_cursor(0)) + eq({ 2, 0 }, meths.nvim_win_get_cursor(0)) funcs.getpos("'(") - eq({ 2, 0 }, meths.win_get_cursor(0)) + eq({ 2, 0 }, meths.nvim_win_get_cursor(0)) funcs.getpos("')") - eq({ 2, 0 }, meths.win_get_cursor(0)) + eq({ 2, 0 }, meths.nvim_win_get_cursor(0)) end) it('in command range does not move cursor #19248', function() - meths.create_user_command('Test', ':', { range = true }) - meths.buf_set_lines(0, 0, 0, true, { 'aaaaa', 'bbbbb', 'ccccc', 'ddddd', 'eeeee' }) - meths.win_set_cursor(0, { 2, 0 }) + meths.nvim_create_user_command('Test', ':', { range = true }) + meths.nvim_buf_set_lines(0, 0, 0, true, { 'aaaaa', 'bbbbb', 'ccccc', 'ddddd', 'eeeee' }) + meths.nvim_win_set_cursor(0, { 2, 0 }) command([['{,'}Test]]) - eq({ 2, 0 }, meths.win_get_cursor(0)) + eq({ 2, 0 }, meths.nvim_win_get_cursor(0)) end) end) diff --git a/test/functional/editor/mode_cmdline_spec.lua b/test/functional/editor/mode_cmdline_spec.lua index d36db80bdf..2aa4542cb7 100644 --- a/test/functional/editor/mode_cmdline_spec.lua +++ b/test/functional/editor/mode_cmdline_spec.lua @@ -85,7 +85,7 @@ describe('cmdline', function() it('correctly clears end of the history', function() -- Regression test: check absence of the memory leak when clearing end of -- the history using cmdhist.c/clr_history(). - meths.set_option_value('history', 1, {}) + meths.nvim_set_option_value('history', 1, {}) eq(1, funcs.histadd(':', 'foo')) eq(1, funcs.histdel(':')) eq('', funcs.histget(':', -1)) diff --git a/test/functional/editor/tabpage_spec.lua b/test/functional/editor/tabpage_spec.lua index f632bbb40f..790340193f 100644 --- a/test/functional/editor/tabpage_spec.lua +++ b/test/functional/editor/tabpage_spec.lua @@ -74,28 +74,28 @@ describe('tabpage', function() end) it('nvim_win_close and nvim_win_hide update tabline #20285', function() - eq(1, #meths.list_tabpages()) + eq(1, #meths.nvim_list_tabpages()) eq({ 1, 1 }, funcs.win_screenpos(0)) local win1 = curwin().id command('tabnew') - eq(2, #meths.list_tabpages()) + eq(2, #meths.nvim_list_tabpages()) eq({ 2, 1 }, funcs.win_screenpos(0)) local win2 = curwin().id - meths.win_close(win1, true) + meths.nvim_win_close(win1, true) eq(win2, curwin().id) - eq(1, #meths.list_tabpages()) + eq(1, #meths.nvim_list_tabpages()) eq({ 1, 1 }, funcs.win_screenpos(0)) command('tabnew') - eq(2, #meths.list_tabpages()) + eq(2, #meths.nvim_list_tabpages()) eq({ 2, 1 }, funcs.win_screenpos(0)) local win3 = curwin().id - meths.win_hide(win2) + meths.nvim_win_hide(win2) eq(win3, curwin().id) - eq(1, #meths.list_tabpages()) + eq(1, #meths.nvim_list_tabpages()) eq({ 1, 1 }, funcs.win_screenpos(0)) end) @@ -143,7 +143,7 @@ describe('tabpage', function() end) it(':tabs does not overflow IObuff with long path with comma #20850', function() - meths.buf_set_name(0, ('x'):rep(1024) .. ',' .. ('x'):rep(1024)) + meths.nvim_buf_set_name(0, ('x'):rep(1024) .. ',' .. ('x'):rep(1024)) command('tabs') assert_alive() end) diff --git a/test/functional/ex_cmds/append_spec.lua b/test/functional/ex_cmds/append_spec.lua index b3c0584568..4bd323a763 100644 --- a/test/functional/ex_cmds/append_spec.lua +++ b/test/functional/ex_cmds/append_spec.lua @@ -42,7 +42,7 @@ local cmdtest = function(cmd, prep, ret1) eq(hisline, funcs.histget(':', -2)) eq(cmd, funcs.histget(':')) -- Test that command-line window was launched - eq('nofile', meths.get_option_value('buftype', {})) + eq('nofile', meths.nvim_get_option_value('buftype', {})) eq('n', funcs.mode(1)) feed('<CR>') eq('c', funcs.mode(1)) diff --git a/test/functional/ex_cmds/echo_spec.lua b/test/functional/ex_cmds/echo_spec.lua index 87bc15ceca..bfc8f57632 100644 --- a/test/functional/ex_cmds/echo_spec.lua +++ b/test/functional/ex_cmds/echo_spec.lua @@ -223,7 +223,7 @@ describe(':echo :echon :echomsg :echoerr', function() end) it('does not crash or halt when dumping partials with reference cycles in self', function() - meths.set_var('d', { v = true }) + meths.nvim_set_var('d', { v = true }) eq( dedent( [[ @@ -251,7 +251,7 @@ describe(':echo :echon :echomsg :echoerr', function() end) it('does not crash or halt when dumping partials with reference cycles in arguments', function() - meths.set_var('l', {}) + meths.nvim_set_var('l', {}) eval('add(l, l)') -- Regression: the below line used to crash (add returns original list and -- there was error in dumping partials). Tested explicitly in @@ -269,8 +269,8 @@ describe(':echo :echon :echomsg :echoerr', function() it( 'does not crash or halt when dumping partials with reference cycles in self and arguments', function() - meths.set_var('d', { v = true }) - meths.set_var('l', {}) + meths.nvim_set_var('d', { v = true }) + meths.nvim_set_var('l', {}) eval('add(l, l)') eval('add(l, function("Test1", l))') eval('add(l, function("Test1", d))') @@ -305,13 +305,13 @@ describe(':echo :echon :echomsg :echoerr', function() end) it('does not error when dumping recursive lists', function() - meths.set_var('l', {}) + meths.nvim_set_var('l', {}) eval('add(l, l)') eq(0, exc_exec('echo String(l)')) end) it('dumps recursive lists without error', function() - meths.set_var('l', {}) + meths.nvim_set_var('l', {}) eval('add(l, l)') eq('[[...@0]]', exec_capture('echo String(l)')) eq('[[[...@1]]]', exec_capture('echo String([l])')) @@ -335,13 +335,13 @@ describe(':echo :echon :echomsg :echoerr', function() end) it('does not error when dumping recursive dictionaries', function() - meths.set_var('d', { d = 1 }) + meths.nvim_set_var('d', { d = 1 }) eval('extend(d, {"d": d})') eq(0, exc_exec('echo String(d)')) end) it('dumps recursive dictionaries without the error', function() - meths.set_var('d', { d = 1 }) + meths.nvim_set_var('d', { d = 1 }) eval('extend(d, {"d": d})') eq("{'d': {...@0}}", exec_capture('echo String(d)')) eq("{'out': {'d': {...@1}}}", exec_capture('echo String({"out": d})')) diff --git a/test/functional/ex_cmds/help_spec.lua b/test/functional/ex_cmds/help_spec.lua index aca0cbbaa6..de79fadd6d 100644 --- a/test/functional/ex_cmds/help_spec.lua +++ b/test/functional/ex_cmds/help_spec.lua @@ -40,6 +40,6 @@ describe(':help', function() command('helptags Xhelptags/doc') command('set rtp+=Xhelptags') command('help …') - eq('*…*', meths.get_current_line()) + eq('*…*', meths.nvim_get_current_line()) end) end) diff --git a/test/functional/ex_cmds/highlight_spec.lua b/test/functional/ex_cmds/highlight_spec.lua index 6aac8c2e3a..f572728b4d 100644 --- a/test/functional/ex_cmds/highlight_spec.lua +++ b/test/functional/ex_cmds/highlight_spec.lua @@ -53,11 +53,11 @@ describe(':highlight', function() end) it('clear', function() - meths.set_var('colors_name', 'foo') + meths.nvim_set_var('colors_name', 'foo') eq(1, funcs.exists('g:colors_name')) command('hi clear') eq(0, funcs.exists('g:colors_name')) - meths.set_var('colors_name', 'foo') + meths.nvim_set_var('colors_name', 'foo') eq(1, funcs.exists('g:colors_name')) exec([[ func HiClear() diff --git a/test/functional/ex_cmds/map_spec.lua b/test/functional/ex_cmds/map_spec.lua index 934dac6a2d..16df6f58b5 100644 --- a/test/functional/ex_cmds/map_spec.lua +++ b/test/functional/ex_cmds/map_spec.lua @@ -16,13 +16,13 @@ describe(':*map', function() before_each(clear) it('are not affected by &isident', function() - meths.set_var('counter', 0) + meths.nvim_set_var('counter', 0) command('nnoremap <C-x> :let counter+=1<CR>') - meths.set_option_value('isident', ('%u'):format(('>'):byte()), {}) + meths.nvim_set_option_value('isident', ('%u'):format(('>'):byte()), {}) command('nnoremap <C-y> :let counter+=1<CR>') -- &isident used to disable keycode parsing here as well feed('\24\25<C-x><C-y>') - eq(4, meths.get_var('counter')) + eq(4, meths.nvim_get_var('counter')) end) it(':imap <M-">', function() @@ -42,9 +42,9 @@ n asdf <Nop>]], end) it('mappings with description can be filtered', function() - meths.set_keymap('n', 'asdf1', 'qwert', { desc = 'do the one thing' }) - meths.set_keymap('n', 'asdf2', 'qwert', { desc = 'doesnot really do anything' }) - meths.set_keymap('n', 'asdf3', 'qwert', { desc = 'do the other thing' }) + meths.nvim_set_keymap('n', 'asdf1', 'qwert', { desc = 'do the one thing' }) + meths.nvim_set_keymap('n', 'asdf2', 'qwert', { desc = 'doesnot really do anything' }) + meths.nvim_set_keymap('n', 'asdf3', 'qwert', { desc = 'do the other thing' }) eq( [[ @@ -58,21 +58,21 @@ n asdf1 qwert it('<Plug> mappings ignore nore', function() command('let x = 0') - eq(0, meths.eval('x')) + eq(0, meths.nvim_eval('x')) command [[ nnoremap <Plug>(Increase_x) <cmd>let x+=1<cr> nmap increase_x_remap <Plug>(Increase_x) nnoremap increase_x_noremap <Plug>(Increase_x) ]] feed('increase_x_remap') - eq(1, meths.eval('x')) + eq(1, meths.nvim_eval('x')) feed('increase_x_noremap') - eq(2, meths.eval('x')) + eq(2, meths.nvim_eval('x')) end) it("Doesn't auto ignore nore for keys before or after <Plug> mapping", function() command('let x = 0') - eq(0, meths.eval('x')) + eq(0, meths.nvim_eval('x')) command [[ nnoremap x <nop> nnoremap <Plug>(Increase_x) <cmd>let x+=1<cr> @@ -83,10 +83,10 @@ n asdf1 qwert eq('Some text', eval("getline('.')")) feed('increase_x_remap') - eq(1, meths.eval('x')) + eq(1, meths.nvim_eval('x')) eq('Some text', eval("getline('.')")) feed('increase_x_noremap') - eq(2, meths.eval('x')) + eq(2, meths.nvim_eval('x')) eq('Some te', eval("getline('.')")) end) diff --git a/test/functional/ex_cmds/mksession_spec.lua b/test/functional/ex_cmds/mksession_spec.lua index cc3a81f7dd..2a62bff6e9 100644 --- a/test/functional/ex_cmds/mksession_spec.lua +++ b/test/functional/ex_cmds/mksession_spec.lua @@ -70,7 +70,7 @@ describe(':mksession', function() -- Restore session. command('source ' .. session_file) - eq(expected_buf_count, #meths.list_bufs()) + eq(expected_buf_count, #meths.nvim_list_bufs()) end it( @@ -80,28 +80,28 @@ describe(':mksession', function() command('edit ' .. tmpfile_base) command('terminal') - local buf_count = #meths.list_bufs() + local buf_count = #meths.nvim_list_bufs() eq(2, buf_count) - eq('terminal', meths.get_option_value('buftype', {})) + eq('terminal', meths.nvim_get_option_value('buftype', {})) test_terminal_session_disabled(2) -- no terminal should be set. As a side effect we end up with a blank buffer - eq('', meths.get_option_value('buftype', { buf = meths.list_bufs()[1] })) - eq('', meths.get_option_value('buftype', { buf = meths.list_bufs()[2] })) + eq('', meths.nvim_get_option_value('buftype', { buf = meths.nvim_list_bufs()[1] })) + eq('', meths.nvim_get_option_value('buftype', { buf = meths.nvim_list_bufs()[2] })) end ) it('do not restore :terminal if not set in sessionoptions, terminal hidden #13078', function() command('terminal') - local terminal_bufnr = meths.get_current_buf() + local terminal_bufnr = meths.nvim_get_current_buf() local tmpfile_base = file_prefix .. '-tmpfile' -- make terminal hidden by opening a new file command('edit ' .. tmpfile_base .. '1') - local buf_count = #meths.list_bufs() + local buf_count = #meths.nvim_list_bufs() eq(2, buf_count) eq(1, funcs.getbufinfo(terminal_bufnr)[1].hidden) @@ -109,20 +109,20 @@ describe(':mksession', function() test_terminal_session_disabled(1) -- no terminal should exist here - neq('', meths.buf_get_name(meths.list_bufs()[1])) + neq('', meths.nvim_buf_get_name(meths.nvim_list_bufs()[1])) end) it('do not restore :terminal if not set in sessionoptions, only buffer #13078', function() command('terminal') - eq('terminal', meths.get_option_value('buftype', {})) + eq('terminal', meths.nvim_get_option_value('buftype', {})) - local buf_count = #meths.list_bufs() + local buf_count = #meths.nvim_list_bufs() eq(1, buf_count) test_terminal_session_disabled(1) -- no terminal should be set - eq('', meths.get_option_value('buftype', {})) + eq('', meths.nvim_get_option_value('buftype', {})) end) it('restores tab-local working directories', function() @@ -238,7 +238,7 @@ describe(':mksession', function() local tmpfile = file_prefix .. '-tmpfile-float' command('edit ' .. tmpfile) - local buf = meths.create_buf(false, true) + local buf = meths.nvim_create_buf(false, true) local config = { relative = 'editor', focusable = false, @@ -248,8 +248,8 @@ describe(':mksession', function() col = 1, style = 'minimal', } - meths.open_win(buf, false, config) - local cmdheight = meths.get_option_value('cmdheight', {}) + meths.nvim_open_win(buf, false, config) + local cmdheight = meths.nvim_get_option_value('cmdheight', {}) command('mksession ' .. session_file) -- Create a new test instance of Nvim. @@ -262,7 +262,7 @@ describe(':mksession', function() -- window was not restored. eq(1, funcs.winnr('$')) -- The command-line height should remain the same as it was. - eq(cmdheight, meths.get_option_value('cmdheight', {})) + eq(cmdheight, meths.nvim_get_option_value('cmdheight', {})) os.remove(tmpfile) end) diff --git a/test/functional/ex_cmds/oldfiles_spec.lua b/test/functional/ex_cmds/oldfiles_spec.lua index 11bebb3793..8330395ed1 100644 --- a/test/functional/ex_cmds/oldfiles_spec.lua +++ b/test/functional/ex_cmds/oldfiles_spec.lua @@ -42,7 +42,7 @@ describe(':oldfiles', function() feed_command('edit testfile2') feed_command('wshada') feed_command('rshada!') - local oldfiles = helpers.meths.get_vvar('oldfiles') + local oldfiles = helpers.meths.nvim_get_vvar('oldfiles') feed_command('oldfiles') screen:expect([[ | @@ -108,7 +108,7 @@ describe(':browse oldfiles', function() -- Ensure v:oldfiles isn't busted. Since things happen so fast, -- the ordering of v:oldfiles is unstable (it uses qsort() under-the-hood). -- Let's verify the contents and the length of v:oldfiles before moving on. - oldfiles = helpers.meths.get_vvar('oldfiles') + oldfiles = helpers.meths.nvim_get_vvar('oldfiles') eq(2, #oldfiles) ok(filename == oldfiles[1] or filename == oldfiles[2]) ok(filename2 == oldfiles[1] or filename2 == oldfiles[2]) diff --git a/test/functional/ex_cmds/script_spec.lua b/test/functional/ex_cmds/script_spec.lua index 465397169a..20fd65fc69 100644 --- a/test/functional/ex_cmds/script_spec.lua +++ b/test/functional/ex_cmds/script_spec.lua @@ -83,7 +83,7 @@ describe('script_get-based command', function() ]])):format(cmd, garbage) ) ) - neq(0, meths.get_var('exc')) + neq(0, meths.nvim_get_var('exc')) end end) end) diff --git a/test/functional/ex_cmds/source_spec.lua b/test/functional/ex_cmds/source_spec.lua index e822fe78b8..765f5d4b05 100644 --- a/test/functional/ex_cmds/source_spec.lua +++ b/test/functional/ex_cmds/source_spec.lua @@ -49,7 +49,7 @@ describe(':source', function() pending("'shellslash' only works on Windows") return end - meths.set_option_value('shellslash', false, {}) + meths.nvim_set_option_value('shellslash', false, {}) mkdir('Xshellslash') write_file( @@ -65,9 +65,9 @@ describe(':source', function() for _ = 1, 2 do command([[source Xshellslash/Xstack.vim]]) - matches([[Xshellslash\Xstack%.vim]], meths.get_var('stack1')) - matches([[Xshellslash/Xstack%.vim]], meths.get_var('stack2')) - matches([[Xshellslash\Xstack%.vim]], meths.get_var('stack3')) + matches([[Xshellslash\Xstack%.vim]], meths.nvim_get_var('stack1')) + matches([[Xshellslash/Xstack%.vim]], meths.nvim_get_var('stack2')) + matches([[Xshellslash\Xstack%.vim]], meths.nvim_get_var('stack3')) end write_file( @@ -83,9 +83,9 @@ describe(':source', function() for _ = 1, 2 do command([[source Xshellslash/Xstack.lua]]) - matches([[Xshellslash\Xstack%.lua]], meths.get_var('stack1')) - matches([[Xshellslash/Xstack%.lua]], meths.get_var('stack2')) - matches([[Xshellslash\Xstack%.lua]], meths.get_var('stack3')) + matches([[Xshellslash\Xstack%.lua]], meths.nvim_get_var('stack1')) + matches([[Xshellslash/Xstack%.lua]], meths.nvim_get_var('stack2')) + matches([[Xshellslash\Xstack%.lua]], meths.nvim_get_var('stack3')) end rmdir('Xshellslash') @@ -182,9 +182,9 @@ describe(':source', function() command('set shellslash') command('source ' .. test_file) eq(1, eval('g:sourced_lua')) - matches([[/test%.lua$]], meths.get_var('sfile_value')) - matches([[/test%.lua$]], meths.get_var('stack_value')) - matches([[/test%.lua$]], meths.get_var('script_value')) + matches([[/test%.lua$]], meths.nvim_get_var('sfile_value')) + matches([[/test%.lua$]], meths.nvim_get_var('stack_value')) + matches([[/test%.lua$]], meths.nvim_get_var('script_value')) os.remove(test_file) end) @@ -229,9 +229,9 @@ describe(':source', function() eq(12, eval('g:c')) eq(' \\ 1\n "\\ 2', exec_lua('return _G.a')) - eq(':source (no file)', meths.get_var('sfile_value')) - eq(':source (no file)', meths.get_var('stack_value')) - eq(':source (no file)', meths.get_var('script_value')) + eq(':source (no file)', meths.nvim_get_var('sfile_value')) + eq(':source (no file)', meths.nvim_get_var('stack_value')) + eq(':source (no file)', meths.nvim_get_var('script_value')) end) end diff --git a/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua b/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua index 105b488f69..99191a2a57 100644 --- a/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua +++ b/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua @@ -438,7 +438,7 @@ describe('quitting swapfile dialog on startup stops TUI properly', function() feed('Gisometext<esc>') poke_eventloop() clear() -- Leaves a swap file behind - meths.ui_attach(80, 30, {}) + meths.nvim_ui_attach(80, 30, {}) end) after_each(function() rmdir(swapdir) @@ -459,7 +459,7 @@ describe('quitting swapfile dialog on startup stops TUI properly', function() eval("getline('$')->trim(' ', 2)") ) end) - meths.chan_send(chan, 'q') + meths.nvim_chan_send(chan, 'q') retry(nil, nil, function() eq( { '', '[Process exited 1]', '' }, @@ -491,7 +491,7 @@ describe('quitting swapfile dialog on startup stops TUI properly', function() eval("getline('$')->trim(' ', 2)") ) end) - meths.chan_send(chan, 'a') + meths.nvim_chan_send(chan, 'a') retry(nil, nil, function() eq( { '', '[Process exited 1]', '' }, @@ -531,11 +531,11 @@ describe('quitting swapfile dialog on startup stops TUI properly', function() eval("getline('$')->trim(' ', 2)") ) end) - meths.chan_send(chan, 'q') + meths.nvim_chan_send(chan, 'q') retry(nil, nil, function() eq('Press ENTER or type command to continue', eval("getline('$')->trim(' ', 2)")) end) - meths.chan_send(chan, '\r') + meths.nvim_chan_send(chan, '\r') retry(nil, nil, function() eq( { '', '[Process exited 1]', '' }, diff --git a/test/functional/ex_cmds/verbose_spec.lua b/test/functional/ex_cmds/verbose_spec.lua index 17f13e0090..dbc81cf5d8 100644 --- a/test/functional/ex_cmds/verbose_spec.lua +++ b/test/functional/ex_cmds/verbose_spec.lua @@ -5,7 +5,7 @@ local eq = helpers.eq local exec = helpers.exec local exec_capture = helpers.exec_capture local write_file = helpers.write_file -local call_viml_function = helpers.meths.call_function +local call_viml_function = helpers.meths.nvim_call_function local function last_set_tests(cmd) local script_location, script_file diff --git a/test/functional/ex_cmds/write_spec.lua b/test/functional/ex_cmds/write_spec.lua index a363578ce6..403e3426f9 100644 --- a/test/functional/ex_cmds/write_spec.lua +++ b/test/functional/ex_cmds/write_spec.lua @@ -133,17 +133,17 @@ describe(':write', function() pcall_err(command, 'write .') ) end - meths.set_option_value('writeany', true, {}) + meths.nvim_set_option_value('writeany', true, {}) -- Message from buf_write eq('Vim(write):E502: "." is a directory', pcall_err(command, 'write .')) funcs.mkdir(fname_bak) - meths.set_option_value('backupdir', '.', {}) - meths.set_option_value('backup', true, {}) + meths.nvim_set_option_value('backupdir', '.', {}) + meths.nvim_set_option_value('backup', true, {}) write_file(fname, 'content0') command('edit ' .. fname) funcs.setline(1, 'TTY') eq("Vim(write):E510: Can't make backup file (add ! to override)", pcall_err(command, 'write')) - meths.set_option_value('backup', false, {}) + meths.nvim_set_option_value('backup', false, {}) funcs.setfperm(fname, 'r--------') eq( 'Vim(write):E505: "Xtest-functional-ex_cmds-write" is read-only (add ! to override)', diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua index a31d2d5b44..dff4a7f13c 100644 --- a/test/functional/helpers.lua +++ b/test/functional/helpers.lua @@ -631,6 +631,9 @@ module.uimeths = module.create_callindex(ui) local function create_api(request, call) local m = {} function m.nvim(method, ...) + if vim.startswith(method, 'nvim_') then + return request(method, ...) + end return request('nvim_' .. method, ...) end @@ -700,6 +703,9 @@ module.describe_lua_and_rpc = function(describe) end end +--- add for typing. The for loop after will overwrite this +module.meths = vim.api + for name, fn in pairs(module.rpc.api) do module[name] = fn end @@ -862,11 +868,11 @@ function module.skip_fragile(pending_fn, cond) end function module.exec(code) - module.meths.exec2(code, {}) + module.meths.nvim_exec2(code, {}) end function module.exec_capture(code) - return module.meths.exec2(code, { output = true }).output + return module.meths.nvim_exec2(code, { output = true }).output end --- @param code string diff --git a/test/functional/legacy/012_directory_spec.lua b/test/functional/legacy/012_directory_spec.lua index 8f0abc471a..368ab382c0 100644 --- a/test/functional/legacy/012_directory_spec.lua +++ b/test/functional/legacy/012_directory_spec.lua @@ -56,9 +56,9 @@ describe("'directory' option", function() line 3 Abcdefghij end of testfile]]) - meths.set_option_value('swapfile', true, {}) - meths.set_option_value('swapfile', true, {}) - meths.set_option_value('directory', '.', {}) + meths.nvim_set_option_value('swapfile', true, {}) + meths.nvim_set_option_value('swapfile', true, {}) + meths.nvim_set_option_value('directory', '.', {}) -- sanity check: files should not exist yet. eq(nil, vim.uv.fs_stat('.Xtest1.swp')) @@ -70,7 +70,7 @@ describe("'directory' option", function() -- reading the output from :!ls. neq(nil, vim.uv.fs_stat('.Xtest1.swp')) - meths.set_option_value('directory', './Xtest2,.', {}) + meths.nvim_set_option_value('directory', './Xtest2,.', {}) command('edit Xtest1') poke_eventloop() @@ -79,10 +79,10 @@ describe("'directory' option", function() eq({ 'Xtest1.swp', 'Xtest3' }, ls_dir_sorted('Xtest2')) - meths.set_option_value('directory', 'Xtest.je', {}) + meths.nvim_set_option_value('directory', 'Xtest.je', {}) command('bdelete') command('edit Xtest2/Xtest3') - eq(true, meths.get_option_value('swapfile', {})) + eq(true, meths.nvim_get_option_value('swapfile', {})) poke_eventloop() eq({ 'Xtest3' }, ls_dir_sorted('Xtest2')) diff --git a/test/functional/legacy/039_visual_block_mode_commands_spec.lua b/test/functional/legacy/039_visual_block_mode_commands_spec.lua index ae2cc1abbe..5387883570 100644 --- a/test/functional/legacy/039_visual_block_mode_commands_spec.lua +++ b/test/functional/legacy/039_visual_block_mode_commands_spec.lua @@ -204,7 +204,7 @@ describe('Visual block mode', function() feed('G2l') feed('2k<C-v>$gj<ESC>') feed_command([[let cpos=getpos("'>")]]) - local cpos = nvim.get_var('cpos') + local cpos = nvim.nvim_get_var('cpos') local expected = { col = 4, off = 0, diff --git a/test/functional/legacy/assert_spec.lua b/test/functional/legacy/assert_spec.lua index 006f71aa4f..038bdd48f2 100644 --- a/test/functional/legacy/assert_spec.lua +++ b/test/functional/legacy/assert_spec.lua @@ -6,11 +6,11 @@ local exc_exec = helpers.exc_exec local eval = helpers.eval local function expected_errors(errors) - eq(errors, nvim.get_vvar('errors')) + eq(errors, nvim.nvim_get_vvar('errors')) end local function expected_empty() - eq({}, nvim.get_vvar('errors')) + eq({}, nvim.nvim_get_vvar('errors')) end describe('assert function:', function() diff --git a/test/functional/legacy/autochdir_spec.lua b/test/functional/legacy/autochdir_spec.lua index c6517a20aa..aca7ba9b39 100644 --- a/test/functional/legacy/autochdir_spec.lua +++ b/test/functional/legacy/autochdir_spec.lua @@ -5,7 +5,7 @@ local source, exec_capture = helpers.source, helpers.exec_capture local mkdir = helpers.mkdir local function expected_empty() - eq({}, meths.get_vvar('errors')) + eq({}, meths.nvim_get_vvar('errors')) end describe('autochdir behavior', function() diff --git a/test/functional/legacy/autocmd_option_spec.lua b/test/functional/legacy/autocmd_option_spec.lua index 88618aeb2c..4143a3159b 100644 --- a/test/functional/legacy/autocmd_option_spec.lua +++ b/test/functional/legacy/autocmd_option_spec.lua @@ -38,7 +38,7 @@ local function init_var() end local function get_result() - local ret = nvim.get_var('ret') + local ret = nvim.nvim_get_var('ret') init_var() return ret end @@ -696,24 +696,24 @@ describe('au OptionSet', function() it('should trigger if a boolean option be set globally', function() set_hook('autochdir') - nvim.set_option_value('autochdir', true, { scope = 'global' }) - eq(true, nvim.get_option_value('autochdir', { scope = 'global' })) + nvim.nvim_set_option_value('autochdir', true, { scope = 'global' }) + eq(true, nvim.nvim_get_option_value('autochdir', { scope = 'global' })) expected_combination({ 'autochdir', false, '', false, true, 'global', 'setglobal' }) end) it('should trigger if a number option be set globally', function() set_hook('cmdheight') - nvim.set_option_value('cmdheight', 5, { scope = 'global' }) - eq(5, nvim.get_option_value('cmdheight', { scope = 'global' })) + nvim.nvim_set_option_value('cmdheight', 5, { scope = 'global' }) + eq(5, nvim.nvim_get_option_value('cmdheight', { scope = 'global' })) expected_combination({ 'cmdheight', 1, '', 1, 5, 'global', 'setglobal' }) end) it('should trigger if a string option be set globally', function() set_hook('ambiwidth') - nvim.set_option_value('ambiwidth', 'double', { scope = 'global' }) - eq('double', nvim.get_option_value('ambiwidth', { scope = 'global' })) + nvim.nvim_set_option_value('ambiwidth', 'double', { scope = 'global' }) + eq('double', nvim.nvim_get_option_value('ambiwidth', { scope = 'global' })) expected_combination({ 'ambiwidth', 'single', diff --git a/test/functional/legacy/buffer_spec.lua b/test/functional/legacy/buffer_spec.lua index 1e8909f0d0..605cd72bf6 100644 --- a/test/functional/legacy/buffer_spec.lua +++ b/test/functional/legacy/buffer_spec.lua @@ -3,14 +3,14 @@ local clear, source = helpers.clear, helpers.source local call, eq, meths = helpers.call, helpers.eq, helpers.meths local function expected_empty() - eq({}, meths.get_vvar('errors')) + eq({}, meths.nvim_get_vvar('errors')) end describe('buffer', function() before_each(function() clear() - meths.ui_attach(80, 24, {}) - meths.set_option_value('hidden', false, {}) + meths.nvim_ui_attach(80, 24, {}) + meths.nvim_set_option_value('hidden', false, {}) end) it('deleting a modified buffer with :confirm', function() diff --git a/test/functional/legacy/cmdline_spec.lua b/test/functional/legacy/cmdline_spec.lua index 8e2ef2aabd..ea6d8409ba 100644 --- a/test/functional/legacy/cmdline_spec.lua +++ b/test/functional/legacy/cmdline_spec.lua @@ -198,9 +198,9 @@ describe('cmdline', function() [3] = { reverse = true }, -- TabLineFill }) screen:attach() - meths.set_option_value('laststatus', 2, {}) - meths.set_option_value('showtabline', 2, {}) - meths.set_option_value('cmdheight', 1, {}) + meths.nvim_set_option_value('laststatus', 2, {}) + meths.nvim_set_option_value('showtabline', 2, {}) + meths.nvim_set_option_value('cmdheight', 1, {}) screen:expect([[ {2: [No Name] }{3: }| ^ | @@ -217,10 +217,10 @@ describe('cmdline', function() [0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText } screen:attach() - meths.set_option_value('ruler', true, {}) - meths.set_option_value('rulerformat', 'longish', {}) - meths.set_option_value('laststatus', 0, {}) - meths.set_option_value('winwidth', 1, {}) + meths.nvim_set_option_value('ruler', true, {}) + meths.nvim_set_option_value('rulerformat', 'longish', {}) + meths.nvim_set_option_value('laststatus', 0, {}) + meths.nvim_set_option_value('winwidth', 1, {}) feed [[<C-W>v<C-W>|<C-W>p]] screen:expect [[ │^ | diff --git a/test/functional/legacy/ex_mode_spec.lua b/test/functional/legacy/ex_mode_spec.lua index 90abf9ebd7..85057938e3 100644 --- a/test/functional/legacy/ex_mode_spec.lua +++ b/test/functional/legacy/ex_mode_spec.lua @@ -16,7 +16,7 @@ describe('Ex mode', function() feed('gQ' .. cmd .. '<C-b>"<CR>') local ret = eval('@:[1:]') -- Remove leading quote. feed('visual<CR>') - eq(meths.replace_termcodes(expected, true, true, true), ret) + eq(meths.nvim_replace_termcodes(expected, true, true, true), ret) end command('set sw=2') test_ex_edit('bar', 'foo bar<C-u>bar') diff --git a/test/functional/legacy/excmd_spec.lua b/test/functional/legacy/excmd_spec.lua index ba41a983e2..160be8acd1 100644 --- a/test/functional/legacy/excmd_spec.lua +++ b/test/functional/legacy/excmd_spec.lua @@ -24,7 +24,7 @@ end describe('Ex command', function() before_each(clear) after_each(function() - eq({}, meths.get_vvar('errors')) + eq({}, meths.nvim_get_vvar('errors')) end) it('checks for address line overflow', function() diff --git a/test/functional/legacy/filechanged_spec.lua b/test/functional/legacy/filechanged_spec.lua index c8e772f597..0a088772a5 100644 --- a/test/functional/legacy/filechanged_spec.lua +++ b/test/functional/legacy/filechanged_spec.lua @@ -5,15 +5,15 @@ local is_os = helpers.is_os local skip = helpers.skip local function expected_empty() - eq({}, meths.get_vvar('errors')) + eq({}, meths.nvim_get_vvar('errors')) end describe('file changed dialog', function() before_each(function() clear() - meths.ui_attach(80, 24, {}) - meths.set_option_value('autoread', false, {}) - meths.set_option_value('fsync', true, {}) + meths.nvim_ui_attach(80, 24, {}) + meths.nvim_set_option_value('autoread', false, {}) + meths.nvim_set_option_value('fsync', true, {}) end) it('works', function() diff --git a/test/functional/legacy/fnamemodify_spec.lua b/test/functional/legacy/fnamemodify_spec.lua index 6262db3a2f..c6beb6d7df 100644 --- a/test/functional/legacy/fnamemodify_spec.lua +++ b/test/functional/legacy/fnamemodify_spec.lua @@ -5,7 +5,7 @@ local clear, source = helpers.clear, helpers.source local call, eq, nvim = helpers.call, helpers.eq, helpers.meths local function expected_empty() - eq({}, nvim.get_vvar('errors')) + eq({}, nvim.nvim_get_vvar('errors')) end describe('filename modifiers', function() diff --git a/test/functional/legacy/increment_spec.lua b/test/functional/legacy/increment_spec.lua index 212ad041c0..9e19841375 100644 --- a/test/functional/legacy/increment_spec.lua +++ b/test/functional/legacy/increment_spec.lua @@ -743,18 +743,18 @@ describe('Ctrl-A/Ctrl-X on visual selections', function() it('works on Test ' .. id, function() command('set nrformats&vi') -- &vi makes Vim compatible call('Test_visual_increment_' .. id) - eq({}, nvim.get_vvar('errors')) + eq({}, nvim.nvim_get_vvar('errors')) end) end it('does not drop leading zeroes', function() command('set nrformats&vi') -- &vi makes Vim compatible call('Test_normal_increment_01') - eq({}, nvim.get_vvar('errors')) + eq({}, nvim.nvim_get_vvar('errors')) end) it('maintains correct column after CTRL-A', function() call('Test_normal_increment_02') - eq({}, nvim.get_vvar('errors')) + eq({}, nvim.nvim_get_vvar('errors')) end) end) diff --git a/test/functional/legacy/mapping_spec.lua b/test/functional/legacy/mapping_spec.lua index 46c9a869ac..7058e70c4f 100644 --- a/test/functional/legacy/mapping_spec.lua +++ b/test/functional/legacy/mapping_spec.lua @@ -134,9 +134,9 @@ describe('mapping', function() command('nnoremap <LeftDrag> <LeftDrag><Cmd><CR>') poke_eventloop() - meths.input_mouse('left', 'press', '', 0, 0, 0) + meths.nvim_input_mouse('left', 'press', '', 0, 0, 0) poke_eventloop() - meths.input_mouse('left', 'drag', '', 0, 0, 1) + meths.nvim_input_mouse('left', 'drag', '', 0, 0, 1) poke_eventloop() eq('s', eval('mode()')) end) @@ -147,9 +147,9 @@ describe('mapping', function() command('inoremap <LeftDrag> <LeftDrag><Cmd>let g:dragged = 1<CR>') feed('i') poke_eventloop() - meths.input_mouse('left', 'press', '', 0, 0, 0) + meths.nvim_input_mouse('left', 'press', '', 0, 0, 0) poke_eventloop() - meths.input_mouse('left', 'drag', '', 0, 0, 1) + meths.nvim_input_mouse('left', 'drag', '', 0, 0, 1) poke_eventloop() eq(1, eval('g:dragged')) eq('v', eval('mode()')) @@ -158,9 +158,9 @@ describe('mapping', function() command([[inoremap <LeftDrag> <LeftDrag><C-\><C-N>]]) feed('i') poke_eventloop() - meths.input_mouse('left', 'press', '', 0, 0, 0) + meths.nvim_input_mouse('left', 'press', '', 0, 0, 0) poke_eventloop() - meths.input_mouse('left', 'drag', '', 0, 0, 1) + meths.nvim_input_mouse('left', 'drag', '', 0, 0, 1) poke_eventloop() eq('n', eval('mode()')) end) diff --git a/test/functional/legacy/messages_spec.lua b/test/functional/legacy/messages_spec.lua index 97c6d23494..c416ebfc99 100644 --- a/test/functional/legacy/messages_spec.lua +++ b/test/functional/legacy/messages_spec.lua @@ -410,9 +410,9 @@ describe('messages', function() screen:attach() command('cd ' .. nvim_dir) - meths.set_option_value('shell', './shell-test', {}) - meths.set_option_value('shellcmdflag', 'REP 20', {}) - meths.set_option_value('shellxquote', '', {}) -- win: avoid extra quotes + meths.nvim_set_option_value('shell', './shell-test', {}) + meths.nvim_set_option_value('shellcmdflag', 'REP 20', {}) + meths.nvim_set_option_value('shellxquote', '', {}) -- win: avoid extra quotes -- display a page and go back, results in exactly the same view feed([[:4 verbose echo system('foo')<CR>]]) diff --git a/test/functional/legacy/prompt_buffer_spec.lua b/test/functional/legacy/prompt_buffer_spec.lua index 76c57a23b9..e372d713c4 100644 --- a/test/functional/legacy/prompt_buffer_spec.lua +++ b/test/functional/legacy/prompt_buffer_spec.lua @@ -180,12 +180,12 @@ describe('prompt buffer', function() call timer_start(0, {-> nvim_buf_set_lines(s:buf, -1, -1, 0, ['walrus'])}) ]] poke_eventloop() - eq({ mode = 'i', blocking = false }, meths.get_mode()) + eq({ mode = 'i', blocking = false }, meths.nvim_get_mode()) end) -- oldtest: Test_prompt_appending_while_hidden() it('accessing hidden prompt buffer does not start insert mode', function() - local prev_win = meths.get_current_win() + local prev_win = meths.nvim_get_current_win() source([[ new prompt set buftype=prompt @@ -205,16 +205,16 @@ describe('prompt buffer', function() endfunc ]]) feed('asomething<CR>') - eq('something', meths.get_var('entered')) - neq(prev_win, meths.get_current_win()) + eq('something', meths.nvim_get_var('entered')) + neq(prev_win, meths.nvim_get_current_win()) feed('exit<CR>') - eq(prev_win, meths.get_current_win()) - eq({ mode = 'n', blocking = false }, meths.get_mode()) + eq(prev_win, meths.nvim_get_current_win()) + eq({ mode = 'n', blocking = false }, meths.nvim_get_mode()) command('call DoAppend()') - eq({ mode = 'n', blocking = false }, meths.get_mode()) + eq({ mode = 'n', blocking = false }, meths.nvim_get_mode()) feed('i') - eq({ mode = 'i', blocking = false }, meths.get_mode()) + eq({ mode = 'i', blocking = false }, meths.nvim_get_mode()) command('call DoAppend()') - eq({ mode = 'i', blocking = false }, meths.get_mode()) + eq({ mode = 'i', blocking = false }, meths.nvim_get_mode()) end) end) diff --git a/test/functional/legacy/put_spec.lua b/test/functional/legacy/put_spec.lua index 791656cc03..1678d8f2d8 100644 --- a/test/functional/legacy/put_spec.lua +++ b/test/functional/legacy/put_spec.lua @@ -16,7 +16,7 @@ end describe('put', function() before_each(clear) after_each(function() - eq({}, meths.get_vvar('errors')) + eq({}, meths.nvim_get_vvar('errors')) end) it('very large count 64-bit', function() diff --git a/test/functional/legacy/undolevels_spec.lua b/test/functional/legacy/undolevels_spec.lua index 1dfc4c17ba..a22cda27b6 100644 --- a/test/functional/legacy/undolevels_spec.lua +++ b/test/functional/legacy/undolevels_spec.lua @@ -57,6 +57,6 @@ describe('undolevel', function() call Test_global_local_undolevels() ]]) - eq({}, nvim.get_vvar('errors')) + eq({}, nvim.nvim_get_vvar('errors')) end) end) diff --git a/test/functional/legacy/vimscript_spec.lua b/test/functional/legacy/vimscript_spec.lua index c97208059b..eb3c70ecc6 100644 --- a/test/functional/legacy/vimscript_spec.lua +++ b/test/functional/legacy/vimscript_spec.lua @@ -12,7 +12,7 @@ describe('Vim script', function() it('Error when if/for/while/try/function is nested too deep', function() local screen = Screen.new(80, 24) screen:attach() - meths.set_option_value('laststatus', 2, {}) + meths.nvim_set_option_value('laststatus', 2, {}) exec([[ " Deep nesting of if ... endif func Test1() diff --git a/test/functional/lua/buffer_updates_spec.lua b/test/functional/lua/buffer_updates_spec.lua index 79e221de4c..5e11349b67 100644 --- a/test/functional/lua/buffer_updates_spec.lua +++ b/test/functional/lua/buffer_updates_spec.lua @@ -54,9 +54,9 @@ end) describe('lua buffer event callbacks: on_lines', function() local function setup_eventcheck(verify, utf_sizes, lines) local lastsize - meths.buf_set_lines(0, 0, -1, true, lines) + meths.nvim_buf_set_lines(0, 0, -1, true, lines) if verify then - lastsize = meths.buf_get_offset(0, meths.buf_line_count(0)) + lastsize = meths.nvim_buf_get_offset(0, meths.nvim_buf_line_count(0)) end exec_lua('return test_register(...)', 0, 'on_lines', 'test1', false, utf_sizes) local verify_name = 'test1' @@ -76,8 +76,9 @@ describe('lua buffer event callbacks: on_lines', function() for _, event in ipairs(events) do if event[1] == verify_name and event[2] == 'lines' then local startline, endline = event[5], event[7] - local newrange = meths.buf_get_offset(0, endline) - meths.buf_get_offset(0, startline) - local newsize = meths.buf_get_offset(0, meths.buf_line_count(0)) + local newrange = meths.nvim_buf_get_offset(0, endline) + - meths.nvim_buf_get_offset(0, startline) + local newsize = meths.nvim_buf_get_offset(0, meths.nvim_buf_line_count(0)) local oldrange = newrange + lastsize - newsize eq(oldrange, event[8]) lastsize = newsize @@ -97,13 +98,13 @@ describe('lua buffer event callbacks: on_lines', function() local function check(verify, utf_sizes) local check_events, verify_name = setup_eventcheck(verify, utf_sizes, origlines) - local tick = meths.buf_get_changedtick(0) + local tick = meths.nvim_buf_get_changedtick(0) command('set autoindent') command('normal! GyyggP') tick = tick + 1 check_events { { 'test1', 'lines', 1, tick, 0, 0, 1, 0 } } - meths.buf_set_lines(0, 3, 5, true, { 'changed line' }) + meths.nvim_buf_set_lines(0, 3, 5, true, { 'changed line' }) tick = tick + 1 check_events { { 'test1', 'lines', 1, tick, 3, 5, 4, 32 } } @@ -141,7 +142,7 @@ describe('lua buffer event callbacks: on_lines', function() -- simulate next callback returning true exec_lua("test_unreg = 'test1'") - meths.buf_set_lines(0, 6, 7, true, { 'x1', 'x2', 'x3' }) + meths.nvim_buf_set_lines(0, 6, 7, true, { 'x1', 'x2', 'x3' }) tick = tick + 1 -- plugins can opt in to receive changedtick events, or choose @@ -153,7 +154,7 @@ describe('lua buffer event callbacks: on_lines', function() verify_name 'test2' - meths.buf_set_lines(0, 1, 1, true, { 'added' }) + meths.nvim_buf_set_lines(0, 1, 1, true, { 'added' }) tick = tick + 1 check_events { { 'test2', 'lines', 1, tick, 1, 1, 2, 0 } } @@ -205,7 +206,7 @@ describe('lua buffer event callbacks: on_lines', function() } local check_events, verify_name = setup_eventcheck(verify, true, unicode_text) - local tick = meths.buf_get_changedtick(0) + local tick = meths.nvim_buf_get_changedtick(0) feed('ggdd') tick = tick + 1 @@ -253,7 +254,7 @@ describe('lua buffer event callbacks: on_lines', function() end) it('has valid cursor position while shifting', function() - meths.buf_set_lines(0, 0, -1, true, { 'line1' }) + meths.nvim_buf_set_lines(0, 0, -1, true, { 'line1' }) exec_lua([[ vim.api.nvim_buf_attach(0, false, { on_lines = function() @@ -262,15 +263,15 @@ describe('lua buffer event callbacks: on_lines', function() }) ]]) feed('>>') - eq(1, meths.get_var('listener_cursor_line')) + eq(1, meths.nvim_get_var('listener_cursor_line')) end) it('has valid cursor position while deleting lines', function() - meths.buf_set_lines(0, 0, -1, true, { 'line_1', 'line_2', 'line_3', 'line_4' }) - meths.win_set_cursor(0, { 2, 0 }) - eq(2, meths.win_get_cursor(0)[1]) - meths.buf_set_lines(0, 0, -1, true, { 'line_1', 'line_2', 'line_3' }) - eq(2, meths.win_get_cursor(0)[1]) + meths.nvim_buf_set_lines(0, 0, -1, true, { 'line_1', 'line_2', 'line_3', 'line_4' }) + meths.nvim_win_set_cursor(0, { 2, 0 }) + eq(2, meths.nvim_win_get_cursor(0)[1]) + meths.nvim_buf_set_lines(0, 0, -1, true, { 'line_1', 'line_2', 'line_3' }) + eq(2, meths.nvim_win_get_cursor(0)[1]) end) it('does not SEGFAULT when accessing window buffer info in on_detach #14998', function() @@ -298,7 +299,7 @@ describe('lua buffer event callbacks: on_lines', function() end) it('#12718 lnume', function() - meths.buf_set_lines(0, 0, -1, true, { '1', '2', '3' }) + meths.nvim_buf_set_lines(0, 0, -1, true, { '1', '2', '3' }) exec_lua([[ vim.api.nvim_buf_attach(0, false, { on_lines = function(...) @@ -311,15 +312,15 @@ describe('lua buffer event callbacks: on_lines', function() feed('G0') feed('p') -- Is the last arg old_byte_size correct? Doesn't matter for this PR - eq(meths.get_var('linesev'), { 'lines', 1, 4, 2, 3, 5, 4 }) + eq(meths.nvim_get_var('linesev'), { 'lines', 1, 4, 2, 3, 5, 4 }) feed('2G0') feed('p') - eq(meths.get_var('linesev'), { 'lines', 1, 5, 1, 4, 4, 8 }) + eq(meths.nvim_get_var('linesev'), { 'lines', 1, 5, 1, 4, 4, 8 }) feed('1G0') feed('P') - eq(meths.get_var('linesev'), { 'lines', 1, 6, 0, 3, 3, 9 }) + eq(meths.nvim_get_var('linesev'), { 'lines', 1, 6, 0, 3, 3, 9 }) end) it( @@ -333,7 +334,7 @@ describe('lua buffer event callbacks: on_lines', function() }) ]]) feed('itest123<Esc><C-A>') - eq('test124', meths.get_current_line()) + eq('test124', meths.nvim_get_current_line()) end ) end) @@ -345,19 +346,19 @@ describe('lua: nvim_buf_attach on_bytes', function() -- test both ways. local function setup_eventcheck(verify, start_txt) if start_txt then - meths.buf_set_lines(0, 0, -1, true, start_txt) + meths.nvim_buf_set_lines(0, 0, -1, true, start_txt) else - start_txt = meths.buf_get_lines(0, 0, -1, true) + start_txt = meths.nvim_buf_get_lines(0, 0, -1, true) end local shadowbytes = table.concat(start_txt, '\n') .. '\n' -- TODO: while we are brewing the real strong coffee, -- verify should check buf_get_offset after every check_events if verify then - local len = meths.buf_get_offset(0, meths.buf_line_count(0)) + local len = meths.nvim_buf_get_offset(0, meths.nvim_buf_line_count(0)) eq(len == -1 and 1 or len, string.len(shadowbytes)) end exec_lua('return test_register(...)', 0, 'on_bytes', 'test1', false, false, true) - meths.buf_get_changedtick(0) + meths.nvim_buf_get_changedtick(0) local verify_name = 'test1' local function check_events(expected) @@ -384,11 +385,11 @@ describe('lua: nvim_buf_attach on_bytes', function() local after = string.sub(shadowbytes, start_byte + old_byte + 1) shadowbytes = before .. unknown .. after elseif event[1] == verify_name and event[2] == 'reload' then - shadowbytes = table.concat(meths.buf_get_lines(0, 0, -1, true), '\n') .. '\n' + shadowbytes = table.concat(meths.nvim_buf_get_lines(0, 0, -1, true), '\n') .. '\n' end end - local text = meths.buf_get_lines(0, 0, -1, true) + local text = meths.nvim_buf_get_lines(0, 0, -1, true) local bytes = table.concat(text, '\n') .. '\n' eq( @@ -425,7 +426,7 @@ describe('lua: nvim_buf_attach on_bytes', function() it('opening lines', function() local check_events = setup_eventcheck(verify, origlines) - -- meths.set_option_value('autoindent', true, {}) + -- meths.nvim_set_option_value('autoindent', true, {}) feed 'Go' check_events { { 'test1', 'bytes', 1, 3, 7, 0, 114, 0, 0, 0, 1, 0, 1 }, @@ -438,7 +439,7 @@ describe('lua: nvim_buf_attach on_bytes', function() it('opening lines with autoindent', function() local check_events = setup_eventcheck(verify, origlines) - meths.set_option_value('autoindent', true, {}) + meths.nvim_set_option_value('autoindent', true, {}) feed 'Go' check_events { { 'test1', 'bytes', 1, 3, 7, 0, 114, 0, 0, 0, 1, 0, 5 }, @@ -463,7 +464,7 @@ describe('lua: nvim_buf_attach on_bytes', function() { 'test1', 'bytes', 1, 5, 2, 0, 20, 0, 15, 15, 0, 3, 3 }, } - local buf_len = meths.buf_line_count(0) + local buf_len = meths.nvim_buf_line_count(0) funcs.setline(buf_len + 1, 'baz') check_events { { 'test1', 'bytes', 1, 6, 7, 0, 90, 0, 0, 0, 1, 0, 4 }, @@ -472,8 +473,8 @@ describe('lua: nvim_buf_attach on_bytes', function() it('continuing comments with fo=or', function() local check_events = setup_eventcheck(verify, { '// Comment' }) - meths.set_option_value('formatoptions', 'ro', {}) - meths.set_option_value('filetype', 'c', {}) + meths.nvim_set_option_value('formatoptions', 'ro', {}) + meths.nvim_set_option_value('filetype', 'c', {}) feed 'A<CR>' check_events { { 'test1', 'bytes', 1, 4, 0, 10, 10, 0, 0, 0, 1, 3, 4 }, @@ -611,7 +612,7 @@ describe('lua: nvim_buf_attach on_bytes', function() it('inccomand=nosplit and substitute', function() local check_events = setup_eventcheck(verify, { 'abcde', '12345' }) - meths.set_option_value('inccommand', 'nosplit', {}) + meths.nvim_set_option_value('inccommand', 'nosplit', {}) -- linewise substitute feed(':%s/bcd/') @@ -696,41 +697,41 @@ describe('lua: nvim_buf_attach on_bytes', function() it('nvim_buf_set_text insert', function() local check_events = setup_eventcheck(verify, { 'bastext' }) - meths.buf_set_text(0, 0, 3, 0, 3, { 'fiol', 'kontra' }) + meths.nvim_buf_set_text(0, 0, 3, 0, 3, { 'fiol', 'kontra' }) check_events { { 'test1', 'bytes', 1, 3, 0, 3, 3, 0, 0, 0, 1, 6, 11 }, } - meths.buf_set_text(0, 1, 6, 1, 6, { 'punkt', 'syntgitarr', 'övnings' }) + meths.nvim_buf_set_text(0, 1, 6, 1, 6, { 'punkt', 'syntgitarr', 'övnings' }) check_events { { 'test1', 'bytes', 1, 4, 1, 6, 14, 0, 0, 0, 2, 8, 25 }, } eq( { 'basfiol', 'kontrapunkt', 'syntgitarr', 'övningstext' }, - meths.buf_get_lines(0, 0, -1, true) + meths.nvim_buf_get_lines(0, 0, -1, true) ) end) it('nvim_buf_set_text replace', function() local check_events = setup_eventcheck(verify, origlines) - meths.buf_set_text(0, 2, 3, 2, 8, { 'very text' }) + meths.nvim_buf_set_text(0, 2, 3, 2, 8, { 'very text' }) check_events { { 'test1', 'bytes', 1, 3, 2, 3, 35, 0, 5, 5, 0, 9, 9 }, } - meths.buf_set_text(0, 3, 5, 3, 7, { ' splitty', 'line ' }) + meths.nvim_buf_set_text(0, 3, 5, 3, 7, { ' splitty', 'line ' }) check_events { { 'test1', 'bytes', 1, 4, 3, 5, 57, 0, 2, 2, 1, 5, 14 }, } - meths.buf_set_text(0, 0, 8, 1, 2, { 'JOINY' }) + meths.nvim_buf_set_text(0, 0, 8, 1, 2, { 'JOINY' }) check_events { { 'test1', 'bytes', 1, 5, 0, 8, 8, 1, 2, 10, 0, 5, 5 }, } - meths.buf_set_text(0, 4, 0, 6, 0, { 'was 5,6', '' }) + meths.nvim_buf_set_text(0, 4, 0, 6, 0, { 'was 5,6', '' }) check_events { { 'test1', 'bytes', 1, 6, 4, 0, 75, 2, 0, 32, 1, 0, 8 }, } @@ -742,20 +743,20 @@ describe('lua: nvim_buf_attach on_bytes', function() 'line l line 4', 'was 5,6', ' indented line', - }, meths.buf_get_lines(0, 0, -1, true)) + }, meths.nvim_buf_get_lines(0, 0, -1, true)) end) it('nvim_buf_set_text delete', function() local check_events = setup_eventcheck(verify, origlines) -- really {""} but accepts {} as a shorthand - meths.buf_set_text(0, 0, 0, 1, 0, {}) + meths.nvim_buf_set_text(0, 0, 0, 1, 0, {}) check_events { { 'test1', 'bytes', 1, 3, 0, 0, 0, 1, 0, 16, 0, 0, 0 }, } -- TODO(bfredl): this works but is not as convenient as set_lines - meths.buf_set_text(0, 4, 15, 5, 17, { '' }) + meths.nvim_buf_set_text(0, 4, 15, 5, 17, { '' }) check_events { { 'test1', 'bytes', 1, 4, 4, 15, 79, 1, 17, 18, 0, 0, 0 }, } @@ -765,7 +766,7 @@ describe('lua: nvim_buf_attach on_bytes', function() 'original line 4', 'original line 5', 'original line 6', - }, meths.buf_get_lines(0, 0, -1, true)) + }, meths.nvim_buf_get_lines(0, 0, -1, true)) end) it('checktime autoread', function() @@ -800,7 +801,7 @@ describe('lua: nvim_buf_attach on_bytes', function() { 'test1', 'bytes', 1, 5, 0, 10, 10, 1, 0, 1, 0, 1, 1 }, } - eq({ 'new line 1 new line 2', 'new line 3' }, meths.buf_get_lines(0, 0, -1, true)) + eq({ 'new line 1 new line 2', 'new line 3' }, meths.nvim_buf_get_lines(0, 0, -1, true)) -- check we can undo and redo a reload event. feed 'u' @@ -924,19 +925,19 @@ describe('lua: nvim_buf_attach on_bytes', function() command('set undodir=. | set undofile') local ns = helpers.request('nvim_create_namespace', 'ns1') - meths.buf_set_extmark(0, ns, 0, 0, {}) + meths.nvim_buf_set_extmark(0, ns, 0, 0, {}) - eq({ '12345', 'hello world' }, meths.buf_get_lines(0, 0, -1, true)) + eq({ '12345', 'hello world' }, meths.nvim_buf_get_lines(0, 0, -1, true)) -- splice feed('gg0d2l') - eq({ '345', 'hello world' }, meths.buf_get_lines(0, 0, -1, true)) + eq({ '345', 'hello world' }, meths.nvim_buf_get_lines(0, 0, -1, true)) -- move command('.m+1') - eq({ 'hello world', '345' }, meths.buf_get_lines(0, 0, -1, true)) + eq({ 'hello world', '345' }, meths.nvim_buf_get_lines(0, 0, -1, true)) -- reload undofile and undo changes command('w') @@ -949,7 +950,7 @@ describe('lua: nvim_buf_attach on_bytes', function() local check_events = setup_eventcheck(verify, nil) feed('u') - eq({ '345', 'hello world' }, meths.buf_get_lines(0, 0, -1, true)) + eq({ '345', 'hello world' }, meths.nvim_buf_get_lines(0, 0, -1, true)) check_events { { 'test1', 'bytes', 2, 6, 1, 0, 12, 1, 0, 4, 0, 0, 0 }, @@ -957,7 +958,7 @@ describe('lua: nvim_buf_attach on_bytes', function() } feed('u') - eq({ '12345', 'hello world' }, meths.buf_get_lines(0, 0, -1, true)) + eq({ '12345', 'hello world' }, meths.nvim_buf_get_lines(0, 0, -1, true)) check_events { { 'test1', 'bytes', 2, 8, 0, 0, 0, 0, 0, 0, 0, 2, 2 }, @@ -968,7 +969,7 @@ describe('lua: nvim_buf_attach on_bytes', function() it('blockwise paste with uneven line lengths', function() local check_events = setup_eventcheck(verify, { 'aaaa', 'aaa', 'aaa' }) - -- eq({}, meths.buf_get_lines(0, 0, -1, true)) + -- eq({}, meths.nvim_buf_get_lines(0, 0, -1, true)) feed('gg0<c-v>jj$d') check_events { @@ -1022,7 +1023,7 @@ describe('lua: nvim_buf_attach on_bytes', function() it('virtual edit', function() local check_events = setup_eventcheck(verify, { '', ' ' }) - meths.set_option_value('virtualedit', 'all', {}) + meths.nvim_set_option_value('virtualedit', 'all', {}) feed [[<Right><Right>iab<ESC>]] @@ -1076,20 +1077,20 @@ describe('lua: nvim_buf_attach on_bytes', function() local check_events = setup_eventcheck(verify, { 'AAA', 'BBB' }) -- delete - meths.buf_set_lines(0, 0, 1, true, {}) + meths.nvim_buf_set_lines(0, 0, 1, true, {}) check_events { { 'test1', 'bytes', 1, 3, 0, 0, 0, 1, 0, 4, 0, 0, 0 }, } -- add - meths.buf_set_lines(0, 0, 0, true, { 'asdf' }) + meths.nvim_buf_set_lines(0, 0, 0, true, { 'asdf' }) check_events { { 'test1', 'bytes', 1, 4, 0, 0, 0, 0, 0, 0, 1, 0, 5 }, } -- replace - meths.buf_set_lines(0, 0, 1, true, { 'asdf', 'fdsa' }) + meths.nvim_buf_set_lines(0, 0, 1, true, { 'asdf', 'fdsa' }) check_events { { 'test1', 'bytes', 1, 5, 0, 0, 0, 1, 0, 5, 2, 0, 10 }, } @@ -1201,13 +1202,13 @@ describe('lua: nvim_buf_attach on_bytes', function() command('diffthis') command('new') command('diffthis') - meths.buf_set_lines(0, 0, -1, true, { 'AAA', 'BBB' }) + meths.nvim_buf_set_lines(0, 0, -1, true, { 'AAA', 'BBB' }) feed('G') command('diffput') check_events { { 'test1', 'bytes', 1, 3, 1, 0, 4, 0, 0, 0, 1, 0, 4 }, } - meths.buf_set_lines(0, 0, -1, true, { 'AAA', 'CCC' }) + meths.nvim_buf_set_lines(0, 0, -1, true, { 'AAA', 'CCC' }) feed('<C-w>pG') command('diffget') check_events { @@ -1249,7 +1250,7 @@ describe('lua: nvim_buf_attach on_bytes', function() { 'test1', 'bytes', 1, 5, 3, 0, 10, 1, 0, 1, 0, 0, 0 }, } - eq('CCC|BBBB|', table.concat(meths.buf_get_lines(0, 0, -1, true), '|')) + eq('CCC|BBBB|', table.concat(meths.nvim_buf_get_lines(0, 0, -1, true), '|')) end) end diff --git a/test/functional/lua/commands_spec.lua b/test/functional/lua/commands_spec.lua index 8d5badb92b..7a4299c480 100644 --- a/test/functional/lua/commands_spec.lua +++ b/test/functional/lua/commands_spec.lua @@ -76,7 +76,7 @@ describe(':lua command', function() it('accepts embedded NLs without heredoc', function() -- Such code is usually used for `:execute 'lua' {generated_string}`: -- heredocs do not work in this case. - meths.command([[ + meths.nvim_command([[ lua vim.api.nvim_buf_set_lines(1, 1, 2, false, {"ETTS"}) vim.api.nvim_buf_set_lines(1, 2, 3, false, {"TTSE"}) diff --git a/test/functional/lua/filetype_spec.lua b/test/functional/lua/filetype_spec.lua index 50db613dde..3f61d1bc52 100644 --- a/test/functional/lua/filetype_spec.lua +++ b/test/functional/lua/filetype_spec.lua @@ -165,6 +165,6 @@ describe('filetype.lua', function() clear({ args = { '--clean', '--cmd', 'autocmd BufRead *.md set filetype=notmarkdown', 'README.md' }, }) - eq('notmarkdown', meths.get_option_value('filetype', {})) + eq('notmarkdown', meths.nvim_get_option_value('filetype', {})) end) end) diff --git a/test/functional/lua/loop_spec.lua b/test/functional/lua/loop_spec.lua index 3bce30bffb..9452866b8e 100644 --- a/test/functional/lua/loop_spec.lua +++ b/test/functional/lua/loop_spec.lua @@ -48,13 +48,13 @@ describe('vim.uv', function() end)() ]] - eq(0, meths.get_var('coroutine_cnt')) + eq(0, meths.nvim_get_var('coroutine_cnt')) exec_lua(code) retry(2, nil, function() sleep(50) - eq(2, meths.get_var('coroutine_cnt')) + eq(2, meths.nvim_get_var('coroutine_cnt')) end) - eq(3, meths.get_var('coroutine_cnt_1')) + eq(3, meths.nvim_get_var('coroutine_cnt_1')) end) it('is API safe', function() diff --git a/test/functional/lua/luaeval_spec.lua b/test/functional/lua/luaeval_spec.lua index 5efc15417a..d461acafb5 100644 --- a/test/functional/lua/luaeval_spec.lua +++ b/test/functional/lua/luaeval_spec.lua @@ -67,17 +67,17 @@ describe('luaeval()', function() describe('strings with NULs', function() it('are successfully converted to blobs', function() command([[let s = luaeval('"\0"')]]) - eq('\000', meths.get_var('s')) + eq('\000', meths.nvim_get_var('s')) end) it('are successfully converted to special dictionaries in table keys', function() command([[let d = luaeval('{["\0"]=1}')]]) - eq({_TYPE={}, _VAL={{{_TYPE={}, _VAL={'\n'}}, 1}}}, meths.get_var('d')) + eq({_TYPE={}, _VAL={{{_TYPE={}, _VAL={'\n'}}, 1}}}, meths.nvim_get_var('d')) eq(1, funcs.eval('d._TYPE is v:msgpack_types.map')) eq(1, funcs.eval('d._VAL[0][0]._TYPE is v:msgpack_types.string')) end) it('are successfully converted to blobs from a list', function() command([[let l = luaeval('{"abc", "a\0b", "c\0d", "def"}')]]) - eq({'abc', 'a\000b', 'c\000d', 'def'}, meths.get_var('l')) + eq({'abc', 'a\000b', 'c\000d', 'def'}, meths.nvim_get_var('l')) end) end) @@ -411,14 +411,14 @@ describe('luaeval()', function() end) it('correctly converts self-containing containers', function() - meths.set_var('l', {}) + meths.nvim_set_var('l', {}) eval('add(l, l)') eq(true, eval('luaeval("_A == _A[1]", l)')) eq(true, eval('luaeval("_A[1] == _A[1][1]", [l])')) eq(true, eval('luaeval("_A.d == _A.d[1]", {"d": l})')) eq(true, eval('luaeval("_A ~= _A[1]", [l])')) - meths.set_var('d', {foo=42}) + meths.nvim_set_var('d', {foo=42}) eval('extend(d, {"d": d})') eq(true, eval('luaeval("_A == _A.d", d)')) eq(true, eval('luaeval("_A[1] == _A[1].d", [d])')) @@ -478,7 +478,7 @@ describe('v:lua', function() eq(7, eval('v:lua.foo(3,4,v:null)')) eq(true, exec_lua([[return _G.val == vim.NIL]])) eq(NIL, eval('v:lua.mymod.noisy("eval")')) - eq("hey eval", meths.get_current_line()) + eq("hey eval", meths.nvim_get_current_line()) eq("string: abc", eval('v:lua.mymod.whatis(0z616263)')) eq("string: ", eval('v:lua.mymod.whatis(v:_null_blob)')) @@ -494,7 +494,7 @@ describe('v:lua', function() eq("boop", exec_lua([[return _G.val]])) eq(NIL, eval('"there"->v:lua.mymod.noisy()')) - eq("hey there", meths.get_current_line()) + eq("hey there", meths.nvim_get_current_line()) eq({5, 10, 15, 20}, eval('[[1], [2, 3], [4]]->v:lua.vim.tbl_flatten()->map({_, v -> v * 5})')) eq("Vim:E5108: Error executing lua [string \"<nvim>\"]:0: attempt to call global 'nonexistent' (a nil value)", @@ -503,7 +503,7 @@ describe('v:lua', function() it('works in :call', function() command(":call v:lua.mymod.noisy('command')") - eq("hey command", meths.get_current_line()) + eq("hey command", meths.nvim_get_current_line()) eq("Vim(call):E5108: Error executing lua [string \"<nvim>\"]:0: attempt to call global 'nonexistent' (a nil value)", pcall_err(command, 'call v:lua.mymod.crashy()')) end) @@ -518,7 +518,7 @@ describe('v:lua', function() [5] = {bold = true, foreground = Screen.colors.SeaGreen4}, }) screen:attach() - meths.set_option_value('omnifunc', 'v:lua.mymod.omni', {}) + meths.nvim_set_option_value('omnifunc', 'v:lua.mymod.omni', {}) feed('isome st<c-x><c-o>') screen:expect{grid=[[ some stuff^ | @@ -528,9 +528,9 @@ describe('v:lua', function() {1:~ }|*3 {4:-- Omni completion (^O^N^P) }{5:match 1 of 3} | ]]} - meths.set_option_value('operatorfunc', 'v:lua.mymod.noisy', {}) + meths.nvim_set_option_value('operatorfunc', 'v:lua.mymod.noisy', {}) feed('<Esc>g@g@') - eq("hey line", meths.get_current_line()) + eq("hey line", meths.nvim_get_current_line()) end) it('supports packages', function() diff --git a/test/functional/lua/overrides_spec.lua b/test/functional/lua/overrides_spec.lua index 00458ecc34..1600616724 100644 --- a/test/functional/lua/overrides_spec.lua +++ b/test/functional/lua/overrides_spec.lua @@ -113,7 +113,7 @@ describe('print', function() eq('Vim(lua):E5108: Error executing lua [NULL]', pcall_err(command, 'lua bad_custom_error()')) end) it('prints strings with NULs and NLs correctly', function() - meths.set_option_value('more', true, {}) + meths.nvim_set_option_value('more', true, {}) eq( 'abc ^@ def\nghi^@^@^@jkl\nTEST\n\n\nT\n', exec_capture([[lua print("abc \0 def\nghi\0\0\0jkl\nTEST\n\n\nT\n")]]) @@ -341,7 +341,7 @@ describe('os.getenv', function() end) it('returns env var set by let', function() local value = 'foo' - meths.command('let $XTEST_1 = "' .. value .. '"') + meths.nvim_command('let $XTEST_1 = "' .. value .. '"') eq(value, funcs.luaeval('os.getenv("XTEST_1")')) end) end) diff --git a/test/functional/lua/secure_spec.lua b/test/functional/lua/secure_spec.lua index 05311d153f..0773988256 100644 --- a/test/functional/lua/secure_spec.lua +++ b/test/functional/lua/secure_spec.lua @@ -170,7 +170,7 @@ describe('vim.secure', function() -- Cannot write file pcall_err(command, 'write') - eq(true, meths.get_option_value('readonly', {})) + eq(true, meths.nvim_get_option_value('readonly', {})) end) end) diff --git a/test/functional/lua/vim_spec.lua b/test/functional/lua/vim_spec.lua index d38d8eaf90..e938f05703 100644 --- a/test/functional/lua/vim_spec.lua +++ b/test/functional/lua/vim_spec.lua @@ -1205,7 +1205,7 @@ describe('lua stdlib', function() chan = vim.fn.jobstart({'cat'}, {rpc=true}) vim.rpcrequest(chan, 'nvim_set_current_line', 'meow') ]]) - eq('meow', meths.get_current_line()) + eq('meow', meths.nvim_get_current_line()) command("let x = [3, 'aa', v:true, v:null]") eq( true, @@ -1250,7 +1250,7 @@ describe('lua stdlib', function() ]]) ) retry(10, nil, function() - eq('foo', meths.get_current_line()) + eq('foo', meths.nvim_get_current_line()) end) local screen = Screen.new(50, 7) @@ -1282,7 +1282,7 @@ describe('lua stdlib', function() ]], } feed('<cr>') - eq({ 3, NIL }, meths.get_var('yy')) + eq({ 3, NIL }, meths.nvim_get_var('yy')) exec_lua([[timer:close()]]) end) @@ -1845,18 +1845,18 @@ describe('lua stdlib', function() eq({}, eval('v:oldfiles')) feed('i foo foo foo<Esc>0/foo<CR>') - eq({ 1, 1 }, meths.win_get_cursor(0)) + eq({ 1, 1 }, meths.nvim_win_get_cursor(0)) eq(1, eval('v:searchforward')) feed('n') - eq({ 1, 5 }, meths.win_get_cursor(0)) + eq({ 1, 5 }, meths.nvim_win_get_cursor(0)) exec_lua([[vim.v.searchforward = 0]]) eq(0, eval('v:searchforward')) feed('n') - eq({ 1, 1 }, meths.win_get_cursor(0)) + eq({ 1, 1 }, meths.nvim_win_get_cursor(0)) exec_lua([[vim.v.searchforward = 1]]) eq(1, eval('v:searchforward')) feed('n') - eq({ 1, 5 }, meths.win_get_cursor(0)) + eq({ 1, 5 }, meths.nvim_win_get_cursor(0)) local screen = Screen.new(60, 3) screen:set_default_attr_ids({ @@ -2886,7 +2886,7 @@ describe('lua stdlib', function() eq({}, exec_lua [[return {re1:match_str("x ac")}]]) eq({ 3, 7 }, exec_lua [[return {re1:match_str("ac abbc")}]]) - meths.buf_set_lines(0, 0, -1, true, { 'yy', 'abc abbc' }) + meths.nvim_buf_set_lines(0, 0, -1, true, { 'yy', 'abc abbc' }) eq({}, exec_lua [[return {re1:match_line(0, 0)}]]) eq({ 0, 3 }, exec_lua [[return {re1:match_line(0, 1)}]]) eq({ 3, 7 }, exec_lua [[return {re1:match_line(0, 1, 1)}]]) @@ -2970,10 +2970,10 @@ describe('lua stdlib', function() it('allows removing on_key listeners', function() -- Create some unused namespaces - meths.create_namespace('unused1') - meths.create_namespace('unused2') - meths.create_namespace('unused3') - meths.create_namespace('unused4') + meths.nvim_create_namespace('unused1') + meths.nvim_create_namespace('unused2') + meths.nvim_create_namespace('unused3') + meths.nvim_create_namespace('unused4') insert([[hello world]]) @@ -3303,8 +3303,8 @@ describe('lua stdlib', function() describe('returns -2 when interrupted', function() before_each(function() - local channel = meths.get_api_info()[1] - meths.set_var('channel', channel) + local channel = meths.nvim_get_api_info()[1] + meths.nvim_set_var('channel', channel) end) it('without callback', function() @@ -3408,14 +3408,14 @@ describe('lua stdlib', function() describe('vim.api.nvim_buf_call', function() it('can access buf options', function() - local buf1 = meths.get_current_buf().id + local buf1 = meths.nvim_get_current_buf().id local buf2 = exec_lua [[ buf2 = vim.api.nvim_create_buf(false, true) return buf2 ]] - eq(false, meths.get_option_value('autoindent', { buf = buf1 })) - eq(false, meths.get_option_value('autoindent', { buf = buf2 })) + eq(false, meths.nvim_get_option_value('autoindent', { buf = buf1 })) + eq(false, meths.nvim_get_option_value('autoindent', { buf = buf2 })) local val = exec_lua [[ return vim.api.nvim_buf_call(buf2, function() @@ -3424,9 +3424,9 @@ describe('lua stdlib', function() end) ]] - eq(false, meths.get_option_value('autoindent', { buf = buf1 })) - eq(true, meths.get_option_value('autoindent', { buf = buf2 })) - eq(buf1, meths.get_current_buf().id) + eq(false, meths.nvim_get_option_value('autoindent', { buf = buf1 })) + eq(true, meths.nvim_get_option_value('autoindent', { buf = buf2 })) + eq(buf1, meths.nvim_get_current_buf().id) eq(buf2, val) end) @@ -3488,7 +3488,7 @@ describe('lua stdlib', function() describe('vim.api.nvim_win_call', function() it('can access window options', function() command('vsplit') - local win1 = meths.get_current_win().id + local win1 = meths.nvim_get_current_win().id command('wincmd w') local win2 = exec_lua [[ win2 = vim.api.nvim_get_current_win() @@ -3496,8 +3496,8 @@ describe('lua stdlib', function() ]] command('wincmd p') - eq('', meths.get_option_value('winhighlight', { win = win1 })) - eq('', meths.get_option_value('winhighlight', { win = win2 })) + eq('', meths.nvim_get_option_value('winhighlight', { win = win1 })) + eq('', meths.nvim_get_option_value('winhighlight', { win = win2 })) local val = exec_lua [[ return vim.api.nvim_win_call(win2, function() @@ -3506,9 +3506,9 @@ describe('lua stdlib', function() end) ]] - eq('', meths.get_option_value('winhighlight', { win = win1 })) - eq('Normal:Normal', meths.get_option_value('winhighlight', { win = win2 })) - eq(win1, meths.get_current_win().id) + eq('', meths.nvim_get_option_value('winhighlight', { win = win1 })) + eq('Normal:Normal', meths.nvim_get_option_value('winhighlight', { win = win2 })) + eq(win1, meths.nvim_get_current_win().id) eq(win2, val) end) @@ -3882,7 +3882,7 @@ describe('vim.keymap', function() feed('aa') - eq({ 'π<M-π>foo<' }, meths.buf_get_lines(0, 0, -1, false)) + eq({ 'π<M-π>foo<' }, meths.nvim_buf_get_lines(0, 0, -1, false)) end) it('can overwrite a mapping', function() diff --git a/test/functional/options/chars_spec.lua b/test/functional/options/chars_spec.lua index d23dc2ed88..acfcc70362 100644 --- a/test/functional/options/chars_spec.lua +++ b/test/functional/options/chars_spec.lua @@ -203,7 +203,7 @@ describe("'listchars'", function() | ]]) - meths._invalidate_glyph_cache() + meths.nvim__invalidate_glyph_cache() screen:_reset() screen:expect([[ {1:d̞̄̃̒̉̎ò́̌̌̂̐ò́̌̌̂̐ò́̌̌̂̐ò́̌̌̂̐ò́̌̌̂̐ò́̌̌̂̐l̞̀̄̆̌̚d̞̄̃̒̉̎ò́̌̌̂̐ò́̌̌̂̐ò́̌̌̂̐ò́̌̌̂̐ò́̌̌̂̐ò́̌̌̂̐l̞̀̄̆̌̚d̞̄̃̒̉̎ò́̌̌̂̐ò́̌̌̂̐ò́̌̌̂̐ò́̌̌̂̐ò́̌̌̂̐ò́̌̌̂̐l̞̀̄̆̌̚}^x{1:å̲} | diff --git a/test/functional/options/defaults_spec.lua b/test/functional/options/defaults_spec.lua index b68682e2bd..6bc74b3540 100644 --- a/test/functional/options/defaults_spec.lua +++ b/test/functional/options/defaults_spec.lua @@ -195,8 +195,8 @@ describe('startup defaults', function() clear { args = {}, args_rm = { '-i' }, env = env } -- Default 'shadafile' is empty. -- This means use the default location. :help shada-file-name - eq('', meths.get_option_value('shadafile', {})) - eq('', meths.get_option_value('viminfofile', {})) + eq('', meths.nvim_get_option_value('shadafile', {})) + eq('', meths.nvim_get_option_value('viminfofile', {})) -- Handles viminfo/viminfofile as alias for shada/shadafile. eq('\n shadafile=', eval('execute("set shadafile?")')) eq('\n shadafile=', eval('execute("set viminfofile?")')) @@ -218,13 +218,13 @@ describe('startup defaults', function() args_rm = { 'runtimepath' }, } -- Defaults to &runtimepath. - eq(meths.get_option_value('runtimepath', {}), meths.get_option_value('packpath', {})) + eq(meths.nvim_get_option_value('runtimepath', {}), meths.nvim_get_option_value('packpath', {})) -- Does not follow modifications to runtimepath. - meths.command('set runtimepath+=foo') - neq(meths.get_option_value('runtimepath', {}), meths.get_option_value('packpath', {})) - meths.command('set packpath+=foo') - eq(meths.get_option_value('runtimepath', {}), meths.get_option_value('packpath', {})) + meths.nvim_command('set runtimepath+=foo') + neq(meths.nvim_get_option_value('runtimepath', {}), meths.nvim_get_option_value('packpath', {})) + meths.nvim_command('set packpath+=foo') + eq(meths.nvim_get_option_value('runtimepath', {}), meths.nvim_get_option_value('packpath', {})) end) it('v:progpath is set to the absolute path', function() @@ -316,10 +316,10 @@ describe('XDG defaults', function() }, }) - eq('.', meths.get_option_value('backupdir', {})) - eq('.', meths.get_option_value('viewdir', {})) - eq('.', meths.get_option_value('directory', {})) - eq('.', meths.get_option_value('undodir', {})) + eq('.', meths.nvim_get_option_value('backupdir', {})) + eq('.', meths.nvim_get_option_value('viewdir', {})) + eq('.', meths.nvim_get_option_value('directory', {})) + eq('.', meths.nvim_get_option_value('undodir', {})) ok((funcs.tempname()):len() > 4) end) end) @@ -328,7 +328,7 @@ describe('XDG defaults', function() local vimruntime = eval('$VIMRUNTIME') -- libdir is hard to calculate reliably across various ci platforms -- local libdir = string.gsub(vimruntime, "share/nvim/runtime$", "lib/nvim") - local libdir = meths._get_lib_dir() + local libdir = meths.nvim__get_lib_dir() return vimruntime, libdir end @@ -428,13 +428,13 @@ describe('XDG defaults', function() .. '/nvim/after' ):gsub('\\', '/') ), - (meths.get_option_value('runtimepath', {})):gsub('\\', '/') + (meths.nvim_get_option_value('runtimepath', {})):gsub('\\', '/') ) - meths.command('set runtimepath&') - meths.command('set backupdir&') - meths.command('set directory&') - meths.command('set undodir&') - meths.command('set viewdir&') + meths.nvim_command('set runtimepath&') + meths.nvim_command('set backupdir&') + meths.nvim_command('set directory&') + meths.nvim_command('set undodir&') + meths.nvim_command('set viewdir&') eq( ( ( @@ -499,23 +499,23 @@ describe('XDG defaults', function() .. '/nvim/after' ):gsub('\\', '/') ), - (meths.get_option_value('runtimepath', {})):gsub('\\', '/') + (meths.nvim_get_option_value('runtimepath', {})):gsub('\\', '/') ) eq( '.,' .. root_path .. ('/X'):rep(4096) .. '/' .. state_dir .. '/backup//', - (meths.get_option_value('backupdir', {}):gsub('\\', '/')) + (meths.nvim_get_option_value('backupdir', {}):gsub('\\', '/')) ) eq( root_path .. ('/X'):rep(4096) .. '/' .. state_dir .. '/swap//', - (meths.get_option_value('directory', {})):gsub('\\', '/') + (meths.nvim_get_option_value('directory', {})):gsub('\\', '/') ) eq( root_path .. ('/X'):rep(4096) .. '/' .. state_dir .. '/undo//', - (meths.get_option_value('undodir', {})):gsub('\\', '/') + (meths.nvim_get_option_value('undodir', {})):gsub('\\', '/') ) eq( root_path .. ('/X'):rep(4096) .. '/' .. state_dir .. '/view//', - (meths.get_option_value('viewdir', {})):gsub('\\', '/') + (meths.nvim_get_option_value('viewdir', {})):gsub('\\', '/') ) end) end) @@ -571,13 +571,13 @@ describe('XDG defaults', function() .. ',$XDG_DATA_HOME/nvim/after' ):gsub('\\', '/') ), - (meths.get_option_value('runtimepath', {})):gsub('\\', '/') + (meths.nvim_get_option_value('runtimepath', {})):gsub('\\', '/') ) - meths.command('set runtimepath&') - meths.command('set backupdir&') - meths.command('set directory&') - meths.command('set undodir&') - meths.command('set viewdir&') + meths.nvim_command('set runtimepath&') + meths.nvim_command('set backupdir&') + meths.nvim_command('set directory&') + meths.nvim_command('set undodir&') + meths.nvim_command('set viewdir&') eq( ( ( @@ -599,25 +599,25 @@ describe('XDG defaults', function() .. ',$XDG_DATA_HOME/nvim/after' ):gsub('\\', '/') ), - (meths.get_option_value('runtimepath', {})):gsub('\\', '/') + (meths.nvim_get_option_value('runtimepath', {})):gsub('\\', '/') ) eq( ('.,$XDG_CONFIG_HOME/' .. state_dir .. '/backup//'), - meths.get_option_value('backupdir', {}):gsub('\\', '/') + meths.nvim_get_option_value('backupdir', {}):gsub('\\', '/') ) eq( ('$XDG_CONFIG_HOME/' .. state_dir .. '/swap//'), - meths.get_option_value('directory', {}):gsub('\\', '/') + meths.nvim_get_option_value('directory', {}):gsub('\\', '/') ) eq( ('$XDG_CONFIG_HOME/' .. state_dir .. '/undo//'), - meths.get_option_value('undodir', {}):gsub('\\', '/') + meths.nvim_get_option_value('undodir', {}):gsub('\\', '/') ) eq( ('$XDG_CONFIG_HOME/' .. state_dir .. '/view//'), - meths.get_option_value('viewdir', {}):gsub('\\', '/') + meths.nvim_get_option_value('viewdir', {}):gsub('\\', '/') ) - meths.command('set all&') + meths.nvim_command('set all&') eq( ( '$XDG_DATA_HOME/nvim' @@ -637,23 +637,23 @@ describe('XDG defaults', function() .. ',$XDG_DATA_DIRS/nvim/after' .. ',$XDG_DATA_HOME/nvim/after' ):gsub('\\', '/'), - (meths.get_option_value('runtimepath', {})):gsub('\\', '/') + (meths.nvim_get_option_value('runtimepath', {})):gsub('\\', '/') ) eq( ('.,$XDG_CONFIG_HOME/' .. state_dir .. '/backup//'), - meths.get_option_value('backupdir', {}):gsub('\\', '/') + meths.nvim_get_option_value('backupdir', {}):gsub('\\', '/') ) eq( ('$XDG_CONFIG_HOME/' .. state_dir .. '/swap//'), - meths.get_option_value('directory', {}):gsub('\\', '/') + meths.nvim_get_option_value('directory', {}):gsub('\\', '/') ) eq( ('$XDG_CONFIG_HOME/' .. state_dir .. '/undo//'), - meths.get_option_value('undodir', {}):gsub('\\', '/') + meths.nvim_get_option_value('undodir', {}):gsub('\\', '/') ) eq( ('$XDG_CONFIG_HOME/' .. state_dir .. '/view//'), - meths.get_option_value('viewdir', {}):gsub('\\', '/') + meths.nvim_get_option_value('viewdir', {}):gsub('\\', '/') ) eq(nil, (funcs.tempname()):match('XDG_RUNTIME_DIR')) end) @@ -743,13 +743,13 @@ describe('XDG defaults', function() .. path_sep .. 'after' ), - meths.get_option_value('runtimepath', {}) + meths.nvim_get_option_value('runtimepath', {}) ) - meths.command('set runtimepath&') - meths.command('set backupdir&') - meths.command('set directory&') - meths.command('set undodir&') - meths.command('set viewdir&') + meths.nvim_command('set runtimepath&') + meths.nvim_command('set backupdir&') + meths.nvim_command('set directory&') + meths.nvim_command('set undodir&') + meths.nvim_command('set viewdir&') eq( ( '\\, \\, \\,' @@ -821,11 +821,11 @@ describe('XDG defaults', function() .. path_sep .. 'after' ), - meths.get_option_value('runtimepath', {}) + meths.nvim_get_option_value('runtimepath', {}) ) eq( '.,\\,=\\,=\\,' .. path_sep .. state_dir .. '' .. path_sep .. 'backup' .. (path_sep):rep(2), - meths.get_option_value('backupdir', {}) + meths.nvim_get_option_value('backupdir', {}) ) eq( '\\,=\\,=\\,' @@ -836,7 +836,7 @@ describe('XDG defaults', function() .. path_sep .. 'swap' .. (path_sep):rep(2), - meths.get_option_value('directory', {}) + meths.nvim_get_option_value('directory', {}) ) eq( '\\,=\\,=\\,' @@ -847,7 +847,7 @@ describe('XDG defaults', function() .. path_sep .. 'undo' .. (path_sep):rep(2), - meths.get_option_value('undodir', {}) + meths.nvim_get_option_value('undodir', {}) ) eq( '\\,=\\,=\\,' @@ -858,7 +858,7 @@ describe('XDG defaults', function() .. path_sep .. 'view' .. (path_sep):rep(2), - meths.get_option_value('viewdir', {}) + meths.nvim_get_option_value('viewdir', {}) ) end) end) @@ -1112,7 +1112,7 @@ describe('stdpath()', function() local function set_paths_at_runtime(var_name, paths) clear({ env = base_env() }) - meths.set_var('env_val', table.concat(paths, env_sep)) + meths.nvim_set_var('env_val', table.concat(paths, env_sep)) command(('let $%s=g:env_val'):format(var_name)) end diff --git a/test/functional/options/num_options_spec.lua b/test/functional/options/num_options_spec.lua index d81b95ab41..9a153fb507 100644 --- a/test/functional/options/num_options_spec.lua +++ b/test/functional/options/num_options_spec.lua @@ -11,7 +11,7 @@ local function should_fail(opt, value, errmsg) feed_command('setlocal ' .. opt .. '=' .. value) eq(errmsg, eval('v:errmsg'):match('E%d*')) feed_command('let v:errmsg = ""') - local status, err = pcall(meths.set_option_value, opt, value, {}) + local status, err = pcall(meths.nvim_set_option_value, opt, value, {}) eq(status, false) eq(errmsg, err:match('E%d*')) eq('', eval('v:errmsg')) @@ -20,8 +20,8 @@ end local function should_succeed(opt, value) feed_command('setglobal ' .. opt .. '=' .. value) feed_command('setlocal ' .. opt .. '=' .. value) - meths.set_option_value(opt, value, {}) - eq(value, meths.get_option_value(opt, {})) + meths.nvim_set_option_value(opt, value, {}) + eq(value, meths.nvim_get_option_value(opt, {})) eq('', eval('v:errmsg')) end @@ -29,12 +29,12 @@ describe(':setlocal', function() before_each(clear) it('setlocal sets only local value', function() - eq(0, meths.get_option_value('iminsert', { scope = 'global' })) + eq(0, meths.nvim_get_option_value('iminsert', { scope = 'global' })) feed_command('setlocal iminsert=1') - eq(0, meths.get_option_value('iminsert', { scope = 'global' })) - eq(-1, meths.get_option_value('imsearch', { scope = 'global' })) + eq(0, meths.nvim_get_option_value('iminsert', { scope = 'global' })) + eq(-1, meths.nvim_get_option_value('imsearch', { scope = 'global' })) feed_command('setlocal imsearch=1') - eq(-1, meths.get_option_value('imsearch', { scope = 'global' })) + eq(-1, meths.nvim_get_option_value('imsearch', { scope = 'global' })) end) end) @@ -77,8 +77,8 @@ describe(':set validation', function() -- If smaller than 1 this one is set to 'lines'-1 feed_command('setglobal window=-10') - meths.set_option_value('window', -10, {}) - eq(23, meths.get_option_value('window', {})) + meths.nvim_set_option_value('window', -10, {}) + eq(23, meths.nvim_get_option_value('window', {})) eq('', eval('v:errmsg')) -- 'scrolloff' and 'sidescrolloff' can have a -1 value when @@ -112,8 +112,8 @@ describe(':set validation', function() local function setto(value) feed_command('setglobal maxcombine=' .. value) feed_command('setlocal maxcombine=' .. value) - meths.set_option_value('maxcombine', value, {}) - eq(6, meths.get_option_value('maxcombine', {})) + meths.nvim_set_option_value('maxcombine', value, {}) + eq(6, meths.nvim_get_option_value('maxcombine', {})) eq('', eval('v:errmsg')) end setto(0) diff --git a/test/functional/plugin/editorconfig_spec.lua b/test/functional/plugin/editorconfig_spec.lua index 2c9ce7ae1a..0689cd09d3 100644 --- a/test/functional/plugin/editorconfig_spec.lua +++ b/test/functional/plugin/editorconfig_spec.lua @@ -13,7 +13,7 @@ local function test_case(name, expected) local filename = testdir .. pathsep .. name command('edit ' .. filename) for opt, val in pairs(expected) do - eq(val, meths.get_option_value(opt, { buf = 0 }), name) + eq(val, meths.nvim_get_option_value(opt, { buf = 0 }), name) end end @@ -195,15 +195,15 @@ But not this one end) it('can be disabled globally', function() - meths.set_var('editorconfig', false) - meths.set_option_value('shiftwidth', 42, {}) + meths.nvim_set_var('editorconfig', false) + meths.nvim_set_option_value('shiftwidth', 42, {}) test_case('3_space.txt', { shiftwidth = 42 }) end) it('can be disabled per-buffer', function() - meths.set_option_value('shiftwidth', 42, {}) + meths.nvim_set_option_value('shiftwidth', 42, {}) local bufnr = funcs.bufadd(testdir .. pathsep .. '3_space.txt') - meths.buf_set_var(bufnr, 'editorconfig', false) + meths.nvim_buf_set_var(bufnr, 'editorconfig', false) test_case('3_space.txt', { shiftwidth = 42 }) test_case('4_space.py', { shiftwidth = 4 }) end) diff --git a/test/functional/plugin/lsp/incremental_sync_spec.lua b/test/functional/plugin/lsp/incremental_sync_spec.lua index 9b33f4451e..ec918ed514 100644 --- a/test/functional/plugin/lsp/incremental_sync_spec.lua +++ b/test/functional/plugin/lsp/incremental_sync_spec.lua @@ -62,7 +62,7 @@ local function test_edit( offset_encoding = offset_encoding or 'utf-16' line_ending = line_ending or '\n' - meths.buf_set_lines(0, 0, -1, true, prev_buffer) + meths.nvim_buf_set_lines(0, 0, -1, true, prev_buffer) exec_lua('return test_register(...)', 0, 'test1', offset_encoding, line_ending) for _, edit in ipairs(edit_operations) do diff --git a/test/functional/plugin/lsp_spec.lua b/test/functional/plugin/lsp_spec.lua index d794a34463..43bfb89e81 100644 --- a/test/functional/plugin/lsp_spec.lua +++ b/test/functional/plugin/lsp_spec.lua @@ -363,9 +363,9 @@ describe('LSP', function() end, on_handler = function(_, _, ctx) if ctx.method == 'finish' then - eq('basic_init', meths.get_var('lsp_attached')) + eq('basic_init', meths.nvim_get_var('lsp_attached')) exec_lua('return lsp.buf_detach_client(BUFFER, TEST_RPC_CLIENT_ID)') - eq('basic_init', meths.get_var('lsp_detached')) + eq('basic_init', meths.nvim_get_var('lsp_detached')) client.stop() end end, diff --git a/test/functional/plugin/matchparen_spec.lua b/test/functional/plugin/matchparen_spec.lua index 1c4e11d30b..2bda41359b 100644 --- a/test/functional/plugin/matchparen_spec.lua +++ b/test/functional/plugin/matchparen_spec.lua @@ -22,7 +22,7 @@ describe('matchparen', function() it('uses correct column after i_<Up>. Vim patch 7.4.1296', function() command('set noautoindent nosmartindent nocindent laststatus=0') - eq(1, meths.get_var('loaded_matchparen')) + eq(1, meths.nvim_get_var('loaded_matchparen')) feed('ivoid f_test()<cr>') feed('{<cr>') feed('}') diff --git a/test/functional/plugin/msgpack_spec.lua b/test/functional/plugin/msgpack_spec.lua index 985252fd75..bc1182afd3 100644 --- a/test/functional/plugin/msgpack_spec.lua +++ b/test/functional/plugin/msgpack_spec.lua @@ -526,17 +526,17 @@ describe('autoload/msgpack.vim', function() end) it('works for special v: values like v:true', function() - meths.set_var('true', true) - meths.set_var('false', false) - meths.set_var('nil', NIL) + meths.nvim_set_var('true', true) + meths.nvim_set_var('false', false) + meths.nvim_set_var('nil', NIL) nvim_command('let true2 = msgpack#deepcopy(true)') nvim_command('let false2 = msgpack#deepcopy(false)') nvim_command('let nil2 = msgpack#deepcopy(nil)') - eq(true, meths.get_var('true')) - eq(false, meths.get_var('false')) - eq(NIL, meths.get_var('nil')) + eq(true, meths.nvim_get_var('true')) + eq(false, meths.nvim_get_var('false')) + eq(NIL, meths.nvim_get_var('nil')) end) end) diff --git a/test/functional/plugin/shada_spec.lua b/test/functional/plugin/shada_spec.lua index 59ddd8f3ce..628ff968d7 100644 --- a/test/functional/plugin/shada_spec.lua +++ b/test/functional/plugin/shada_spec.lua @@ -2644,7 +2644,8 @@ describe('plugin/shada.vim', function() wshada('\004\000\009\147\000\196\002ab\196\001a') wshada_tmp('\004\000\009\147\000\196\002ab\196\001b') - local bufread_commands = meths.get_autocmds({ group = 'ShaDaCommands', event = 'BufReadCmd' }) + local bufread_commands = + meths.nvim_get_autocmds({ group = 'ShaDaCommands', event = 'BufReadCmd' }) eq(2, #bufread_commands--[[, vim.inspect(bufread_commands) ]]) -- Need to set nohidden so that the buffer containing 'fname' is not unloaded diff --git a/test/functional/provider/clipboard_spec.lua b/test/functional/provider/clipboard_spec.lua index a48404164f..1b2e3ee689 100644 --- a/test/functional/provider/clipboard_spec.lua +++ b/test/functional/provider/clipboard_spec.lua @@ -188,7 +188,7 @@ describe('clipboard', function() it('valid g:clipboard', function() -- provider#clipboard#Executable() only checks the structure. - meths.set_var('clipboard', { + meths.nvim_set_var('clipboard', { ['name'] = 'clippy!', ['copy'] = { ['+'] = 'any command', ['*'] = 'some other' }, ['paste'] = { ['+'] = 'any command', ['*'] = 'some other' }, @@ -545,7 +545,7 @@ describe('clipboard (with fake clipboard.vim)', function() eq({ { 'text', '' }, 'V' }, eval("g:test_clip['*']")) command("let g:test_clip['*'] = [['star'], 'c']") feed('p') - eq('textstar', meths.get_current_line()) + eq('textstar', meths.nvim_get_current_line()) end) it('Block paste works correctly', function() diff --git a/test/functional/provider/perl_spec.lua b/test/functional/provider/perl_spec.lua index ae110cb3b0..d0a9ea618e 100644 --- a/test/functional/provider/perl_spec.lua +++ b/test/functional/provider/perl_spec.lua @@ -48,7 +48,7 @@ describe('legacy perl provider', function() -- :perldo 1; doesn't change $_, -- the buffer should not be changed command('normal :perldo 1;') - eq(false, meths.get_option_value('modified', {})) + eq(false, meths.nvim_get_option_value('modified', {})) -- insert some text insert('abc\ndef\nghi') expect([[ diff --git a/test/functional/provider/ruby_spec.lua b/test/functional/provider/ruby_spec.lua index 438f41450a..2a64830bca 100644 --- a/test/functional/provider/ruby_spec.lua +++ b/test/functional/provider/ruby_spec.lua @@ -43,12 +43,12 @@ end) describe(':ruby command', function() it('evaluates ruby', function() command('ruby VIM.command("let g:set_by_ruby = [100, 0]")') - eq({ 100, 0 }, meths.get_var('set_by_ruby')) + eq({ 100, 0 }, meths.nvim_get_var('set_by_ruby')) end) it('supports nesting', function() command([[ruby VIM.command('ruby VIM.command("let set_by_nested_ruby = 555")')]]) - eq(555, meths.get_var('set_by_nested_ruby')) + eq(555, meths.nvim_get_var('set_by_nested_ruby')) end) end) @@ -57,7 +57,7 @@ describe(':rubyfile command', function() local fname = 'rubyfile.rb' write_file(fname, 'VIM.command("let set_by_rubyfile = 123")') command('rubyfile rubyfile.rb') - eq(123, meths.get_var('set_by_rubyfile')) + eq(123, meths.nvim_get_var('set_by_rubyfile')) os.remove(fname) end) end) @@ -97,7 +97,7 @@ describe(':rubydo command', function() it('does not modify the buffer if no changes are made', function() command('normal :rubydo 42') - eq(false, meths.get_option_value('modified', {})) + eq(false, meths.nvim_get_option_value('modified', {})) end) end) diff --git a/test/functional/shada/buffers_spec.lua b/test/functional/shada/buffers_spec.lua index b16fa975b6..c0fb3815b6 100644 --- a/test/functional/shada/buffers_spec.lua +++ b/test/functional/shada/buffers_spec.lua @@ -48,7 +48,7 @@ describe('shada support code', function() reset('set shada+=%') nvim_command('edit ' .. testfilename) nvim_command('edit ' .. testfilename_2) - meths.set_option_value('buflisted', false, {}) + meths.nvim_set_option_value('buflisted', false, {}) expect_exit(nvim_command, 'qall') reset('set shada+=%') eq(2, funcs.bufnr('$')) @@ -60,7 +60,7 @@ describe('shada support code', function() reset('set shada+=%') nvim_command('edit ' .. testfilename) nvim_command('edit ' .. testfilename_2) - meths.set_option_value('buftype', 'quickfix', {}) + meths.nvim_set_option_value('buftype', 'quickfix', {}) expect_exit(nvim_command, 'qall') reset('set shada+=%') eq(2, funcs.bufnr('$')) diff --git a/test/functional/shada/helpers.lua b/test/functional/shada/helpers.lua index d8ffdaf753..5235458528 100644 --- a/test/functional/shada/helpers.lua +++ b/test/functional/shada/helpers.lua @@ -28,7 +28,7 @@ local function reset(o) args_rm = args_rm, args = args, } - meths.set_var('tmpname', tmpname) + meths.nvim_set_var('tmpname', tmpname) end local clear = function() diff --git a/test/functional/shada/history_spec.lua b/test/functional/shada/history_spec.lua index 476036312d..da0ce2def7 100644 --- a/test/functional/shada/history_spec.lua +++ b/test/functional/shada/history_spec.lua @@ -104,40 +104,40 @@ describe('ShaDa support code', function() end) it('dumps and loads last search pattern with offset', function() - meths.set_option_value('wrapscan', false, {}) + meths.nvim_set_option_value('wrapscan', false, {}) funcs.setline('.', { 'foo', 'bar--' }) nvim_feed('gg0/a/e+1\n') eq({ 0, 2, 3, 0 }, funcs.getpos('.')) nvim_command('wshada') reset() - meths.set_option_value('wrapscan', false, {}) + meths.nvim_set_option_value('wrapscan', false, {}) funcs.setline('.', { 'foo', 'bar--' }) nvim_feed('gg0n') eq({ 0, 2, 3, 0 }, funcs.getpos('.')) - eq(1, meths.get_vvar('searchforward')) + eq(1, meths.nvim_get_vvar('searchforward')) end) it('dumps and loads last search pattern with offset and backward direction', function() - meths.set_option_value('wrapscan', false, {}) + meths.nvim_set_option_value('wrapscan', false, {}) funcs.setline('.', { 'foo', 'bar--' }) nvim_feed('G$?a?e+1\n') eq({ 0, 2, 3, 0 }, funcs.getpos('.')) nvim_command('wshada') reset() - meths.set_option_value('wrapscan', false, {}) + meths.nvim_set_option_value('wrapscan', false, {}) funcs.setline('.', { 'foo', 'bar--' }) nvim_feed('G$n') eq({ 0, 2, 3, 0 }, funcs.getpos('.')) - eq(0, meths.get_vvar('searchforward')) + eq(0, meths.nvim_get_vvar('searchforward')) end) it('saves v:hlsearch=1', function() nvim_command('set hlsearch shada-=h') nvim_feed('/test\n') - eq(1, meths.get_vvar('hlsearch')) + eq(1, meths.nvim_get_vvar('hlsearch')) expect_exit(nvim_command, 'qall') reset() - eq(1, meths.get_vvar('hlsearch')) + eq(1, meths.nvim_get_vvar('hlsearch')) end) it('saves v:hlsearch=0 with :nohl', function() @@ -146,16 +146,16 @@ describe('ShaDa support code', function() nvim_command('nohlsearch') expect_exit(nvim_command, 'qall') reset() - eq(0, meths.get_vvar('hlsearch')) + eq(0, meths.nvim_get_vvar('hlsearch')) end) it('saves v:hlsearch=0 with default &shada', function() nvim_command('set hlsearch') nvim_feed('/test\n') - eq(1, meths.get_vvar('hlsearch')) + eq(1, meths.nvim_get_vvar('hlsearch')) expect_exit(nvim_command, 'qall') reset() - eq(0, meths.get_vvar('hlsearch')) + eq(0, meths.nvim_get_vvar('hlsearch')) end) it('dumps and loads last substitute pattern and replacement string', function() diff --git a/test/functional/shada/marks_spec.lua b/test/functional/shada/marks_spec.lua index a1c851a9d5..b50df23be4 100644 --- a/test/functional/shada/marks_spec.lua +++ b/test/functional/shada/marks_spec.lua @@ -124,7 +124,7 @@ describe('ShaDa support code', function() local tf_full_2 = curbufmeths.get_name() expect_exit(nvim_command, 'qall') reset() - local oldfiles = meths.get_vvar('oldfiles') + local oldfiles = meths.nvim_get_vvar('oldfiles') table.sort(oldfiles) eq(2, #oldfiles) eq(testfilename, oldfiles[1]:sub(-#testfilename)) @@ -132,7 +132,7 @@ describe('ShaDa support code', function() eq(tf_full, oldfiles[1]) eq(tf_full_2, oldfiles[2]) nvim_command('rshada!') - oldfiles = meths.get_vvar('oldfiles') + oldfiles = meths.nvim_get_vvar('oldfiles') table.sort(oldfiles) eq(2, #oldfiles) eq(testfilename, oldfiles[1]:sub(-#testfilename)) @@ -229,7 +229,7 @@ describe('ShaDa support code', function() }, args = { '-i', - meths.get_var('tmpname'), -- Use same shada file as parent. + meths.nvim_get_var('tmpname'), -- Use same shada file as parent. '--cmd', 'silent edit ' .. non_existent_testfilename, '-c', @@ -248,7 +248,7 @@ describe('ShaDa support code', function() }, args = { '-i', - meths.get_var('tmpname'), -- Use same shada file as parent. + meths.nvim_get_var('tmpname'), -- Use same shada file as parent. '-c', 'silent edit ' .. non_existent_testfilename, '-c', diff --git a/test/functional/shada/shada_spec.lua b/test/functional/shada/shada_spec.lua index 4b52c1835b..b16a19ef31 100644 --- a/test/functional/shada/shada_spec.lua +++ b/test/functional/shada/shada_spec.lua @@ -175,7 +175,7 @@ describe('ShaDa support code', function() it('correctly uses shada-r option', function() nvim_command('set shellslash') - meths.set_var('__home', paths.test_source_path) + meths.nvim_set_var('__home', paths.test_source_path) nvim_command('let $HOME = __home') nvim_command('unlet __home') nvim_command('edit ~/README.md') @@ -203,7 +203,7 @@ describe('ShaDa support code', function() local pwd = funcs.getcwd() local relfname = 'абв/test' local fname = pwd .. '/' .. relfname - meths.set_var('__fname', fname) + meths.nvim_set_var('__fname', fname) nvim_command('silent! edit `=__fname`') funcs.setline(1, { 'a', 'b', 'c', 'd' }) nvim_command('normal! GmAggmaAabc') @@ -217,30 +217,30 @@ describe('ShaDa support code', function() end) it('is able to set &shada after &viminfo', function() - meths.set_option_value('viminfo', "'10", {}) - eq("'10", meths.get_option_value('viminfo', {})) - eq("'10", meths.get_option_value('shada', {})) - meths.set_option_value('shada', '', {}) - eq('', meths.get_option_value('viminfo', {})) - eq('', meths.get_option_value('shada', {})) + meths.nvim_set_option_value('viminfo', "'10", {}) + eq("'10", meths.nvim_get_option_value('viminfo', {})) + eq("'10", meths.nvim_get_option_value('shada', {})) + meths.nvim_set_option_value('shada', '', {}) + eq('', meths.nvim_get_option_value('viminfo', {})) + eq('', meths.nvim_get_option_value('shada', {})) end) it('is able to set all& after setting &shada', function() - meths.set_option_value('shada', "'10", {}) - eq("'10", meths.get_option_value('viminfo', {})) - eq("'10", meths.get_option_value('shada', {})) + meths.nvim_set_option_value('shada', "'10", {}) + eq("'10", meths.nvim_get_option_value('viminfo', {})) + eq("'10", meths.nvim_get_option_value('shada', {})) nvim_command('set all&') - eq("!,'100,<50,s10,h", meths.get_option_value('viminfo', {})) - eq("!,'100,<50,s10,h", meths.get_option_value('shada', {})) + eq("!,'100,<50,s10,h", meths.nvim_get_option_value('viminfo', {})) + eq("!,'100,<50,s10,h", meths.nvim_get_option_value('shada', {})) end) it('is able to set &shada after &viminfo using :set', function() nvim_command("set viminfo='10") - eq("'10", meths.get_option_value('viminfo', {})) - eq("'10", meths.get_option_value('shada', {})) + eq("'10", meths.nvim_get_option_value('viminfo', {})) + eq("'10", meths.nvim_get_option_value('shada', {})) nvim_command('set shada=') - eq('', meths.get_option_value('viminfo', {})) - eq('', meths.get_option_value('shada', {})) + eq('', meths.nvim_get_option_value('viminfo', {})) + eq('', meths.nvim_get_option_value('shada', {})) end) it('setting &shada gives proper error message on missing number', function() @@ -259,14 +259,14 @@ describe('ShaDa support code', function() funcs.mkdir(dirname, '', 0) eq(0, funcs.filewritable(dirname)) reset { shadafile = dirshada, args = { '--cmd', 'set shada=' } } - meths.set_option_value('shada', "'10", {}) + meths.nvim_set_option_value('shada', "'10", {}) eq( 'Vim(wshada):E886: System error while opening ShaDa file ' .. 'Xtest-functional-shada-shada.d/main.shada for reading to merge ' .. 'before writing it: permission denied', exc_exec('wshada') ) - meths.set_option_value('shada', '', {}) + meths.nvim_set_option_value('shada', '', {}) end) end) diff --git a/test/functional/shada/variables_spec.lua b/test/functional/shada/variables_spec.lua index 49dd5837a7..6096c72bcb 100644 --- a/test/functional/shada/variables_spec.lua +++ b/test/functional/shada/variables_spec.lua @@ -12,13 +12,13 @@ describe('ShaDa support code', function() after_each(clear) it('is able to dump and read back string variable', function() - meths.set_var('STRVAR', 'foo') + meths.nvim_set_var('STRVAR', 'foo') nvim_command('set shada+=!') nvim_command('wshada') reset() nvim_command('set shada+=!') nvim_command('rshada') - eq('foo', meths.get_var('STRVAR')) + eq('foo', meths.nvim_get_var('STRVAR')) end) local autotest = function(tname, varname, varval, val_is_expr) @@ -26,9 +26,9 @@ describe('ShaDa support code', function() reset('set shada+=!') if val_is_expr then nvim_command('let g:' .. varname .. ' = ' .. varval) - varval = meths.get_var(varname) + varval = meths.nvim_get_var(varname) else - meths.set_var(varname, varval) + meths.nvim_set_var(varname, varval) end local vartype = eval('type(g:' .. varname .. ')') -- Exit during `reset` is not a regular exit: it does not write shada @@ -36,7 +36,7 @@ describe('ShaDa support code', function() expect_exit(nvim_command, 'qall') reset('set shada+=!') eq(vartype, eval('type(g:' .. varname .. ')')) - eq(varval, meths.get_var(varname)) + eq(varval, meths.nvim_get_var(varname)) end) end @@ -53,7 +53,7 @@ describe('ShaDa support code', function() autotest('blob (with NULs)', 'BLOBVARNULS', '0z004e554c7300', true) it('does not read back variables without `!` in &shada', function() - meths.set_var('STRVAR', 'foo') + meths.nvim_set_var('STRVAR', 'foo') nvim_command('set shada+=!') nvim_command('wshada') reset('set shada-=!') @@ -63,7 +63,7 @@ describe('ShaDa support code', function() it('does not dump variables without `!` in &shada', function() nvim_command('set shada-=!') - meths.set_var('STRVAR', 'foo') + meths.nvim_set_var('STRVAR', 'foo') nvim_command('wshada') reset() nvim_command('set shada+=!') @@ -73,7 +73,7 @@ describe('ShaDa support code', function() it('does not dump session variables', function() nvim_command('set shada+=!') - meths.set_var('StrVar', 'foo') + meths.nvim_set_var('StrVar', 'foo') nvim_command('wshada') reset() nvim_command('set shada+=!') @@ -83,7 +83,7 @@ describe('ShaDa support code', function() it('does not dump regular variables', function() nvim_command('set shada+=!') - meths.set_var('str_var', 'foo') + meths.nvim_set_var('str_var', 'foo') nvim_command('wshada') reset() nvim_command('set shada+=!') @@ -93,70 +93,73 @@ describe('ShaDa support code', function() it('dumps and loads variables correctly with utf-8 strings', function() reset() - meths.set_var('STRVAR', '«') - meths.set_var('LSTVAR', { '«' }) - meths.set_var('DCTVAR', { ['«'] = '«' }) - meths.set_var('NESTEDVAR', { ['«'] = { { '«' }, { ['«'] = '«' }, { a = 'Test' } } }) + meths.nvim_set_var('STRVAR', '«') + meths.nvim_set_var('LSTVAR', { '«' }) + meths.nvim_set_var('DCTVAR', { ['«'] = '«' }) + meths.nvim_set_var('NESTEDVAR', { ['«'] = { { '«' }, { ['«'] = '«' }, { a = 'Test' } } }) expect_exit(nvim_command, 'qall') reset() - eq('«', meths.get_var('STRVAR')) - eq({ '«' }, meths.get_var('LSTVAR')) - eq({ ['«'] = '«' }, meths.get_var('DCTVAR')) - eq({ ['«'] = { { '«' }, { ['«'] = '«' }, { a = 'Test' } } }, meths.get_var('NESTEDVAR')) + eq('«', meths.nvim_get_var('STRVAR')) + eq({ '«' }, meths.nvim_get_var('LSTVAR')) + eq({ ['«'] = '«' }, meths.nvim_get_var('DCTVAR')) + eq( + { ['«'] = { { '«' }, { ['«'] = '«' }, { a = 'Test' } } }, + meths.nvim_get_var('NESTEDVAR') + ) end) it('dumps and loads variables correctly with 8-bit strings', function() reset() -- \171 is U+00AB LEFT-POINTING DOUBLE ANGLE QUOTATION MARK in latin1 -- This is invalid unicode, but we should still dump and restore it. - meths.set_var('STRVAR', '\171') - meths.set_var('LSTVAR', { '\171' }) - meths.set_var('DCTVAR', { ['«\171'] = '«\171' }) - meths.set_var( + meths.nvim_set_var('STRVAR', '\171') + meths.nvim_set_var('LSTVAR', { '\171' }) + meths.nvim_set_var('DCTVAR', { ['«\171'] = '«\171' }) + meths.nvim_set_var( 'NESTEDVAR', { ['\171'] = { { '\171«' }, { ['\171'] = '\171' }, { a = 'Test' } } } ) expect_exit(nvim_command, 'qall') reset() - eq('\171', meths.get_var('STRVAR')) - eq({ '\171' }, meths.get_var('LSTVAR')) - eq({ ['«\171'] = '«\171' }, meths.get_var('DCTVAR')) + eq('\171', meths.nvim_get_var('STRVAR')) + eq({ '\171' }, meths.nvim_get_var('LSTVAR')) + eq({ ['«\171'] = '«\171' }, meths.nvim_get_var('DCTVAR')) eq( { ['\171'] = { { '\171«' }, { ['\171'] = '\171' }, { a = 'Test' } } }, - meths.get_var('NESTEDVAR') + meths.nvim_get_var('NESTEDVAR') ) end) it('ignore when a funcref is stored in a variable', function() nvim_command('let F = function("tr")') - meths.set_var('U', '10') + meths.nvim_set_var('U', '10') nvim_command('set shada+=!') nvim_command('wshada') reset() nvim_command('set shada+=!') nvim_command('rshada') - eq('10', meths.get_var('U')) + eq('10', meths.nvim_get_var('U')) end) it('ignore when a partial is stored in a variable', function() nvim_command('let P = { -> 1 }') - meths.set_var('U', '10') + meths.nvim_set_var('U', '10') nvim_command('set shada+=!') nvim_command('wshada') reset() nvim_command('set shada+=!') nvim_command('rshada') - eq('10', meths.get_var('U')) + eq('10', meths.nvim_get_var('U')) end) it('ignore when a self-referencing list is stored in a variable', function() - meths.set_var('L', {}) + meths.nvim_set_var('L', {}) nvim_command('call add(L, L)') - meths.set_var('U', '10') + meths.nvim_set_var('U', '10') nvim_command('set shada+=!') nvim_command('wshada') reset() nvim_command('rshada') - eq('10', meths.get_var('U')) + eq('10', meths.nvim_get_var('U')) end) end) diff --git a/test/functional/terminal/buffer_spec.lua b/test/functional/terminal/buffer_spec.lua index 48a38864d6..541812b4be 100644 --- a/test/functional/terminal/buffer_spec.lua +++ b/test/functional/terminal/buffer_spec.lua @@ -321,8 +321,8 @@ describe(':terminal buffer', function() it('emits TermRequest events #26972', function() command('split') command('enew') - local term = meths.open_term(0, {}) - local termbuf = meths.get_current_buf().id + local term = meths.nvim_open_term(0, {}) + local termbuf = meths.nvim_get_current_buf().id -- Test that autocommand buffer is associated with the terminal buffer, not the current buffer command('au TermRequest * let g:termbuf = +expand("<abuf>")') @@ -332,7 +332,7 @@ describe(':terminal buffer', function() local cwd = funcs.getcwd():gsub('\\', '/') local parent = cwd:match('^(.+/)') local expected = '\027]7;file://host' .. parent - meths.chan_send(term, string.format('%s\027\\', expected)) + meths.nvim_chan_send(term, string.format('%s\027\\', expected)) eq(expected, eval('v:termrequest')) eq(termbuf, eval('g:termbuf')) end) @@ -405,11 +405,11 @@ end) it('terminal truncates number of composing characters to 5', function() clear() - local chan = meths.open_term(0, {}) + local chan = meths.nvim_open_term(0, {}) local composing = ('a̳'):sub(2) - meths.chan_send(chan, 'a' .. composing:rep(8)) + meths.nvim_chan_send(chan, 'a' .. composing:rep(8)) retry(nil, nil, function() - eq('a' .. composing:rep(5), meths.get_current_line()) + eq('a' .. composing:rep(5), meths.nvim_get_current_line()) end) end) @@ -512,7 +512,7 @@ describe('terminal input', function() }) do feed('<CR><C-V>' .. key) retry(nil, nil, function() - eq(key, meths.get_current_line()) + eq(key, meths.nvim_get_current_line()) end) end end) diff --git a/test/functional/terminal/channel_spec.lua b/test/functional/terminal/channel_spec.lua index b2553bf2e0..80333fcf2f 100644 --- a/test/functional/terminal/channel_spec.lua +++ b/test/functional/terminal/channel_spec.lua @@ -140,7 +140,7 @@ describe('no crash when TermOpen autocommand', function() before_each(function() clear() - meths.set_option_value('shell', testprg('shell-test'), {}) + meths.nvim_set_option_value('shell', testprg('shell-test'), {}) command('set shellcmdflag=EXE shellredir= shellpipe= shellquote= shellxquote=') screen = Screen.new(60, 4) screen:set_default_attr_ids({ @@ -232,11 +232,11 @@ describe('nvim_open_term', function() end) it('with force_crlf=true converts newlines', function() - local win = meths.get_current_win() - local buf = meths.create_buf(false, true) - local term = meths.open_term(buf, { force_crlf = true }) - meths.win_set_buf(win, buf) - meths.chan_send(term, 'here\nthere\nfoo\r\nbar\n\ntest') + local win = meths.nvim_get_current_win() + local buf = meths.nvim_create_buf(false, true) + local term = meths.nvim_open_term(buf, { force_crlf = true }) + meths.nvim_win_set_buf(win, buf) + meths.nvim_chan_send(term, 'here\nthere\nfoo\r\nbar\n\ntest') screen:expect { grid = [[ ^here | @@ -248,7 +248,7 @@ describe('nvim_open_term', function() |*4 ]], } - meths.chan_send(term, '\nfirst') + meths.nvim_chan_send(term, '\nfirst') screen:expect { grid = [[ ^here | @@ -264,11 +264,11 @@ describe('nvim_open_term', function() end) it('with force_crlf=false does not convert newlines', function() - local win = meths.get_current_win() - local buf = meths.create_buf(false, true) - local term = meths.open_term(buf, { force_crlf = false }) - meths.win_set_buf(win, buf) - meths.chan_send(term, 'here\nthere') + local win = meths.nvim_get_current_win() + local buf = meths.nvim_create_buf(false, true) + local term = meths.nvim_open_term(buf, { force_crlf = false }) + meths.nvim_win_set_buf(win, buf) + meths.nvim_chan_send(term, 'here\nthere') screen:expect { grid = [[ ^here | there | diff --git a/test/functional/terminal/edit_spec.lua b/test/functional/terminal/edit_spec.lua index 7625e09891..4f462b9e5b 100644 --- a/test/functional/terminal/edit_spec.lua +++ b/test/functional/terminal/edit_spec.lua @@ -21,15 +21,15 @@ describe(':edit term://*', function() before_each(function() clear() - meths.set_option_value('shell', testprg('shell-test'), {}) - meths.set_option_value('shellcmdflag', 'EXE', {}) + meths.nvim_set_option_value('shell', testprg('shell-test'), {}) + meths.nvim_set_option_value('shellcmdflag', 'EXE', {}) end) it('runs TermOpen event', function() - meths.set_var('termopen_runs', {}) + meths.nvim_set_var('termopen_runs', {}) command('autocmd TermOpen * :call add(g:termopen_runs, expand("<amatch>"))') command('edit term://') - local termopen_runs = meths.get_var('termopen_runs') + local termopen_runs = meths.nvim_get_var('termopen_runs') eq(1, #termopen_runs) local cwd = funcs.fnamemodify('.', ':p:~'):gsub([[[\/]*$]], '') matches('^term://' .. pesc(cwd) .. '//%d+:$', termopen_runs[1]) @@ -39,7 +39,7 @@ describe(':edit term://*', function() local columns, lines = 20, 4 local scr = get_screen(columns, lines) local rep = 97 - meths.set_option_value('shellcmdflag', 'REP ' .. rep, {}) + meths.nvim_set_option_value('shellcmdflag', 'REP ' .. rep, {}) command('set shellxquote=') -- win: avoid extra quotes local sb = 10 command( diff --git a/test/functional/terminal/scrollback_spec.lua b/test/functional/terminal/scrollback_spec.lua index f5c9887cdd..7c1da6b32b 100644 --- a/test/functional/terminal/scrollback_spec.lua +++ b/test/functional/terminal/scrollback_spec.lua @@ -400,7 +400,7 @@ describe("'scrollback' option", function() screen = thelpers.screen_setup(nil, { 'sh' }, 30) end - meths.set_option_value('scrollback', 0, {}) + meths.nvim_set_option_value('scrollback', 0, {}) feed_data(('%s REP 31 line%s'):format(testprg('shell-test'), is_os('win') and '\r' or '\n')) screen:expect { any = '30: line ' } retry(nil, nil, function() @@ -418,7 +418,7 @@ describe("'scrollback' option", function() screen = thelpers.screen_setup(nil, { 'sh' }, 30) end - meths.set_option_value('scrollback', 200, {}) + meths.nvim_set_option_value('scrollback', 200, {}) -- Wait for prompt. screen:expect { any = '%$' } @@ -429,12 +429,12 @@ describe("'scrollback' option", function() retry(nil, nil, function() expect_lines(33, 2) end) - meths.set_option_value('scrollback', 10, {}) + meths.nvim_set_option_value('scrollback', 10, {}) poke_eventloop() retry(nil, nil, function() expect_lines(16) end) - meths.set_option_value('scrollback', 10000, {}) + meths.nvim_set_option_value('scrollback', 10000, {}) retry(nil, nil, function() expect_lines(16) end) @@ -495,18 +495,18 @@ describe("'scrollback' option", function() ]]) local term_height = 6 -- Actual terminal screen height, not the scrollback -- Initial - local scrollback = meths.get_option_value('scrollback', {}) + local scrollback = meths.nvim_get_option_value('scrollback', {}) eq(scrollback + term_height, eval('line("$")')) -- Reduction scrollback = scrollback - 2 - meths.set_option_value('scrollback', scrollback, {}) + meths.nvim_set_option_value('scrollback', scrollback, {}) eq(scrollback + term_height, eval('line("$")')) end) it('defaults to 10000 in :terminal buffers', function() set_fake_shell() command('terminal') - eq(10000, meths.get_option_value('scrollback', {})) + eq(10000, meths.nvim_get_option_value('scrollback', {})) end) it('error if set to invalid value', function() @@ -519,7 +519,7 @@ describe("'scrollback' option", function() it('defaults to -1 on normal buffers', function() command('new') - eq(-1, meths.get_option_value('scrollback', {})) + eq(-1, meths.nvim_get_option_value('scrollback', {})) end) it(':setlocal in a :terminal buffer', function() @@ -528,45 +528,45 @@ describe("'scrollback' option", function() -- _Global_ scrollback=-1 defaults :terminal to 10_000. command('setglobal scrollback=-1') command('terminal') - eq(10000, meths.get_option_value('scrollback', {})) + eq(10000, meths.nvim_get_option_value('scrollback', {})) -- _Local_ scrollback=-1 in :terminal forces the _maximum_. command('setlocal scrollback=-1') retry(nil, nil, function() -- Fixup happens on refresh, not immediately. - eq(100000, meths.get_option_value('scrollback', {})) + eq(100000, meths.nvim_get_option_value('scrollback', {})) end) -- _Local_ scrollback=-1 during TermOpen forces the maximum. #9605 command('setglobal scrollback=-1') command('autocmd TermOpen * setlocal scrollback=-1') command('terminal') - eq(100000, meths.get_option_value('scrollback', {})) + eq(100000, meths.nvim_get_option_value('scrollback', {})) end) it(':setlocal in a normal buffer', function() command('new') -- :setlocal to -1. command('setlocal scrollback=-1') - eq(-1, meths.get_option_value('scrollback', {})) + eq(-1, meths.nvim_get_option_value('scrollback', {})) -- :setlocal to anything except -1. Currently, this just has no effect. command('setlocal scrollback=42') - eq(42, meths.get_option_value('scrollback', {})) + eq(42, meths.nvim_get_option_value('scrollback', {})) end) it(':set updates local value and global default', function() set_fake_shell() command('set scrollback=42') -- set global value - eq(42, meths.get_option_value('scrollback', {})) + eq(42, meths.nvim_get_option_value('scrollback', {})) command('terminal') - eq(42, meths.get_option_value('scrollback', {})) -- inherits global default + eq(42, meths.nvim_get_option_value('scrollback', {})) -- inherits global default command('setlocal scrollback=99') - eq(99, meths.get_option_value('scrollback', {})) + eq(99, meths.nvim_get_option_value('scrollback', {})) command('set scrollback<') -- reset to global default - eq(42, meths.get_option_value('scrollback', {})) + eq(42, meths.nvim_get_option_value('scrollback', {})) command('setglobal scrollback=734') -- new global default - eq(42, meths.get_option_value('scrollback', {})) -- local value did not change + eq(42, meths.nvim_get_option_value('scrollback', {})) -- local value did not change command('terminal') - eq(734, meths.get_option_value('scrollback', {})) + eq(734, meths.nvim_get_option_value('scrollback', {})) end) end) diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua index e65e57bc7f..bd122ee848 100644 --- a/test/functional/terminal/tui_spec.lua +++ b/test/functional/terminal/tui_spec.lua @@ -375,7 +375,7 @@ describe('TUI', function() if esc then feed_data('\027[<65;8;1M') else - meths.input_mouse('wheel', 'down', '', 0, 0, 7) + meths.nvim_input_mouse('wheel', 'down', '', 0, 0, 7) end screen:expect([[ {11: 2 }{1:0}----1----2----3----4│{11: 1 }0----1----2----3----| @@ -390,7 +390,7 @@ describe('TUI', function() if esc then feed_data('\027[<65;48;1M') else - meths.input_mouse('wheel', 'down', '', 0, 0, 47) + meths.nvim_input_mouse('wheel', 'down', '', 0, 0, 47) end screen:expect([[ {11: 2 }{1:0}----1----2----3----4│{11: 2 }0----1----2----3----| @@ -405,7 +405,7 @@ describe('TUI', function() if esc then feed_data('\027[<67;8;1M') else - meths.input_mouse('wheel', 'right', '', 0, 0, 7) + meths.nvim_input_mouse('wheel', 'right', '', 0, 0, 7) end screen:expect([[ {11: 2 }{1:-}---1----2----3----4-│{11: 2 }0----1----2----3----| @@ -420,7 +420,7 @@ describe('TUI', function() if esc then feed_data('\027[<67;48;1M') else - meths.input_mouse('wheel', 'right', '', 0, 0, 47) + meths.nvim_input_mouse('wheel', 'right', '', 0, 0, 47) end screen:expect([[ {11: 2 }{1:-}---1----2----3----4-│{11: 2 }----1----2----3----4| @@ -435,7 +435,7 @@ describe('TUI', function() if esc then feed_data('\027[<69;8;1M') else - meths.input_mouse('wheel', 'down', 'S', 0, 0, 7) + meths.nvim_input_mouse('wheel', 'down', 'S', 0, 0, 7) end screen:expect([[ {11: 5 }{1:-}---1----2----3----4-│{11: 2 }----1----2----3----4| @@ -450,7 +450,7 @@ describe('TUI', function() if esc then feed_data('\027[<69;48;1M') else - meths.input_mouse('wheel', 'down', 'S', 0, 0, 47) + meths.nvim_input_mouse('wheel', 'down', 'S', 0, 0, 47) end screen:expect([[ {11: 5 }{1:-}---1----2----3----4-│{11: 5 }----1----2----3----4| @@ -465,7 +465,7 @@ describe('TUI', function() if esc then feed_data('\027[<71;8;1M') else - meths.input_mouse('wheel', 'right', 'S', 0, 0, 7) + meths.nvim_input_mouse('wheel', 'right', 'S', 0, 0, 7) end screen:expect([[ {11: 5 }{1:-}---6----7----8----9 │{11: 5 }----1----2----3----4| @@ -480,7 +480,7 @@ describe('TUI', function() if esc then feed_data('\027[<71;48;1M') else - meths.input_mouse('wheel', 'right', 'S', 0, 0, 47) + meths.nvim_input_mouse('wheel', 'right', 'S', 0, 0, 47) end screen:expect([[ {11: 5 }{1:-}---6----7----8----9 │{11: 5 }5----6----7----8----| @@ -495,7 +495,7 @@ describe('TUI', function() if esc then feed_data('\027[<64;8;1M') else - meths.input_mouse('wheel', 'up', '', 0, 0, 7) + meths.nvim_input_mouse('wheel', 'up', '', 0, 0, 7) end screen:expect([[ {11: 4 }----6----7----8----9 │{11: 5 }5----6----7----8----| @@ -510,7 +510,7 @@ describe('TUI', function() if esc then feed_data('\027[<64;48;1M') else - meths.input_mouse('wheel', 'up', '', 0, 0, 47) + meths.nvim_input_mouse('wheel', 'up', '', 0, 0, 47) end screen:expect([[ {11: 4 }----6----7----8----9 │{11: 4 }5----6----7----8----| @@ -525,7 +525,7 @@ describe('TUI', function() if esc then feed_data('\027[<66;8;1M') else - meths.input_mouse('wheel', 'left', '', 0, 0, 7) + meths.nvim_input_mouse('wheel', 'left', '', 0, 0, 7) end screen:expect([[ {11: 4 }5----6----7----8----9│{11: 4 }5----6----7----8----| @@ -540,7 +540,7 @@ describe('TUI', function() if esc then feed_data('\027[<66;48;1M') else - meths.input_mouse('wheel', 'left', '', 0, 0, 47) + meths.nvim_input_mouse('wheel', 'left', '', 0, 0, 47) end screen:expect([[ {11: 4 }5----6----7----8----9│{11: 4 }-5----6----7----8---| @@ -555,7 +555,7 @@ describe('TUI', function() if esc then feed_data('\027[<68;8;1M') else - meths.input_mouse('wheel', 'up', 'S', 0, 0, 7) + meths.nvim_input_mouse('wheel', 'up', 'S', 0, 0, 7) end screen:expect([[ {11: 1 }5----6----7----8----9│{11: 4 }-5----6----7----8---| @@ -570,7 +570,7 @@ describe('TUI', function() if esc then feed_data('\027[<68;48;1M') else - meths.input_mouse('wheel', 'up', 'S', 0, 0, 47) + meths.nvim_input_mouse('wheel', 'up', 'S', 0, 0, 47) end screen:expect([[ {11: 1 }5----6----7----8----9│{11: 1 }-5----6----7----8---| @@ -585,7 +585,7 @@ describe('TUI', function() if esc then feed_data('\027[<70;8;1M') else - meths.input_mouse('wheel', 'left', 'S', 0, 0, 7) + meths.nvim_input_mouse('wheel', 'left', 'S', 0, 0, 7) end screen:expect([[ {11: 1 }0----1----2----3----4│{11: 1 }-5----6----7----8---| @@ -600,7 +600,7 @@ describe('TUI', function() if esc then feed_data('\027[<70;48;1M') else - meths.input_mouse('wheel', 'left', 'S', 0, 0, 47) + meths.nvim_input_mouse('wheel', 'left', 'S', 0, 0, 47) end screen:expect([[ {11: 1 }0----1----2----3----4│{11: 1 }0----1----2----3----| @@ -642,7 +642,7 @@ describe('TUI', function() if esc then feed_data('\027[<2;5;1M') else - meths.input_mouse('right', 'press', '', 0, 0, 4) + meths.nvim_input_mouse('right', 'press', '', 0, 0, 4) end screen:expect([[ {1:p}opup menu test | @@ -656,13 +656,13 @@ describe('TUI', function() if esc then feed_data('\027[<2;5;1m') else - meths.input_mouse('right', 'release', '', 0, 0, 4) + meths.nvim_input_mouse('right', 'release', '', 0, 0, 4) end screen:expect_unchanged() if esc then feed_data('\027[<35;7;4M') else - meths.input_mouse('move', '', '', 0, 3, 6) + meths.nvim_input_mouse('move', '', '', 0, 3, 6) end screen:expect([[ {1:p}opup menu test | @@ -676,7 +676,7 @@ describe('TUI', function() if esc then feed_data('\027[<0;7;3M') else - meths.input_mouse('left', 'press', '', 0, 2, 6) + meths.nvim_input_mouse('left', 'press', '', 0, 2, 6) end screen:expect([[ {1:p}opup menu test | @@ -688,13 +688,13 @@ describe('TUI', function() if esc then feed_data('\027[<0;7;3m') else - meths.input_mouse('left', 'release', '', 0, 2, 6) + meths.nvim_input_mouse('left', 'release', '', 0, 2, 6) end screen:expect_unchanged() if esc then feed_data('\027[<2;45;3M') else - meths.input_mouse('right', 'press', '', 0, 2, 44) + meths.nvim_input_mouse('right', 'press', '', 0, 2, 44) end screen:expect([[ {1:p}opup menu test | @@ -707,7 +707,7 @@ describe('TUI', function() if esc then feed_data('\027[<34;48;6M') else - meths.input_mouse('right', 'drag', '', 0, 5, 47) + meths.nvim_input_mouse('right', 'drag', '', 0, 5, 47) end screen:expect([[ {1:p}opup menu test | @@ -720,7 +720,7 @@ describe('TUI', function() if esc then feed_data('\027[<2;48;6m') else - meths.input_mouse('right', 'release', '', 0, 5, 47) + meths.nvim_input_mouse('right', 'release', '', 0, 5, 47) end screen:expect([[ {1:p}opup menu test | @@ -2989,7 +2989,7 @@ describe('TUI as a client', function() local client_super = spawn_argv(true) set_session(server) - local server_pipe = meths.get_vvar('servername') + local server_pipe = meths.nvim_get_vvar('servername') server:request('nvim_input', 'iHalloj!<Esc>') server:request('nvim_command', 'set notermguicolors') @@ -3022,10 +3022,10 @@ describe('TUI as a client', function() ]], } - eq(0, meths.get_vvar('shell_error')) + eq(0, meths.nvim_get_vvar('shell_error')) -- exits on input eof #22244 funcs.system({ nvim_prog, '--server', server_pipe, '--remote-ui' }) - eq(1, meths.get_vvar('shell_error')) + eq(1, meths.nvim_get_vvar('shell_error')) client_super:close() server:close() diff --git a/test/functional/terminal/window_split_tab_spec.lua b/test/functional/terminal/window_split_tab_spec.lua index 846188685b..5cfff301a2 100644 --- a/test/functional/terminal/window_split_tab_spec.lua +++ b/test/functional/terminal/window_split_tab_spec.lua @@ -19,7 +19,7 @@ describe(':terminal', function() clear() -- set the statusline to a constant value because of variables like pid -- and current directory and to improve visibility of splits - meths.set_option_value('statusline', '==========', {}) + meths.nvim_set_option_value('statusline', '==========', {}) command('highlight StatusLine cterm=NONE') command('highlight StatusLineNC cterm=NONE') command('highlight VertSplit cterm=NONE') @@ -69,10 +69,10 @@ describe(':terminal', function() end) it('does not change size if updated when not visible in any window #19665', function() - local channel = meths.get_option_value('channel', {}) + local channel = meths.nvim_get_option_value('channel', {}) command('enew') sleep(100) - meths.chan_send(channel, 'foo') + meths.nvim_chan_send(channel, 'foo') sleep(100) command('bprevious') screen:expect([[ diff --git a/test/functional/treesitter/highlight_spec.lua b/test/functional/treesitter/highlight_spec.lua index afcb3a8ef6..a5dfd460c0 100644 --- a/test/functional/treesitter/highlight_spec.lua +++ b/test/functional/treesitter/highlight_spec.lua @@ -709,11 +709,11 @@ describe('treesitter highlighting (C)', function() it('@foo.bar groups has the correct fallback behavior', function() local get_hl = function(name) - return meths.get_hl_by_name(name, 1).foreground + return meths.nvim_get_hl_by_name(name, 1).foreground end - meths.set_hl(0, '@foo', { fg = 1 }) - meths.set_hl(0, '@foo.bar', { fg = 2 }) - meths.set_hl(0, '@foo.bar.baz', { fg = 3 }) + meths.nvim_set_hl(0, '@foo', { fg = 1 }) + meths.nvim_set_hl(0, '@foo.bar', { fg = 2 }) + meths.nvim_set_hl(0, '@foo.bar.baz', { fg = 3 }) eq(1, get_hl '@foo') eq(1, get_hl '@foo.a.b.c.d') @@ -725,7 +725,7 @@ describe('treesitter highlighting (C)', function() -- lookup is case insensitive eq(2, get_hl '@FOO.BAR.SPAM') - meths.set_hl(0, '@foo.missing.exists', { fg = 3 }) + meths.nvim_set_hl(0, '@foo.missing.exists', { fg = 3 }) eq(1, get_hl '@foo.missing') eq(3, get_hl '@foo.missing.exists') eq(3, get_hl '@foo.missing.exists.bar') diff --git a/test/functional/ui/bufhl_spec.lua b/test/functional/ui/bufhl_spec.lua index 220537f58a..13fea71fec 100644 --- a/test/functional/ui/bufhl_spec.lua +++ b/test/functional/ui/bufhl_spec.lua @@ -494,7 +494,7 @@ describe('Buffer highlighting', function() it('respects priority', function() local set_extmark = curbufmeths.set_extmark - local id = meths.create_namespace('') + local id = meths.nvim_create_namespace('') insert [[foobar]] set_extmark(id, 0, 0, { @@ -901,9 +901,9 @@ describe('Buffer highlighting', function() local set_virtual_text = curbufmeths.set_virtual_text eq(1, add_highlight(0, 'String', 0, 0, -1)) eq(2, set_virtual_text(0, 0, { { '= text', 'Comment' } }, {})) - eq(3, meths.create_namespace('my-ns')) + eq(3, meths.nvim_create_namespace('my-ns')) eq(4, add_highlight(0, 'String', 0, 0, -1)) eq(5, set_virtual_text(0, 0, { { '= text', 'Comment' } }, {})) - eq(6, meths.create_namespace('other-ns')) + eq(6, meths.nvim_create_namespace('other-ns')) end) end) diff --git a/test/functional/ui/cmdline_highlight_spec.lua b/test/functional/ui/cmdline_highlight_spec.lua index 4b3657f834..99f6e2eed8 100644 --- a/test/functional/ui/cmdline_highlight_spec.lua +++ b/test/functional/ui/cmdline_highlight_spec.lua @@ -157,16 +157,16 @@ before_each(function() end) local function set_color_cb(funcname, callback_return, id) - meths.set_var('id', id or '') + meths.nvim_set_var('id', id or '') if id and id ~= '' and funcs.exists('*' .. funcname .. 'N') then command(('let g:Nvim_color_input%s = {cmdline -> %sN(%s, cmdline)}'):format(id, funcname, id)) if callback_return then - meths.set_var('callback_return' .. id, callback_return) + meths.nvim_set_var('callback_return' .. id, callback_return) end else - meths.set_var('Nvim_color_input', funcname) + meths.nvim_set_var('Nvim_color_input', funcname) if callback_return then - meths.set_var('callback_return', callback_return) + meths.nvim_set_var('callback_return', callback_return) end end end @@ -177,7 +177,7 @@ end describe('Command-line coloring', function() it('works', function() set_color_cb('RainBowParens') - meths.set_option_value('more', false, {}) + meths.nvim_set_option_value('more', false, {}) start_prompt() screen:expect([[ | @@ -362,7 +362,7 @@ describe('Command-line coloring', function() | ]]) feed('\n') - eq('let x = "«»«»«»«»«»"', meths.get_var('out')) + eq('let x = "«»«»«»«»«»"', meths.nvim_get_var('out')) local msg = '\nE5405: Chunk 0 start 10 splits multibyte character' eq(msg:rep(1), funcs.execute('messages')) end) @@ -398,7 +398,7 @@ describe('Command-line coloring', function() :echo 42 | ]]) feed('\n') - eq('echo 42', meths.get_var('out')) + eq('echo 42', meths.nvim_get_var('out')) feed('<C-c>') screen:expect([[ ^ | @@ -564,16 +564,16 @@ describe('Command-line coloring', function() {EOB:~ }|*6 | ]]) - eq('1234', meths.get_var('out')) - eq('234', meths.get_var('out1')) - eq('34', meths.get_var('out2')) - eq('4', meths.get_var('out3')) + eq('1234', meths.nvim_get_var('out')) + eq('234', meths.nvim_get_var('out1')) + eq('34', meths.nvim_get_var('out2')) + eq('4', meths.nvim_get_var('out3')) eq(0, funcs.exists('g:out4')) end) it('runs callback with the same data only once', function() local function new_recording_calls(...) - eq({ ... }, meths.get_var('recording_calls')) - meths.set_var('recording_calls', {}) + eq({ ... }, meths.nvim_get_var('recording_calls')) + meths.nvim_set_var('recording_calls', {}) end set_color_cb('Recording') start_prompt('') @@ -594,7 +594,7 @@ describe('Command-line coloring', function() feed('<BS>') new_recording_calls() -- ('a') feed('<CR><CR>') - eq('', meths.get_var('out')) + eq('', meths.nvim_get_var('out')) end) it('does not crash when callback has caught not-a-editor-command exception', function() source([[ @@ -609,12 +609,12 @@ describe('Command-line coloring', function() ]]) set_color_cb('CaughtExc') start_prompt('1') - eq(1, meths.eval('1')) + eq(1, meths.nvim_eval('1')) end) end) describe('Ex commands coloring', function() it('works', function() - meths.set_var('Nvim_color_cmdline', 'RainBowParens') + meths.nvim_set_var('Nvim_color_cmdline', 'RainBowParens') feed(':echo (((1)))') screen:expect([[ | @@ -623,9 +623,9 @@ describe('Ex commands coloring', function() ]]) end) it('still executes command-line even if errored out', function() - meths.set_var('Nvim_color_cmdline', 'SplitMultibyteStart') + meths.nvim_set_var('Nvim_color_cmdline', 'SplitMultibyteStart') feed(':let x = "«"\n') - eq('«', meths.get_var('x')) + eq('«', meths.nvim_get_var('x')) local msg = 'E5405: Chunk 0 start 10 splits multibyte character' eq('\n' .. msg, funcs.execute('messages')) end) @@ -709,7 +709,7 @@ describe('Ex commands coloring', function() ) end) it('errors out when failing to get callback', function() - meths.set_var('Nvim_color_cmdline', 42) + meths.nvim_set_var('Nvim_color_cmdline', 42) feed(':#') screen:expect([[ | @@ -725,10 +725,10 @@ describe('Ex commands coloring', function() end) describe('Expressions coloring support', function() it('works', function() - meths.command('hi clear NvimNumber') - meths.command('hi clear NvimNestingParenthesis') - meths.command('hi NvimNumber guifg=Blue2') - meths.command('hi NvimNestingParenthesis guifg=Yellow') + meths.nvim_command('hi clear NvimNumber') + meths.nvim_command('hi clear NvimNestingParenthesis') + meths.nvim_command('hi NvimNumber guifg=Blue2') + meths.nvim_command('hi NvimNestingParenthesis guifg=Yellow') feed(':echo <C-r>=(((1)))') screen:expect([[ | @@ -737,10 +737,10 @@ describe('Expressions coloring support', function() ]]) end) it('does not use Nvim_color_expr', function() - meths.set_var('Nvim_color_expr', 42) + meths.nvim_set_var('Nvim_color_expr', 42) -- Used to error out due to failing to get callback. - meths.command('hi clear NvimNumber') - meths.command('hi NvimNumber guifg=Blue2') + meths.nvim_command('hi clear NvimNumber') + meths.nvim_command('hi NvimNumber guifg=Blue2') feed(':<C-r>=1') screen:expect([[ | @@ -749,12 +749,12 @@ describe('Expressions coloring support', function() ]]) end) it('works correctly with non-ASCII and control characters', function() - meths.command('hi clear NvimStringBody') - meths.command('hi clear NvimStringQuote') - meths.command('hi clear NvimInvalid') - meths.command('hi NvimStringQuote guifg=Blue3') - meths.command('hi NvimStringBody guifg=Blue4') - meths.command('hi NvimInvalid guifg=Red guibg=Blue') + meths.nvim_command('hi clear NvimStringBody') + meths.nvim_command('hi clear NvimStringQuote') + meths.nvim_command('hi clear NvimInvalid') + meths.nvim_command('hi NvimStringQuote guifg=Blue3') + meths.nvim_command('hi NvimStringBody guifg=Blue4') + meths.nvim_command('hi NvimInvalid guifg=Red guibg=Blue') feed('i<C-r>="«»"«»') screen:expect([[ | diff --git a/test/functional/ui/cmdline_spec.lua b/test/functional/ui/cmdline_spec.lua index 82ff633fcb..2670288cbb 100644 --- a/test/functional/ui/cmdline_spec.lua +++ b/test/functional/ui/cmdline_spec.lua @@ -922,7 +922,7 @@ describe('cmdline redraw', function() it('with rightleftcmd', function() command('set rightleft rightleftcmd=search shortmess+=s') - meths.buf_set_lines(0, 0, -1, true, { "let's rock!" }) + meths.nvim_buf_set_lines(0, 0, -1, true, { "let's rock!" }) screen:expect { grid = [[ !kcor s'te^l| @@ -1531,7 +1531,7 @@ describe('cmdheight=0', function() it('with multigrid', function() clear { args = { '--cmd', 'set cmdheight=0' } } screen:attach { ext_multigrid = true } - meths.buf_set_lines(0, 0, -1, true, { 'p' }) + meths.nvim_buf_set_lines(0, 0, -1, true, { 'p' }) screen:expect { grid = [[ ## grid 1 @@ -1701,9 +1701,9 @@ describe('cmdheight=0', function() {1:~ }|*3 {3:[No Name] }| ]]) - meths.input_mouse('left', 'press', '', 0, 6, 10) + meths.nvim_input_mouse('left', 'press', '', 0, 6, 10) poke_eventloop() - meths.input_mouse('left', 'drag', '', 0, 5, 10) + meths.nvim_input_mouse('left', 'drag', '', 0, 5, 10) screen:expect_unchanged() end) end) diff --git a/test/functional/ui/cursor_spec.lua b/test/functional/ui/cursor_spec.lua index 9b3de1e108..601d242de0 100644 --- a/test/functional/ui/cursor_spec.lua +++ b/test/functional/ui/cursor_spec.lua @@ -299,7 +299,7 @@ describe('ui/cursor', function() } -- Another cursor style. - meths.set_option_value( + meths.nvim_set_option_value( 'guicursor', 'n-v-c:ver35-blinkwait171-blinkoff172-blinkon173' .. ',ve:hor35,o:ver50,i-ci:block,r-cr:hor90,sm:ver42', @@ -326,7 +326,7 @@ describe('ui/cursor', function() end) -- If there is no setting for guicursor, it becomes the default setting. - meths.set_option_value( + meths.nvim_set_option_value( 'guicursor', 'n:ver35-blinkwait171-blinkoff172-blinkon173-Cursor/lCursor', {} @@ -346,7 +346,7 @@ describe('ui/cursor', function() end) it("empty 'guicursor' sets cursor_shape=block in all modes", function() - meths.set_option_value('guicursor', '', {}) + meths.nvim_set_option_value('guicursor', '', {}) screen:expect(function() -- Empty 'guicursor' sets enabled=false. eq(false, screen._cursor_style_enabled) diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 6ff2a12ded..91a5f10c84 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -243,7 +243,7 @@ describe('decorations providers', function() ]]} -- spell=false with higher priority does disable spell - local ns = meths.create_namespace "spell" + local ns = meths.nvim_create_namespace "spell" local id = curbufmeths.set_extmark(ns, 0, 0, { priority = 30, end_row = 2, end_col = 23, spell = false }) screen:expect{grid=[[ @@ -306,7 +306,7 @@ describe('decorations providers', function() LineNr = {italic=true, bg="Magenta"}; Comment = {fg="#FF0000", bg = 80*256+40}; CursorLine = {link="ErrorMsg"}; - } do meths.set_hl(ns1, k, v) end + } do meths.nvim_set_hl(ns1, k, v) end screen:expect{grid=[[ {3: 1 }{4:// just to see if there was an accid}| @@ -327,7 +327,7 @@ describe('decorations providers', function() | ]]} - meths.set_hl_ns(ns1) + meths.nvim_set_hl_ns(ns1) screen:expect{grid=[[ {10: 1 }{11:// just to see if there was an accid}| {10: }{11:ent} | @@ -387,7 +387,7 @@ describe('decorations providers', function() highlight link LinkGroup OriginalGroup ]] - meths.buf_set_virtual_text(0, 0, 2, {{'- not red', 'LinkGroup'}}, {}) + meths.nvim_buf_set_virtual_text(0, 0, 2, {{'- not red', 'LinkGroup'}}, {}) screen:expect{grid=[[ // just to see if there was an accident | // on Mulholland Drive | @@ -399,8 +399,8 @@ describe('decorations providers', function() | ]]} - meths.set_hl(ns1, 'LinkGroup', {fg = 'Blue'}) - meths.set_hl_ns(ns1) + meths.nvim_set_hl(ns1, 'LinkGroup', {fg = 'Blue'}) + meths.nvim_set_hl_ns(ns1) screen:expect{grid=[[ // just to see if there was an accident | @@ -423,7 +423,7 @@ describe('decorations providers', function() highlight link LinkGroup OriginalGroup ]] - meths.buf_set_virtual_text(0, 0, 2, {{'- not red', 'LinkGroup'}}, {}) + meths.nvim_buf_set_virtual_text(0, 0, 2, {{'- not red', 'LinkGroup'}}, {}) screen:expect{grid=[[ // just to see if there was an accident | // on Mulholland Drive | @@ -435,8 +435,8 @@ describe('decorations providers', function() | ]]} - meths.set_hl(ns1, 'LinkGroup', {fg = 'Blue', default=true}) - meths.set_hl_ns(ns1) + meths.nvim_set_hl(ns1, 'LinkGroup', {fg = 'Blue', default=true}) + meths.nvim_set_hl_ns(ns1) feed 'k' screen:expect{grid=[[ @@ -626,7 +626,7 @@ describe('decorations providers', function() end ]]) command([[autocmd CursorMoved * call line('w$')]]) - meths.win_set_cursor(0, {100, 0}) + meths.nvim_win_set_cursor(0, {100, 0}) screen:expect([[ {14: }hello97 | {14: }hello98 | @@ -637,7 +637,7 @@ describe('decorations providers', function() {14: }hello103 | | ]]) - meths.win_set_cursor(0, {1, 0}) + meths.nvim_win_set_cursor(0, {1, 0}) screen:expect([[ ^hello1 | hello2 | @@ -766,7 +766,7 @@ describe('extmark decorations', function() [43] = {background = Screen.colors.Yellow, undercurl = true, special = Screen.colors.Red}; } - ns = meths.create_namespace 'test' + ns = meths.nvim_create_namespace 'test' end) it('empty virtual text at eol should not break colorcolumn #17860', function() @@ -789,7 +789,7 @@ describe('extmark decorations', function() {1:~ }|*2 | ]]) - meths.buf_set_extmark(0, ns, 4, 0, { virt_text={{''}}, virt_text_pos='eol'}) + meths.nvim_buf_set_extmark(0, ns, 4, 0, { virt_text={{''}}, virt_text_pos='eol'}) screen:expect_unchanged() end) @@ -798,19 +798,19 @@ describe('extmark decorations', function() feed 'gg' for i = 1,9 do - meths.buf_set_extmark(0, ns, i, 0, { virt_text={{'|', 'LineNr'}}, virt_text_pos='overlay'}) + meths.nvim_buf_set_extmark(0, ns, i, 0, { virt_text={{'|', 'LineNr'}}, virt_text_pos='overlay'}) if i == 3 or (i >= 6 and i <= 9) then - meths.buf_set_extmark(0, ns, i, 4, { virt_text={{'|', 'NonText'}}, virt_text_pos='overlay'}) + meths.nvim_buf_set_extmark(0, ns, i, 4, { virt_text={{'|', 'NonText'}}, virt_text_pos='overlay'}) end end - meths.buf_set_extmark(0, ns, 9, 10, { virt_text={{'foo'}, {'bar', 'MoreMsg'}, {'!!', 'ErrorMsg'}}, virt_text_pos='overlay'}) + meths.nvim_buf_set_extmark(0, ns, 9, 10, { virt_text={{'foo'}, {'bar', 'MoreMsg'}, {'!!', 'ErrorMsg'}}, virt_text_pos='overlay'}) -- can "float" beyond end of line - meths.buf_set_extmark(0, ns, 5, 28, { virt_text={{'loopy', 'ErrorMsg'}}, virt_text_pos='overlay'}) + meths.nvim_buf_set_extmark(0, ns, 5, 28, { virt_text={{'loopy', 'ErrorMsg'}}, virt_text_pos='overlay'}) -- bound check: right edge of window - meths.buf_set_extmark(0, ns, 2, 26, { virt_text={{'bork bork bork'}, {(' bork'):rep(10), 'ErrorMsg'}}, virt_text_pos='overlay'}) + meths.nvim_buf_set_extmark(0, ns, 2, 26, { virt_text={{'bork bork bork'}, {(' bork'):rep(10), 'ErrorMsg'}}, virt_text_pos='overlay'}) -- empty virt_text should not change anything - meths.buf_set_extmark(0, ns, 6, 16, { virt_text={{''}}, virt_text_pos='overlay'}) + meths.nvim_buf_set_extmark(0, ns, 6, 16, { virt_text={{''}}, virt_text_pos='overlay'}) screen:expect{grid=[[ ^for _,item in ipairs(items) do | @@ -859,12 +859,12 @@ describe('extmark decorations', function() ]]} -- truncating in the middle of a char leaves a space - meths.buf_set_lines(0, 0, 1, true, {'for _,item in ipairs(items) do -- 古古古'}) - meths.buf_set_lines(0, 10, 12, true, {' end -- ??????????', 'end -- ?古古古古?古古'}) - meths.buf_set_extmark(0, ns, 0, 35, { virt_text={{'A', 'ErrorMsg'}, {'AA'}}, virt_text_pos='overlay'}) - meths.buf_set_extmark(0, ns, 10, 19, { virt_text={{'口口口', 'ErrorMsg'}}, virt_text_pos='overlay'}) - meths.buf_set_extmark(0, ns, 11, 21, { virt_text={{'口口口', 'ErrorMsg'}}, virt_text_pos='overlay'}) - meths.buf_set_extmark(0, ns, 11, 8, { virt_text={{'口口', 'ErrorMsg'}}, virt_text_pos='overlay'}) + meths.nvim_buf_set_lines(0, 0, 1, true, {'for _,item in ipairs(items) do -- 古古古'}) + meths.nvim_buf_set_lines(0, 10, 12, true, {' end -- ??????????', 'end -- ?古古古古?古古'}) + meths.nvim_buf_set_extmark(0, ns, 0, 35, { virt_text={{'A', 'ErrorMsg'}, {'AA'}}, virt_text_pos='overlay'}) + meths.nvim_buf_set_extmark(0, ns, 10, 19, { virt_text={{'口口口', 'ErrorMsg'}}, virt_text_pos='overlay'}) + meths.nvim_buf_set_extmark(0, ns, 11, 21, { virt_text={{'口口口', 'ErrorMsg'}}, virt_text_pos='overlay'}) + meths.nvim_buf_set_extmark(0, ns, 11, 8, { virt_text={{'口口', 'ErrorMsg'}}, virt_text_pos='overlay'}) screen:expect{grid=[[ ^for _,item in ipairs(i| tems) do -- {4:A}AA 古 | @@ -909,7 +909,7 @@ describe('extmark decorations', function() | ]]} - meths.buf_clear_namespace(0, ns, 0, -1) + meths.nvim_buf_clear_namespace(0, ns, 0, -1) screen:expect{grid=[[ ^for _,item in ipairs(items) do -- 古古古 | local text, hl_id_cell, count = unpack(item) | @@ -931,8 +931,8 @@ describe('extmark decorations', function() screen:try_resize(50, 6) insert(('ab'):rep(100)) for i = 0, 9 do - meths.buf_set_extmark(0, ns, 0, 42 + i, { virt_text={{tostring(i), 'ErrorMsg'}}, virt_text_pos='overlay'}) - meths.buf_set_extmark(0, ns, 0, 91 + i, { virt_text={{tostring(i), 'ErrorMsg'}}, virt_text_pos='overlay', virt_text_hide=true}) + meths.nvim_buf_set_extmark(0, ns, 0, 42 + i, { virt_text={{tostring(i), 'ErrorMsg'}}, virt_text_pos='overlay'}) + meths.nvim_buf_set_extmark(0, ns, 0, 91 + i, { virt_text={{tostring(i), 'ErrorMsg'}}, virt_text_pos='overlay', virt_text_hide=true}) end screen:expect{grid=[[ ababababababababababababababababababababab{4:01234567}| @@ -1028,9 +1028,9 @@ describe('extmark decorations', function() it('virt_text_hide hides overlay virtual text when extmark is off-screen', function() screen:try_resize(50, 3) command('set nowrap') - meths.buf_set_lines(0, 0, -1, true, {'-- ' .. ('…'):rep(57)}) - meths.buf_set_extmark(0, ns, 0, 0, { virt_text={{'?????', 'ErrorMsg'}}, virt_text_pos='overlay', virt_text_hide=true}) - meths.buf_set_extmark(0, ns, 0, 123, { virt_text={{'!!!!!', 'ErrorMsg'}}, virt_text_pos='overlay', virt_text_hide=true}) + meths.nvim_buf_set_lines(0, 0, -1, true, {'-- ' .. ('…'):rep(57)}) + meths.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text={{'?????', 'ErrorMsg'}}, virt_text_pos='overlay', virt_text_hide=true}) + meths.nvim_buf_set_extmark(0, ns, 0, 123, { virt_text={{'!!!!!', 'ErrorMsg'}}, virt_text_pos='overlay', virt_text_hide=true}) screen:expect{grid=[[ {4:^?????}……………………………………………………………………………………………………{4:!!!!!}……| {1:~ }| @@ -1083,10 +1083,10 @@ describe('extmark decorations', function() it('overlay virtual text works on and after a TAB #24022', function() screen:try_resize(40, 3) - meths.buf_set_lines(0, 0, -1, true, {'\t\tline 1'}) - meths.buf_set_extmark(0, ns, 0, 0, { virt_text = {{'AA', 'Search'}}, virt_text_pos = 'overlay', hl_mode = 'combine' }) - meths.buf_set_extmark(0, ns, 0, 1, { virt_text = {{'BB', 'Search'}}, virt_text_pos = 'overlay', hl_mode = 'combine' }) - meths.buf_set_extmark(0, ns, 0, 2, { virt_text = {{'CC', 'Search'}}, virt_text_pos = 'overlay', hl_mode = 'combine' }) + meths.nvim_buf_set_lines(0, 0, -1, true, {'\t\tline 1'}) + meths.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = {{'AA', 'Search'}}, virt_text_pos = 'overlay', hl_mode = 'combine' }) + meths.nvim_buf_set_extmark(0, ns, 0, 1, { virt_text = {{'BB', 'Search'}}, virt_text_pos = 'overlay', hl_mode = 'combine' }) + meths.nvim_buf_set_extmark(0, ns, 0, 2, { virt_text = {{'CC', 'Search'}}, virt_text_pos = 'overlay', hl_mode = 'combine' }) screen:expect{grid=[[ {34:AA} ^ {34:BB} {34:CC}ne 1 | {1:~ }| @@ -1125,13 +1125,13 @@ describe('extmark decorations', function() ]]} command 'hi Blendy guibg=Red blend=30' - meths.buf_set_extmark(0, ns, 1, 5, { virt_text={{'blendy text - here', 'Blendy'}}, virt_text_pos='overlay', hl_mode='blend'}) - meths.buf_set_extmark(0, ns, 2, 5, { virt_text={{'combining color', 'Blendy'}}, virt_text_pos='overlay', hl_mode='combine'}) - meths.buf_set_extmark(0, ns, 3, 5, { virt_text={{'replacing color', 'Blendy'}}, virt_text_pos='overlay', hl_mode='replace'}) + meths.nvim_buf_set_extmark(0, ns, 1, 5, { virt_text={{'blendy text - here', 'Blendy'}}, virt_text_pos='overlay', hl_mode='blend'}) + meths.nvim_buf_set_extmark(0, ns, 2, 5, { virt_text={{'combining color', 'Blendy'}}, virt_text_pos='overlay', hl_mode='combine'}) + meths.nvim_buf_set_extmark(0, ns, 3, 5, { virt_text={{'replacing color', 'Blendy'}}, virt_text_pos='overlay', hl_mode='replace'}) - meths.buf_set_extmark(0, ns, 4, 5, { virt_text={{'blendy text - here', 'Blendy'}}, virt_text_pos='overlay', hl_mode='blend', virt_text_hide=true}) - meths.buf_set_extmark(0, ns, 5, 5, { virt_text={{'combining color', 'Blendy'}}, virt_text_pos='overlay', hl_mode='combine', virt_text_hide=true}) - meths.buf_set_extmark(0, ns, 6, 5, { virt_text={{'replacing color', 'Blendy'}}, virt_text_pos='overlay', hl_mode='replace', virt_text_hide=true}) + meths.nvim_buf_set_extmark(0, ns, 4, 5, { virt_text={{'blendy text - here', 'Blendy'}}, virt_text_pos='overlay', hl_mode='blend', virt_text_hide=true}) + meths.nvim_buf_set_extmark(0, ns, 5, 5, { virt_text={{'combining color', 'Blendy'}}, virt_text_pos='overlay', hl_mode='combine', virt_text_hide=true}) + meths.nvim_buf_set_extmark(0, ns, 6, 5, { virt_text={{'replacing color', 'Blendy'}}, virt_text_pos='overlay', hl_mode='replace', virt_text_hide=true}) screen:expect{grid=[[ {5:^for} _,item {5:in} {6:ipairs}(items) {5:do} | @@ -1190,17 +1190,17 @@ describe('extmark decorations', function() it('can have virtual text of right_align and fixed win_col position', function() insert(example_text) feed 'gg' - meths.buf_set_extmark(0, ns, 1, 0, { virt_text={{'Very', 'ErrorMsg'}}, virt_text_win_col=31, hl_mode='blend'}) - meths.buf_set_extmark(0, ns, 1, 0, { virt_text={{'VERY', 'ErrorMsg'}}, virt_text_pos='right_align', hl_mode='blend'}) - meths.buf_set_extmark(0, ns, 2, 10, { virt_text={{'Much', 'ErrorMsg'}}, virt_text_win_col=31, hl_mode='blend'}) - meths.buf_set_extmark(0, ns, 2, 10, { virt_text={{'MUCH', 'ErrorMsg'}}, virt_text_pos='right_align', hl_mode='blend'}) - meths.buf_set_extmark(0, ns, 3, 14, { virt_text={{'Error', 'ErrorMsg'}}, virt_text_win_col=31, hl_mode='blend'}) - meths.buf_set_extmark(0, ns, 3, 14, { virt_text={{'ERROR', 'ErrorMsg'}}, virt_text_pos='right_align', hl_mode='blend'}) - meths.buf_set_extmark(0, ns, 7, 21, { virt_text={{'-', 'NonText'}}, virt_text_win_col=4, hl_mode='blend'}) - meths.buf_set_extmark(0, ns, 7, 21, { virt_text={{'-', 'NonText'}}, virt_text_pos='right_align', hl_mode='blend'}) + meths.nvim_buf_set_extmark(0, ns, 1, 0, { virt_text={{'Very', 'ErrorMsg'}}, virt_text_win_col=31, hl_mode='blend'}) + meths.nvim_buf_set_extmark(0, ns, 1, 0, { virt_text={{'VERY', 'ErrorMsg'}}, virt_text_pos='right_align', hl_mode='blend'}) + meths.nvim_buf_set_extmark(0, ns, 2, 10, { virt_text={{'Much', 'ErrorMsg'}}, virt_text_win_col=31, hl_mode='blend'}) + meths.nvim_buf_set_extmark(0, ns, 2, 10, { virt_text={{'MUCH', 'ErrorMsg'}}, virt_text_pos='right_align', hl_mode='blend'}) + meths.nvim_buf_set_extmark(0, ns, 3, 14, { virt_text={{'Error', 'ErrorMsg'}}, virt_text_win_col=31, hl_mode='blend'}) + meths.nvim_buf_set_extmark(0, ns, 3, 14, { virt_text={{'ERROR', 'ErrorMsg'}}, virt_text_pos='right_align', hl_mode='blend'}) + meths.nvim_buf_set_extmark(0, ns, 7, 21, { virt_text={{'-', 'NonText'}}, virt_text_win_col=4, hl_mode='blend'}) + meths.nvim_buf_set_extmark(0, ns, 7, 21, { virt_text={{'-', 'NonText'}}, virt_text_pos='right_align', hl_mode='blend'}) -- empty virt_text should not change anything - meths.buf_set_extmark(0, ns, 8, 0, { virt_text={{''}}, virt_text_win_col=14, hl_mode='blend'}) - meths.buf_set_extmark(0, ns, 8, 0, { virt_text={{''}}, virt_text_pos='right_align', hl_mode='blend'}) + meths.nvim_buf_set_extmark(0, ns, 8, 0, { virt_text={{''}}, virt_text_win_col=14, hl_mode='blend'}) + meths.nvim_buf_set_extmark(0, ns, 8, 0, { virt_text={{''}}, virt_text_pos='right_align', hl_mode='blend'}) screen:expect{grid=[[ ^for _,item in ipairs(items) do | @@ -1294,7 +1294,7 @@ describe('extmark decorations', function() | ]]} - meths.buf_set_extmark(0, ns, 4, 50, { virt_text={{'EOL', 'NonText'}} }) + meths.nvim_buf_set_extmark(0, ns, 4, 50, { virt_text={{'EOL', 'NonText'}} }) screen:expect{grid=[[ for _,item in ipairs(items) do | local text, hl_id_cell, cou{4:Very} unpack(ite{4:VERY}| @@ -1450,7 +1450,7 @@ describe('extmark decorations', function() it('virtual text win_col out of window does not break display #25645', function() screen:try_resize(51, 6) command('vnew') - meths.buf_set_lines(0, 0, -1, false, { string.rep('a', 50) }) + meths.nvim_buf_set_lines(0, 0, -1, false, { string.rep('a', 50) }) screen:expect{grid=[[ ^aaaaaaaaaaaaaaaaaaaaaaaaa│ | aaaaaaaaaaaaaaaaaaaaaaaaa│{1:~ }| @@ -1459,7 +1459,7 @@ describe('extmark decorations', function() | ]]} local extmark_opts = { virt_text_win_col = 35, virt_text = { { ' ', 'Comment' } } } - meths.buf_set_extmark(0, ns, 0, 0, extmark_opts) + meths.nvim_buf_set_extmark(0, ns, 0, 0, extmark_opts) screen:expect_unchanged() assert_alive() end) @@ -1475,9 +1475,9 @@ describe('extmark decorations', function() -- XXX: the behavior of overlay virtual text at non-zero column is strange: -- 1. With 'wrap' it is never shown. -- 2. With 'nowrap' it is shown only if the extmark is hidden before leftcol. - meths.buf_set_extmark(0, ns, 0, 0, { virt_text = {{'AA', 'Underlined'}}, hl_mode = 'combine', virt_text_pos = 'overlay' }) - meths.buf_set_extmark(0, ns, 0, 5, { virt_text = {{'BB', 'Underlined'}}, hl_mode = 'combine', virt_text_win_col = 10 }) - meths.buf_set_extmark(0, ns, 0, 2, { virt_text = {{'CC', 'Underlined'}}, hl_mode = 'combine', virt_text_pos = 'right_align' }) + meths.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = {{'AA', 'Underlined'}}, hl_mode = 'combine', virt_text_pos = 'overlay' }) + meths.nvim_buf_set_extmark(0, ns, 0, 5, { virt_text = {{'BB', 'Underlined'}}, hl_mode = 'combine', virt_text_win_col = 10 }) + meths.nvim_buf_set_extmark(0, ns, 0, 2, { virt_text = {{'CC', 'Underlined'}}, hl_mode = 'combine', virt_text_pos = 'right_align' }) screen:expect{grid=[[ {29:AA}{33:- 2 lin}{29:BB}{33:: 11111·····························}{29:CC}| 3333^3 | @@ -1520,9 +1520,9 @@ describe('extmark decorations', function() ddddd eeeee]]) command('windo diffthis') - meths.buf_set_extmark(0, ns, 0, 0, { virt_text = {{'AA', 'Underlined'}}, virt_text_pos = 'overlay' }) - meths.buf_set_extmark(0, ns, 0, 0, { virt_text = {{'BB', 'Underlined'}}, virt_text_win_col = 10 }) - meths.buf_set_extmark(0, ns, 0, 0, { virt_text = {{'CC', 'Underlined'}}, virt_text_pos = 'right_align' }) + meths.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = {{'AA', 'Underlined'}}, virt_text_pos = 'overlay' }) + meths.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = {{'BB', 'Underlined'}}, virt_text_win_col = 10 }) + meths.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = {{'CC', 'Underlined'}}, virt_text_pos = 'right_align' }) screen:expect{grid=[[ {37: }{38:aaaaa }│{37: }{39:------------------------}| {37: }bbbbb │{37: }{28:AA}bbb {28:BB} {28:CC}| @@ -1565,10 +1565,10 @@ describe('extmark decorations', function() {'d', {'BgTwo', 'FgZwei'}}; {'X', {'BgTwo', 'FgZwei', 'VeryBold'}}; } - meths.buf_set_extmark(0, ns, 0, 0, { virt_text = vt, virt_text_pos = 'eol' }) - meths.buf_set_extmark(0, ns, 0, 0, { virt_text = vt, virt_text_pos = 'right_align' }) - meths.buf_set_extmark(0, ns, 0, 0, { virt_text = vt, virt_text_pos = 'inline' }) - meths.buf_set_extmark(0, ns, 0, 0, { virt_lines = { vt, vt } }) + meths.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = vt, virt_text_pos = 'eol' }) + meths.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = vt, virt_text_pos = 'right_align' }) + meths.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = vt, virt_text_pos = 'inline' }) + meths.nvim_buf_set_extmark(0, ns, 0, 0, { virt_lines = { vt, vt } }) screen:expect{grid=[[ {2:a}{3:b}{4:c}{5:d}{6:X}#^# {2:a}{3:b}{4:c}{5:d}{6:X} {2:a}{3:b}{4:c}{5:d}{6:X}| {2:a}{3:b}{4:c}{5:d}{6:X} |*2 @@ -1603,7 +1603,7 @@ describe('extmark decorations', function() it('conceal with conceal char #19007', function() screen:try_resize(50, 5) insert('foo\n') - meths.buf_set_extmark(0, ns, 0, 0, {end_col=0, end_row=2, conceal='X'}) + meths.nvim_buf_set_extmark(0, ns, 0, 0, {end_col=0, end_row=2, conceal='X'}) command('set conceallevel=2') screen:expect([[ {26:X} | @@ -1614,13 +1614,13 @@ describe('extmark decorations', function() command('set conceallevel=1') screen:expect_unchanged() - eq("conceal char has to be printable", pcall_err(meths.buf_set_extmark, 0, ns, 0, 0, {end_col=0, end_row=2, conceal='\255'})) + eq("conceal char has to be printable", pcall_err(meths.nvim_buf_set_extmark, 0, ns, 0, 0, {end_col=0, end_row=2, conceal='\255'})) end) it('conceal with composed conceal char', function() screen:try_resize(50, 5) insert('foo\n') - meths.buf_set_extmark(0, ns, 0, 0, {end_col=0, end_row=2, conceal='ẍ̲'}) + meths.nvim_buf_set_extmark(0, ns, 0, 0, {end_col=0, end_row=2, conceal='ẍ̲'}) command('set conceallevel=2') screen:expect([[ {26:ẍ̲} | @@ -1632,7 +1632,7 @@ describe('extmark decorations', function() screen:expect_unchanged() -- this is rare, but could happen. Save at least the first codepoint - meths._invalidate_glyph_cache() + meths.nvim__invalidate_glyph_cache() screen:expect{grid=[[ {26:x} | ^ | @@ -1644,7 +1644,7 @@ describe('extmark decorations', function() it('conceal without conceal char #24782', function() screen:try_resize(50, 5) insert('foobar\n') - meths.buf_set_extmark(0, ns, 0, 0, {end_col=3, conceal=''}) + meths.nvim_buf_set_extmark(0, ns, 0, 0, {end_col=3, conceal=''}) command('set listchars=conceal:?') command('let &conceallevel=1') screen:expect([[ @@ -1664,8 +1664,8 @@ describe('extmark decorations', function() it('conceal works just before truncated double-width char #21486', function() screen:try_resize(40, 4) - meths.buf_set_lines(0, 0, -1, true, {'', ('a'):rep(37) .. '<>古'}) - meths.buf_set_extmark(0, ns, 1, 37, {end_col=39, conceal=''}) + meths.nvim_buf_set_lines(0, 0, -1, true, {'', ('a'):rep(37) .. '<>古'}) + meths.nvim_buf_set_extmark(0, ns, 1, 37, {end_col=39, conceal=''}) command('setlocal conceallevel=2') screen:expect{grid=[[ ^ | @@ -1739,32 +1739,32 @@ describe('extmark decorations', function() [6] = {bold = true, undercurl = true, special = Screen.colors.Red}; }) - meths.buf_set_extmark(0, ns, 0, 0, { end_col = 9, hl_group = 'TestUL', priority = 20 }) - meths.buf_set_extmark(0, ns, 0, 3, { end_col = 6, hl_group = 'TestUC', priority = 30 }) + meths.nvim_buf_set_extmark(0, ns, 0, 0, { end_col = 9, hl_group = 'TestUL', priority = 20 }) + meths.nvim_buf_set_extmark(0, ns, 0, 3, { end_col = 6, hl_group = 'TestUC', priority = 30 }) screen:expect([[ {1:aaa}{4:bbb}{1:aa^a} | {0:~ }| | ]]) - meths.buf_clear_namespace(0, ns, 0, -1) - meths.buf_set_extmark(0, ns, 0, 0, { end_col = 9, hl_group = 'TestUC', priority = 20 }) - meths.buf_set_extmark(0, ns, 0, 3, { end_col = 6, hl_group = 'TestUL', priority = 30 }) + meths.nvim_buf_clear_namespace(0, ns, 0, -1) + meths.nvim_buf_set_extmark(0, ns, 0, 0, { end_col = 9, hl_group = 'TestUC', priority = 20 }) + meths.nvim_buf_set_extmark(0, ns, 0, 3, { end_col = 6, hl_group = 'TestUL', priority = 30 }) screen:expect([[ {2:aaa}{3:bbb}{2:aa^a} | {0:~ }| | ]]) - meths.buf_clear_namespace(0, ns, 0, -1) - meths.buf_set_extmark(0, ns, 0, 0, { end_col = 9, hl_group = 'TestUL', priority = 30 }) - meths.buf_set_extmark(0, ns, 0, 3, { end_col = 6, hl_group = 'TestUC', priority = 20 }) + meths.nvim_buf_clear_namespace(0, ns, 0, -1) + meths.nvim_buf_set_extmark(0, ns, 0, 0, { end_col = 9, hl_group = 'TestUL', priority = 30 }) + meths.nvim_buf_set_extmark(0, ns, 0, 3, { end_col = 6, hl_group = 'TestUC', priority = 20 }) screen:expect([[ {1:aaa}{3:bbb}{1:aa^a} | {0:~ }| | ]]) - meths.buf_clear_namespace(0, ns, 0, -1) - meths.buf_set_extmark(0, ns, 0, 0, { end_col = 9, hl_group = 'TestUC', priority = 30 }) - meths.buf_set_extmark(0, ns, 0, 3, { end_col = 6, hl_group = 'TestUL', priority = 20 }) + meths.nvim_buf_clear_namespace(0, ns, 0, -1) + meths.nvim_buf_set_extmark(0, ns, 0, 0, { end_col = 9, hl_group = 'TestUC', priority = 30 }) + meths.nvim_buf_set_extmark(0, ns, 0, 3, { end_col = 6, hl_group = 'TestUL', priority = 20 }) screen:expect([[ {2:aaa}{4:bbb}{2:aa^a} | {0:~ }| @@ -1773,14 +1773,14 @@ describe('extmark decorations', function() -- When only one highlight group has an underline attribute, it should always take effect. for _, d in ipairs({-5, 5}) do - meths.buf_clear_namespace(0, ns, 0, -1) + meths.nvim_buf_clear_namespace(0, ns, 0, -1) screen:expect([[ aaabbbaa^a | {0:~ }| | ]]) - meths.buf_set_extmark(0, ns, 0, 0, { end_col = 9, hl_group = 'TestUL', priority = 25 + d }) - meths.buf_set_extmark(0, ns, 0, 3, { end_col = 6, hl_group = 'TestBold', priority = 25 - d }) + meths.nvim_buf_set_extmark(0, ns, 0, 0, { end_col = 9, hl_group = 'TestUL', priority = 25 + d }) + meths.nvim_buf_set_extmark(0, ns, 0, 3, { end_col = 6, hl_group = 'TestBold', priority = 25 - d }) screen:expect([[ {1:aaa}{5:bbb}{1:aa^a} | {0:~ }| @@ -1788,14 +1788,14 @@ describe('extmark decorations', function() ]]) end for _, d in ipairs({-5, 5}) do - meths.buf_clear_namespace(0, ns, 0, -1) + meths.nvim_buf_clear_namespace(0, ns, 0, -1) screen:expect([[ aaabbbaa^a | {0:~ }| | ]]) - meths.buf_set_extmark(0, ns, 0, 0, { end_col = 9, hl_group = 'TestUC', priority = 25 + d }) - meths.buf_set_extmark(0, ns, 0, 3, { end_col = 6, hl_group = 'TestBold', priority = 25 - d }) + meths.nvim_buf_set_extmark(0, ns, 0, 0, { end_col = 9, hl_group = 'TestUC', priority = 25 + d }) + meths.nvim_buf_set_extmark(0, ns, 0, 3, { end_col = 6, hl_group = 'TestBold', priority = 25 - d }) screen:expect([[ {2:aaa}{6:bbb}{2:aa^a} | {0:~ }| @@ -1812,7 +1812,7 @@ describe('extmark decorations', function() feed('gg') command('set ft=lua') command('syntax on') - meths.buf_set_extmark(0, ns, 0, 0, { end_col = 3, hl_mode = 'combine', hl_group = 'Visual' }) + meths.nvim_buf_set_extmark(0, ns, 0, 0, { end_col = 3, hl_mode = 'combine', hl_group = 'Visual' }) command('hi default MyLine gui=underline') command('sign define CurrentLine linehl=MyLine') funcs.sign_place(6, 'Test', 'CurrentLine', '', { lnum = 1 }) @@ -1826,8 +1826,8 @@ describe('extmark decorations', function() it('highlight works after TAB with sidescroll #14201', function() screen:try_resize(50, 3) command('set nowrap') - meths.buf_set_lines(0, 0, -1, true, {'\tword word word word'}) - meths.buf_set_extmark(0, ns, 0, 1, { end_col = 3, hl_group = 'ErrorMsg' }) + meths.nvim_buf_set_lines(0, 0, -1, true, {'\tword word word word'}) + meths.nvim_buf_set_extmark(0, ns, 0, 1, { end_col = 3, hl_group = 'ErrorMsg' }) screen:expect{grid=[[ ^ {4:wo}rd word word word | {1:~ }| @@ -1855,16 +1855,16 @@ describe('extmark decorations', function() it('highlights the beginning of a TAB char correctly #23734', function() screen:try_resize(50, 3) - meths.buf_set_lines(0, 0, -1, true, {'this is the\ttab'}) - meths.buf_set_extmark(0, ns, 0, 11, { end_col = 15, hl_group = 'ErrorMsg' }) + meths.nvim_buf_set_lines(0, 0, -1, true, {'this is the\ttab'}) + meths.nvim_buf_set_extmark(0, ns, 0, 11, { end_col = 15, hl_group = 'ErrorMsg' }) screen:expect{grid=[[ ^this is the{4: tab} | {1:~ }| | ]]} - meths.buf_clear_namespace(0, ns, 0, -1) - meths.buf_set_extmark(0, ns, 0, 12, { end_col = 15, hl_group = 'ErrorMsg' }) + meths.nvim_buf_clear_namespace(0, ns, 0, -1) + meths.nvim_buf_set_extmark(0, ns, 0, 12, { end_col = 15, hl_group = 'ErrorMsg' }) screen:expect{grid=[[ ^this is the {4:tab} | {1:~ }| @@ -1874,10 +1874,10 @@ describe('extmark decorations', function() it('highlight applies to a full TAB on line with matches #20885', function() screen:try_resize(50, 3) - meths.buf_set_lines(0, 0, -1, true, {'\t-- match1', ' -- match2'}) + meths.nvim_buf_set_lines(0, 0, -1, true, {'\t-- match1', ' -- match2'}) funcs.matchadd('Underlined', 'match') - meths.buf_set_extmark(0, ns, 0, 0, { end_row = 1, end_col = 0, hl_group = 'Visual' }) - meths.buf_set_extmark(0, ns, 1, 0, { end_row = 2, end_col = 0, hl_group = 'Visual' }) + meths.nvim_buf_set_extmark(0, ns, 0, 0, { end_row = 1, end_col = 0, hl_group = 'Visual' }) + meths.nvim_buf_set_extmark(0, ns, 1, 0, { end_row = 2, end_col = 0, hl_group = 'Visual' }) screen:expect{grid=[[ {18: ^ -- }{29:match}{18:1} | {18: -- }{29:match}{18:2} | @@ -1887,8 +1887,8 @@ describe('extmark decorations', function() pending('highlight applies to a full TAB in visual block mode', function() screen:try_resize(50, 8) - meths.buf_set_lines(0, 0, -1, true, {'asdf', '\tasdf', '\tasdf', '\tasdf', 'asdf'}) - meths.buf_set_extmark(0, ns, 0, 0, {end_row = 5, end_col = 0, hl_group = 'Underlined'}) + meths.nvim_buf_set_lines(0, 0, -1, true, {'asdf', '\tasdf', '\tasdf', '\tasdf', 'asdf'}) + meths.nvim_buf_set_extmark(0, ns, 0, 0, {end_row = 5, end_col = 0, hl_group = 'Underlined'}) screen:expect([[ {28:^asdf} | {28: asdf} |*3 @@ -1909,7 +1909,7 @@ describe('extmark decorations', function() it('highlight works properly with multibyte text and spell #26771', function() insert('口口\n') screen:try_resize(50, 3) - meths.buf_set_extmark(0, ns, 0, 0, { end_col = 3, hl_group = 'Search' }) + meths.nvim_buf_set_extmark(0, ns, 0, 0, { end_col = 3, hl_group = 'Search' }) screen:expect([[ {34:口}口 | ^ | @@ -1928,7 +1928,7 @@ describe('extmark decorations', function() feed 'gg' for _,i in ipairs {1,2,3,5,6,7} do for _,j in ipairs {2,5,10,15} do - meths.buf_set_extmark(0, ns, i, j, { end_col=j+2, hl_group = 'NonText'}) + meths.nvim_buf_set_extmark(0, ns, i, j, { end_col=j+2, hl_group = 'NonText'}) end end screen:expect{grid=[[ @@ -1960,7 +1960,7 @@ describe('extmark decorations', function() | ]]} - meths.buf_set_extmark(0, ns, 1, 0, { end_line=8, end_col=10, hl_group = 'ErrorMsg'}) + meths.nvim_buf_set_extmark(0, ns, 1, 0, { end_line=8, end_col=10, hl_group = 'ErrorMsg'}) screen:expect{grid=[[ {4:^ }{36: }{4:f}{36:or}{4: _ }{36:= }{4:1, }{36:(c}{4:ount or 1) do} | {4: }{36: }{4: }{36: }{4: lo}{36:ca}{4:l c}{36:el}{4:l = line[colpos]} | @@ -1978,7 +1978,7 @@ describe('extmark decorations', function() screen:try_resize(50, 5) insert(example_text) feed'gg' - meths.buf_set_extmark(0, ns, 0, 6, { end_col=13, hl_group = 'NonText', undo_restore=val}) + meths.nvim_buf_set_extmark(0, ns, 0, 6, { end_col=13, hl_group = 'NonText', undo_restore=val}) screen:expect{grid=[[ ^for _,{1:item in} ipairs(items) do | local text, hl_id_cell, count = unpack(item) | @@ -1987,7 +1987,7 @@ describe('extmark decorations', function() | ]]} - meths.buf_set_text(0, 0, 4, 0, 8, {''}) + meths.nvim_buf_set_text(0, 0, 4, 0, 8, {''}) screen:expect{grid=[[ ^for {1:em in} ipairs(items) do | local text, hl_id_cell, count = unpack(item) | @@ -2025,7 +2025,7 @@ describe('extmark decorations', function() eq({ { 1, 0, 8, { end_col = 13, end_right_gravity = false, end_row = 0, hl_eol = false, hl_group = "NonText", undo_restore = false, ns_id = 1, priority = 4096, right_gravity = true } } }, - meths.buf_get_extmarks(0, ns, {0,0}, {0, -1}, {details=true})) + meths.nvim_buf_get_extmarks(0, ns, {0,0}, {0, -1}, {details=true})) end) it('virtual text works with rightleft', function() @@ -2033,10 +2033,10 @@ describe('extmark decorations', function() insert('abcdefghijklmn') feed('0') command('set rightleft') - meths.buf_set_extmark(0, ns, 0, 0, { virt_text = {{'EOL', 'Underlined'}}}) - meths.buf_set_extmark(0, ns, 0, 0, { virt_text = {{'right_align', 'Underlined'}}, virt_text_pos = 'right_align' }) - meths.buf_set_extmark(0, ns, 0, 0, { virt_text = {{'win_col', 'Underlined'}}, virt_text_win_col = 20 }) - meths.buf_set_extmark(0, ns, 0, 2, { virt_text = {{'overlayed', 'Underlined'}}, virt_text_pos = 'overlay' }) + meths.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = {{'EOL', 'Underlined'}}}) + meths.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = {{'right_align', 'Underlined'}}, virt_text_pos = 'right_align' }) + meths.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = {{'win_col', 'Underlined'}}, virt_text_win_col = 20 }) + meths.nvim_buf_set_extmark(0, ns, 0, 2, { virt_text = {{'overlayed', 'Underlined'}}, virt_text_pos = 'overlay' }) screen:expect{grid=[[ {28:ngila_thgir} {28:loc_niw} {28:LOE} nml{28:deyalrevo}b^a| {1: ~}| @@ -2086,7 +2086,7 @@ describe('extmark decorations', function() screen:try_resize(50, 3) insert('abcdefghij口klmnopqrstu口vwx口yz') feed('0') - meths.buf_set_extmark(0, ns, 0, 0, { virt_text = {{'!!!!!', 'Underlined'}}, virt_text_win_col = 11 }) + meths.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = {{'!!!!!', 'Underlined'}}, virt_text_win_col = 11 }) screen:expect{grid=[[ ^abcdefghij {28:!!!!!}opqrstu口vwx口yz | {1:~ }| @@ -2117,7 +2117,7 @@ describe('extmark decorations', function() insert('abcdefghij口klmnopqrstu口vwx口yz') feed('0') command('hi Blendy guibg=Red blend=30') - meths.buf_set_extmark(0, ns, 0, 0, { virt_text = {{' ! ! ', 'Blendy'}}, virt_text_win_col = 8, hl_mode = 'blend' }) + meths.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = {{' ! ! ', 'Blendy'}}, virt_text_win_col = 8, hl_mode = 'blend' }) screen:expect{grid=[[ ^abcdefgh{10:i}{7:!}{10:口}{7:!}{10:l}mnopqrstu口vwx口yz | {1:~ }| @@ -2159,10 +2159,10 @@ describe('extmark decorations', function() {1: ~}| | ]]} - meths.buf_set_extmark(0, ns, 0, 2, { virt_text = {{'overlayed', 'Underlined'}}, virt_text_pos = 'overlay' }) - meths.buf_set_extmark(0, ns, 0, 14, { virt_text = {{'古', 'Underlined'}}, virt_text_pos = 'overlay' }) - meths.buf_set_extmark(0, ns, 0, 20, { virt_text = {{'\t', 'Underlined'}}, virt_text_pos = 'overlay' }) - meths.buf_set_extmark(0, ns, 0, 29, { virt_text = {{'古', 'Underlined'}}, virt_text_pos = 'overlay' }) + meths.nvim_buf_set_extmark(0, ns, 0, 2, { virt_text = {{'overlayed', 'Underlined'}}, virt_text_pos = 'overlay' }) + meths.nvim_buf_set_extmark(0, ns, 0, 14, { virt_text = {{'古', 'Underlined'}}, virt_text_pos = 'overlay' }) + meths.nvim_buf_set_extmark(0, ns, 0, 20, { virt_text = {{'\t', 'Underlined'}}, virt_text_pos = 'overlay' }) + meths.nvim_buf_set_extmark(0, ns, 0, 29, { virt_text = {{'古', 'Underlined'}}, virt_text_pos = 'overlay' }) screen:expect{grid=[[ zy {28:古}wv {28: }qpon{28:古}k {28:deyalrevo}b^a| {1: ~}| @@ -2173,7 +2173,7 @@ describe('extmark decorations', function() it('works with both hl_group and sign_hl_group', function() screen:try_resize(screen._width, 3) insert('abcdefghijklmn') - meths.buf_set_extmark(0, ns, 0, 0, {sign_text='S', sign_hl_group='NonText', hl_group='Error', end_col=14}) + meths.nvim_buf_set_extmark(0, ns, 0, 0, {sign_text='S', sign_hl_group='NonText', hl_group='Error', end_col=14}) screen:expect{grid=[[ {1:S }{4:abcdefghijklm^n} | {1:~ }| @@ -2183,10 +2183,10 @@ describe('extmark decorations', function() it('virt_text_repeat_linebreak repeats virtual text on wrapped lines', function() screen:try_resize(40, 5) - meths.set_option_value('breakindent', true, {}) + meths.nvim_set_option_value('breakindent', true, {}) insert(example_text) - meths.buf_set_extmark(0, ns, 1, 0, { virt_text = {{'│', 'NonText'}}, virt_text_pos = 'overlay', virt_text_repeat_linebreak = true }) - meths.buf_set_extmark(0, ns, 1, 3, { virt_text = {{'│', 'NonText'}}, virt_text_pos = 'overlay', virt_text_repeat_linebreak = true }) + meths.nvim_buf_set_extmark(0, ns, 1, 0, { virt_text = {{'│', 'NonText'}}, virt_text_pos = 'overlay', virt_text_repeat_linebreak = true }) + meths.nvim_buf_set_extmark(0, ns, 1, 3, { virt_text = {{'│', 'NonText'}}, virt_text_pos = 'overlay', virt_text_repeat_linebreak = true }) command('norm gg') screen:expect{grid=[[ ^for _,item in ipairs(items) do | @@ -2195,9 +2195,9 @@ describe('extmark decorations', function() if hl_id_cell ~= nil then | | ]]} - meths.buf_clear_namespace(0, ns, 0, -1) - meths.buf_set_extmark(0, ns, 1, 0, { virt_text = {{'│', 'NonText'}}, virt_text_repeat_linebreak = true, virt_text_win_col = 0 }) - meths.buf_set_extmark(0, ns, 1, 0, { virt_text = {{'│', 'NonText'}}, virt_text_repeat_linebreak = true, virt_text_win_col = 2 }) + meths.nvim_buf_clear_namespace(0, ns, 0, -1) + meths.nvim_buf_set_extmark(0, ns, 1, 0, { virt_text = {{'│', 'NonText'}}, virt_text_repeat_linebreak = true, virt_text_win_col = 0 }) + meths.nvim_buf_set_extmark(0, ns, 1, 0, { virt_text = {{'│', 'NonText'}}, virt_text_repeat_linebreak = true, virt_text_win_col = 2 }) screen:expect{grid=[[ ^for _,item in ipairs(items) do | {1:│} {1:│} local text, hl_id_cell, count = unpa| @@ -2238,7 +2238,7 @@ describe('decorations: inline virtual text', function() [21] = {reverse = true, foreground = Screen.colors.SlateBlue} } - ns = meths.create_namespace 'test' + ns = meths.nvim_create_namespace 'test' end) @@ -2259,7 +2259,7 @@ describe('decorations: inline virtual text', function() | ]]} - meths.buf_set_extmark(0, ns, 1, 14, {virt_text={{': ', 'Special'}, {'string', 'Type'}}, virt_text_pos='inline'}) + meths.nvim_buf_set_extmark(0, ns, 1, 14, {virt_text={{': ', 'Special'}, {'string', 'Type'}}, virt_text_pos='inline'}) screen:expect{grid=[[ ^for _,item in ipairs(items) do | local text{10:: }{3:string}, hl_id_cell, count = unpack| @@ -2319,9 +2319,9 @@ describe('decorations: inline virtual text', function() | ]]} - meths.buf_set_extmark(0, ns, 0, 5, {virt_text={{''}, {''}}, virt_text_pos='inline'}) - meths.buf_set_extmark(0, ns, 1, 14, {virt_text={{''}, {': ', 'Special'}}, virt_text_pos='inline'}) - meths.buf_set_extmark(0, ns, 1, 48, {virt_text={{''}, {''}}, virt_text_pos='inline'}) + meths.nvim_buf_set_extmark(0, ns, 0, 5, {virt_text={{''}, {''}}, virt_text_pos='inline'}) + meths.nvim_buf_set_extmark(0, ns, 1, 14, {virt_text={{''}, {': ', 'Special'}}, virt_text_pos='inline'}) + meths.nvim_buf_set_extmark(0, ns, 1, 48, {virt_text={{''}, {''}}, virt_text_pos='inline'}) screen:expect{grid=[[ ^for _,item in ipairs(items) do | local text{10:: }, hl_id_cell, count = unpack(item)| @@ -2335,7 +2335,7 @@ describe('decorations: inline virtual text', function() | ]]} - meths.buf_set_extmark(0, ns, 1, 14, {virt_text={{''}, {'string', 'Type'}}, virt_text_pos='inline'}) + meths.nvim_buf_set_extmark(0, ns, 1, 14, {virt_text={{''}, {'string', 'Type'}}, virt_text_pos='inline'}) feed('V') screen:expect{grid=[[ ^f{7:or _,item in ipairs(items) do} | @@ -2367,8 +2367,8 @@ describe('decorations: inline virtual text', function() it('Normal mode "gM" command works properly', function() command([[call setline(1, '123456789')]]) - meths.buf_set_extmark(0, ns, 0, 2, { virt_text = { { 'bbb', 'Special' } }, virt_text_pos = 'inline' }) - meths.buf_set_extmark(0, ns, 0, 7, { virt_text = { { 'bbb', 'Special' } }, virt_text_pos = 'inline' }) + meths.nvim_buf_set_extmark(0, ns, 0, 2, { virt_text = { { 'bbb', 'Special' } }, virt_text_pos = 'inline' }) + meths.nvim_buf_set_extmark(0, ns, 0, 7, { virt_text = { { 'bbb', 'Special' } }, virt_text_pos = 'inline' }) feed('gM') screen:expect{grid=[[ 12{10:bbb}34^567{10:bbb}89 | @@ -2380,8 +2380,8 @@ describe('decorations: inline virtual text', function() local function test_normal_gj_gk() screen:try_resize(60, 6) command([[call setline(1, repeat([repeat('a', 55)], 2))]]) - meths.buf_set_extmark(0, ns, 0, 40, { virt_text = { { ('b'):rep(10), 'Special' } }, virt_text_pos = 'inline' }) - meths.buf_set_extmark(0, ns, 1, 40, { virt_text = { { ('b'):rep(10), 'Special' } }, virt_text_pos = 'inline' }) + meths.nvim_buf_set_extmark(0, ns, 0, 40, { virt_text = { { ('b'):rep(10), 'Special' } }, virt_text_pos = 'inline' }) + meths.nvim_buf_set_extmark(0, ns, 1, 40, { virt_text = { { ('b'):rep(10), 'Special' } }, virt_text_pos = 'inline' }) screen:expect{grid=[[ ^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{10:bbbbbbbbbb}aaaaaaaaaa| aaaaa | @@ -2459,8 +2459,8 @@ describe('decorations: inline virtual text', function() it('cursor positions are correct with multiple inline virtual text', function() insert('12345678') - meths.buf_set_extmark(0, ns, 0, 4, { virt_text = { { ' virtual text ', 'Special' } }, virt_text_pos = 'inline' }) - meths.buf_set_extmark(0, ns, 0, 4, { virt_text = { { ' virtual text ', 'Special' } }, virt_text_pos = 'inline' }) + meths.nvim_buf_set_extmark(0, ns, 0, 4, { virt_text = { { ' virtual text ', 'Special' } }, virt_text_pos = 'inline' }) + meths.nvim_buf_set_extmark(0, ns, 0, 4, { virt_text = { { ' virtual text ', 'Special' } }, virt_text_pos = 'inline' }) feed '^' feed '4l' screen:expect{grid=[[ @@ -2473,7 +2473,7 @@ describe('decorations: inline virtual text', function() it('adjusts cursor location correctly when inserting around inline virtual text', function() insert('12345678') feed '$' - meths.buf_set_extmark(0, ns, 0, 4, { virt_text = { { ' virtual text ', 'Special' } }, virt_text_pos = 'inline' }) + meths.nvim_buf_set_extmark(0, ns, 0, 4, { virt_text = { { ' virtual text ', 'Special' } }, virt_text_pos = 'inline' }) screen:expect{grid=[[ 1234{10: virtual text }567^8 | @@ -2484,7 +2484,7 @@ describe('decorations: inline virtual text', function() it('has correct highlighting with multi-byte characters', function() insert('12345678') - meths.buf_set_extmark(0, ns, 0, 4, { virt_text = { { 'múlti-byté chñröcters 修补', 'Special' } }, virt_text_pos = 'inline' }) + meths.nvim_buf_set_extmark(0, ns, 0, 4, { virt_text = { { 'múlti-byté chñröcters 修补', 'Special' } }, virt_text_pos = 'inline' }) screen:expect{grid=[[ 1234{10:múlti-byté chñröcters 修补}567^8 | @@ -2495,7 +2495,7 @@ describe('decorations: inline virtual text', function() it('has correct cursor position when inserting around virtual text', function() insert('12345678') - meths.buf_set_extmark(0, ns, 0, 4, { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) + meths.nvim_buf_set_extmark(0, ns, 0, 4, { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) feed '^' feed '3l' feed 'a' @@ -2521,7 +2521,7 @@ describe('decorations: inline virtual text', function() end) it('has correct cursor position with virtual text on an empty line', function() - meths.buf_set_extmark(0, ns, 0, 0, { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) + meths.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) screen:expect{grid=[[ {10:^virtual text} | {1:~ }| @@ -2535,8 +2535,8 @@ describe('decorations: inline virtual text', function() call setline(1, ['', 'aaa', '', 'bbbbbb']) normal gg0 ]]) - meths.buf_set_extmark(0, ns, 0, 0, { virt_text = { { string.rep('X', 60), 'Special' } }, virt_text_pos = 'inline' }) - meths.buf_set_extmark(0, ns, 2, 0, { virt_text = { { string.rep('X', 61), 'Special' } }, virt_text_pos = 'inline' }) + meths.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = { { string.rep('X', 60), 'Special' } }, virt_text_pos = 'inline' }) + meths.nvim_buf_set_extmark(0, ns, 2, 0, { virt_text = { { string.rep('X', 61), 'Special' } }, virt_text_pos = 'inline' }) feed('$') screen:expect{grid=[[ {10:^XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| @@ -2626,7 +2626,7 @@ describe('decorations: inline virtual text', function() feed('<TAB>') feed('test') feed('<ESC>') - meths.buf_set_extmark(0, ns, 0, 1, { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) + meths.nvim_buf_set_extmark(0, ns, 0, 1, { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) feed('0') screen:expect{grid=[[ ^ {10:virtual text} test | @@ -2667,7 +2667,7 @@ describe('decorations: inline virtual text', function() command('set linebreak') insert('one twoword') feed('0') - meths.buf_set_extmark(0, ns, 0, 3, { virt_text = { { ': virtual text', 'Special' } }, virt_text_pos = 'inline' }) + meths.nvim_buf_set_extmark(0, ns, 0, 3, { virt_text = { { ': virtual text', 'Special' } }, virt_text_pos = 'inline' }) screen:expect{grid=[[ ^one{10:: virtual text} twoword | {1:~ }| @@ -2678,10 +2678,10 @@ describe('decorations: inline virtual text', function() it('search highlight is correct', function() insert('foo foo foo bar\nfoo foo foo bar') feed('gg0') - meths.buf_set_extmark(0, ns, 0, 9, { virt_text = { { 'AAA', 'Special' } }, virt_text_pos = 'inline' }) - meths.buf_set_extmark(0, ns, 0, 9, { virt_text = { { 'BBB', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) - meths.buf_set_extmark(0, ns, 1, 9, { virt_text = { { 'CCC', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) - meths.buf_set_extmark(0, ns, 1, 9, { virt_text = { { 'DDD', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'replace' }) + meths.nvim_buf_set_extmark(0, ns, 0, 9, { virt_text = { { 'AAA', 'Special' } }, virt_text_pos = 'inline' }) + meths.nvim_buf_set_extmark(0, ns, 0, 9, { virt_text = { { 'BBB', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) + meths.nvim_buf_set_extmark(0, ns, 1, 9, { virt_text = { { 'CCC', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) + meths.nvim_buf_set_extmark(0, ns, 1, 9, { virt_text = { { 'DDD', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'replace' }) screen:expect{grid=[[ ^foo foo f{10:AAABBB}oo bar | foo foo f{10:CCCDDD}oo bar | @@ -2695,7 +2695,7 @@ describe('decorations: inline virtual text', function() /foo^ | ]]} - meths.buf_set_extmark(0, ns, 0, 13, { virt_text = { { 'EEE', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) + meths.nvim_buf_set_extmark(0, ns, 0, 13, { virt_text = { { 'EEE', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) feed('<C-G>') screen:expect{grid=[[ {12:foo} {12:foo} {13:f}{10:AAA}{21:BBB}{13:oo} b{10:EEE}ar | @@ -2707,10 +2707,10 @@ describe('decorations: inline virtual text', function() it('Visual select highlight is correct', function() insert('foo foo foo bar\nfoo foo foo bar') feed('gg0') - meths.buf_set_extmark(0, ns, 0, 8, { virt_text = { { 'AAA', 'Special' } }, virt_text_pos = 'inline' }) - meths.buf_set_extmark(0, ns, 0, 8, { virt_text = { { 'BBB', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) - meths.buf_set_extmark(0, ns, 1, 8, { virt_text = { { 'CCC', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) - meths.buf_set_extmark(0, ns, 1, 8, { virt_text = { { 'DDD', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'replace' }) + meths.nvim_buf_set_extmark(0, ns, 0, 8, { virt_text = { { 'AAA', 'Special' } }, virt_text_pos = 'inline' }) + meths.nvim_buf_set_extmark(0, ns, 0, 8, { virt_text = { { 'BBB', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) + meths.nvim_buf_set_extmark(0, ns, 1, 8, { virt_text = { { 'CCC', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) + meths.nvim_buf_set_extmark(0, ns, 1, 8, { virt_text = { { 'DDD', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'replace' }) feed('8l') screen:expect{grid=[[ foo foo {10:AAABBB}^foo bar | @@ -2726,7 +2726,7 @@ describe('decorations: inline virtual text', function() {8:-- VISUAL BLOCK --} | ]]} - meths.buf_set_extmark(0, ns, 0, 10, { virt_text = { { 'EEE', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) + meths.nvim_buf_set_extmark(0, ns, 0, 10, { virt_text = { { 'EEE', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) screen:expect{grid=[[ foo fo{7:o }{10:AAA}{20:BBB}{7:f}o{10:EEE}o bar | foo fo^o{7: }{20:CCC}{10:DDD}{7:f}oo bar | @@ -2736,12 +2736,12 @@ describe('decorations: inline virtual text', function() it('inside highlight range of another extmark', function() insert('foo foo foo bar\nfoo foo foo bar') - meths.buf_set_extmark(0, ns, 0, 8, { virt_text = { { 'AAA', 'Special' } }, virt_text_pos = 'inline' }) - meths.buf_set_extmark(0, ns, 0, 8, { virt_text = { { 'BBB', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) - meths.buf_set_extmark(0, ns, 1, 8, { virt_text = { { 'CCC', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) - meths.buf_set_extmark(0, ns, 1, 8, { virt_text = { { 'DDD', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'replace' }) - meths.buf_set_extmark(0, ns, 0, 4, { end_col = 11, hl_group = 'Search' }) - meths.buf_set_extmark(0, ns, 1, 4, { end_col = 11, hl_group = 'Search' }) + meths.nvim_buf_set_extmark(0, ns, 0, 8, { virt_text = { { 'AAA', 'Special' } }, virt_text_pos = 'inline' }) + meths.nvim_buf_set_extmark(0, ns, 0, 8, { virt_text = { { 'BBB', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) + meths.nvim_buf_set_extmark(0, ns, 1, 8, { virt_text = { { 'CCC', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) + meths.nvim_buf_set_extmark(0, ns, 1, 8, { virt_text = { { 'DDD', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'replace' }) + meths.nvim_buf_set_extmark(0, ns, 0, 4, { end_col = 11, hl_group = 'Search' }) + meths.nvim_buf_set_extmark(0, ns, 1, 4, { end_col = 11, hl_group = 'Search' }) screen:expect{grid=[[ foo {12:foo }{10:AAA}{19:BBB}{12:foo} bar | foo {12:foo }{19:CCC}{10:DDD}{12:foo} ba^r | @@ -2751,10 +2751,10 @@ describe('decorations: inline virtual text', function() it('inside highlight range of syntax', function() insert('foo foo foo bar\nfoo foo foo bar') - meths.buf_set_extmark(0, ns, 0, 8, { virt_text = { { 'AAA', 'Special' } }, virt_text_pos = 'inline' }) - meths.buf_set_extmark(0, ns, 0, 8, { virt_text = { { 'BBB', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) - meths.buf_set_extmark(0, ns, 1, 8, { virt_text = { { 'CCC', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) - meths.buf_set_extmark(0, ns, 1, 8, { virt_text = { { 'DDD', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'replace' }) + meths.nvim_buf_set_extmark(0, ns, 0, 8, { virt_text = { { 'AAA', 'Special' } }, virt_text_pos = 'inline' }) + meths.nvim_buf_set_extmark(0, ns, 0, 8, { virt_text = { { 'BBB', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) + meths.nvim_buf_set_extmark(0, ns, 1, 8, { virt_text = { { 'CCC', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) + meths.nvim_buf_set_extmark(0, ns, 1, 8, { virt_text = { { 'DDD', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'replace' }) command([[syntax match Search 'foo \zsfoo foo\ze bar']]) screen:expect{grid=[[ foo {12:foo }{10:AAA}{19:BBB}{12:foo} bar | @@ -2766,7 +2766,7 @@ describe('decorations: inline virtual text', function() it('cursor position is correct when inserting around a virtual text with left gravity', function() screen:try_resize(27, 4) insert(('a'):rep(15)) - meths.buf_set_extmark(0, ns, 0, 8, { virt_text = { { ('>'):rep(43), 'Special' } }, virt_text_pos = 'inline', right_gravity = false }) + meths.nvim_buf_set_extmark(0, ns, 0, 8, { virt_text = { { ('>'):rep(43), 'Special' } }, virt_text_pos = 'inline', right_gravity = false }) command('setlocal showbreak=+ breakindent breakindentopt=shift:2') feed('08l') screen:expect{grid=[[ @@ -2837,8 +2837,8 @@ describe('decorations: inline virtual text', function() screen:try_resize(30, 4) command('setlocal showbreak=+ breakindent breakindentopt=shift:2') insert(('a'):rep(15)) - meths.buf_set_extmark(0, ns, 0, 8, { virt_text = {{ ('>'):rep(32), 'Special' }}, virt_text_pos = 'inline', right_gravity = false }) - meths.buf_set_extmark(0, ns, 0, 8, { virt_text = {{ ('<'):rep(32), 'Special' }}, virt_text_pos = 'inline', right_gravity = true }) + meths.nvim_buf_set_extmark(0, ns, 0, 8, { virt_text = {{ ('>'):rep(32), 'Special' }}, virt_text_pos = 'inline', right_gravity = false }) + meths.nvim_buf_set_extmark(0, ns, 0, 8, { virt_text = {{ ('<'):rep(32), 'Special' }}, virt_text_pos = 'inline', right_gravity = true }) feed('08l') screen:expect{grid=[[ aaaaaaaa{10:>>>>>>>>>>>>>>>>>>>>>>}| @@ -2935,8 +2935,8 @@ describe('decorations: inline virtual text', function() it('draws correctly with no wrap multiple virtual text, where one is hidden', function() insert('abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz') command("set nowrap") - meths.buf_set_extmark(0, ns, 0, 50, { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) - meths.buf_set_extmark(0, ns, 0, 2, { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) + meths.nvim_buf_set_extmark(0, ns, 0, 50, { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) + meths.nvim_buf_set_extmark(0, ns, 0, 2, { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) feed('$') screen:expect{grid=[[ opqrstuvwxyzabcdefghijklmnopqrstuvwx{10:virtual text}y^z| @@ -2948,7 +2948,7 @@ describe('decorations: inline virtual text', function() it('draws correctly with no wrap and a long virtual text', function() insert('abcdefghi') command("set nowrap") - meths.buf_set_extmark(0, ns, 0, 2, { virt_text = { { string.rep('X', 55), 'Special' } }, virt_text_pos = 'inline' }) + meths.nvim_buf_set_extmark(0, ns, 0, 2, { virt_text = { { string.rep('X', 55), 'Special' } }, virt_text_pos = 'inline' }) feed('$') screen:expect{grid=[[ {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}cdefgh^i| @@ -2960,7 +2960,7 @@ describe('decorations: inline virtual text', function() it('tabs are the correct length with no wrap following virtual text', function() command('set nowrap') feed('itest<TAB>a<ESC>') - meths.buf_set_extmark(0, ns, 0, 0, { virt_text = { { string.rep('a', 55), 'Special' } }, virt_text_pos = 'inline' }) + meths.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = { { string.rep('a', 55), 'Special' } }, virt_text_pos = 'inline' }) feed('gg$') screen:expect{grid=[[ {10:aaaaaaaaaaaaaaaaaaaaaaaaa}test ^a | @@ -2972,7 +2972,7 @@ describe('decorations: inline virtual text', function() it('highlighting does not extend with no wrap and a long virtual text', function() insert('abcdef') command("set nowrap") - meths.buf_set_extmark(0, ns, 0, 3, { virt_text = { { string.rep('X', 50), 'Special' } }, virt_text_pos = 'inline' }) + meths.nvim_buf_set_extmark(0, ns, 0, 3, { virt_text = { { string.rep('X', 50), 'Special' } }, virt_text_pos = 'inline' }) feed('$') screen:expect{grid=[[ {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}de^f| @@ -2984,7 +2984,7 @@ describe('decorations: inline virtual text', function() it('hidden virtual text does not interfere with Visual highlight', function() insert('abcdef') command('set nowrap') - meths.buf_set_extmark(0, ns, 0, 0, { virt_text = { { 'XXX', 'Special' } }, virt_text_pos = 'inline' }) + meths.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = { { 'XXX', 'Special' } }, virt_text_pos = 'inline' }) feed('V2zl') screen:expect{grid=[[ {10:X}{7:abcde}^f | @@ -3011,7 +3011,7 @@ describe('decorations: inline virtual text', function() test test]]) command('set number') - meths.buf_set_extmark(0, ns, 0, 1, { virt_text = { { string.rep('X', 55), 'Special' } }, virt_text_pos = 'inline' }) + meths.nvim_buf_set_extmark(0, ns, 0, 1, { virt_text = { { string.rep('X', 55), 'Special' } }, virt_text_pos = 'inline' }) feed('gg0') screen:expect{grid=[[ {2: 1 }^t{10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| @@ -3024,7 +3024,7 @@ describe('decorations: inline virtual text', function() it('highlighting is correct when virtual text is proceeded with a match', function() insert([[test]]) - meths.buf_set_extmark(0, ns, 0, 2, { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) + meths.nvim_buf_set_extmark(0, ns, 0, 2, { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) feed('gg0') command('match ErrorMsg /e/') screen:expect{grid=[[ @@ -3042,7 +3042,7 @@ describe('decorations: inline virtual text', function() it('smoothscroll works correctly when virtual text wraps', function() insert('foobar') - meths.buf_set_extmark(0, ns, 0, 3, { virt_text = { { string.rep('X', 55), 'Special' } }, virt_text_pos = 'inline' }) + meths.nvim_buf_set_extmark(0, ns, 0, 3, { virt_text = { { string.rep('X', 55), 'Special' } }, virt_text_pos = 'inline' }) command('setlocal smoothscroll') screen:expect{grid=[[ foo{10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| @@ -3068,9 +3068,9 @@ describe('decorations: inline virtual text', function() ]]) insert('aaa\tbbb') command("set diff") - meths.buf_set_extmark(0, ns, 0, 1, { virt_text = { { 'test', 'Special' } }, virt_text_pos = 'inline', right_gravity = false }) - meths.buf_set_extmark(0, ns, 5, 0, { virt_text = { { '!', 'Special' } }, virt_text_pos = 'inline' }) - meths.buf_set_extmark(0, ns, 5, 3, { virt_text = { { '' } }, virt_text_pos = 'inline' }) + meths.nvim_buf_set_extmark(0, ns, 0, 1, { virt_text = { { 'test', 'Special' } }, virt_text_pos = 'inline', right_gravity = false }) + meths.nvim_buf_set_extmark(0, ns, 5, 0, { virt_text = { { '!', 'Special' } }, virt_text_pos = 'inline' }) + meths.nvim_buf_set_extmark(0, ns, 5, 3, { virt_text = { { '' } }, virt_text_pos = 'inline' }) command("vnew") insert([[ 000 @@ -3109,8 +3109,8 @@ describe('decorations: inline virtual text', function() it('correctly draws when there are multiple overlapping virtual texts on the same line with nowrap', function() command('set nowrap') insert('a') - meths.buf_set_extmark(0, ns, 0, 0, { virt_text = { { string.rep('a', 55), 'Special' } }, virt_text_pos = 'inline' }) - meths.buf_set_extmark(0, ns, 0, 0, { virt_text = { { string.rep('b', 55), 'Special' } }, virt_text_pos = 'inline' }) + meths.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = { { string.rep('a', 55), 'Special' } }, virt_text_pos = 'inline' }) + meths.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = { { string.rep('b', 55), 'Special' } }, virt_text_pos = 'inline' }) feed('$') screen:expect{grid=[[ {10:bbbbbbbbbbbbbbbbbbbbbbbbb}^a | @@ -3122,7 +3122,7 @@ describe('decorations: inline virtual text', function() it('correctly draws when overflowing virtual text is followed by TAB with no wrap', function() command('set nowrap') feed('i<TAB>test<ESC>') - meths.buf_set_extmark( 0, ns, 0, 0, { virt_text = { { string.rep('a', 60), 'Special' } }, virt_text_pos = 'inline' }) + meths.nvim_buf_set_extmark( 0, ns, 0, 0, { virt_text = { { string.rep('a', 60), 'Special' } }, virt_text_pos = 'inline' }) feed('0') screen:expect({grid=[[ {10:aaaaaaaaaaaaaaaaaaaaaa} ^ test | @@ -3140,8 +3140,8 @@ describe('decorations: inline virtual text', function() bbbbb ccccc]]) - meths.buf_set_extmark(0, ns, 0, 0, { virt_text = {{'foo'}}, virt_text_pos = 'inline' }) - meths.buf_set_extmark(0, ns, 2, 0, { virt_text = {{'bar'}}, virt_text_pos = 'inline' }) + meths.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = {{'foo'}}, virt_text_pos = 'inline' }) + meths.nvim_buf_set_extmark(0, ns, 2, 0, { virt_text = {{'bar'}}, virt_text_pos = 'inline' }) screen:expect{grid=[[ fooaaaaa | bbbbb | @@ -3183,7 +3183,7 @@ describe('decorations: inline virtual text', function() it('does not crash at right edge of wide window #23848', function() screen:try_resize(82, 5) - meths.buf_set_extmark(0, ns, 0, 0, {virt_text = {{('a'):rep(82)}, {'b'}}, virt_text_pos = 'inline'}) + meths.nvim_buf_set_extmark(0, ns, 0, 0, {virt_text = {{('a'):rep(82)}, {'b'}}, virt_text_pos = 'inline'}) screen:expect{grid=[[ ^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| b | @@ -3217,7 +3217,7 @@ describe('decorations: inline virtual text', function() setlocal nowrap list listchars=extends:! call setline(1, repeat('a', 51)) ]]) - meths.buf_set_extmark(0, ns, 0, 50, { virt_text = { { 'bbb', 'Special' } }, virt_text_pos = 'inline' }) + meths.nvim_buf_set_extmark(0, ns, 0, 50, { virt_text = { { 'bbb', 'Special' } }, virt_text_pos = 'inline' }) feed('20l') screen:expect{grid=[[ aaaaaaaaaaaaaaaaaaaa^aaaaaaaaaaaaaaaaaaaaaaaaaaaaa{1:!}| @@ -3254,7 +3254,7 @@ describe('decorations: inline virtual text', function() command('set nowrap') command('set list') command('set listchars+=extends:c') - meths.buf_set_extmark(0, ns, 0, 0, { virt_text = { { 'test', 'Special' } }, virt_text_pos = 'inline' }) + meths.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = { { 'test', 'Special' } }, virt_text_pos = 'inline' }) insert(string.rep('a', 50)) feed('gg0') screen:expect{grid=[[ @@ -3267,8 +3267,8 @@ describe('decorations: inline virtual text', function() it('blockwise Visual highlight with double-width virtual text (replace)', function() screen:try_resize(60, 6) insert('123456789\n123456789\n123456789\n123456789') - meths.buf_set_extmark(0, ns, 1, 1, { virt_text = { { '-口-', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'replace' }) - meths.buf_set_extmark(0, ns, 2, 2, { virt_text = { { '口', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'replace' }) + meths.nvim_buf_set_extmark(0, ns, 1, 1, { virt_text = { { '-口-', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'replace' }) + meths.nvim_buf_set_extmark(0, ns, 2, 2, { virt_text = { { '口', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'replace' }) feed('gg0') screen:expect{grid=[[ ^123456789 | @@ -3337,8 +3337,8 @@ describe('decorations: inline virtual text', function() it('blockwise Visual highlight with double-width virtual text (combine)', function() screen:try_resize(60, 6) insert('123456789\n123456789\n123456789\n123456789') - meths.buf_set_extmark(0, ns, 1, 1, { virt_text = { { '-口-', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) - meths.buf_set_extmark(0, ns, 2, 2, { virt_text = { { '口', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) + meths.nvim_buf_set_extmark(0, ns, 1, 1, { virt_text = { { '-口-', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) + meths.nvim_buf_set_extmark(0, ns, 2, 2, { virt_text = { { '口', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) feed('gg0') screen:expect{grid=[[ ^123456789 | @@ -3413,7 +3413,7 @@ describe('decorations: inline virtual text', function() call setline(1, repeat('a', 28)) normal! $ ]]) - meths.buf_set_extmark(0, ns, 0, 27, { virt_text = { { ('123'):rep(23) } }, virt_text_pos = 'inline' }) + meths.nvim_buf_set_extmark(0, ns, 0, 27, { virt_text = { { ('123'):rep(23) } }, virt_text_pos = 'inline' }) feed(':<CR>') -- Have a screen line that doesn't start with spaces screen:expect{grid=[[ 1 aaaaaaaaaaaaaaaaaaaaaaaaaa| @@ -3626,7 +3626,7 @@ describe('decorations: inline virtual text', function() call setline(1, repeat("\t", 4) .. 'a') normal! $ ]]) - meths.buf_set_extmark(0, ns, 0, 3, { virt_text = { { ('12'):rep(32) } }, virt_text_pos = 'inline' }) + meths.nvim_buf_set_extmark(0, ns, 0, 3, { virt_text = { { ('12'):rep(32) } }, virt_text_pos = 'inline' }) screen:expect{grid=[[ {1:<------><------><------>}121212| 121212121212121212121212121212| @@ -3722,7 +3722,7 @@ describe('decorations: inline virtual text', function() call setline(1, repeat('a', 50) .. ' ' .. repeat('c', 45)) normal! $ ]]) - meths.buf_set_extmark(0, ns, 0, 50, { virt_text = { { ('b'):rep(10) } }, virt_text_pos = 'inline' }) + meths.nvim_buf_set_extmark(0, ns, 0, 50, { virt_text = { { ('b'):rep(10) } }, virt_text_pos = 'inline' }) screen:expect{grid=[[ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| {1:+}bbbbbbbbbb | @@ -3745,7 +3745,7 @@ describe('decorations: inline virtual text', function() call setline(1, repeat('a', 40) .. '口' .. '12345') normal! $ ]]) - meths.buf_set_extmark(0, ns, 0, 40, { virt_text = { { ('b'):rep(9) } }, virt_text_pos = 'inline' }) + meths.nvim_buf_set_extmark(0, ns, 0, 40, { virt_text = { { ('b'):rep(9) } }, virt_text_pos = 'inline' }) screen:expect{grid=[[ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbb{1:>}| 口1234^5 | @@ -3772,7 +3772,7 @@ describe('decorations: virtual lines', function() [9] = {foreground = Screen.colors.Brown}; } - ns = meths.create_namespace 'test' + ns = meths.nvim_create_namespace 'test' end) local example_text2 = [[ @@ -3788,7 +3788,7 @@ if (h->n_buckets < new_n_buckets) { // expand it('works with one line', function() insert(example_text2) feed 'gg' - meths.buf_set_extmark(0, ns, 1, 33, { + meths.nvim_buf_set_extmark(0, ns, 1, 33, { virt_lines={ {{">> ", "NonText"}, {"krealloc", "Identifier"}, {": change the size of an allocation"}}}; virt_lines_above=true; }) @@ -3857,7 +3857,7 @@ if (h->n_buckets < new_n_buckets) { // expand | ]]} - meths.buf_set_extmark(0, ns, 5, 0, { + meths.nvim_buf_set_extmark(0, ns, 5, 0, { virt_lines = { {{"^^ REVIEW:", "Todo"}, {" new_vals variable seems unnecessary?", "Comment"}} }; }) -- TODO: what about the cursor?? @@ -3876,7 +3876,7 @@ if (h->n_buckets < new_n_buckets) { // expand | ]]} - meths.buf_clear_namespace(0, ns, 0, -1) + meths.nvim_buf_clear_namespace(0, ns, 0, -1) -- Cursor should be drawn on the correct line. #22704 screen:expect{grid=[[ if (h->n_buckets < new_n_buckets) { // expand | @@ -3913,7 +3913,7 @@ if (h->n_buckets < new_n_buckets) { // expand | ]]} - meths.buf_set_extmark(0, ns, 0, 0, { + meths.nvim_buf_set_extmark(0, ns, 0, 0, { virt_lines={ {{"refactor(khash): ", "Special"}, {"take size of values as parameter"}}; {{"Author: Dev Devsson, "}, {"Tue Aug 31 10:13:37 2021", "Comment"}}; @@ -3974,7 +3974,7 @@ if (h->n_buckets < new_n_buckets) { // expand | ]]} - local id = meths.buf_set_extmark(0, ns, 7, 0, { + local id = meths.nvim_buf_set_extmark(0, ns, 7, 0, { virt_lines={{{"Grugg"}}}; right_gravity=false; }) @@ -4057,7 +4057,7 @@ if (h->n_buckets < new_n_buckets) { // expand | ]]} - meths.buf_del_extmark(0, ns, id) + meths.nvim_buf_del_extmark(0, ns, id) screen:expect{grid=[[ if (h->n_buckets < new_n_buckets) { // expand | khkey_t *new_keys = (khkey_t *)krealloc((void *)| @@ -4093,7 +4093,7 @@ if (h->n_buckets < new_n_buckets) { // expand | ]]} - local id = meths.buf_set_extmark(0, ns, 8, 0, { + local id = meths.nvim_buf_set_extmark(0, ns, 8, 0, { virt_lines={{{"Grugg"}}}; virt_lines_above = true, }) @@ -4151,7 +4151,7 @@ if (h->n_buckets < new_n_buckets) { // expand --No lines in buffer-- | ]]} - meths.buf_del_extmark(0, ns, id) + meths.nvim_buf_del_extmark(0, ns, id) screen:expect{grid=[[ ^ | {1:~ }|*10 @@ -4163,7 +4163,7 @@ if (h->n_buckets < new_n_buckets) { // expand command([[syntax region foo keepend start='^foo' end='^$']]) command('syntax sync minlines=100') insert('foo') - meths.buf_set_extmark(0, ns, 0, 0, {virt_lines = {{{'bar', 'Comment'}}}}) + meths.nvim_buf_set_extmark(0, ns, 0, 0, {virt_lines = {{{'bar', 'Comment'}}}}) screen:expect([[ fo^o | {6:bar} | @@ -4177,7 +4177,7 @@ if (h->n_buckets < new_n_buckets) { // expand insert("aa\nbb\ncc\ndd\nee\nff\ngg\nhh") feed 'gg' - meths.buf_set_extmark(0, ns, 6, 0, { + meths.nvim_buf_set_extmark(0, ns, 6, 0, { virt_lines={ {{"they see me"}}; {{"scrolling", "Special"}}; @@ -4327,7 +4327,7 @@ if (h->n_buckets < new_n_buckets) { // expand | ]]} - local markid = meths.buf_set_extmark(0, ns, 2, 0, { + local markid = meths.nvim_buf_set_extmark(0, ns, 2, 0, { virt_lines={ {{"Some special", "Special"}}; {{"remark about codes", "Comment"}}; @@ -4349,7 +4349,7 @@ if (h->n_buckets < new_n_buckets) { // expand | ]]} - meths.buf_set_extmark(0, ns, 2, 0, { + meths.nvim_buf_set_extmark(0, ns, 2, 0, { virt_lines={ {{"Some special", "Special"}}; {{"remark about codes", "Comment"}}; @@ -4377,7 +4377,7 @@ if (h->n_buckets < new_n_buckets) { // expand it('works with hard TABs', function() insert(example_text2) feed 'gg' - meths.buf_set_extmark(0, ns, 1, 0, { + meths.nvim_buf_set_extmark(0, ns, 1, 0, { virt_lines={ {{">>", "NonText"}, {"\tvery\ttabby", "Identifier"}, {"text\twith\ttabs"}}}; }) screen:expect{grid=[[ @@ -4451,8 +4451,8 @@ if (h->n_buckets < new_n_buckets) { // expand bbb ccc ddd]]) - meths.buf_set_extmark(0, ns, 0, 0, {end_row = 2, virt_lines = {{{'VIRT LINE 1', 'NonText'}}}}) - meths.buf_set_extmark(0, ns, 3, 0, {end_col = 2, virt_lines = {{{'VIRT LINE 2', 'NonText'}}}}) + meths.nvim_buf_set_extmark(0, ns, 0, 0, {end_row = 2, virt_lines = {{{'VIRT LINE 1', 'NonText'}}}}) + meths.nvim_buf_set_extmark(0, ns, 3, 0, {end_col = 2, virt_lines = {{{'VIRT LINE 2', 'NonText'}}}}) screen:expect{grid=[[ aaa | {1:VIRT LINE 1} | @@ -4473,8 +4473,8 @@ if (h->n_buckets < new_n_buckets) { // expand ccc ddd]]) command('set number rightleft') - meths.buf_set_extmark(0, ns, 0, 0, {virt_lines = {{{'VIRT LINE 1', 'NonText'}}}, virt_lines_leftcol = true}) - meths.buf_set_extmark(0, ns, 3, 0, {virt_lines = {{{'VIRT LINE 2', 'NonText'}}}}) + meths.nvim_buf_set_extmark(0, ns, 0, 0, {virt_lines = {{{'VIRT LINE 1', 'NonText'}}}, virt_lines_leftcol = true}) + meths.nvim_buf_set_extmark(0, ns, 3, 0, {virt_lines = {{{'VIRT LINE 2', 'NonText'}}}}) screen:expect{grid=[[ aaa{9: 1 }| {1:1 ENIL TRIV}| @@ -4494,7 +4494,7 @@ if (h->n_buckets < new_n_buckets) { // expand line3 line4 line5]]) - meths.buf_set_extmark(0, ns, 0, 0, {virt_lines={{{"foo"}}, {{"bar"}}, {{"baz"}}}}) + meths.nvim_buf_set_extmark(0, ns, 0, 0, {virt_lines={{{"foo"}}, {{"bar"}}, {{"baz"}}}}) screen:expect{grid=[[ line1 | foo | @@ -4551,8 +4551,8 @@ describe('decorations: signs', function() [3] = {background = Screen.colors.Yellow1, foreground = Screen.colors.Blue1}; } - ns = meths.create_namespace 'test' - meths.set_option_value('signcolumn', 'auto:9', {}) + ns = meths.nvim_create_namespace 'test' + meths.nvim_set_option_value('signcolumn', 'auto:9', {}) end) local example_test3 = [[ @@ -4567,7 +4567,7 @@ l5 insert(example_test3) feed 'gg' - meths.buf_set_extmark(0, ns, 1, -1, {sign_text='S'}) + meths.nvim_buf_set_extmark(0, ns, 1, -1, {sign_text='S'}) screen:expect{grid=[[ {1: }^l1 | @@ -4585,7 +4585,7 @@ l5 insert(example_test3) feed 'gg' - meths.buf_set_extmark(0, ns, 1, -1, {sign_text='S', end_row=1}) + meths.nvim_buf_set_extmark(0, ns, 1, -1, {sign_text='S', end_row=1}) screen:expect{grid=[[ {1: }^l1 | @@ -4603,7 +4603,7 @@ l5 insert(example_test3) feed 'gg' - meths.buf_set_extmark(0, ns, 1, 0, {sign_text='S', hl_group='Todo', end_col=1}) + meths.nvim_buf_set_extmark(0, ns, 1, 0, {sign_text='S', hl_group='Todo', end_col=1}) screen:expect{grid=[[ {1: }^l1 | S {3:l}2 | @@ -4615,14 +4615,14 @@ l5 | ]]} - meths.buf_clear_namespace(0, ns, 0, -1) + meths.nvim_buf_clear_namespace(0, ns, 0, -1) end) it('can add multiple signs (single extmark)', function() insert(example_test3) feed 'gg' - meths.buf_set_extmark(0, ns, 1, -1, {sign_text='S', end_row = 2}) + meths.nvim_buf_set_extmark(0, ns, 1, -1, {sign_text='S', end_row = 2}) screen:expect{grid=[[ {1: }^l1 | @@ -4640,8 +4640,8 @@ l5 insert(example_test3) feed'gg' - meths.buf_set_extmark(0, ns, 1, -1, {sign_text='S1'}) - meths.buf_set_extmark(0, ns, 3, -1, {sign_text='S2', end_row = 4}) + meths.nvim_buf_set_extmark(0, ns, 1, -1, {sign_text='S1'}) + meths.nvim_buf_set_extmark(0, ns, 3, -1, {sign_text='S2', end_row = 4}) screen:expect{grid=[[ {1: }^l1 | @@ -4659,8 +4659,8 @@ l5 insert(example_test3) feed 'gg' - meths.buf_set_extmark(0, ns, 3, -1, {sign_text='S1'}) - meths.buf_set_extmark(0, ns, 1, -1, {sign_text='S2', end_row = 3}) + meths.nvim_buf_set_extmark(0, ns, 3, -1, {sign_text='S1'}) + meths.nvim_buf_set_extmark(0, ns, 1, -1, {sign_text='S2', end_row = 3}) screen:expect{grid=[[ {1: }^l1 | S2{1: }l2 | @@ -4678,8 +4678,8 @@ l5 insert(example_test3) feed 'gg' - meths.buf_set_extmark(0, ns, 1, -1, {sign_text='S1', end_row=2}) - meths.buf_set_extmark(0, ns, 2, -1, {sign_text='S2', end_row=3}) + meths.nvim_buf_set_extmark(0, ns, 1, -1, {sign_text='S1', end_row=2}) + meths.nvim_buf_set_extmark(0, ns, 2, -1, {sign_text='S2', end_row=3}) screen:expect{grid=[[ {1: }^l1 | @@ -4697,8 +4697,8 @@ l5 insert(example_test3) feed 'gg' - meths.buf_set_extmark(0, ns, 0, -1, {sign_text='S1', end_row=0}) - meths.buf_set_extmark(0, ns, 1, -1, {sign_text='S2', end_row=1}) + meths.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S1', end_row=0}) + meths.nvim_buf_set_extmark(0, ns, 1, -1, {sign_text='S2', end_row=1}) screen:expect{grid=[[ S1^l1 | @@ -4719,10 +4719,10 @@ l5 helpers.command('sign define Oldsign text=x') helpers.command([[exe 'sign place 42 line=2 name=Oldsign buffer=' . bufnr('')]]) - meths.buf_set_extmark(0, ns, 0, -1, {sign_text='S1'}) - meths.buf_set_extmark(0, ns, 1, -1, {sign_text='S2'}) - meths.buf_set_extmark(0, ns, 0, -1, {sign_text='S4'}) - meths.buf_set_extmark(0, ns, 2, -1, {sign_text='S5'}) + meths.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S1'}) + meths.nvim_buf_set_extmark(0, ns, 1, -1, {sign_text='S2'}) + meths.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S4'}) + meths.nvim_buf_set_extmark(0, ns, 2, -1, {sign_text='S5'}) screen:expect{grid=[[ S1S4^l1 | @@ -4743,11 +4743,11 @@ l5 helpers.command('sign define Oldsign text=x') helpers.command([[exe 'sign place 42 line=2 name=Oldsign buffer=' . bufnr('')]]) - meths.buf_set_extmark(0, ns, 0, -1, {sign_text='S1'}) - meths.buf_set_extmark(0, ns, 1, -1, {sign_text='S2'}) - meths.buf_set_extmark(0, ns, 0, -1, {sign_text='S3', end_row = 4}) - meths.buf_set_extmark(0, ns, 0, -1, {sign_text='S4'}) - meths.buf_set_extmark(0, ns, 2, -1, {sign_text='S5'}) + meths.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S1'}) + meths.nvim_buf_set_extmark(0, ns, 1, -1, {sign_text='S2'}) + meths.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S3', end_row = 4}) + meths.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S4'}) + meths.nvim_buf_set_extmark(0, ns, 2, -1, {sign_text='S5'}) screen:expect{grid=[[ S1S3S4^l1 | @@ -4767,7 +4767,7 @@ l5 feed 'gg' feed '2<C-e>' - meths.buf_set_extmark(0, ns, 1, -1, {sign_text='X', end_row=3}) + meths.nvim_buf_set_extmark(0, ns, 1, -1, {sign_text='X', end_row=3}) screen:expect{grid=[[ X {1: }^l3 | @@ -4784,18 +4784,18 @@ l5 command 'normal 10oa b c d e f g h' for i = 1, 10 do - meths.buf_set_extmark(0, ns, i, 0, { end_col = 1, hl_group='Todo' }) - meths.buf_set_extmark(0, ns, i, 2, { end_col = 3, hl_group='Todo' }) - meths.buf_set_extmark(0, ns, i, 4, { end_col = 5, hl_group='Todo' }) - meths.buf_set_extmark(0, ns, i, 6, { end_col = 7, hl_group='Todo' }) - meths.buf_set_extmark(0, ns, i, 8, { end_col = 9, hl_group='Todo' }) - meths.buf_set_extmark(0, ns, i, 10, { end_col = 11, hl_group='Todo' }) - meths.buf_set_extmark(0, ns, i, 12, { end_col = 13, hl_group='Todo' }) - meths.buf_set_extmark(0, ns, i, 14, { end_col = 15, hl_group='Todo' }) - meths.buf_set_extmark(0, ns, i, -1, { sign_text='W' }) - meths.buf_set_extmark(0, ns, i, -1, { sign_text='X' }) - meths.buf_set_extmark(0, ns, i, -1, { sign_text='Y' }) - meths.buf_set_extmark(0, ns, i, -1, { sign_text='Z' }) + meths.nvim_buf_set_extmark(0, ns, i, 0, { end_col = 1, hl_group='Todo' }) + meths.nvim_buf_set_extmark(0, ns, i, 2, { end_col = 3, hl_group='Todo' }) + meths.nvim_buf_set_extmark(0, ns, i, 4, { end_col = 5, hl_group='Todo' }) + meths.nvim_buf_set_extmark(0, ns, i, 6, { end_col = 7, hl_group='Todo' }) + meths.nvim_buf_set_extmark(0, ns, i, 8, { end_col = 9, hl_group='Todo' }) + meths.nvim_buf_set_extmark(0, ns, i, 10, { end_col = 11, hl_group='Todo' }) + meths.nvim_buf_set_extmark(0, ns, i, 12, { end_col = 13, hl_group='Todo' }) + meths.nvim_buf_set_extmark(0, ns, i, 14, { end_col = 15, hl_group='Todo' }) + meths.nvim_buf_set_extmark(0, ns, i, -1, { sign_text='W' }) + meths.nvim_buf_set_extmark(0, ns, i, -1, { sign_text='X' }) + meths.nvim_buf_set_extmark(0, ns, i, -1, { sign_text='Y' }) + meths.nvim_buf_set_extmark(0, ns, i, -1, { sign_text='Z' }) end screen:expect{grid=[[ @@ -4813,10 +4813,10 @@ l5 command('sign define Oldsign text=O3') command([[exe 'sign place 42 line=1 name=Oldsign priority=10 buffer=' . bufnr('')]]) - meths.buf_set_extmark(0, ns, 0, -1, {sign_text='S4', priority=100}) - meths.buf_set_extmark(0, ns, 0, -1, {sign_text='S2', priority=5}) - meths.buf_set_extmark(0, ns, 0, -1, {sign_text='S5', priority=200}) - meths.buf_set_extmark(0, ns, 0, -1, {sign_text='S1', priority=1}) + meths.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S4', priority=100}) + meths.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S2', priority=5}) + meths.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S5', priority=200}) + meths.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S1', priority=1}) screen:expect{grid=[[ S1S2O3S4S5^l1 | @@ -4825,7 +4825,7 @@ l5 ]]} -- Check truncation works too - meths.set_option_value('signcolumn', 'auto', {}) + meths.nvim_set_option_value('signcolumn', 'auto', {}) screen:expect{grid=[[ S5^l1 | @@ -4854,10 +4854,10 @@ l5 | ]]} - meths.buf_set_extmark(0, ns, 0, -1, {sign_text='S1', priority=1}) + meths.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S1', priority=1}) screen:expect_unchanged() - meths.buf_set_extmark(0, ns, 0, -1, {sign_text='S5', priority=200}) + meths.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S5', priority=200}) screen:expect{grid=[[ O3O3O3O3O3O3O3O3S5^ | {2:~ }| @@ -4869,10 +4869,10 @@ l5 it('does not set signcolumn for signs without text', function() screen:try_resize(20, 3) - meths.set_option_value('signcolumn', 'auto', {}) + meths.nvim_set_option_value('signcolumn', 'auto', {}) insert(example_test3) feed 'gg' - meths.buf_set_extmark(0, ns, 0, -1, {number_hl_group='Error'}) + meths.nvim_buf_set_extmark(0, ns, 0, -1, {number_hl_group='Error'}) screen:expect{grid=[[ ^l1 | l2 | @@ -4883,9 +4883,9 @@ l5 it('correct width when removing multiple signs from sentinel line', function() screen:try_resize(20, 4) insert(example_test3) - meths.buf_set_extmark(0, ns, 0, -1, {sign_text='S1', end_row=3}) - meths.buf_set_extmark(0, ns, 1, -1, {invalidate = true, sign_text='S2'}) - meths.buf_set_extmark(0, ns, 1, -1, {invalidate = true, sign_text='S3'}) + meths.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S1', end_row=3}) + meths.nvim_buf_set_extmark(0, ns, 1, -1, {invalidate = true, sign_text='S2'}) + meths.nvim_buf_set_extmark(0, ns, 1, -1, {invalidate = true, sign_text='S3'}) feed('2Gdd') screen:expect{grid=[[ @@ -4899,8 +4899,8 @@ l5 it('correct width with multiple overlapping signs', function() screen:try_resize(20, 4) insert(example_test3) - meths.buf_set_extmark(0, ns, 0, -1, {sign_text='S1', end_row=2}) - meths.buf_set_extmark(0, ns, 1, -1, {sign_text='S2', end_row=2}) + meths.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S1', end_row=2}) + meths.nvim_buf_set_extmark(0, ns, 1, -1, {sign_text='S2', end_row=2}) feed('gg') screen:expect{grid=[[ @@ -4935,9 +4935,9 @@ describe('decorations: virt_text', function() command 'normal 4ohello' command 'normal aVIRTUAL' - local ns = meths.create_namespace('test') + local ns = meths.nvim_create_namespace('test') - meths.buf_set_extmark(0, ns, 2, 0, { + meths.nvim_buf_set_extmark(0, ns, 2, 0, { virt_text = {{"hello", "String"}}, virt_text_win_col = 20, }) @@ -4977,9 +4977,9 @@ describe('decorations: virt_text', function() | ]]} - local ns = meths.create_namespace('ns') + local ns = meths.nvim_create_namespace('ns') for row = 1, 5 do - meths.buf_set_extmark(0, ns, row, 0, { id = 1, virt_text = {{'world', 'Normal'}} }) + meths.nvim_buf_set_extmark(0, ns, row, 0, { id = 1, virt_text = {{'world', 'Normal'}} }) end screen:expect{grid=[[ diff --git a/test/functional/ui/diff_spec.lua b/test/functional/ui/diff_spec.lua index e208385e92..0c9ca6199b 100644 --- a/test/functional/ui/diff_spec.lua +++ b/test/functional/ui/diff_spec.lua @@ -1053,7 +1053,7 @@ AAAB]] write_file(fname, 'aaa\nbbb\nccc\n\nxx', false) write_file(fname_2, 'aaa\nbbb\nccc\n\nyy', false) reread() - local buf = meths.get_current_buf() + local buf = meths.nvim_get_current_buf() command('botright new') screen:expect { grid = [[ @@ -1071,7 +1071,7 @@ AAAB]] ]], } - meths.buf_set_lines(buf, 1, 2, true, { 'BBB' }) + meths.nvim_buf_set_lines(buf, 1, 2, true, { 'BBB' }) screen:expect { grid = [[ {1: }aaa │{1: }aaa | @@ -1093,7 +1093,7 @@ AAAB]] write_file(fname, 'aaa\nbbb\nccc\n\nxx', false) write_file(fname_2, 'aaa\nbbb\nccc\n\nyy', false) reread() - local buf = meths.get_current_buf() + local buf = meths.nvim_get_current_buf() command('botright split | diffoff') screen:expect { grid = [[ @@ -1115,7 +1115,7 @@ AAAB]] ]], } - meths.buf_set_lines(buf, 1, 2, true, { 'BBB' }) + meths.nvim_buf_set_lines(buf, 1, 2, true, { 'BBB' }) screen:expect { grid = [[ {1: }aaa │{1: }aaa | @@ -1372,14 +1372,14 @@ it("diff mode doesn't restore invalid 'foldcolumn' value #21647", function() [0] = { foreground = Screen.colors.Blue, bold = true }, }) screen:attach() - eq('0', meths.get_option_value('foldcolumn', {})) + eq('0', meths.nvim_get_option_value('foldcolumn', {})) command('diffsplit | bd') screen:expect([[ ^ | {0:~ }|*4 | ]]) - eq('0', meths.get_option_value('foldcolumn', {})) + eq('0', meths.nvim_get_option_value('foldcolumn', {})) end) -- oldtest: Test_diff_binary() diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua index 6febb2e2df..645cce25aa 100644 --- a/test/functional/ui/float_spec.lua +++ b/test/functional/ui/float_spec.lua @@ -30,9 +30,9 @@ describe('float window', function() -- Create three windows and test that ":wincmd <direction>" changes to the -- first window, if the previous window is invalid. command('split') - meths.open_win(0, true, {width=10, height=10, relative='editor', row=0, col=0}) + meths.nvim_open_win(0, true, {width=10, height=10, relative='editor', row=0, col=0}) eq(1002, funcs.win_getid()) - eq('editor', meths.win_get_config(1002).relative) + eq('editor', meths.nvim_win_get_config(1002).relative) command([[ call nvim_win_close(1001, v:false) wincmd j @@ -41,9 +41,9 @@ describe('float window', function() end) it('win_execute() should work' , function() - local buf = meths.create_buf(false, false) - meths.buf_set_lines(buf, 0, -1, true, {'the floatwin', 'abc', 'def'}) - local win = meths.open_win(buf, false, {relative='win', width=16, height=1, row=0, col=10}) + local buf = meths.nvim_create_buf(false, false) + meths.nvim_buf_set_lines(buf, 0, -1, true, {'the floatwin', 'abc', 'def'}) + local win = meths.nvim_open_win(buf, false, {relative='win', width=16, height=1, row=0, col=10}) local line = funcs.win_execute(win, 'echo getline(1)') eq('\nthe floatwin', line) eq('\n1', funcs.win_execute(win, 'echo line(".",'..win.id..')')) @@ -54,9 +54,9 @@ describe('float window', function() it("win_execute() call commands that are not allowed when 'hidden' is not set" , function() command('set nohidden') - local buf = meths.create_buf(false, false) - meths.buf_set_lines(buf, 0, -1, true, {'the floatwin'}) - local win = meths.open_win(buf, true, {relative='win', width=16, height=1, row=0, col=10}) + local buf = meths.nvim_create_buf(false, false) + meths.nvim_buf_set_lines(buf, 0, -1, true, {'the floatwin'}) + local win = meths.nvim_open_win(buf, true, {relative='win', width=16, height=1, row=0, col=10}) eq('Vim(close):E37: No write since last change (add ! to override)', pcall_err(funcs.win_execute, win, 'close')) eq('Vim(bdelete):E89: No write since last change for buffer 2 (add ! to override)', pcall_err(funcs.win_execute, win, 'bdelete')) funcs.win_execute(win, 'bwipe!') @@ -192,7 +192,7 @@ describe('float window', function() end) it('opened with correct position relative to the mouse', function() - meths.input_mouse('left', 'press', '', 0, 10, 10) + meths.nvim_input_mouse('left', 'press', '', 0, 10, 10) local pos = exec_lua([[ local bufnr = vim.api.nvim_create_buf(false, true) @@ -479,67 +479,67 @@ describe('float window', function() it('no crash with bufpos and non-existent window', function() command('new') - local closed_win = meths.get_current_win().id + local closed_win = meths.nvim_get_current_win().id command('close') - local buf = meths.create_buf(false,false) - meths.open_win(buf, true, {relative='win', win=closed_win, width=1, height=1, bufpos={0,0}}) + local buf = meths.nvim_create_buf(false,false) + meths.nvim_open_win(buf, true, {relative='win', win=closed_win, width=1, height=1, bufpos={0,0}}) assert_alive() end) it("no segfault when setting minimal style after clearing local 'fillchars' #19510", function() local float_opts = {relative = 'editor', row = 1, col = 1, width = 1, height = 1} - local float_win = meths.open_win(0, true, float_opts) - meths.set_option_value('fillchars', NIL, {win=float_win.id}) + local float_win = meths.nvim_open_win(0, true, float_opts) + meths.nvim_set_option_value('fillchars', NIL, {win=float_win.id}) float_opts.style = 'minimal' - meths.win_set_config(float_win, float_opts) + meths.nvim_win_set_config(float_win, float_opts) assert_alive() end) it("should re-apply 'style' when present", function() local float_opts = {style = 'minimal', relative = 'editor', row = 1, col = 1, width = 1, height = 1} - local float_win = meths.open_win(0, true, float_opts) - meths.set_option_value('number', true, { win = float_win }) + local float_win = meths.nvim_open_win(0, true, float_opts) + meths.nvim_set_option_value('number', true, { win = float_win }) float_opts.row = 2 - meths.win_set_config(float_win, float_opts) - eq(false, meths.get_option_value('number', { win = float_win })) + meths.nvim_win_set_config(float_win, float_opts) + eq(false, meths.nvim_get_option_value('number', { win = float_win })) end) it("should not re-apply 'style' when missing", function() local float_opts = {style = 'minimal', relative = 'editor', row = 1, col = 1, width = 1, height = 1} - local float_win = meths.open_win(0, true, float_opts) - meths.set_option_value('number', true, { win = float_win }) + local float_win = meths.nvim_open_win(0, true, float_opts) + meths.nvim_set_option_value('number', true, { win = float_win }) float_opts.row = 2 float_opts.style = nil - meths.win_set_config(float_win, float_opts) - eq(true, meths.get_option_value('number', { win = float_win })) + meths.nvim_win_set_config(float_win, float_opts) + eq(true, meths.nvim_get_option_value('number', { win = float_win })) end) it("'scroll' is computed correctly when opening float with splitkeep=screen #20684", function() - meths.set_option_value('splitkeep', 'screen', {}) + meths.nvim_set_option_value('splitkeep', 'screen', {}) local float_opts = {relative = 'editor', row = 1, col = 1, width = 10, height = 10} - local float_win = meths.open_win(0, true, float_opts) - eq(5, meths.get_option_value('scroll', {win=float_win.id})) + local float_win = meths.nvim_open_win(0, true, float_opts) + eq(5, meths.nvim_get_option_value('scroll', {win=float_win.id})) end) it(':unhide works when there are floating windows', function() local float_opts = {relative = 'editor', row = 1, col = 1, width = 5, height = 5} local w0 = curwin() - meths.open_win(0, false, float_opts) - meths.open_win(0, false, float_opts) - eq(3, #meths.list_wins()) + meths.nvim_open_win(0, false, float_opts) + meths.nvim_open_win(0, false, float_opts) + eq(3, #meths.nvim_list_wins()) command('unhide') - eq({ w0 }, meths.list_wins()) + eq({ w0 }, meths.nvim_list_wins()) end) it(':all works when there are floating windows', function() command('args Xa.txt') local float_opts = {relative = 'editor', row = 1, col = 1, width = 5, height = 5} local w0 = curwin() - meths.open_win(0, false, float_opts) - meths.open_win(0, false, float_opts) - eq(3, #meths.list_wins()) + meths.nvim_open_win(0, false, float_opts) + meths.nvim_open_win(0, false, float_opts) + eq(3, #meths.nvim_list_wins()) command('all') - eq({ w0 }, meths.list_wins()) + eq({ w0 }, meths.nvim_list_wins()) end) describe('with only one tabpage,', function() @@ -552,37 +552,37 @@ describe('float window', function() end) describe('closing the last non-floating window gives E444', function() before_each(function() - meths.open_win(old_buf, true, float_opts) + meths.nvim_open_win(old_buf, true, float_opts) end) it('if called from non-floating window', function() - meths.set_current_win(old_win) + meths.nvim_set_current_win(old_win) eq('Vim:E444: Cannot close last window', - pcall_err(meths.win_close, old_win, false)) + pcall_err(meths.nvim_win_close, old_win, false)) end) it('if called from floating window', function() eq('Vim:E444: Cannot close last window', - pcall_err(meths.win_close, old_win, false)) + pcall_err(meths.nvim_win_close, old_win, false)) end) end) describe("deleting the last non-floating window's buffer", function() describe('leaves one window with an empty buffer when there is only one buffer', function() local same_buf_float before_each(function() - same_buf_float = meths.open_win(old_buf, false, float_opts).id + same_buf_float = meths.nvim_open_win(old_buf, false, float_opts).id end) after_each(function() eq(old_win, curwin().id) expect('') - eq(1, #meths.list_wins()) + eq(1, #meths.nvim_list_wins()) end) it('if called from non-floating window', function() - meths.buf_delete(old_buf, {force = true}) + meths.nvim_buf_delete(old_buf, {force = true}) end) it('if called from floating window', function() - meths.set_current_win(same_buf_float) + meths.nvim_set_current_win(same_buf_float) command('autocmd WinLeave * let g:win_leave = nvim_get_current_win()') command('autocmd WinEnter * let g:win_enter = nvim_get_current_win()') - meths.buf_delete(old_buf, {force = true}) + meths.nvim_buf_delete(old_buf, {force = true}) eq(same_buf_float, eval('g:win_leave')) eq(old_win, eval('g:win_enter')) end) @@ -590,67 +590,67 @@ describe('float window', function() describe('closes other windows with that buffer when there are other buffers', function() local same_buf_float, other_buf, other_buf_float before_each(function() - same_buf_float = meths.open_win(old_buf, false, float_opts).id - other_buf = meths.create_buf(true, false).id - other_buf_float = meths.open_win(other_buf, true, float_opts).id + same_buf_float = meths.nvim_open_win(old_buf, false, float_opts).id + other_buf = meths.nvim_create_buf(true, false).id + other_buf_float = meths.nvim_open_win(other_buf, true, float_opts).id insert('bar') - meths.set_current_win(old_win) + meths.nvim_set_current_win(old_win) end) after_each(function() eq(other_buf, curbuf().id) expect('bar') - eq(2, #meths.list_wins()) + eq(2, #meths.nvim_list_wins()) end) it('if called from non-floating window', function() - meths.buf_delete(old_buf, {force = true}) + meths.nvim_buf_delete(old_buf, {force = true}) eq(old_win, curwin().id) end) it('if called from floating window with the same buffer', function() - meths.set_current_win(same_buf_float) + meths.nvim_set_current_win(same_buf_float) command('autocmd WinLeave * let g:win_leave = nvim_get_current_win()') command('autocmd WinEnter * let g:win_enter = nvim_get_current_win()') - meths.buf_delete(old_buf, {force = true}) + meths.nvim_buf_delete(old_buf, {force = true}) eq(same_buf_float, eval('g:win_leave')) eq(old_win, eval('g:win_enter')) eq(old_win, curwin().id) end) -- TODO: this case is too hard to deal with pending('if called from floating window with another buffer', function() - meths.set_current_win(other_buf_float) - meths.buf_delete(old_buf, {force = true}) + meths.nvim_set_current_win(other_buf_float) + meths.nvim_buf_delete(old_buf, {force = true}) end) end) describe('creates an empty buffer when there is only one listed buffer', function() local same_buf_float, unlisted_buf_float before_each(function() - same_buf_float = meths.open_win(old_buf, false, float_opts).id - local unlisted_buf = meths.create_buf(true, false).id - unlisted_buf_float = meths.open_win(unlisted_buf, true, float_opts).id + same_buf_float = meths.nvim_open_win(old_buf, false, float_opts).id + local unlisted_buf = meths.nvim_create_buf(true, false).id + unlisted_buf_float = meths.nvim_open_win(unlisted_buf, true, float_opts).id insert('unlisted') command('set nobuflisted') - meths.set_current_win(old_win) + meths.nvim_set_current_win(old_win) end) after_each(function() expect('') - eq(2, #meths.list_wins()) + eq(2, #meths.nvim_list_wins()) end) it('if called from non-floating window', function() - meths.buf_delete(old_buf, {force = true}) + meths.nvim_buf_delete(old_buf, {force = true}) eq(old_win, curwin().id) end) it('if called from floating window with the same buffer', function() - meths.set_current_win(same_buf_float) + meths.nvim_set_current_win(same_buf_float) command('autocmd WinLeave * let g:win_leave = nvim_get_current_win()') command('autocmd WinEnter * let g:win_enter = nvim_get_current_win()') - meths.buf_delete(old_buf, {force = true}) + meths.nvim_buf_delete(old_buf, {force = true}) eq(same_buf_float, eval('g:win_leave')) eq(old_win, eval('g:win_enter')) eq(old_win, curwin().id) end) -- TODO: this case is too hard to deal with pending('if called from floating window with an unlisted buffer', function() - meths.set_current_win(unlisted_buf_float) - meths.buf_delete(old_buf, {force = true}) + meths.nvim_set_current_win(unlisted_buf_float) + meths.nvim_buf_delete(old_buf, {force = true}) end) end) end) @@ -661,20 +661,20 @@ describe('float window', function() command('botright vnew') insert('unlisted') command('set nobuflisted') - meths.set_current_win(old_win) - same_buf_float = meths.open_win(old_buf, false, float_opts).id + meths.nvim_set_current_win(old_win) + same_buf_float = meths.nvim_open_win(old_buf, false, float_opts).id end) after_each(function() expect('') - eq(2, #meths.list_wins()) + eq(2, #meths.nvim_list_wins()) end) it('if called from non-floating window with the deleted buffer', function() - meths.buf_delete(old_buf, {force = true}) + meths.nvim_buf_delete(old_buf, {force = true}) eq(old_win, curwin().id) end) it('if called from floating window with the deleted buffer', function() - meths.set_current_win(same_buf_float) - meths.buf_delete(old_buf, {force = true}) + meths.nvim_set_current_win(same_buf_float) + meths.nvim_buf_delete(old_buf, {force = true}) eq(same_buf_float, curwin().id) end) end) @@ -696,28 +696,28 @@ describe('float window', function() describe('without splits, deleting the last listed buffer creates an empty buffer', function() local same_buf_float before_each(function() - meths.set_current_win(old_win) - same_buf_float = meths.open_win(old_buf, false, float_opts).id + meths.nvim_set_current_win(old_win) + same_buf_float = meths.nvim_open_win(old_buf, false, float_opts).id end) after_each(function() expect('') - eq(2, #meths.list_wins()) - eq(2, #meths.list_tabpages()) + eq(2, #meths.nvim_list_wins()) + eq(2, #meths.nvim_list_tabpages()) end) it('if called from non-floating window', function() - meths.buf_delete(old_buf, {force = true}) + meths.nvim_buf_delete(old_buf, {force = true}) eq(old_win, curwin().id) end) it('if called from non-floating window in another tabpage', function() command('tab split') - eq(3, #meths.list_tabpages()) - meths.buf_delete(old_buf, {force = true}) + eq(3, #meths.nvim_list_tabpages()) + meths.nvim_buf_delete(old_buf, {force = true}) end) it('if called from floating window with the same buffer', function() - meths.set_current_win(same_buf_float) + meths.nvim_set_current_win(same_buf_float) command('autocmd WinLeave * let g:win_leave = nvim_get_current_win()') command('autocmd WinEnter * let g:win_enter = nvim_get_current_win()') - meths.buf_delete(old_buf, {force = true}) + meths.nvim_buf_delete(old_buf, {force = true}) eq(same_buf_float, eval('g:win_leave')) eq(old_win, eval('g:win_enter')) eq(old_win, curwin().id) @@ -727,22 +727,22 @@ describe('float window', function() local same_buf_float before_each(function() command('botright vsplit') - meths.set_current_buf(unlisted_buf) - meths.set_current_win(old_win) - same_buf_float = meths.open_win(old_buf, false, float_opts).id + meths.nvim_set_current_buf(unlisted_buf) + meths.nvim_set_current_win(old_win) + same_buf_float = meths.nvim_open_win(old_buf, false, float_opts).id end) after_each(function() expect('') - eq(3, #meths.list_wins()) - eq(2, #meths.list_tabpages()) + eq(3, #meths.nvim_list_wins()) + eq(2, #meths.nvim_list_tabpages()) end) it('if called from non-floating window with the deleted buffer', function() - meths.buf_delete(old_buf, {force = true}) + meths.nvim_buf_delete(old_buf, {force = true}) eq(old_win, curwin().id) end) it('if called from floating window with the deleted buffer', function() - meths.set_current_win(same_buf_float) - meths.buf_delete(old_buf, {force = true}) + meths.nvim_set_current_win(same_buf_float) + meths.nvim_buf_delete(old_buf, {force = true}) eq(same_buf_float, curwin().id) end) end) @@ -762,38 +762,38 @@ describe('float window', function() describe('closes the tabpage when all floating windows are closeable', function() local same_buf_float before_each(function() - same_buf_float = meths.open_win(old_buf, false, float_opts).id + same_buf_float = meths.nvim_open_win(old_buf, false, float_opts).id end) after_each(function() eq(old_tabpage, curtab().id) expect('oldtab') - eq(1, #meths.list_tabpages()) + eq(1, #meths.nvim_list_tabpages()) end) it('if called from non-floating window', function() - meths.win_close(old_win, false) + meths.nvim_win_close(old_win, false) end) it('if called from floating window', function() - meths.set_current_win(same_buf_float) - meths.win_close(old_win, false) + meths.nvim_set_current_win(same_buf_float) + meths.nvim_win_close(old_win, false) end) end) describe('gives E5601 when there are non-closeable floating windows', function() local other_buf_float before_each(function() command('set nohidden') - local other_buf = meths.create_buf(true, false).id - other_buf_float = meths.open_win(other_buf, true, float_opts).id + local other_buf = meths.nvim_create_buf(true, false).id + other_buf_float = meths.nvim_open_win(other_buf, true, float_opts).id insert('foo') - meths.set_current_win(old_win) + meths.nvim_set_current_win(old_win) end) it('if called from non-floating window', function() eq('Vim:E5601: Cannot close window, only floating window would remain', - pcall_err(meths.win_close, old_win, false)) + pcall_err(meths.nvim_win_close, old_win, false)) end) it('if called from floating window', function() - meths.set_current_win(other_buf_float) + meths.nvim_set_current_win(other_buf_float) eq('Vim:E5601: Cannot close window, only floating window would remain', - pcall_err(meths.win_close, old_win, false)) + pcall_err(meths.nvim_win_close, old_win, false)) end) end) end) @@ -801,27 +801,27 @@ describe('float window', function() describe('closes the tabpage when all floating windows are closeable', function() local same_buf_float, other_buf, other_buf_float before_each(function() - same_buf_float = meths.open_win(old_buf, false, float_opts).id - other_buf = meths.create_buf(true, false).id - other_buf_float = meths.open_win(other_buf, true, float_opts).id - meths.set_current_win(old_win) + same_buf_float = meths.nvim_open_win(old_buf, false, float_opts).id + other_buf = meths.nvim_create_buf(true, false).id + other_buf_float = meths.nvim_open_win(other_buf, true, float_opts).id + meths.nvim_set_current_win(old_win) end) after_each(function() eq(old_tabpage, curtab().id) expect('oldtab') - eq(1, #meths.list_tabpages()) + eq(1, #meths.nvim_list_tabpages()) end) it('if called from non-floating window', function() - meths.buf_delete(old_buf, {force = false}) + meths.nvim_buf_delete(old_buf, {force = false}) end) it('if called from floating window with the same buffer', function() - meths.set_current_win(same_buf_float) - meths.buf_delete(old_buf, {force = false}) + meths.nvim_set_current_win(same_buf_float) + meths.nvim_buf_delete(old_buf, {force = false}) end) -- TODO: this case is too hard to deal with pending('if called from floating window with another buffer', function() - meths.set_current_win(other_buf_float) - meths.buf_delete(old_buf, {force = false}) + meths.nvim_set_current_win(other_buf_float) + meths.nvim_buf_delete(old_buf, {force = false}) end) end) -- TODO: what to do when there are non-closeable floating windows? @@ -868,8 +868,8 @@ describe('float window', function() end) it('can be created and reconfigured', function() - local buf = meths.create_buf(false,false) - local win = meths.open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5}) + local buf = meths.nvim_create_buf(false,false) + local win = meths.nvim_open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5}) local expected_pos = { [4]={{id=1001}, 'NW', 1, 2, 5, true}, } @@ -900,7 +900,7 @@ describe('float window', function() end - meths.win_set_config(win, {relative='editor', row=0, col=10}) + meths.nvim_win_set_config(win, {relative='editor', row=0, col=10}) expected_pos[4][4] = 0 expected_pos[4][5] = 10 if multigrid then @@ -926,7 +926,7 @@ describe('float window', function() ]]) end - meths.win_close(win, false) + meths.nvim_win_close(win, false) if multigrid then screen:expect([[ ## grid 1 @@ -949,8 +949,8 @@ describe('float window', function() it('window position fixed', function() command('rightbelow 20vsplit') - local buf = meths.create_buf(false,false) - local win = meths.open_win(buf, false, { + local buf = meths.nvim_create_buf(false,false) + local win = meths.nvim_open_win(buf, false, { relative='win', width=15, height=2, row=2, col=10, anchor='NW', fixed=true}) if multigrid then @@ -985,7 +985,7 @@ describe('float window', function() ]]) end - meths.win_set_config(win, {fixed=false}) + meths.nvim_win_set_config(win, {fixed=false}) if multigrid then screen:expect_unchanged() @@ -1009,8 +1009,8 @@ describe('float window', function() -- or something. command("set redrawdebug=compositor") command("set wd=1") - local buf = meths.create_buf(false,false) - local win = meths.open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5}) + local buf = meths.nvim_create_buf(false,false) + local win = meths.nvim_open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5}) local expected_pos = { [4]={{id=1001}, 'NW', 1, 2, 5, true}, } @@ -1041,7 +1041,7 @@ describe('float window', function() end - meths.win_set_config(win, {relative='editor', row=0, col=10}) + meths.nvim_win_set_config(win, {relative='editor', row=0, col=10}) expected_pos[4][4] = 0 expected_pos[4][5] = 10 if multigrid then @@ -1067,7 +1067,7 @@ describe('float window', function() ]]) end - meths.win_close(win, false) + meths.nvim_win_close(win, false) if multigrid then screen:expect([[ ## grid 1 @@ -1089,16 +1089,16 @@ describe('float window', function() end) it('return their configuration', function() - local buf = meths.create_buf(false, false) - local win = meths.open_win(buf, false, {relative='editor', width=20, height=2, row=3, col=5, zindex=60}) + local buf = meths.nvim_create_buf(false, false) + local win = meths.nvim_open_win(buf, false, {relative='editor', width=20, height=2, row=3, col=5, zindex=60}) local expected = {anchor='NW', col=5, external=false, focusable=true, height=2, relative='editor', row=3, width=20, zindex=60, hide=false} - eq(expected, meths.win_get_config(win)) + eq(expected, meths.nvim_win_get_config(win)) - eq({relative='', external=false, focusable=true, hide=false}, meths.win_get_config(0)) + eq({relative='', external=false, focusable=true, hide=false}, meths.nvim_win_get_config(0)) if multigrid then - meths.win_set_config(win, {external=true, width=10, height=1}) - eq({external=true,focusable=true,width=10,height=1,relative='',hide=false}, meths.win_get_config(win)) + meths.nvim_win_set_config(win, {external=true, width=10, height=1}) + eq({external=true,focusable=true,width=10,height=1,relative='',hide=false}, meths.nvim_win_get_config(win)) end end) @@ -1106,7 +1106,7 @@ describe('float window', function() command('set number') command('hi NormalFloat guibg=#333333 guifg=NONE') feed('ix<cr>y<cr><esc>gg') - local win = meths.open_win(0, false, {relative='editor', width=20, height=4, row=4, col=10}) + local win = meths.nvim_open_win(0, false, {relative='editor', width=20, height=4, row=4, col=10}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -1137,8 +1137,8 @@ describe('float window', function() ]]) end - local buf = meths.create_buf(false, true) - meths.win_set_buf(win, buf) + local buf = meths.nvim_create_buf(false, true) + meths.nvim_win_set_buf(win, buf) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -1174,7 +1174,7 @@ describe('float window', function() command('set foldcolumn=1') command('hi NormalFloat guibg=#333333 guifg=NONE') feed('ix<cr>y<cr><esc>gg') - local win = meths.open_win(0, false, {relative='editor', width=20, height=4, row=4, col=10, style='minimal'}) + local win = meths.nvim_open_win(0, false, {relative='editor', width=20, height=4, row=4, col=10, style='minimal'}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -1238,8 +1238,8 @@ describe('float window', function() end command('sign unplace 1 buffer=1') - local buf = meths.create_buf(false, true) - meths.win_set_buf(win, buf) + local buf = meths.nvim_create_buf(false, true) + meths.nvim_win_set_buf(win, buf) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -1274,7 +1274,7 @@ describe('float window', function() command('set foldcolumn=1') command('hi NormalFloat guibg=#333333 guifg=NONE') feed('ix<cr>y<cr><esc>gg') - local win = meths.open_win(0, false, {relative='editor', width=20, height=4, row=4, col=10, style='minimal'}) + local win = meths.nvim_open_win(0, false, {relative='editor', width=20, height=4, row=4, col=10, style='minimal'}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -1338,8 +1338,8 @@ describe('float window', function() end command('sign unplace 1 buffer=1') - local buf = meths.create_buf(false, true) - meths.win_set_buf(win, buf) + local buf = meths.nvim_create_buf(false, true) + meths.nvim_win_set_buf(win, buf) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -1375,7 +1375,7 @@ describe('float window', function() command('set statuscolumn=%l%s%C') command('hi NormalFloat guibg=#333333 guifg=NONE') feed('ix<cr>y<cr><esc>gg') - meths.open_win(0, false, {relative='editor', width=20, height=4, row=4, col=10, style='minimal'}) + meths.nvim_open_win(0, false, {relative='editor', width=20, height=4, row=4, col=10, style='minimal'}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -1406,10 +1406,10 @@ describe('float window', function() end) it('can have border', function() - local buf = meths.create_buf(false, false) - meths.buf_set_lines(buf, 0, -1, true, {' halloj! ', + local buf = meths.nvim_create_buf(false, false) + meths.nvim_buf_set_lines(buf, 0, -1, true, {' halloj! ', ' BORDAA '}) - local win = meths.open_win(buf, false, {relative='editor', width=9, height=2, row=2, col=5, border="double"}) + local win = meths.nvim_open_win(buf, false, {relative='editor', width=9, height=2, row=2, col=5, border="double"}) if multigrid then screen:expect{grid=[[ @@ -1444,7 +1444,7 @@ describe('float window', function() ]]} end - meths.win_set_config(win, {border="single"}) + meths.nvim_win_set_config(win, {border="single"}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -1478,7 +1478,7 @@ describe('float window', function() ]]} end - meths.win_set_config(win, {border="rounded"}) + meths.nvim_win_set_config(win, {border="rounded"}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -1512,7 +1512,7 @@ describe('float window', function() ]]} end - meths.win_set_config(win, {border="solid"}) + meths.nvim_win_set_config(win, {border="solid"}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -1547,7 +1547,7 @@ describe('float window', function() end -- support: ascii char, UTF-8 char, composed char, highlight per char - meths.win_set_config(win, {border={"x", {"å", "ErrorMsg"}, {"\\"}, {"n̈̊", "Search"}}}) + meths.nvim_win_set_config(win, {border={"x", {"å", "ErrorMsg"}, {"\\"}, {"n̈̊", "Search"}}}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -1581,7 +1581,7 @@ describe('float window', function() ]]} end - meths.win_set_config(win, {border="none"}) + meths.nvim_win_set_config(win, {border="none"}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -1612,7 +1612,7 @@ describe('float window', function() ]]} end - meths.win_set_config(win, {border={"", "", "", ">", "", "", "", "<"}}) + meths.nvim_win_set_config(win, {border={"", "", "", ">", "", "", "", "<"}}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -1643,7 +1643,7 @@ describe('float window', function() ]]} end - meths.win_set_config(win, {border={"", "_", "", "", "", "-", "", ""}}) + meths.nvim_win_set_config(win, {border={"", "_", "", "", "", "-", "", ""}}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -1685,7 +1685,7 @@ describe('float window', function() of border shadow ]] - meths.win_set_config(win, {border="shadow"}) + meths.nvim_win_set_config(win, {border="shadow"}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -1724,13 +1724,13 @@ describe('float window', function() end) it('validates title title_pos', function() - local buf = meths.create_buf(false,false) + local buf = meths.nvim_create_buf(false,false) eq("title requires border to be set", - pcall_err(meths.open_win,buf, false, { + pcall_err(meths.nvim_open_win,buf, false, { relative='editor', width=9, height=2, row=2, col=5, title='Title', })) eq("title_pos requires title to be set", - pcall_err(meths.open_win,buf, false, { + pcall_err(meths.nvim_open_win,buf, false, { relative='editor', width=9, height=2, row=2, col=5, border='single', title_pos='left', })) @@ -1758,13 +1758,13 @@ describe('float window', function() end) it('validates footer footer_pos', function() - local buf = meths.create_buf(false,false) + local buf = meths.nvim_create_buf(false,false) eq("footer requires border to be set", - pcall_err(meths.open_win,buf, false, { + pcall_err(meths.nvim_open_win,buf, false, { relative='editor', width=9, height=2, row=2, col=5, footer='Footer', })) eq("footer_pos requires footer to be set", - pcall_err(meths.open_win,buf, false, { + pcall_err(meths.nvim_open_win,buf, false, { relative='editor', width=9, height=2, row=2, col=5, border='single', footer_pos='left', })) @@ -1792,10 +1792,10 @@ describe('float window', function() end) it('center aligned title longer than window width #25746', function() - local buf = meths.create_buf(false, false) - meths.buf_set_lines(buf, 0, -1, true, {' halloj! ', + local buf = meths.nvim_create_buf(false, false) + meths.nvim_buf_set_lines(buf, 0, -1, true, {' halloj! ', ' BORDAA '}) - local win = meths.open_win(buf, false, { + local win = meths.nvim_open_win(buf, false, { relative='editor', width=9, height=2, row=2, col=5, border="double", title = "abcdefghijklmnopqrstuvwxyz",title_pos = "center", }) @@ -1833,15 +1833,15 @@ describe('float window', function() ]]} end - meths.win_close(win, false) + meths.nvim_win_close(win, false) assert_alive() end) it('border with title', function() - local buf = meths.create_buf(false, false) - meths.buf_set_lines(buf, 0, -1, true, {' halloj! ', + local buf = meths.nvim_create_buf(false, false) + meths.nvim_buf_set_lines(buf, 0, -1, true, {' halloj! ', ' BORDAA '}) - local win = meths.open_win(buf, false, { + local win = meths.nvim_open_win(buf, false, { relative='editor', width=9, height=2, row=2, col=5, border="double", title = "Left",title_pos = "left", }) @@ -1879,7 +1879,7 @@ describe('float window', function() ]]} end - meths.win_set_config(win, {title= "Center",title_pos="center"}) + meths.nvim_win_set_config(win, {title= "Center",title_pos="center"}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -1913,7 +1913,7 @@ describe('float window', function() ]]} end - meths.win_set_config(win, {title= "Right",title_pos="right"}) + meths.nvim_win_set_config(win, {title= "Right",title_pos="right"}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -1947,7 +1947,7 @@ describe('float window', function() ]]} end - meths.win_set_config(win, {title= { {"🦄"},{"BB"}},title_pos="right"}) + meths.nvim_win_set_config(win, {title= { {"🦄"},{"BB"}},title_pos="right"}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -1983,10 +1983,10 @@ describe('float window', function() end) it('border with footer', function() - local buf = meths.create_buf(false, false) - meths.buf_set_lines(buf, 0, -1, true, {' halloj! ', + local buf = meths.nvim_create_buf(false, false) + meths.nvim_buf_set_lines(buf, 0, -1, true, {' halloj! ', ' BORDAA '}) - local win = meths.open_win(buf, false, { + local win = meths.nvim_open_win(buf, false, { relative='editor', width=9, height=2, row=2, col=5, border="double", footer = "Left",footer_pos = "left", }) @@ -2024,7 +2024,7 @@ describe('float window', function() ]]} end - meths.win_set_config(win, {footer= "Center",footer_pos="center"}) + meths.nvim_win_set_config(win, {footer= "Center",footer_pos="center"}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -2058,7 +2058,7 @@ describe('float window', function() ]]} end - meths.win_set_config(win, {footer= "Right",footer_pos="right"}) + meths.nvim_win_set_config(win, {footer= "Right",footer_pos="right"}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -2092,7 +2092,7 @@ describe('float window', function() ]]} end - meths.win_set_config(win, {footer= { {"🦄"},{"BB"}},footer_pos="right"}) + meths.nvim_win_set_config(win, {footer= { {"🦄"},{"BB"}},footer_pos="right"}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -2128,10 +2128,10 @@ describe('float window', function() end) it('border with title and footer', function() - local buf = meths.create_buf(false, false) - meths.buf_set_lines(buf, 0, -1, true, {' halloj! ', + local buf = meths.nvim_create_buf(false, false) + meths.nvim_buf_set_lines(buf, 0, -1, true, {' halloj! ', ' BORDAA '}) - local win = meths.open_win(buf, false, { + local win = meths.nvim_open_win(buf, false, { relative='editor', width=9, height=2, row=2, col=5, border="double", title = "Left", title_pos = "left", footer = "Right", footer_pos = "right", }) @@ -2169,7 +2169,7 @@ describe('float window', function() ]]} end - meths.win_set_config(win, {title= "Center",title_pos="center",footer= "Center",footer_pos="center"}) + meths.nvim_win_set_config(win, {title= "Center",title_pos="center",footer= "Center",footer_pos="center"}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -2203,7 +2203,7 @@ describe('float window', function() ]]} end - meths.win_set_config(win, {title= "Right",title_pos="right",footer= "Left",footer_pos="left"}) + meths.nvim_win_set_config(win, {title= "Right",title_pos="right",footer= "Left",footer_pos="left"}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -2239,7 +2239,7 @@ describe('float window', function() command('hi B0 guibg=Red guifg=Black') command('hi B1 guifg=White') - meths.win_set_config(win, { + meths.nvim_win_set_config(win, { title = {{"🦄"}, {"BB", {"B0", "B1"}}}, title_pos = "right", footer= {{"🦄"}, {"BB", {"B0", "B1"}}}, footer_pos = "right", }) @@ -2278,8 +2278,8 @@ describe('float window', function() end) it('terminates border on edge of viewport when window extends past viewport', function() - local buf = meths.create_buf(false, false) - meths.open_win(buf, false, {relative='editor', width=40, height=7, row=0, col=0, border="single", zindex=201}) + local buf = meths.nvim_create_buf(false, false) + meths.nvim_open_win(buf, false, {relative='editor', width=40, height=7, row=0, col=0, border="single", zindex=201}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -2313,10 +2313,10 @@ describe('float window', function() it('with border show popupmenu', function() screen:try_resize(40,10) - local buf = meths.create_buf(false, false) - meths.buf_set_lines(buf, 0, -1, true, {'aaa aab ', + local buf = meths.nvim_create_buf(false, false) + meths.nvim_buf_set_lines(buf, 0, -1, true, {'aaa aab ', 'abb acc ', ''}) - meths.open_win(buf, true, {relative='editor', width=9, height=3, row=0, col=5, border="double"}) + meths.nvim_open_win(buf, true, {relative='editor', width=9, height=3, row=0, col=5, border="double"}) feed 'G' if multigrid then @@ -2482,10 +2482,10 @@ describe('float window', function() it('show ruler of current floating window', function() command 'set ruler' - local buf = meths.create_buf(false, false) - meths.buf_set_lines(buf, 0, -1, true, {'aaa aab ', + local buf = meths.nvim_create_buf(false, false) + meths.nvim_buf_set_lines(buf, 0, -1, true, {'aaa aab ', 'abb acc '}) - meths.open_win(buf, true, {relative='editor', width=9, height=3, row=0, col=5}) + meths.nvim_open_win(buf, true, {relative='editor', width=9, height=3, row=0, col=5}) feed 'gg' if multigrid then @@ -2552,7 +2552,7 @@ describe('float window', function() it("correct ruler position in current float with 'rulerformat' set", function() command 'set ruler rulerformat=fish:<><' - meths.open_win(0, true, {relative='editor', width=9, height=3, row=0, col=5}) + meths.nvim_open_win(0, true, {relative='editor', width=9, height=3, row=0, col=5}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -2585,10 +2585,10 @@ describe('float window', function() it('does not show ruler of not-last current float during ins-completion', function() screen:try_resize(50,9) command 'set ruler showmode' - meths.open_win(0, false, {relative='editor', width=3, height=3, row=0, col=0}) - meths.open_win(0, false, {relative='editor', width=3, height=3, row=0, col=5}) + meths.nvim_open_win(0, false, {relative='editor', width=3, height=3, row=0, col=0}) + meths.nvim_open_win(0, false, {relative='editor', width=3, height=3, row=0, col=5}) feed '<c-w>w' - neq('', meths.win_get_config(0).relative) + neq('', meths.nvim_win_get_config(0).relative) neq(funcs.winnr '$', funcs.winnr()) if multigrid then screen:expect{grid=[[ @@ -2659,9 +2659,9 @@ describe('float window', function() it('can have minimum size', function() insert("the background text") - local buf = meths.create_buf(false, true) - meths.buf_set_lines(buf, 0, -1, true, {'x'}) - local win = meths.open_win(buf, false, {relative='win', width=1, height=1, row=0, col=4, focusable=false}) + local buf = meths.nvim_create_buf(false, true) + meths.nvim_buf_set_lines(buf, 0, -1, true, {'x'}) + local win = meths.nvim_open_win(buf, false, {relative='win', width=1, height=1, row=0, col=4, focusable=false}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -2685,7 +2685,7 @@ describe('float window', function() ]]) end - meths.win_set_config(win, {relative='win', row=0, col=15}) + meths.nvim_win_set_config(win, {relative='win', row=0, col=15}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -2709,7 +2709,7 @@ describe('float window', function() ]]) end - meths.win_close(win,false) + meths.nvim_win_close(win,false) if multigrid then screen:expect([[ ## grid 1 @@ -2745,8 +2745,8 @@ describe('float window', function() command('sargument 6') local float_opts = { relative = 'editor', row = 6, col = 0, width = 40, height = 1 } - meths.win_set_config(w3, float_opts) - meths.win_set_config(w4, float_opts) + meths.nvim_win_set_config(w3, float_opts) + meths.nvim_win_set_config(w4, float_opts) command('wincmd =') if multigrid then screen:expect{grid=[[ @@ -2875,36 +2875,36 @@ describe('float window', function() end) it('API has proper error messages', function() - local buf = meths.create_buf(false,false) + local buf = meths.nvim_create_buf(false,false) eq("Invalid key: 'bork'", - pcall_err(meths.open_win,buf, false, {width=20,height=2,bork=true})) + pcall_err(meths.nvim_open_win,buf, false, {width=20,height=2,bork=true})) eq("'win' key is only valid with relative='win'", - pcall_err(meths.open_win,buf, false, {width=20,height=2,relative='editor',row=0,col=0,win=0})) + pcall_err(meths.nvim_open_win,buf, false, {width=20,height=2,relative='editor',row=0,col=0,win=0})) eq("Only one of 'relative' and 'external' must be used", - pcall_err(meths.open_win,buf, false, {width=20,height=2,relative='editor',row=0,col=0,external=true})) + pcall_err(meths.nvim_open_win,buf, false, {width=20,height=2,relative='editor',row=0,col=0,external=true})) eq("Invalid value of 'relative' key", - pcall_err(meths.open_win,buf, false, {width=20,height=2,relative='shell',row=0,col=0})) + pcall_err(meths.nvim_open_win,buf, false, {width=20,height=2,relative='shell',row=0,col=0})) eq("Invalid value of 'anchor' key", - pcall_err(meths.open_win,buf, false, {width=20,height=2,relative='editor',row=0,col=0,anchor='bottom'})) + pcall_err(meths.nvim_open_win,buf, false, {width=20,height=2,relative='editor',row=0,col=0,anchor='bottom'})) eq("'relative' requires 'row'/'col' or 'bufpos'", - pcall_err(meths.open_win,buf, false, {width=20,height=2,relative='editor'})) + pcall_err(meths.nvim_open_win,buf, false, {width=20,height=2,relative='editor'})) eq("'width' key must be a positive Integer", - pcall_err(meths.open_win,buf, false, {width=-1,height=2,relative='editor', row=0, col=0})) + pcall_err(meths.nvim_open_win,buf, false, {width=-1,height=2,relative='editor', row=0, col=0})) eq("'height' key must be a positive Integer", - pcall_err(meths.open_win,buf, false, {width=20,height=-1,relative='editor', row=0, col=0})) + pcall_err(meths.nvim_open_win,buf, false, {width=20,height=-1,relative='editor', row=0, col=0})) eq("'height' key must be a positive Integer", - pcall_err(meths.open_win,buf, false, {width=20,height=0,relative='editor', row=0, col=0})) + pcall_err(meths.nvim_open_win,buf, false, {width=20,height=0,relative='editor', row=0, col=0})) eq("Must specify 'width'", - pcall_err(meths.open_win,buf, false, {relative='editor', row=0, col=0})) + pcall_err(meths.nvim_open_win,buf, false, {relative='editor', row=0, col=0})) eq("Must specify 'height'", - pcall_err(meths.open_win,buf, false, {relative='editor', row=0, col=0, width=2})) + pcall_err(meths.nvim_open_win,buf, false, {relative='editor', row=0, col=0, width=2})) end) it('can be placed relative window or cursor', function() screen:try_resize(40,9) - meths.buf_set_lines(0, 0, -1, true, {'just some', 'example text'}) + meths.nvim_buf_set_lines(0, 0, -1, true, {'just some', 'example text'}) feed('gge') - local oldwin = meths.get_current_win() + local oldwin = meths.nvim_get_current_win() command('below split') if multigrid then screen:expect([[ @@ -2939,9 +2939,9 @@ describe('float window', function() ]]) end - local buf = meths.create_buf(false,false) + local buf = meths.nvim_create_buf(false,false) -- no 'win' arg, relative default window - local win = meths.open_win(buf, false, {relative='win', width=20, height=2, row=0, col=10}) + local win = meths.nvim_open_win(buf, false, {relative='win', width=20, height=2, row=0, col=10}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -2980,7 +2980,7 @@ describe('float window', function() ]]) end - meths.win_set_config(win, {relative='cursor', row=1, col=-2}) + meths.nvim_win_set_config(win, {relative='cursor', row=1, col=-2}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -3019,7 +3019,7 @@ describe('float window', function() ]]) end - meths.win_set_config(win, {relative='cursor', row=0, col=0, anchor='SW'}) + meths.nvim_win_set_config(win, {relative='cursor', row=0, col=0, anchor='SW'}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -3058,7 +3058,7 @@ describe('float window', function() ]]) end - meths.win_set_config(win, {relative='win', win=oldwin, row=1, col=10, anchor='NW'}) + meths.nvim_win_set_config(win, {relative='win', win=oldwin, row=1, col=10, anchor='NW'}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -3097,7 +3097,7 @@ describe('float window', function() ]]) end - meths.win_set_config(win, {relative='win', win=oldwin, row=3, col=39, anchor='SE'}) + meths.nvim_win_set_config(win, {relative='win', win=oldwin, row=3, col=39, anchor='SE'}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -3136,7 +3136,7 @@ describe('float window', function() ]]) end - meths.win_set_config(win, {relative='win', win=0, row=0, col=50, anchor='NE'}) + meths.nvim_win_set_config(win, {relative='win', win=0, row=0, col=50, anchor='NE'}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -3206,7 +3206,7 @@ describe('float window', function() it('always anchor to corner including border', function() screen:try_resize(40,13) - meths.buf_set_lines(0, 0, -1, true, {'just some example text', 'some more example text'}) + meths.nvim_buf_set_lines(0, 0, -1, true, {'just some example text', 'some more example text'}) feed('ggeee') command('below split') if multigrid then @@ -3242,10 +3242,10 @@ describe('float window', function() ]]) end - local buf = meths.create_buf(false, false) - meths.buf_set_lines(buf, 0, -1, true, {' halloj! ', + local buf = meths.nvim_create_buf(false, false) + meths.nvim_buf_set_lines(buf, 0, -1, true, {' halloj! ', ' BORDAA '}) - local win = meths.open_win(buf, false, {relative='cursor', width=9, height=2, row=1, col=-2, border="double"}) + local win = meths.nvim_open_win(buf, false, {relative='cursor', width=9, height=2, row=1, col=-2, border="double"}) if multigrid then screen:expect{grid=[[ @@ -3289,7 +3289,7 @@ describe('float window', function() ]]) end - meths.win_set_config(win, {relative='cursor', row=0, col=-2, anchor='NE'}) + meths.nvim_win_set_config(win, {relative='cursor', row=0, col=-2, anchor='NE'}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -3332,7 +3332,7 @@ describe('float window', function() ]]) end - meths.win_set_config(win, {relative='cursor', row=1, col=-2, anchor='SE'}) + meths.nvim_win_set_config(win, {relative='cursor', row=1, col=-2, anchor='SE'}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -3375,7 +3375,7 @@ describe('float window', function() ]]) end - meths.win_set_config(win, {relative='cursor', row=0, col=-2, anchor='SW'}) + meths.nvim_win_set_config(win, {relative='cursor', row=0, col=-2, anchor='SW'}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -3595,8 +3595,8 @@ describe('float window', function() it('can be placed relative text in a window', function() screen:try_resize(30,5) - local firstwin = meths.get_current_win().id - meths.buf_set_lines(0, 0, -1, true, {'just some', 'example text that is wider than the window', '', '', 'more text'}) + local firstwin = meths.nvim_get_current_win().id + meths.nvim_buf_set_lines(0, 0, -1, true, {'just some', 'example text that is wider than the window', '', '', 'more text'}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -3619,10 +3619,10 @@ describe('float window', function() ]]} end - local buf = meths.create_buf(false,false) - meths.buf_set_lines(buf, 0, -1, true, {'some info!'}) + local buf = meths.nvim_create_buf(false,false) + meths.nvim_buf_set_lines(buf, 0, -1, true, {'some info!'}) - local win = meths.open_win(buf, false, {relative='win', width=12, height=1, bufpos={1,32}}) + local win = meths.nvim_open_win(buf, false, {relative='win', width=12, height=1, bufpos={1,32}}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -3650,7 +3650,7 @@ describe('float window', function() ]]} end eq({relative='win', width=12, height=1, bufpos={1,32}, anchor='NW', hide=false, - external=false, col=0, row=1, win=firstwin, focusable=true, zindex=50}, meths.win_get_config(win)) + external=false, col=0, row=1, win=firstwin, focusable=true, zindex=50}, meths.nvim_win_get_config(win)) feed('<c-e>') if multigrid then @@ -3738,7 +3738,7 @@ describe('float window', function() ]]} end - meths.win_set_config(win, {relative='win', bufpos={1,32}, anchor='SW'}) + meths.nvim_win_set_config(win, {relative='win', bufpos={1,32}, anchor='SW'}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -3811,7 +3811,7 @@ describe('float window', function() end command('close') - meths.win_set_config(win, {relative='win', bufpos={1,32}, anchor='NW', col=-2}) + meths.nvim_win_set_config(win, {relative='win', bufpos={1,32}, anchor='NW', col=-2}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -3842,7 +3842,7 @@ describe('float window', function() ]]} end - meths.win_set_config(win, {relative='win', bufpos={1,32}, row=2}) + meths.nvim_win_set_config(win, {relative='win', bufpos={1,32}, row=2}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -3923,9 +3923,9 @@ describe('float window', function() ]]) end - local buf = meths.create_buf(false,true) - meths.buf_set_lines(buf, 0, -1, true, {'some floaty text'}) - meths.open_win(buf, false, {relative='editor', width=20, height=1, row=3, col=1}) + local buf = meths.nvim_create_buf(false,true) + meths.nvim_buf_set_lines(buf, 0, -1, true, {'some floaty text'}) + meths.nvim_open_win(buf, false, {relative='editor', width=20, height=1, row=3, col=1}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -3958,8 +3958,8 @@ describe('float window', function() local screen2 = Screen.new(40,7) screen2:attach(nil, session2) screen2:set_default_attr_ids(attrs) - local buf = meths.create_buf(false,false) - meths.open_win(buf, true, {relative='editor', width=20, height=2, row=2, col=5}) + local buf = meths.nvim_create_buf(false,false) + meths.nvim_open_win(buf, true, {relative='editor', width=20, height=2, row=2, col=5}) local expected_pos = { [2]={{id=1001}, 'NW', 1, 2, 5} } @@ -3985,9 +3985,9 @@ describe('float window', function() it('handles resized screen', function() - local buf = meths.create_buf(false,false) - meths.buf_set_lines(buf, 0, -1, true, {'such', 'very', 'float'}) - local win = meths.open_win(buf, false, {relative='editor', width=15, height=4, row=2, col=10}) + local buf = meths.nvim_create_buf(false,false) + meths.nvim_buf_set_lines(buf, 0, -1, true, {'such', 'very', 'float'}) + local win = meths.nvim_open_win(buf, false, {relative='editor', width=15, height=4, row=2, col=10}) local expected_pos = { [4]={{id=1001}, 'NW', 1, 2, 10, true}, } @@ -4150,7 +4150,7 @@ describe('float window', function() ]]) end - meths.win_set_config(win, {height=3}) + meths.nvim_win_set_config(win, {height=3}) feed('gg') if multigrid then screen:expect{grid=[[ @@ -4435,8 +4435,8 @@ describe('float window', function() command("set inccommand=split") command("set laststatus=2") - local buf = meths.create_buf(false,false) - meths.open_win(buf, true, {relative='editor', width=30, height=3, row=2, col=0}) + local buf = meths.nvim_create_buf(false,false) + meths.nvim_open_win(buf, true, {relative='editor', width=30, height=3, row=2, col=0}) insert([[ foo @@ -4532,17 +4532,17 @@ describe('float window', function() end) it('does not crash when set cmdheight #9680', function() - local buf = meths.create_buf(false,false) - meths.open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5}) + local buf = meths.nvim_create_buf(false,false) + meths.nvim_open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5}) command("set cmdheight=2") - eq(1, meths.eval('1')) + eq(1, meths.nvim_eval('1')) end) describe('and completion', function() before_each(function() - local buf = meths.create_buf(false,false) - local win = meths.open_win(buf, true, {relative='editor', width=12, height=4, row=2, col=5}).id - meths.set_option_value('winhl', 'Normal:ErrorMsg', {win=win}) + local buf = meths.nvim_create_buf(false,false) + local win = meths.nvim_open_win(buf, true, {relative='editor', width=12, height=4, row=2, col=5}).id + meths.nvim_set_option_value('winhl', 'Normal:ErrorMsg', {win=win}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -4890,9 +4890,9 @@ describe('float window', function() ]]) end - local buf = meths.create_buf(false,true) - meths.buf_set_lines(buf,0,-1,true,{"some info", "about item"}) - win = meths.open_win(buf, false, {relative='cursor', width=12, height=2, row=1, col=10}) + local buf = meths.nvim_create_buf(false,true) + meths.nvim_buf_set_lines(buf,0,-1,true,{"some info", "about item"}) + win = meths.nvim_open_win(buf, false, {relative='cursor', width=12, height=2, row=1, col=10}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -4954,7 +4954,7 @@ describe('float window', function() ]]) end - meths.win_close(win, false) + meths.nvim_win_close(win, false) if multigrid then screen:expect([[ ## grid 1 @@ -4976,7 +4976,7 @@ describe('float window', function() end) it('and close float first', function() - meths.win_close(win, false) + meths.nvim_win_close(win, false) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -5028,10 +5028,10 @@ describe('float window', function() end) it("can use Normal as background", function() - local buf = meths.create_buf(false,false) - meths.buf_set_lines(buf,0,-1,true,{"here", "float"}) - local win = meths.open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5}) - meths.set_option_value('winhl', 'Normal:Normal', {win=win}) + local buf = meths.nvim_create_buf(false,false) + meths.nvim_buf_set_lines(buf,0,-1,true,{"here", "float"}) + local win = meths.nvim_open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5}) + meths.nvim_set_option_value('winhl', 'Normal:Normal', {win=win}) if multigrid then screen:expect{grid=[[ @@ -5071,10 +5071,10 @@ describe('float window', function() -- the default, but be explicit: command("set laststatus=1") command("set hidden") - meths.buf_set_lines(0,0,-1,true,{"x"}) - local buf = meths.create_buf(false,false) - win = meths.open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5}) - meths.buf_set_lines(buf,0,-1,true,{"y"}) + meths.nvim_buf_set_lines(0,0,-1,true,{"x"}) + local buf = meths.nvim_create_buf(false,false) + win = meths.nvim_open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5}) + meths.nvim_buf_set_lines(buf,0,-1,true,{"y"}) expected_pos = { [4]={{id=1001}, 'NW', 1, 2, 5, true} } @@ -5159,7 +5159,7 @@ describe('float window', function() end) it("w with focusable=false", function() - meths.win_set_config(win, {focusable=false}) + meths.nvim_win_set_config(win, {focusable=false}) expected_pos[4][6] = false feed("<c-w>wi") -- i to provoke redraw if multigrid then @@ -5270,7 +5270,7 @@ describe('float window', function() it("focus by mouse", function() if multigrid then - meths.input_mouse('left', 'press', '', 4, 0, 0) + meths.nvim_input_mouse('left', 'press', '', 4, 0, 0) screen:expect{grid=[[ ## grid 1 [2:----------------------------------------]|*6 @@ -5285,7 +5285,7 @@ describe('float window', function() {2:~ }| ]], float_pos=expected_pos} else - meths.input_mouse('left', 'press', '', 0, 2, 5) + meths.nvim_input_mouse('left', 'press', '', 0, 2, 5) screen:expect([[ x | {0:~ }| @@ -5297,7 +5297,7 @@ describe('float window', function() end if multigrid then - meths.input_mouse('left', 'press', '', 2, 0, 0) + meths.nvim_input_mouse('left', 'press', '', 2, 0, 0) screen:expect{grid=[[ ## grid 1 [2:----------------------------------------]|*6 @@ -5312,7 +5312,7 @@ describe('float window', function() {2:~ }| ]], float_pos=expected_pos} else - meths.input_mouse('left', 'press', '', 0, 0, 0) + meths.nvim_input_mouse('left', 'press', '', 0, 0, 0) screen:expect([[ ^x | {0:~ }| @@ -5325,11 +5325,11 @@ describe('float window', function() end) it("focus by mouse (focusable=false)", function() - meths.win_set_config(win, {focusable=false}) - meths.buf_set_lines(0, -1, -1, true, {"a"}) + meths.nvim_win_set_config(win, {focusable=false}) + meths.nvim_buf_set_lines(0, -1, -1, true, {"a"}) expected_pos[4][6] = false if multigrid then - meths.input_mouse('left', 'press', '', 4, 0, 0) + meths.nvim_input_mouse('left', 'press', '', 4, 0, 0) screen:expect{grid=[[ ## grid 1 [2:----------------------------------------]|*6 @@ -5345,7 +5345,7 @@ describe('float window', function() {2:~ }| ]], float_pos=expected_pos} else - meths.input_mouse('left', 'press', '', 0, 2, 5) + meths.nvim_input_mouse('left', 'press', '', 0, 2, 5) screen:expect([[ x | ^a | @@ -5357,7 +5357,7 @@ describe('float window', function() end if multigrid then - meths.input_mouse('left', 'press', '', 2, 0, 0) + meths.nvim_input_mouse('left', 'press', '', 2, 0, 0) screen:expect{grid=[[ ## grid 1 [2:----------------------------------------]|*6 @@ -5373,7 +5373,7 @@ describe('float window', function() {2:~ }| ]], float_pos=expected_pos, unchanged=true} else - meths.input_mouse('left', 'press', '', 0, 0, 0) + meths.nvim_input_mouse('left', 'press', '', 0, 0, 0) screen:expect([[ ^x | a | @@ -6155,7 +6155,7 @@ describe('float window', function() -- enter first float feed('<c-w><c-w>') -- enter second float - meths.open_win(0, true, {relative='editor', width=20, height=2, row=4, col=8}) + meths.nvim_open_win(0, true, {relative='editor', width=20, height=2, row=4, col=8}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -6475,7 +6475,7 @@ describe('float window', function() end if multigrid then - meths.win_set_config(0, {external=true, width=30, height=2}) + meths.nvim_win_set_config(0, {external=true, width=30, height=2}) expected_pos = {[4]={external=true}} screen:expect{grid=[[ ## grid 1 @@ -6493,7 +6493,7 @@ describe('float window', function() ]], float_pos=expected_pos} else eq("UI doesn't support external windows", - pcall_err(meths.win_set_config, 0, {external=true, width=30, height=2})) + pcall_err(meths.nvim_win_set_config, 0, {external=true, width=30, height=2})) return end @@ -6519,7 +6519,7 @@ describe('float window', function() end) it('J (float with border)', function() - meths.win_set_config(win, {relative='editor', width=20, height=2, row=2, col=5, border='single'}) + meths.nvim_win_set_config(win, {relative='editor', width=20, height=2, row=2, col=5, border='single'}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -6791,7 +6791,7 @@ describe('float window', function() it(":tabnew and :tabnext (external)", function() if multigrid then -- also test external window wider than main screen - meths.win_set_config(win, {external=true, width=65, height=4}) + meths.nvim_win_set_config(win, {external=true, width=65, height=4}) expected_pos = {[4]={external=true}} feed(":tabnew<cr>") screen:expect{grid=[[ @@ -6813,7 +6813,7 @@ describe('float window', function() ]], float_pos=expected_pos} else eq("UI doesn't support external windows", - pcall_err(meths.win_set_config, 0, {external=true, width=65, height=4})) + pcall_err(meths.nvim_win_set_config, 0, {external=true, width=65, height=4})) end feed(":tabnext<cr>") @@ -6861,9 +6861,9 @@ describe('float window', function() end) it("left drag changes visual selection in float window", function() - local buf = meths.create_buf(false,false) - meths.buf_set_lines(buf, 0, -1, true, {'foo', 'bar', 'baz'}) - meths.open_win(buf, false, {relative='editor', width=20, height=3, row=2, col=5}) + local buf = meths.nvim_create_buf(false,false) + meths.nvim_buf_set_lines(buf, 0, -1, true, {'foo', 'bar', 'baz'}) + meths.nvim_open_win(buf, false, {relative='editor', width=20, height=3, row=2, col=5}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -6885,7 +6885,7 @@ describe('float window', function() [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3, sum_scroll_delta = 0}; }} - meths.input_mouse('left', 'press', '', 4, 0, 0) + meths.nvim_input_mouse('left', 'press', '', 4, 0, 0) screen:expect{grid=[[ ## grid 1 [2:----------------------------------------]|*6 @@ -6906,7 +6906,7 @@ describe('float window', function() [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3, sum_scroll_delta = 0}; }} - meths.input_mouse('left', 'drag', '', 4, 1, 2) + meths.nvim_input_mouse('left', 'drag', '', 4, 1, 2) screen:expect{grid=[[ ## grid 1 [2:----------------------------------------]|*6 @@ -6937,7 +6937,7 @@ describe('float window', function() | ]]} - meths.input_mouse('left', 'press', '', 0, 2, 5) + meths.nvim_input_mouse('left', 'press', '', 0, 2, 5) screen:expect{grid=[[ | {0:~ }| @@ -6948,7 +6948,7 @@ describe('float window', function() | ]]} - meths.input_mouse('left', 'drag', '', 0, 3, 7) + meths.nvim_input_mouse('left', 'drag', '', 0, 3, 7) screen:expect{grid=[[ | {0:~ }| @@ -6962,9 +6962,9 @@ describe('float window', function() end) it("left drag changes visual selection in float window with border", function() - local buf = meths.create_buf(false,false) - meths.buf_set_lines(buf, 0, -1, true, {'foo', 'bar', 'baz'}) - meths.open_win(buf, false, {relative='editor', width=20, height=3, row=0, col=5, border='single'}) + local buf = meths.nvim_create_buf(false,false) + meths.nvim_buf_set_lines(buf, 0, -1, true, {'foo', 'bar', 'baz'}) + meths.nvim_open_win(buf, false, {relative='editor', width=20, height=3, row=0, col=5, border='single'}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -6988,7 +6988,7 @@ describe('float window', function() [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3, sum_scroll_delta = 0}; }} - meths.input_mouse('left', 'press', '', 4, 1, 1) + meths.nvim_input_mouse('left', 'press', '', 4, 1, 1) screen:expect{grid=[[ ## grid 1 [2:----------------------------------------]|*6 @@ -7011,7 +7011,7 @@ describe('float window', function() [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3, sum_scroll_delta = 0}; }} - meths.input_mouse('left', 'drag', '', 4, 2, 3) + meths.nvim_input_mouse('left', 'drag', '', 4, 2, 3) screen:expect{grid=[[ ## grid 1 [2:----------------------------------------]|*6 @@ -7044,7 +7044,7 @@ describe('float window', function() | ]]} - meths.input_mouse('left', 'press', '', 0, 1, 6) + meths.nvim_input_mouse('left', 'press', '', 0, 1, 6) screen:expect{grid=[[ {5:┌────────────────────┐} | {0:~ }{5:│}{1:^foo }{5:│}{0: }| @@ -7055,7 +7055,7 @@ describe('float window', function() | ]]} - meths.input_mouse('left', 'drag', '', 0, 2, 8) + meths.nvim_input_mouse('left', 'drag', '', 0, 2, 8) screen:expect{grid=[[ {5:┌────────────────────┐} | {0:~ }{5:│}{27:foo}{1: }{5:│}{0: }| @@ -7069,10 +7069,10 @@ describe('float window', function() end) it("left drag changes visual selection in float window with winbar", function() - local buf = meths.create_buf(false,false) - meths.buf_set_lines(buf, 0, -1, true, {'foo', 'bar', 'baz'}) - local float_win = meths.open_win(buf, false, {relative='editor', width=20, height=4, row=1, col=5}) - meths.set_option_value('winbar', 'floaty bar', {win=float_win.id}) + local buf = meths.nvim_create_buf(false,false) + meths.nvim_buf_set_lines(buf, 0, -1, true, {'foo', 'bar', 'baz'}) + local float_win = meths.nvim_open_win(buf, false, {relative='editor', width=20, height=4, row=1, col=5}) + meths.nvim_set_option_value('winbar', 'floaty bar', {win=float_win.id}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -7095,7 +7095,7 @@ describe('float window', function() [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3, sum_scroll_delta = 0}; }} - meths.input_mouse('left', 'press', '', 4, 1, 0) + meths.nvim_input_mouse('left', 'press', '', 4, 1, 0) screen:expect{grid=[[ ## grid 1 [2:----------------------------------------]|*6 @@ -7117,7 +7117,7 @@ describe('float window', function() [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3, sum_scroll_delta = 0}; }} - meths.input_mouse('left', 'drag', '', 4, 2, 2) + meths.nvim_input_mouse('left', 'drag', '', 4, 2, 2) screen:expect{grid=[[ ## grid 1 [2:----------------------------------------]|*6 @@ -7149,7 +7149,7 @@ describe('float window', function() | ]]} - meths.input_mouse('left', 'press', '', 0, 2, 5) + meths.nvim_input_mouse('left', 'press', '', 0, 2, 5) screen:expect{grid=[[ | {0:~ }{3:floaty bar }{0: }| @@ -7160,7 +7160,7 @@ describe('float window', function() | ]]} - meths.input_mouse('left', 'drag', '', 0, 3, 7) + meths.nvim_input_mouse('left', 'drag', '', 0, 3, 7) screen:expect{grid=[[ | {0:~ }{3:floaty bar }{0: }| @@ -7174,9 +7174,9 @@ describe('float window', function() end) it('left drag changes visual selection if float window is turned into a split', function() - local buf = meths.create_buf(false,false) - meths.buf_set_lines(buf, 0, -1, true, {'foo', 'bar', 'baz'}) - meths.open_win(buf, true, {relative='editor', width=20, height=3, row=2, col=5}) + local buf = meths.nvim_create_buf(false,false) + meths.nvim_buf_set_lines(buf, 0, -1, true, {'foo', 'bar', 'baz'}) + meths.nvim_open_win(buf, true, {relative='editor', width=20, height=3, row=2, col=5}) command('wincmd L') if multigrid then screen:expect([[ @@ -7196,7 +7196,7 @@ describe('float window', function() {0:~ }|*2 ]]) - meths.input_mouse('left', 'press', '', 4, 2, 2) + meths.nvim_input_mouse('left', 'press', '', 4, 2, 2) screen:expect([[ ## grid 1 [2:-------------------]{5:│}[4:--------------------]|*5 @@ -7214,7 +7214,7 @@ describe('float window', function() {0:~ }|*2 ]]) - meths.input_mouse('left', 'drag', '', 4, 1, 1) + meths.nvim_input_mouse('left', 'drag', '', 4, 1, 1) screen:expect([[ ## grid 1 [2:-------------------]{5:│}[4:--------------------]|*5 @@ -7241,7 +7241,7 @@ describe('float window', function() | ]]) - meths.input_mouse('left', 'press', '', 0, 2, 22) + meths.nvim_input_mouse('left', 'press', '', 0, 2, 22) screen:expect([[ {5:│}foo | {0:~ }{5:│}bar | @@ -7251,7 +7251,7 @@ describe('float window', function() | ]]) - meths.input_mouse('left', 'drag', '', 0, 1, 21) + meths.nvim_input_mouse('left', 'drag', '', 0, 1, 21) screen:expect([[ {5:│}foo | {0:~ }{5:│}b^a{27:r} | @@ -7264,9 +7264,9 @@ describe('float window', function() end) it('left click sets correct curswant in float window with border', function() - local buf = meths.create_buf(false,false) - meths.buf_set_lines(buf, 0, -1, true, {'', '', ''}) - meths.open_win(buf, false, {relative='editor', width=20, height=3, row=0, col=5, border='single'}) + local buf = meths.nvim_create_buf(false,false) + meths.nvim_buf_set_lines(buf, 0, -1, true, {'', '', ''}) + meths.nvim_open_win(buf, false, {relative='editor', width=20, height=3, row=0, col=5, border='single'}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -7298,23 +7298,23 @@ describe('float window', function() end if multigrid then - meths.input_mouse('left', 'press', '', 4, 3, 1) + meths.nvim_input_mouse('left', 'press', '', 4, 3, 1) else - meths.input_mouse('left', 'press', '', 0, 3, 6) + meths.nvim_input_mouse('left', 'press', '', 0, 3, 6) end eq({0, 3, 1, 0, 1}, funcs.getcurpos()) if multigrid then - meths.input_mouse('left', 'press', '', 4, 3, 2) + meths.nvim_input_mouse('left', 'press', '', 4, 3, 2) else - meths.input_mouse('left', 'press', '', 0, 3, 7) + meths.nvim_input_mouse('left', 'press', '', 0, 3, 7) end eq({0, 3, 1, 0, 2}, funcs.getcurpos()) if multigrid then - meths.input_mouse('left', 'press', '', 4, 3, 10) + meths.nvim_input_mouse('left', 'press', '', 4, 3, 10) else - meths.input_mouse('left', 'press', '', 0, 3, 15) + meths.nvim_input_mouse('left', 'press', '', 0, 3, 15) end eq({0, 3, 1, 0, 10}, funcs.getcurpos()) @@ -7355,7 +7355,7 @@ describe('float window', function() end if multigrid then - meths.input_mouse('left', 'press', '', 4, 2, 1) + meths.nvim_input_mouse('left', 'press', '', 4, 2, 1) screen:expect{grid=[[ ## grid 1 [2:----------------------------------------]|*6 @@ -7378,7 +7378,7 @@ describe('float window', function() [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3, sum_scroll_delta = 0}; }} else - meths.input_mouse('left', 'press', '', 0, 2, 6) + meths.nvim_input_mouse('left', 'press', '', 0, 2, 6) screen:expect{grid=[[ {5:┌────────────────────┐} | {0:~ }{5:│}{19: }{1:^ }{5:│}{0: }| @@ -7391,23 +7391,23 @@ describe('float window', function() end if multigrid then - meths.input_mouse('left', 'press', '', 4, 2, 2) + meths.nvim_input_mouse('left', 'press', '', 4, 2, 2) else - meths.input_mouse('left', 'press', '', 0, 2, 7) + meths.nvim_input_mouse('left', 'press', '', 0, 2, 7) end eq({0, 2, 1, 0, 1}, funcs.getcurpos()) if multigrid then - meths.input_mouse('left', 'press', '', 4, 2, 3) + meths.nvim_input_mouse('left', 'press', '', 4, 2, 3) else - meths.input_mouse('left', 'press', '', 0, 2, 8) + meths.nvim_input_mouse('left', 'press', '', 0, 2, 8) end eq({0, 2, 1, 0, 2}, funcs.getcurpos()) if multigrid then - meths.input_mouse('left', 'press', '', 4, 2, 11) + meths.nvim_input_mouse('left', 'press', '', 4, 2, 11) else - meths.input_mouse('left', 'press', '', 0, 2, 16) + meths.nvim_input_mouse('left', 'press', '', 0, 2, 16) end eq({0, 2, 1, 0, 10}, funcs.getcurpos()) end) @@ -7453,9 +7453,9 @@ describe('float window', function() occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.]]) - local buf = meths.create_buf(false,false) - meths.buf_set_lines(buf, 0, -1, true, {"test", "", "popup text"}) - local win = meths.open_win(buf, false, {relative='editor', width=15, height=3, row=2, col=5}) + local buf = meths.nvim_create_buf(false,false) + meths.nvim_buf_set_lines(buf, 0, -1, true, {"test", "", "popup text"}) + local win = meths.nvim_open_win(buf, false, {relative='editor', width=15, height=3, row=2, col=5}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -7491,7 +7491,7 @@ describe('float window', function() ]]) end - meths.set_option_value("winblend", 30, {win=win.id}) + meths.nvim_set_option_value("winblend", 30, {win=win.id}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -7528,7 +7528,7 @@ describe('float window', function() end -- Check that 'winblend' works with NormalNC highlight - meths.set_option_value('winhighlight', 'NormalNC:Visual', {win = win}) + meths.nvim_set_option_value('winhighlight', 'NormalNC:Visual', {win = win}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -7573,7 +7573,7 @@ describe('float window', function() command('hi clear NormalNC') command('hi SpecialRegion guifg=Red blend=0') - meths.buf_add_highlight(buf, -1, "SpecialRegion", 2, 0, -1) + meths.nvim_buf_add_highlight(buf, -1, "SpecialRegion", 2, 0, -1) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -7647,7 +7647,7 @@ describe('float window', function() -- Test scrolling by mouse if multigrid then - meths.input_mouse('wheel', 'down', '', 4, 2, 2) + meths.nvim_input_mouse('wheel', 'down', '', 4, 2, 2) screen:expect{grid=[[ ## grid 1 [2:--------------------------------------------------]|*8 @@ -7668,7 +7668,7 @@ describe('float window', function() {12:~ }|*2 ]], float_pos={[4] = {{id = 1001}, "NW", 1, 2, 5, true}}} else - meths.input_mouse('wheel', 'down', '', 0, 4, 7) + meths.nvim_input_mouse('wheel', 'down', '', 0, 4, 7) screen:expect([[ Ut enim ad minim veniam, quis nostrud | exercitation ullamco laboris nisi ut aliquip ex | @@ -7683,9 +7683,9 @@ describe('float window', function() end -- Check that 'winblend' applies to border/title/footer - meths.win_set_config(win, {border='single', title='Title', footer='Footer'}) - meths.set_option_value('winblend', 100, {win=win.id}) - meths.set_option_value("cursorline", true, {win=0}) + meths.nvim_win_set_config(win, {border='single', title='Title', footer='Footer'}) + meths.nvim_set_option_value('winblend', 100, {win=win.id}) + meths.nvim_set_option_value("cursorline", true, {win=0}) command('hi clear VertSplit') feed('k0') if multigrid then @@ -7729,9 +7729,9 @@ describe('float window', function() insert([[ # TODO: 测试字典信息的准确性 # FIXME: 测试字典信息的准确性]]) - local buf = meths.create_buf(false,false) - meths.buf_set_lines(buf, 0, -1, true, {'口', '口'}) - local win = meths.open_win(buf, false, {relative='editor', width=5, height=3, row=0, col=11, style='minimal'}) + local buf = meths.nvim_create_buf(false,false) + meths.nvim_buf_set_lines(buf, 0, -1, true, {'口', '口'}) + local win = meths.nvim_open_win(buf, false, {relative='editor', width=5, height=3, row=0, col=11, style='minimal'}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -7757,7 +7757,7 @@ describe('float window', function() ]]) end - meths.win_close(win, false) + meths.nvim_win_close(win, false) if multigrid then screen:expect([[ ## grid 1 @@ -7782,9 +7782,9 @@ describe('float window', function() -- The interaction between 'winblend' and doublewidth chars in the background -- does not look very good. But check no chars get incorrectly placed -- at least. Also check invisible EndOfBuffer region blends correctly. - meths.buf_set_lines(buf, 0, -1, true, {" x x x xx", " x x x x"}) - win = meths.open_win(buf, false, {relative='editor', width=12, height=3, row=0, col=11, style='minimal'}) - meths.set_option_value('winblend', 30, {win=win.id}) + meths.nvim_buf_set_lines(buf, 0, -1, true, {" x x x xx", " x x x x"}) + win = meths.nvim_open_win(buf, false, {relative='editor', width=12, height=3, row=0, col=11, style='minimal'}) + meths.nvim_set_option_value('winblend', 30, {win=win.id}) screen:set_default_attr_ids({ [1] = {foreground = tonumber('0xb282b2'), background = tonumber('0xffcfff')}, [2] = {foreground = Screen.colors.Grey0, background = tonumber('0xffcfff')}, @@ -7820,7 +7820,7 @@ describe('float window', function() ]]) end - meths.win_set_config(win, {relative='editor', row=0, col=12}) + meths.nvim_win_set_config(win, {relative='editor', row=0, col=12}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -7974,9 +7974,9 @@ describe('float window', function() end) it("correctly orders multiple opened floats (current last)", function() - local buf = meths.create_buf(false,false) - local win = meths.open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5}) - meths.set_option_value("winhl", "Normal:ErrorMsg,EndOfBuffer:ErrorMsg", {win=win.id}) + local buf = meths.nvim_create_buf(false,false) + local win = meths.nvim_open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5}) + meths.nvim_set_option_value("winhl", "Normal:ErrorMsg,EndOfBuffer:ErrorMsg", {win=win.id}) if multigrid then screen:expect{grid=[[ @@ -8060,9 +8060,9 @@ describe('float window', function() end) it("correctly orders multiple opened floats (non-current last)", function() - local buf = meths.create_buf(false,false) - local win = meths.open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5}) - meths.set_option_value("winhl", "Normal:ErrorMsg,EndOfBuffer:ErrorMsg", {win=win.id}) + local buf = meths.nvim_create_buf(false,false) + local win = meths.nvim_open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5}) + meths.nvim_set_option_value("winhl", "Normal:ErrorMsg,EndOfBuffer:ErrorMsg", {win=win.id}) if multigrid then screen:expect{grid=[[ @@ -8146,13 +8146,13 @@ describe('float window', function() end) it('can use z-index', function() - local buf = meths.create_buf(false,false) - local win1 = meths.open_win(buf, false, {relative='editor', width=20, height=3, row=1, col=5, zindex=30}) - meths.set_option_value("winhl", "Normal:ErrorMsg,EndOfBuffer:ErrorMsg", {win=win1.id}) - local win2 = meths.open_win(buf, false, {relative='editor', width=20, height=3, row=2, col=6, zindex=50}) - meths.set_option_value("winhl", "Normal:Search,EndOfBuffer:Search", {win=win2.id}) - local win3 = meths.open_win(buf, false, {relative='editor', width=20, height=3, row=3, col=7, zindex=40}) - meths.set_option_value("winhl", "Normal:Question,EndOfBuffer:Question", {win=win3.id}) + local buf = meths.nvim_create_buf(false,false) + local win1 = meths.nvim_open_win(buf, false, {relative='editor', width=20, height=3, row=1, col=5, zindex=30}) + meths.nvim_set_option_value("winhl", "Normal:ErrorMsg,EndOfBuffer:ErrorMsg", {win=win1.id}) + local win2 = meths.nvim_open_win(buf, false, {relative='editor', width=20, height=3, row=2, col=6, zindex=50}) + meths.nvim_set_option_value("winhl", "Normal:Search,EndOfBuffer:Search", {win=win2.id}) + local win3 = meths.nvim_open_win(buf, false, {relative='editor', width=20, height=3, row=3, col=7, zindex=40}) + meths.nvim_set_option_value("winhl", "Normal:Question,EndOfBuffer:Question", {win=win3.id}) if multigrid then screen:expect{grid=[[ @@ -8197,9 +8197,9 @@ describe('float window', function() end) it('can use winbar', function() - local buf = meths.create_buf(false,false) - local win1 = meths.open_win(buf, false, {relative='editor', width=15, height=3, row=1, col=5}) - meths.set_option_value('winbar', 'floaty bar', {win=win1.id}) + local buf = meths.nvim_create_buf(false,false) + local win1 = meths.nvim_open_win(buf, false, {relative='editor', width=15, height=3, row=1, col=5}) + meths.nvim_set_option_value('winbar', 'floaty bar', {win=win1.id}) if multigrid then screen:expect{grid=[[ @@ -8233,7 +8233,7 @@ describe('float window', function() end -- resize and add a border - meths.win_set_config(win1, {relative='editor', width=15, height=4, row=0, col=4, border = 'single'}) + meths.nvim_win_set_config(win1, {relative='editor', width=15, height=4, row=0, col=4, border = 'single'}) if multigrid then screen:expect{grid=[[ @@ -8272,8 +8272,8 @@ describe('float window', function() it('it can be resized with messages and cmdheight=0 #20106', function() screen:try_resize(40,9) command 'set cmdheight=0' - local buf = meths.create_buf(false,true) - local win = meths.open_win(buf, false, {relative='editor', width=40, height=4, anchor='SW', row=9, col=0, style='minimal', border="single", noautocmd=true}) + local buf = meths.nvim_create_buf(false,true) + local win = meths.nvim_open_win(buf, false, {relative='editor', width=40, height=4, anchor='SW', row=9, col=0, style='minimal', border="single", noautocmd=true}) if multigrid then screen:expect{grid=[[ @@ -8338,7 +8338,7 @@ describe('float window', function() end - meths.win_close(win, true) + meths.nvim_win_close(win, true) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -8360,8 +8360,8 @@ describe('float window', function() it('it can be resized with messages and cmdheight=1', function() screen:try_resize(40,9) - local buf = meths.create_buf(false,true) - local win = meths.open_win(buf, false, {relative='editor', width=40, height=4, anchor='SW', row=8, col=0, style='minimal', border="single", noautocmd=true}) + local buf = meths.nvim_create_buf(false,true) + local win = meths.nvim_open_win(buf, false, {relative='editor', width=40, height=4, anchor='SW', row=8, col=0, style='minimal', border="single", noautocmd=true}) if multigrid then screen:expect{grid=[[ @@ -8468,7 +8468,7 @@ describe('float window', function() ]]} end - meths.win_close(win, true) + meths.nvim_win_close(win, true) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -8494,7 +8494,7 @@ describe('float window', function() describe('no crash after moving and closing float window #21547', function() local function test_float_move_close(cmd) local float_opts = {relative = 'editor', row = 1, col = 1, width = 10, height = 10} - meths.open_win(meths.create_buf(false, false), true, float_opts) + meths.nvim_open_win(meths.nvim_create_buf(false, false), true, float_opts) if multigrid then screen:expect({float_pos = {[4] = {{id = 1001}, 'NW', 1, 1, 1, true}}}) end @@ -8521,7 +8521,7 @@ describe('float window', function() it(':sleep cursor placement #22639', function() local float_opts = {relative = 'editor', row = 1, col = 1, width = 4, height = 3} - local win = meths.open_win(meths.create_buf(false, false), true, float_opts) + local win = meths.nvim_open_win(meths.nvim_create_buf(false, false), true, float_opts) feed('iab<CR>cd<Esc>') feed(':sleep 100') if multigrid then @@ -8589,7 +8589,7 @@ describe('float window', function() feed('<C-C>') screen:expect_unchanged() - meths.win_set_config(win, {border = 'single'}) + meths.nvim_win_set_config(win, {border = 'single'}) feed(':sleep 100') if multigrid then screen:expect{grid=[[ @@ -8738,7 +8738,7 @@ describe('float window', function() it('with rightleft and border #22640', function() local float_opts = {relative='editor', width=5, height=3, row=1, col=1, border='single'} - meths.open_win(meths.create_buf(false, false), true, float_opts) + meths.nvim_open_win(meths.nvim_create_buf(false, false), true, float_opts) command('setlocal rightleft') feed('iabc<CR>def<Esc>') if multigrid then @@ -8777,8 +8777,8 @@ describe('float window', function() end) it('float window with hide option', function() - local buf = meths.create_buf(false,false) - local win = meths.open_win(buf, false, {relative='editor', width=10, height=2, row=2, col=5, hide = true}) + local buf = meths.nvim_create_buf(false,false) + local win = meths.nvim_open_win(buf, false, {relative='editor', width=10, height=2, row=2, col=5, hide = true}) local expected_pos = { [4]={{id=1001}, 'NW', 1, 2, 5, true}, } @@ -8806,7 +8806,7 @@ describe('float window', function() ]]) end - meths.win_set_config(win, {hide = false}) + meths.nvim_win_set_config(win, {hide = false}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -8833,7 +8833,7 @@ describe('float window', function() ]]) end - meths.win_set_config(win, {hide=true}) + meths.nvim_win_set_config(win, {hide=true}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -8859,18 +8859,18 @@ describe('float window', function() end) it(':fclose command #9663', function() - local buf_a = meths.create_buf(false,false) - local buf_b = meths.create_buf(false,false) - local buf_c = meths.create_buf(false,false) - local buf_d = meths.create_buf(false,false) + local buf_a = meths.nvim_create_buf(false,false) + local buf_b = meths.nvim_create_buf(false,false) + local buf_c = meths.nvim_create_buf(false,false) + local buf_d = meths.nvim_create_buf(false,false) local config_a = {relative='editor', width=11, height=11, row=5, col=5, border ='single', zindex=50} local config_b = {relative='editor', width=8, height=8, row=7, col=7, border ='single', zindex=70} local config_c = {relative='editor', width=4, height=4, row=9, col=9, border ='single',zindex=90} local config_d = {relative='editor', width=2, height=2, row=10, col=10, border ='single',zindex=100} - meths.open_win(buf_a, false, config_a) - meths.open_win(buf_b, false, config_b) - meths.open_win(buf_c, false, config_c) - meths.open_win(buf_d, false, config_d) + meths.nvim_open_win(buf_a, false, config_a) + meths.nvim_open_win(buf_b, false, config_b) + meths.nvim_open_win(buf_c, false, config_c) + meths.nvim_open_win(buf_d, false, config_d) local expected_pos = { [4]={{id=1001}, 'NW', 1, 5, 5, true, 50}, [5]={{id=1002}, 'NW', 1, 7, 7, true, 70}, diff --git a/test/functional/ui/fold_spec.lua b/test/functional/ui/fold_spec.lua index 6951d2eb9a..08dcd18aa0 100644 --- a/test/functional/ui/fold_spec.lua +++ b/test/functional/ui/fold_spec.lua @@ -317,7 +317,7 @@ describe('folded lines', function() feed_command('set norightleft') if multigrid then - meths.input_mouse('left', 'press', '', 2, 0, 1) + meths.nvim_input_mouse('left', 'press', '', 2, 0, 1) screen:expect([[ ## grid 1 [2:---------------------------------------------]|*7 @@ -330,7 +330,7 @@ describe('folded lines', function() :set norightleft | ]]) else - meths.input_mouse('left', 'press', '', 0, 0, 1) + meths.nvim_input_mouse('left', 'press', '', 0, 0, 1) screen:expect([[ {7:▾▸}{5:^+--- 5 lines: aa··························}| {7:│ }ff | @@ -340,7 +340,7 @@ describe('folded lines', function() end if multigrid then - meths.input_mouse('left', 'press', '', 2, 0, 0) + meths.nvim_input_mouse('left', 'press', '', 2, 0, 0) screen:expect([[ ## grid 1 [2:---------------------------------------------]|*7 @@ -352,7 +352,7 @@ describe('folded lines', function() :set norightleft | ]]) else - meths.input_mouse('left', 'press', '', 0, 0, 0) + meths.nvim_input_mouse('left', 'press', '', 0, 0, 0) screen:expect([[ {7:▸ }{5:^+-- 6 lines: aa···························}| {1:~ }|*6 @@ -363,7 +363,7 @@ describe('folded lines', function() -- Add a winbar to avoid double-clicks command('setlocal winbar=!!!!!!') if multigrid then - meths.input_mouse('left', 'press', '', 2, 1, 0) + meths.nvim_input_mouse('left', 'press', '', 2, 1, 0) screen:expect([[ ## grid 1 [2:---------------------------------------------]|*7 @@ -377,7 +377,7 @@ describe('folded lines', function() :set norightleft | ]]) else - meths.input_mouse('left', 'press', '', 0, 1, 0) + meths.nvim_input_mouse('left', 'press', '', 0, 1, 0) screen:expect([[ {11:!!!!!! }| {7:▾▸}{5:^+--- 5 lines: aa··························}| @@ -388,7 +388,7 @@ describe('folded lines', function() end if multigrid then - meths.input_mouse('left', 'press', '', 2, 1, 1) + meths.nvim_input_mouse('left', 'press', '', 2, 1, 1) screen:expect([[ ## grid 1 [2:---------------------------------------------]|*7 @@ -405,7 +405,7 @@ describe('folded lines', function() :set norightleft | ]]) else - meths.input_mouse('left', 'press', '', 0, 1, 1) + meths.nvim_input_mouse('left', 'press', '', 0, 1, 1) screen:expect([[ {11:!!!!!! }| {7:▾▾}^aa | @@ -447,7 +447,7 @@ describe('folded lines', function() feed_command('1') feed('zf2j') if multigrid then - meths.input_mouse('left', 'press', '', 4, 0, 0) + meths.nvim_input_mouse('left', 'press', '', 4, 0, 0) screen:expect([[ ## grid 1 [2:---------------------------------------------]|*2 @@ -466,7 +466,7 @@ describe('folded lines', function() {7:│}ff | ]]) else - meths.input_mouse('left', 'press', '', 0, 3, 0) + meths.nvim_input_mouse('left', 'press', '', 0, 3, 0) screen:expect([[ {7:-}aa | {7:-}bb | @@ -480,7 +480,7 @@ describe('folded lines', function() end if multigrid then - meths.input_mouse('left', 'press', '', 4, 1, 0) + meths.nvim_input_mouse('left', 'press', '', 4, 1, 0) screen:expect([[ ## grid 1 [2:---------------------------------------------]|*2 @@ -499,7 +499,7 @@ describe('folded lines', function() {7:2}cc | ]]) else - meths.input_mouse('left', 'press', '', 0, 4, 0) + meths.nvim_input_mouse('left', 'press', '', 0, 4, 0) screen:expect([[ {7:-}aa | {7:-}bb | @@ -513,7 +513,7 @@ describe('folded lines', function() end if multigrid then - meths.input_mouse('left', 'press', '', 2, 1, 0) + meths.nvim_input_mouse('left', 'press', '', 2, 1, 0) screen:expect([[ ## grid 1 [2:---------------------------------------------]|*2 @@ -532,7 +532,7 @@ describe('folded lines', function() {7:2}cc | ]]) else - meths.input_mouse('left', 'press', '', 0, 1, 0) + meths.nvim_input_mouse('left', 'press', '', 0, 1, 0) screen:expect([[ {7:-}aa | {7:+}{5:^+--- 4 lines: bb···························}| @@ -546,7 +546,7 @@ describe('folded lines', function() end if multigrid then - meths.input_mouse('left', 'press', '', 2, 0, 0) + meths.nvim_input_mouse('left', 'press', '', 2, 0, 0) screen:expect([[ ## grid 1 [2:---------------------------------------------]|*2 @@ -565,7 +565,7 @@ describe('folded lines', function() {7:2}cc | ]]) else - meths.input_mouse('left', 'press', '', 0, 0, 0) + meths.nvim_input_mouse('left', 'press', '', 0, 0, 0) screen:expect([[ {7:+}{5:^+-- 6 lines: aa····························}| {1:~ }| @@ -607,7 +607,7 @@ describe('folded lines', function() feed_command('1') feed('zf2j') if multigrid then - meths.input_mouse('left', 'press', '', 4, 0, 0) + meths.nvim_input_mouse('left', 'press', '', 4, 0, 0) screen:expect([[ ## grid 1 [2:----------------------]{2:│}[4:----------------------]|*6 @@ -629,7 +629,7 @@ describe('folded lines', function() {1:~ }|*3 ]]) else - meths.input_mouse('left', 'press', '', 0, 0, 23) + meths.nvim_input_mouse('left', 'press', '', 0, 0, 23) screen:expect([[ {7:-}aa {2:│}{7:-}^aa | {7:-}bb {2:│}{7:+}{5:+--- 4 lines: bb····}| @@ -643,7 +643,7 @@ describe('folded lines', function() end if multigrid then - meths.input_mouse('left', 'press', '', 4, 1, 0) + meths.nvim_input_mouse('left', 'press', '', 4, 1, 0) screen:expect([[ ## grid 1 [2:----------------------]{2:│}[4:----------------------]|*6 @@ -667,7 +667,7 @@ describe('folded lines', function() {7:│}ff | ]]) else - meths.input_mouse('left', 'press', '', 0, 1, 23) + meths.nvim_input_mouse('left', 'press', '', 0, 1, 23) screen:expect([[ {7:-}aa {2:│}{7:-}^aa | {7:-}bb {2:│}{7:-}bb | @@ -681,7 +681,7 @@ describe('folded lines', function() end if multigrid then - meths.input_mouse('left', 'press', '', 2, 1, 0) + meths.nvim_input_mouse('left', 'press', '', 2, 1, 0) screen:expect([[ ## grid 1 [2:----------------------]{2:│}[4:----------------------]|*6 @@ -703,7 +703,7 @@ describe('folded lines', function() {7:│}ff | ]]) else - meths.input_mouse('left', 'press', '', 0, 1, 0) + meths.nvim_input_mouse('left', 'press', '', 0, 1, 0) screen:expect([[ {7:-}aa {2:│}{7:-}aa | {7:+}{5:^+--- 4 lines: bb····}{2:│}{7:-}bb | @@ -717,7 +717,7 @@ describe('folded lines', function() end if multigrid then - meths.input_mouse('left', 'press', '', 2, 0, 0) + meths.nvim_input_mouse('left', 'press', '', 2, 0, 0) screen:expect([[ ## grid 1 [2:----------------------]{2:│}[4:----------------------]|*6 @@ -737,7 +737,7 @@ describe('folded lines', function() {7:│}ff | ]]) else - meths.input_mouse('left', 'press', '', 0, 0, 0) + meths.nvim_input_mouse('left', 'press', '', 0, 0, 0) screen:expect([[ {7:+}{5:^+-- 6 lines: aa·····}{2:│}{7:-}aa | {1:~ }{2:│}{7:-}bb | @@ -767,7 +767,7 @@ describe('folded lines', function() feed('zO') feed_command('tab split') if multigrid then - meths.input_mouse('left', 'press', '', 4, 1, 1) + meths.nvim_input_mouse('left', 'press', '', 4, 1, 1) screen:expect([[ ## grid 1 {10: + [No Name] }{11: + [No Name] }{2: }{10:X}| @@ -790,7 +790,7 @@ describe('folded lines', function() {1:~ }|*3 ]]) else - meths.input_mouse('left', 'press', '', 0, 2, 1) + meths.nvim_input_mouse('left', 'press', '', 0, 2, 1) screen:expect([[ {10: + [No Name] }{11: + [No Name] }{2: }{10:X}| {7:- }^aa | @@ -802,7 +802,7 @@ describe('folded lines', function() end if multigrid then - meths.input_mouse('left', 'press', '', 4, 0, 0) + meths.nvim_input_mouse('left', 'press', '', 4, 0, 0) screen:expect([[ ## grid 1 {10: + [No Name] }{11: + [No Name] }{2: }{10:X}| @@ -823,7 +823,7 @@ describe('folded lines', function() {1:~ }|*5 ]]) else - meths.input_mouse('left', 'press', '', 0, 1, 0) + meths.nvim_input_mouse('left', 'press', '', 0, 1, 0) screen:expect([[ {10: + [No Name] }{11: + [No Name] }{2: }{10:X}| {7:+ }{5:^+-- 6 lines: aa···························}| @@ -834,7 +834,7 @@ describe('folded lines', function() feed_command('tabnext') if multigrid then - meths.input_mouse('left', 'press', '', 2, 1, 1) + meths.nvim_input_mouse('left', 'press', '', 2, 1, 1) screen:expect([[ ## grid 1 {11: + [No Name] }{10: + [No Name] }{2: }{10:X}| @@ -852,7 +852,7 @@ describe('folded lines', function() {1:~ }|*5 ]]) else - meths.input_mouse('left', 'press', '', 0, 2, 1) + meths.nvim_input_mouse('left', 'press', '', 0, 2, 1) screen:expect([[ {11: + [No Name] }{10: + [No Name] }{2: }{10:X}| {7:- }^aa | @@ -864,7 +864,7 @@ describe('folded lines', function() end if multigrid then - meths.input_mouse('left', 'press', '', 2, 0, 0) + meths.nvim_input_mouse('left', 'press', '', 2, 0, 0) screen:expect([[ ## grid 1 {11: + [No Name] }{10: + [No Name] }{2: }{10:X}| @@ -880,7 +880,7 @@ describe('folded lines', function() {1:~ }|*5 ]]) else - meths.input_mouse('left', 'press', '', 0, 1, 0) + meths.nvim_input_mouse('left', 'press', '', 0, 1, 0) screen:expect([[ {11: + [No Name] }{10: + [No Name] }{2: }{10:X}| {7:+ }{5:^+-- 6 lines: aa···························}| @@ -891,7 +891,7 @@ describe('folded lines', function() end) it('works with multibyte text', function() - eq(true, meths.get_option_value('arabicshape', {})) + eq(true, meths.nvim_get_option_value('arabicshape', {})) insert([[ å 语 x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢͟ العَرَبِيَّة möre text]]) @@ -1531,23 +1531,35 @@ describe('folded lines', function() funcs.setline(3, 'line 3') funcs.setline(4, 'line 4') feed('zfj') - local ns = meths.create_namespace('ns') - meths.buf_set_extmark( + local ns = meths.nvim_create_namespace('ns') + meths.nvim_buf_set_extmark( 0, ns, 0, 0, { virt_lines_above = true, virt_lines = { { { 'virt_line above line 1', '' } } } } ) - meths.buf_set_extmark(0, ns, 1, 0, { virt_lines = { { { 'virt_line below line 2', '' } } } }) - meths.buf_set_extmark( + meths.nvim_buf_set_extmark( + 0, + ns, + 1, + 0, + { virt_lines = { { { 'virt_line below line 2', '' } } } } + ) + meths.nvim_buf_set_extmark( 0, ns, 2, 0, { virt_lines_above = true, virt_lines = { { { 'virt_line above line 3', '' } } } } ) - meths.buf_set_extmark(0, ns, 3, 0, { virt_lines = { { { 'virt_line below line 4', '' } } } }) + meths.nvim_buf_set_extmark( + 0, + ns, + 3, + 0, + { virt_lines = { { { 'virt_line below line 4', '' } } } } + ) if multigrid then screen:expect { grid = [[ @@ -1667,7 +1679,7 @@ describe('folded lines', function() ]]) end - meths.input_mouse('left', 'press', '', multigrid and 2 or 0, 4, 0) + meths.nvim_input_mouse('left', 'press', '', multigrid and 2 or 0, 4, 0) eq({ screencol = 1, screenrow = 5, @@ -1679,7 +1691,7 @@ describe('folded lines', function() coladd = 0, }, funcs.getmousepos()) - meths.buf_set_extmark( + meths.nvim_buf_set_extmark( 0, ns, 1, @@ -1953,7 +1965,7 @@ describe('folded lines', function() ]]) end - meths.input_mouse('left', 'press', '3', multigrid and 2 or 0, 3, 0) + meths.nvim_input_mouse('left', 'press', '3', multigrid and 2 or 0, 3, 0) if multigrid then screen:expect { grid = [[ @@ -1992,7 +2004,7 @@ describe('folded lines', function() ]]) end - meths.input_mouse('left', 'drag', '3', multigrid and 2 or 0, 7, 0) + meths.nvim_input_mouse('left', 'drag', '3', multigrid and 2 or 0, 7, 0) if multigrid then screen:expect { grid = [[ @@ -2029,7 +2041,7 @@ describe('folded lines', function() ]]) end - meths.input_mouse('left', 'drag', '3', multigrid and 2 or 0, 7, 5) + meths.nvim_input_mouse('left', 'drag', '3', multigrid and 2 or 0, 7, 5) if multigrid then screen:expect { grid = [[ @@ -2419,9 +2431,9 @@ describe('folded lines', function() command('hi! CursorLine guibg=NONE guifg=Red gui=NONE') command('hi F0 guibg=Red guifg=Black') command('hi F1 guifg=White') - meths.set_option_value('cursorline', true, {}) - meths.set_option_value('foldcolumn', '4', {}) - meths.set_option_value( + meths.nvim_set_option_value('cursorline', true, {}) + meths.nvim_set_option_value('foldcolumn', '4', {}) + meths.nvim_set_option_value( 'foldtext', '[' .. '["▶", ["F0", "F1"]], ' @@ -2511,7 +2523,7 @@ describe('folded lines', function() ]]) end - meths.set_option_value('rightleft', true, {}) + meths.nvim_set_option_value('rightleft', true, {}) if multigrid then screen:expect([[ ## grid 1 diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua index 54c14fb44a..857fd29f19 100644 --- a/test/functional/ui/highlight_spec.lua +++ b/test/functional/ui/highlight_spec.lua @@ -2403,13 +2403,13 @@ describe('highlight namespaces', function() [10] = { bold = true, foreground = Screen.colors.SeaGreen }, } - ns1 = meths.create_namespace 'grungy' - ns2 = meths.create_namespace 'ultrared' + ns1 = meths.nvim_create_namespace 'grungy' + ns2 = meths.nvim_create_namespace 'ultrared' - meths.set_hl(ns1, 'Normal', { bg = 'DarkGrey' }) - meths.set_hl(ns1, 'NonText', { bg = 'DarkOrange4', fg = 'DarkCyan', italic = true }) - meths.set_hl(ns2, 'Normal', { bg = 'DarkMagenta' }) - meths.set_hl(ns2, 'NonText', { fg = 'Crimson' }) + meths.nvim_set_hl(ns1, 'Normal', { bg = 'DarkGrey' }) + meths.nvim_set_hl(ns1, 'NonText', { bg = 'DarkOrange4', fg = 'DarkCyan', italic = true }) + meths.nvim_set_hl(ns2, 'Normal', { bg = 'DarkMagenta' }) + meths.nvim_set_hl(ns2, 'NonText', { fg = 'Crimson' }) end) it('can be used globally', function() @@ -2421,7 +2421,7 @@ describe('highlight namespaces', function() ]], } - meths.set_hl_ns(ns1) + meths.nvim_set_hl_ns(ns1) screen:expect { grid = [[ {2:^ }| @@ -2430,7 +2430,7 @@ describe('highlight namespaces', function() ]], } - meths.set_hl_ns(ns2) + meths.nvim_set_hl_ns(ns2) screen:expect { grid = [[ {4:^ }| @@ -2439,7 +2439,7 @@ describe('highlight namespaces', function() ]], } - meths.set_hl_ns(0) + meths.nvim_set_hl_ns(0) screen:expect { grid = [[ ^ | @@ -2450,13 +2450,13 @@ describe('highlight namespaces', function() end) it('can be used per window', function() - local win1 = meths.get_current_win() + local win1 = meths.nvim_get_current_win() command 'split' - local win2 = meths.get_current_win() + local win2 = meths.nvim_get_current_win() command 'split' - meths.win_set_hl_ns(win1, ns1) - meths.win_set_hl_ns(win2, ns2) + meths.nvim_win_set_hl_ns(win1, ns1) + meths.nvim_win_set_hl_ns(win2, ns2) screen:expect { grid = [[ @@ -2483,7 +2483,7 @@ describe('highlight namespaces', function() ]], } - meths.set_hl(0, 'EndOfBuffer', { fg = '#333333' }) + meths.nvim_set_hl(0, 'EndOfBuffer', { fg = '#333333' }) screen:expect { grid = [[ ^ | @@ -2508,7 +2508,7 @@ describe('highlight namespaces', function() it('Normal in set_hl #25474', function() command('highlight Ignore guifg=bg ctermfg=White') - meths.set_hl(0, 'Normal', { bg = '#333333' }) + meths.nvim_set_hl(0, 'Normal', { bg = '#333333' }) command('highlight Ignore') screen:expect { grid = [[ diff --git a/test/functional/ui/hlstate_spec.lua b/test/functional/ui/hlstate_spec.lua index 8147636326..d6fd864536 100644 --- a/test/functional/ui/hlstate_spec.lua +++ b/test/functional/ui/hlstate_spec.lua @@ -28,8 +28,8 @@ describe('ext_hlstate detailed highlights', function() insert([[ these are some lines with colorful text]]) - meths.buf_add_highlight(0, -1, 'String', 0, 10, 14) - meths.buf_add_highlight(0, -1, 'Statement', 1, 5, -1) + meths.nvim_buf_add_highlight(0, -1, 'String', 0, 10, 14) + meths.nvim_buf_add_highlight(0, -1, 'Statement', 1, 5, -1) command('/th co') screen:expect( diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua index 60bdf97b79..c97fd02562 100644 --- a/test/functional/ui/inccommand_spec.lua +++ b/test/functional/ui/inccommand_spec.lua @@ -158,7 +158,7 @@ describe(":substitute, 'inccommand' preserves", function() common_setup(screen, 'nosplit', ('abc\ndef\n'):rep(50)) feed('ggyG') - local X = meths.get_vvar('maxcol') + local X = meths.nvim_get_vvar('maxcol') eq({ 0, 1, 1, 0 }, funcs.getpos("'[")) eq({ 0, 101, X, 0 }, funcs.getpos("']")) @@ -205,8 +205,8 @@ describe(":substitute, 'inccommand' preserves", function() feed(':%s/as/glork/') poke_eventloop() feed('<enter>') - eq(meths.get_option_value('undolevels', { scope = 'global' }), 139) - eq(meths.get_option_value('undolevels', { buf = 0 }), 34) + eq(meths.nvim_get_option_value('undolevels', { scope = 'global' }), 139) + eq(meths.nvim_get_option_value('undolevels', { buf = 0 }), 34) end) end @@ -1119,7 +1119,7 @@ describe(':substitute, inccommand=split', function() it("deactivates if 'redrawtime' is exceeded #5602", function() -- prevent redraws from 'incsearch' - meths.set_option_value('incsearch', false, {}) + meths.nvim_set_option_value('incsearch', false, {}) -- Assert that 'inccommand' is ENABLED initially. eq('split', eval('&inccommand')) -- Set 'redrawtime' to minimal value, to ensure timeout is triggered. @@ -1752,7 +1752,7 @@ describe("'inccommand' autocommands", function() end local function register_autocmd(event) - meths.set_var(event .. '_fired', {}) + meths.nvim_set_var(event .. '_fired', {}) command('autocmd ' .. event .. ' * call add(g:' .. event .. "_fired, expand('<abuf>'))") end @@ -1768,14 +1768,14 @@ describe("'inccommand' autocommands", function() feed(':%s/tw') for event, _ in pairs(eventsExpected) do - eventsObserved[event].open = meths.get_var(event .. '_fired') - meths.set_var(event .. '_fired', {}) + eventsObserved[event].open = meths.nvim_get_var(event .. '_fired') + meths.nvim_set_var(event .. '_fired', {}) end feed('/<enter>') for event, _ in pairs(eventsExpected) do - eventsObserved[event].close = meths.get_var(event .. '_fired') + eventsObserved[event].close = meths.nvim_get_var(event .. '_fired') end for event, _ in pairs(eventsExpected) do @@ -2614,8 +2614,8 @@ it(':substitute with inccommand, allows :redraw before first separator is typed local screen = Screen.new(30, 6) common_setup(screen, 'split', 'foo bar baz\nbar baz fox\nbar foo baz') command('hi! link NormalFloat CursorLine') - local float_buf = meths.create_buf(false, true) - meths.open_win(float_buf, false, { + local float_buf = meths.nvim_create_buf(false, true) + meths.nvim_open_win(float_buf, false, { relative = 'editor', height = 1, width = 5, @@ -2641,7 +2641,7 @@ it(':substitute with inccommand, allows :redraw before first separator is typed {15:~ }| :%s^ | ]]) - meths.buf_set_lines(float_buf, 0, -1, true, { 'foo' }) + meths.nvim_buf_set_lines(float_buf, 0, -1, true, { 'foo' }) command('redraw') screen:expect([[ foo bar baz | @@ -2745,7 +2745,7 @@ it(':substitute with inccommand works properly if undo is not synced #20029', fu clear() local screen = Screen.new(30, 6) common_setup(screen, 'nosplit', 'foo\nbar\nbaz') - meths.set_keymap('x', '<F2>', '<Esc>`<Oaaaaa asdf<Esc>`>obbbbb asdf<Esc>V`<k:s/asdf/', {}) + meths.nvim_set_keymap('x', '<F2>', '<Esc>`<Oaaaaa asdf<Esc>`>obbbbb asdf<Esc>V`<k:s/asdf/', {}) feed('gg0<C-V>lljj<F2>') screen:expect([[ aaaaa | diff --git a/test/functional/ui/input_spec.lua b/test/functional/ui/input_spec.lua index 7cb8d4622d..8a08d459c4 100644 --- a/test/functional/ui/input_spec.lua +++ b/test/functional/ui/input_spec.lua @@ -392,7 +392,7 @@ end) describe('event processing and input', function() it('not blocked by event bursts', function() - meths.set_keymap( + meths.nvim_set_keymap( '', '<f2>', "<cmd>lua vim.rpcnotify(1, 'stop') winning = true <cr>", diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua index 2a402437fd..25ae74daf1 100644 --- a/test/functional/ui/messages_spec.lua +++ b/test/functional/ui/messages_spec.lua @@ -1445,7 +1445,7 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim it('prints lines in Ex mode correctly with a burst of carriage returns #19341', function() command('set number') - meths.buf_set_lines(0, 0, 0, true, { 'aaa', 'bbb', 'ccc' }) + meths.nvim_buf_set_lines(0, 0, 0, true, { 'aaa', 'bbb', 'ccc' }) feed('gggQ<CR><CR>1<CR><CR>vi') screen:expect([[ Entering Ex mode. Type "visual" to go to Normal mode. | @@ -1542,7 +1542,7 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim {1:~ }|*5 | ]]) - eq(1, meths.get_option_value('cmdheight', {})) + eq(1, meths.nvim_get_option_value('cmdheight', {})) end) it('using nvim_echo in VimResized does not cause hit-enter prompt #26139', function() @@ -1553,7 +1553,7 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim {1:~ }|*3 | ]]) - eq({ mode = 'n', blocking = false }, meths.get_mode()) + eq({ mode = 'n', blocking = false }, meths.nvim_get_mode()) end) end) @@ -1675,9 +1675,9 @@ describe('ui/ext_messages', function() }) feed(':set mouse=a<cr>') - meths.input_mouse('left', 'press', '', 0, 12, 10) + meths.nvim_input_mouse('left', 'press', '', 0, 12, 10) poke_eventloop() - meths.input_mouse('left', 'drag', '', 0, 11, 10) + meths.nvim_input_mouse('left', 'drag', '', 0, 11, 10) feed('<c-l>') feed(':set cmdheight<cr>') screen:expect({ diff --git a/test/functional/ui/mouse_spec.lua b/test/functional/ui/mouse_spec.lua index d1479c13fe..f3025c0d53 100644 --- a/test/functional/ui/mouse_spec.lua +++ b/test/functional/ui/mouse_spec.lua @@ -12,8 +12,8 @@ describe('ui/mouse/input', function() before_each(function() clear() - meths.set_option_value('mouse', 'a', {}) - meths.set_option_value('list', true, {}) + meths.nvim_set_option_value('mouse', 'a', {}) + meths.nvim_set_option_value('list', true, {}) -- NB: this is weird, but mostly irrelevant to the test -- So I didn't bother to change it command('set listchars=eol:$') @@ -69,7 +69,7 @@ describe('ui/mouse/input', function() end) it("in external ui works with unset 'mouse'", function() - meths.set_option_value('mouse', '', {}) + meths.nvim_set_option_value('mouse', '', {}) feed('<LeftMouse><2,1>') screen:expect { grid = [[ @@ -379,7 +379,7 @@ describe('ui/mouse/input', function() end) it('left click in default tabline (position 24) closes tab', function() - meths.set_option_value('hidden', true, {}) + meths.nvim_set_option_value('hidden', true, {}) feed_command('%delete') insert('this is foo') feed_command('silent file foo | tabnew | file bar') @@ -399,7 +399,7 @@ describe('ui/mouse/input', function() end) it('double click in default tabline (position 4) opens new tab', function() - meths.set_option_value('hidden', true, {}) + meths.nvim_set_option_value('hidden', true, {}) feed_command('%delete') insert('this is foo') feed_command('silent file foo | tabnew | file bar') @@ -432,8 +432,8 @@ describe('ui/mouse/input', function() return call('Test', a:000 + [2]) endfunction ]]) - meths.set_option_value('tabline', '%@Test@test%X-%5@Test2@test2', {}) - meths.set_option_value('showtabline', 2, {}) + meths.nvim_set_option_value('tabline', '%@Test@test%X-%5@Test2@test2', {}) + meths.nvim_set_option_value('showtabline', 2, {}) screen:expect([[ {fill:test-test2 }| testing | @@ -441,12 +441,12 @@ describe('ui/mouse/input', function() support and selectio^n | | ]]) - meths.set_var('reply', {}) + meths.nvim_set_var('reply', {}) end) local check_reply = function(expected) - eq(expected, meths.get_var('reply')) - meths.set_var('reply', {}) + eq(expected, meths.nvim_get_var('reply')) + meths.nvim_set_var('reply', {}) end local test_click = function(name, click_str, click_num, mouse_button, modifiers) @@ -475,7 +475,7 @@ describe('ui/mouse/input', function() for char in string.gmatch(modifiers, '%w') do modstr = modstr .. char .. '-' -- - not needed but should be accepted end - meths.input_mouse(buttons[mouse_button], 'press', modstr, 0, row, col) + meths.nvim_input_mouse(buttons[mouse_button], 'press', modstr, 0, row, col) end) end) end @@ -609,7 +609,7 @@ describe('ui/mouse/input', function() ]], } - meths.input_mouse('left', 'press', '', 0, 6, 27) + meths.nvim_input_mouse('left', 'press', '', 0, 6, 27) screen:expect { grid = [[ testing │testing | @@ -624,7 +624,7 @@ describe('ui/mouse/input', function() | ]], } - meths.input_mouse('left', 'drag', '', 0, 7, 30) + meths.nvim_input_mouse('left', 'drag', '', 0, 7, 30) screen:expect { grid = [[ @@ -779,7 +779,7 @@ describe('ui/mouse/input', function() end) it('ctrl + left click will search for a tag', function() - meths.set_option_value('tags', './non-existent-tags-file', {}) + meths.nvim_set_option_value('tags', './non-existent-tags-file', {}) feed('<C-LeftMouse><0,0>') screen:expect([[ {6:E433: No tags file} | @@ -792,28 +792,28 @@ describe('ui/mouse/input', function() end) it('x1 and x2 can be triggered by api', function() - meths.set_var('x1_pressed', 0) - meths.set_var('x1_released', 0) - meths.set_var('x2_pressed', 0) - meths.set_var('x2_released', 0) + meths.nvim_set_var('x1_pressed', 0) + meths.nvim_set_var('x1_released', 0) + meths.nvim_set_var('x2_pressed', 0) + meths.nvim_set_var('x2_released', 0) command('nnoremap <X1Mouse> <Cmd>let g:x1_pressed += 1<CR>') command('nnoremap <X1Release> <Cmd>let g:x1_released += 1<CR>') command('nnoremap <X2Mouse> <Cmd>let g:x2_pressed += 1<CR>') command('nnoremap <X2Release> <Cmd>let g:x2_released += 1<CR>') - meths.input_mouse('x1', 'press', '', 0, 0, 0) - meths.input_mouse('x1', 'release', '', 0, 0, 0) - meths.input_mouse('x2', 'press', '', 0, 0, 0) - meths.input_mouse('x2', 'release', '', 0, 0, 0) - eq(1, meths.get_var('x1_pressed'), 'x1 pressed once') - eq(1, meths.get_var('x1_released'), 'x1 released once') - eq(1, meths.get_var('x2_pressed'), 'x2 pressed once') - eq(1, meths.get_var('x2_released'), 'x2 released once') + meths.nvim_input_mouse('x1', 'press', '', 0, 0, 0) + meths.nvim_input_mouse('x1', 'release', '', 0, 0, 0) + meths.nvim_input_mouse('x2', 'press', '', 0, 0, 0) + meths.nvim_input_mouse('x2', 'release', '', 0, 0, 0) + eq(1, meths.nvim_get_var('x1_pressed'), 'x1 pressed once') + eq(1, meths.nvim_get_var('x1_released'), 'x1 released once') + eq(1, meths.nvim_get_var('x2_pressed'), 'x2 pressed once') + eq(1, meths.nvim_get_var('x2_released'), 'x2 released once') end) it('dragging vertical separator', function() screen:try_resize(45, 5) command('setlocal nowrap') - local oldwin = meths.get_current_win().id + local oldwin = meths.nvim_get_current_win().id command('rightbelow vnew') screen:expect([[ testing │{0:^$} | @@ -822,9 +822,9 @@ describe('ui/mouse/input', function() {4:[No Name] [+] }{5:[No Name] }| | ]]) - meths.input_mouse('left', 'press', '', 0, 0, 22) + meths.nvim_input_mouse('left', 'press', '', 0, 0, 22) poke_eventloop() - meths.input_mouse('left', 'drag', '', 0, 1, 12) + meths.nvim_input_mouse('left', 'drag', '', 0, 1, 12) screen:expect([[ testing │{0:^$} | mouse │{0:~ }| @@ -832,7 +832,7 @@ describe('ui/mouse/input', function() {4:< Name] [+] }{5:[No Name] }| | ]]) - meths.input_mouse('left', 'drag', '', 0, 2, 2) + meths.nvim_input_mouse('left', 'drag', '', 0, 2, 2) screen:expect([[ te│{0:^$} | mo│{0:~ }| @@ -840,17 +840,17 @@ describe('ui/mouse/input', function() {4:< }{5:[No Name] }| | ]]) - meths.input_mouse('left', 'release', '', 0, 2, 2) - meths.set_option_value('statuscolumn', 'foobar', { win = oldwin }) + meths.nvim_input_mouse('left', 'release', '', 0, 2, 2) + meths.nvim_set_option_value('statuscolumn', 'foobar', { win = oldwin }) screen:expect([[ {8:fo}│{0:^$} | {8:fo}│{0:~ }|*2 {4:< }{5:[No Name] }| | ]]) - meths.input_mouse('left', 'press', '', 0, 0, 2) + meths.nvim_input_mouse('left', 'press', '', 0, 0, 2) poke_eventloop() - meths.input_mouse('left', 'drag', '', 0, 1, 12) + meths.nvim_input_mouse('left', 'drag', '', 0, 1, 12) screen:expect([[ {8:foobar}testin│{0:^$} | {8:foobar}mouse │{0:~ }| @@ -858,7 +858,7 @@ describe('ui/mouse/input', function() {4:< Name] [+] }{5:[No Name] }| | ]]) - meths.input_mouse('left', 'drag', '', 0, 2, 22) + meths.nvim_input_mouse('left', 'drag', '', 0, 2, 22) screen:expect([[ {8:foobar}testing │{0:^$} | {8:foobar}mouse │{0:~ }| @@ -866,7 +866,7 @@ describe('ui/mouse/input', function() {4:[No Name] [+] }{5:[No Name] }| | ]]) - meths.input_mouse('left', 'release', '', 0, 2, 22) + meths.nvim_input_mouse('left', 'release', '', 0, 2, 22) end) local function wheel(use_api) @@ -901,7 +901,7 @@ describe('ui/mouse/input', function() :vsp | ]]) if use_api then - meths.input_mouse('wheel', 'down', '', 0, 0, 0) + meths.nvim_input_mouse('wheel', 'down', '', 0, 0, 0) else feed('<ScrollWheelDown><0,0>') end @@ -922,7 +922,7 @@ describe('ui/mouse/input', function() :vsp | ]]) if use_api then - meths.input_mouse('wheel', 'up', '', 0, 0, 27) + meths.nvim_input_mouse('wheel', 'up', '', 0, 0, 27) else feed('<ScrollWheelUp><27,0>') end @@ -943,8 +943,8 @@ describe('ui/mouse/input', function() :vsp | ]]) if use_api then - meths.input_mouse('wheel', 'up', '', 0, 7, 27) - meths.input_mouse('wheel', 'up', '', 0, 7, 27) + meths.nvim_input_mouse('wheel', 'up', '', 0, 7, 27) + meths.nvim_input_mouse('wheel', 'up', '', 0, 7, 27) else feed('<ScrollWheelUp><27,7><ScrollWheelUp>') end @@ -1016,7 +1016,7 @@ describe('ui/mouse/input', function() | ]]) - meths.input_mouse('wheel', 'left', '', 0, 0, 27) + meths.nvim_input_mouse('wheel', 'left', '', 0, 0, 27) screen:expect([[ |*2 n bbbbbbbbbbbbbbbbbbb^b | @@ -1025,7 +1025,7 @@ describe('ui/mouse/input', function() ]]) feed('^') - meths.input_mouse('wheel', 'right', '', 0, 0, 0) + meths.nvim_input_mouse('wheel', 'right', '', 0, 0, 0) screen:expect([[ g | | @@ -1048,7 +1048,7 @@ describe('ui/mouse/input', function() | ]]) - meths.input_mouse('wheel', 'right', '', 0, 0, 27) + meths.nvim_input_mouse('wheel', 'right', '', 0, 0, 27) screen:expect([[ g | | @@ -1068,7 +1068,7 @@ describe('ui/mouse/input', function() | ]]) - meths.input_mouse('wheel', 'right', '', 0, 0, 27) + meths.nvim_input_mouse('wheel', 'right', '', 0, 0, 27) screen:expect([[ g | | @@ -1614,30 +1614,30 @@ describe('ui/mouse/input', function() describe('(extmarks)', function() before_each(function() - local ns = meths.create_namespace('conceal') - meths.buf_set_extmark(0, ns, 0, 11, { end_col = 12, conceal = '' }) - meths.buf_set_extmark(0, ns, 0, 14, { end_col = 15, conceal = '' }) - meths.buf_set_extmark(0, ns, 1, 5, { end_col = 6, conceal = '' }) - meths.buf_set_extmark(0, ns, 1, 8, { end_col = 9, conceal = '' }) - meths.buf_set_extmark(0, ns, 1, 10, { end_col = 11, conceal = '' }) - meths.buf_set_extmark(0, ns, 1, 13, { end_col = 14, conceal = '' }) - meths.buf_set_extmark(0, ns, 1, 15, { end_col = 16, conceal = '' }) - meths.buf_set_extmark(0, ns, 1, 18, { end_col = 19, conceal = '' }) - meths.buf_set_extmark(0, ns, 2, 24, { end_col = 25, conceal = '' }) - meths.buf_set_extmark(0, ns, 2, 29, { end_col = 30, conceal = '' }) - meths.buf_set_extmark(0, ns, 2, 25, { end_col = 29, conceal = 'X' }) - meths.buf_set_extmark(0, ns, 2, 0, { end_col = 1, conceal = '>' }) + local ns = meths.nvim_create_namespace('conceal') + meths.nvim_buf_set_extmark(0, ns, 0, 11, { end_col = 12, conceal = '' }) + meths.nvim_buf_set_extmark(0, ns, 0, 14, { end_col = 15, conceal = '' }) + meths.nvim_buf_set_extmark(0, ns, 1, 5, { end_col = 6, conceal = '' }) + meths.nvim_buf_set_extmark(0, ns, 1, 8, { end_col = 9, conceal = '' }) + meths.nvim_buf_set_extmark(0, ns, 1, 10, { end_col = 11, conceal = '' }) + meths.nvim_buf_set_extmark(0, ns, 1, 13, { end_col = 14, conceal = '' }) + meths.nvim_buf_set_extmark(0, ns, 1, 15, { end_col = 16, conceal = '' }) + meths.nvim_buf_set_extmark(0, ns, 1, 18, { end_col = 19, conceal = '' }) + meths.nvim_buf_set_extmark(0, ns, 2, 24, { end_col = 25, conceal = '' }) + meths.nvim_buf_set_extmark(0, ns, 2, 29, { end_col = 30, conceal = '' }) + meths.nvim_buf_set_extmark(0, ns, 2, 25, { end_col = 29, conceal = 'X' }) + meths.nvim_buf_set_extmark(0, ns, 2, 0, { end_col = 1, conceal = '>' }) end) test_mouse_click_conceal() end) end) it('getmousepos() works correctly', function() - local winwidth = meths.get_option_value('winwidth', {}) + local winwidth = meths.nvim_get_option_value('winwidth', {}) -- Set winwidth=1 so that window sizes don't change. - meths.set_option_value('winwidth', 1, {}) + meths.nvim_set_option_value('winwidth', 1, {}) command('tabedit') - local tabpage = meths.get_current_tabpage() + local tabpage = meths.nvim_get_current_tabpage() insert('hello') command('vsplit') local opts = { @@ -1651,18 +1651,18 @@ describe('ui/mouse/input', function() border = 'single', focusable = 1, } - local float = meths.open_win(meths.get_current_buf(), false, opts) + local float = meths.nvim_open_win(meths.nvim_get_current_buf(), false, opts) command('redraw') - local lines = meths.get_option_value('lines', {}) - local columns = meths.get_option_value('columns', {}) + local lines = meths.nvim_get_option_value('lines', {}) + local columns = meths.nvim_get_option_value('columns', {}) -- Test that screenrow and screencol are set properly for all positions. for row = 0, lines - 1 do for col = 0, columns - 1 do -- Skip the X button that would close the tab. if row ~= 0 or col ~= columns - 1 then - meths.input_mouse('left', 'press', '', 0, row, col) - meths.set_current_tabpage(tabpage) + meths.nvim_input_mouse('left', 'press', '', 0, row, col) + meths.nvim_set_current_tabpage(tabpage) local mousepos = funcs.getmousepos() eq(row + 1, mousepos.screenrow) eq(col + 1, mousepos.screencol) @@ -1686,7 +1686,7 @@ describe('ui/mouse/input', function() for win_col = 0, opts.width + 1 do local row = win_row + opts.row local col = win_col + opts.col - meths.input_mouse('left', 'press', '', 0, row, col) + meths.nvim_input_mouse('left', 'press', '', 0, row, col) local mousepos = funcs.getmousepos() eq(float.id, mousepos.winid) eq(win_row + 1, mousepos.winrow) @@ -1715,13 +1715,13 @@ describe('ui/mouse/input', function() -- Test that mouse position values are properly set for the floating -- window, after removing the border. opts.border = 'none' - meths.win_set_config(float, opts) + meths.nvim_win_set_config(float, opts) command('redraw') for win_row = 0, opts.height - 1 do for win_col = 0, opts.width - 1 do local row = win_row + opts.row local col = win_col + opts.col - meths.input_mouse('left', 'press', '', 0, row, col) + meths.nvim_input_mouse('left', 'press', '', 0, row, col) local mousepos = funcs.getmousepos() eq(float.id, mousepos.winid) eq(win_row + 1, mousepos.winrow) @@ -1740,14 +1740,14 @@ describe('ui/mouse/input', function() -- that getmousepos() does not consider unfocusable floats. (see discussion -- in PR #14937 for details). opts.focusable = false - meths.win_set_config(float, opts) + meths.nvim_win_set_config(float, opts) command('redraw') for nr = 1, 2 do for win_row = 0, funcs.winheight(nr) - 1 do for win_col = 0, funcs.winwidth(nr) - 1 do local row = win_row + funcs.win_screenpos(nr)[1] - 1 local col = win_col + funcs.win_screenpos(nr)[2] - 1 - meths.input_mouse('left', 'press', '', 0, row, col) + meths.nvim_input_mouse('left', 'press', '', 0, row, col) local mousepos = funcs.getmousepos() eq(funcs.win_getid(nr), mousepos.winid) eq(win_row + 1, mousepos.winrow) @@ -1764,34 +1764,34 @@ describe('ui/mouse/input', function() -- Restore state and release mouse. command('tabclose!') - meths.set_option_value('winwidth', winwidth, {}) - meths.input_mouse('left', 'release', '', 0, 0, 0) + meths.nvim_set_option_value('winwidth', winwidth, {}) + meths.nvim_input_mouse('left', 'release', '', 0, 0, 0) end) it('scroll keys are not translated into multiclicks and can be mapped #6211 #6989', function() - meths.set_var('mouse_up', 0) - meths.set_var('mouse_up2', 0) + meths.nvim_set_var('mouse_up', 0) + meths.nvim_set_var('mouse_up2', 0) command('nnoremap <ScrollWheelUp> <Cmd>let g:mouse_up += 1<CR>') command('nnoremap <2-ScrollWheelUp> <Cmd>let g:mouse_up2 += 1<CR>') feed('<ScrollWheelUp><0,0>') feed('<ScrollWheelUp><0,0>') - meths.input_mouse('wheel', 'up', '', 0, 0, 0) - meths.input_mouse('wheel', 'up', '', 0, 0, 0) - eq(4, meths.get_var('mouse_up')) - eq(0, meths.get_var('mouse_up2')) + meths.nvim_input_mouse('wheel', 'up', '', 0, 0, 0) + meths.nvim_input_mouse('wheel', 'up', '', 0, 0, 0) + eq(4, meths.nvim_get_var('mouse_up')) + eq(0, meths.nvim_get_var('mouse_up2')) end) it('<MouseMove> is not translated into multiclicks and can be mapped', function() - meths.set_var('mouse_move', 0) - meths.set_var('mouse_move2', 0) + meths.nvim_set_var('mouse_move', 0) + meths.nvim_set_var('mouse_move2', 0) command('nnoremap <MouseMove> <Cmd>let g:mouse_move += 1<CR>') command('nnoremap <2-MouseMove> <Cmd>let g:mouse_move2 += 1<CR>') feed('<MouseMove><0,0>') feed('<MouseMove><0,0>') - meths.input_mouse('move', '', '', 0, 0, 0) - meths.input_mouse('move', '', '', 0, 0, 0) - eq(4, meths.get_var('mouse_move')) - eq(0, meths.get_var('mouse_move2')) + meths.nvim_input_mouse('move', '', '', 0, 0, 0) + meths.nvim_input_mouse('move', '', '', 0, 0, 0) + eq(4, meths.nvim_get_var('mouse_move')) + eq(0, meths.nvim_get_var('mouse_move2')) end) it('feeding <MouseMove> in Normal mode does not use uninitialized memory #19480', function() @@ -1818,102 +1818,102 @@ describe('ui/mouse/input', function() vmenu PopUp.baz y:<C-U>let g:menustr = 'baz'<CR> ]]) - meths.win_set_cursor(0, { 1, 0 }) - meths.input_mouse('right', 'press', '', 0, 0, 4) - meths.input_mouse('right', 'release', '', 0, 0, 4) + meths.nvim_win_set_cursor(0, { 1, 0 }) + meths.nvim_input_mouse('right', 'press', '', 0, 0, 4) + meths.nvim_input_mouse('right', 'release', '', 0, 0, 4) feed('<Down><Down><CR>') - eq('bar', meths.get_var('menustr')) - eq({ 1, 4 }, meths.win_get_cursor(0)) + eq('bar', meths.nvim_get_var('menustr')) + eq({ 1, 4 }, meths.nvim_win_get_cursor(0)) -- Test for right click in visual mode inside the selection funcs.setreg('"', '') - meths.win_set_cursor(0, { 1, 9 }) + meths.nvim_win_set_cursor(0, { 1, 9 }) feed('vee') - meths.input_mouse('right', 'press', '', 0, 0, 11) - meths.input_mouse('right', 'release', '', 0, 0, 11) + meths.nvim_input_mouse('right', 'press', '', 0, 0, 11) + meths.nvim_input_mouse('right', 'release', '', 0, 0, 11) feed('<Down><CR>') - eq({ 1, 9 }, meths.win_get_cursor(0)) + eq({ 1, 9 }, meths.nvim_win_get_cursor(0)) eq('ran away', funcs.getreg('"')) -- Test for right click in visual mode right before the selection funcs.setreg('"', '') - meths.win_set_cursor(0, { 1, 9 }) + meths.nvim_win_set_cursor(0, { 1, 9 }) feed('vee') - meths.input_mouse('right', 'press', '', 0, 0, 8) - meths.input_mouse('right', 'release', '', 0, 0, 8) + meths.nvim_input_mouse('right', 'press', '', 0, 0, 8) + meths.nvim_input_mouse('right', 'release', '', 0, 0, 8) feed('<Down><CR>') - eq({ 1, 8 }, meths.win_get_cursor(0)) + eq({ 1, 8 }, meths.nvim_win_get_cursor(0)) eq('', funcs.getreg('"')) -- Test for right click in visual mode right after the selection funcs.setreg('"', '') - meths.win_set_cursor(0, { 1, 9 }) + meths.nvim_win_set_cursor(0, { 1, 9 }) feed('vee') - meths.input_mouse('right', 'press', '', 0, 0, 17) - meths.input_mouse('right', 'release', '', 0, 0, 17) + meths.nvim_input_mouse('right', 'press', '', 0, 0, 17) + meths.nvim_input_mouse('right', 'release', '', 0, 0, 17) feed('<Down><CR>') - eq({ 1, 17 }, meths.win_get_cursor(0)) + eq({ 1, 17 }, meths.nvim_win_get_cursor(0)) eq('', funcs.getreg('"')) -- Test for right click in block-wise visual mode inside the selection funcs.setreg('"', '') - meths.win_set_cursor(0, { 1, 15 }) + meths.nvim_win_set_cursor(0, { 1, 15 }) feed('<C-V>j3l') - meths.input_mouse('right', 'press', '', 0, 1, 16) - meths.input_mouse('right', 'release', '', 0, 1, 16) + meths.nvim_input_mouse('right', 'press', '', 0, 1, 16) + meths.nvim_input_mouse('right', 'release', '', 0, 1, 16) feed('<Down><CR>') - eq({ 1, 15 }, meths.win_get_cursor(0)) + eq({ 1, 15 }, meths.nvim_win_get_cursor(0)) eq('\0224', funcs.getregtype('"')) -- Test for right click in block-wise visual mode outside the selection funcs.setreg('"', '') - meths.win_set_cursor(0, { 1, 15 }) + meths.nvim_win_set_cursor(0, { 1, 15 }) feed('<C-V>j3l') - meths.input_mouse('right', 'press', '', 0, 1, 1) - meths.input_mouse('right', 'release', '', 0, 1, 1) + meths.nvim_input_mouse('right', 'press', '', 0, 1, 1) + meths.nvim_input_mouse('right', 'release', '', 0, 1, 1) feed('<Down><CR>') - eq({ 2, 1 }, meths.win_get_cursor(0)) + eq({ 2, 1 }, meths.nvim_win_get_cursor(0)) eq('v', funcs.getregtype('"')) eq('', funcs.getreg('"')) -- Test for right click in line-wise visual mode inside the selection funcs.setreg('"', '') - meths.win_set_cursor(0, { 1, 15 }) + meths.nvim_win_set_cursor(0, { 1, 15 }) feed('V') - meths.input_mouse('right', 'press', '', 0, 0, 9) - meths.input_mouse('right', 'release', '', 0, 0, 9) + meths.nvim_input_mouse('right', 'press', '', 0, 0, 9) + meths.nvim_input_mouse('right', 'release', '', 0, 0, 9) feed('<Down><CR>') - eq({ 1, 0 }, meths.win_get_cursor(0)) -- After yanking, the cursor goes to 1,1 + eq({ 1, 0 }, meths.nvim_win_get_cursor(0)) -- After yanking, the cursor goes to 1,1 eq('V', funcs.getregtype('"')) eq(1, #funcs.getreg('"', 1, true)) -- Test for right click in multi-line line-wise visual mode inside the selection funcs.setreg('"', '') - meths.win_set_cursor(0, { 1, 15 }) + meths.nvim_win_set_cursor(0, { 1, 15 }) feed('Vj') - meths.input_mouse('right', 'press', '', 0, 1, 19) - meths.input_mouse('right', 'release', '', 0, 1, 19) + meths.nvim_input_mouse('right', 'press', '', 0, 1, 19) + meths.nvim_input_mouse('right', 'release', '', 0, 1, 19) feed('<Down><CR>') - eq({ 1, 0 }, meths.win_get_cursor(0)) -- After yanking, the cursor goes to 1,1 + eq({ 1, 0 }, meths.nvim_win_get_cursor(0)) -- After yanking, the cursor goes to 1,1 eq('V', funcs.getregtype('"')) eq(2, #funcs.getreg('"', 1, true)) -- Test for right click in line-wise visual mode outside the selection funcs.setreg('"', '') - meths.win_set_cursor(0, { 1, 15 }) + meths.nvim_win_set_cursor(0, { 1, 15 }) feed('V') - meths.input_mouse('right', 'press', '', 0, 1, 9) - meths.input_mouse('right', 'release', '', 0, 1, 9) + meths.nvim_input_mouse('right', 'press', '', 0, 1, 9) + meths.nvim_input_mouse('right', 'release', '', 0, 1, 9) feed('<Down><CR>') - eq({ 2, 9 }, meths.win_get_cursor(0)) + eq({ 2, 9 }, meths.nvim_win_get_cursor(0)) eq('', funcs.getreg('"')) -- Try clicking outside the window funcs.setreg('"', '') - meths.win_set_cursor(0, { 2, 1 }) + meths.nvim_win_set_cursor(0, { 2, 1 }) feed('vee') - meths.input_mouse('right', 'press', '', 0, 6, 1) - meths.input_mouse('right', 'release', '', 0, 6, 1) + meths.nvim_input_mouse('right', 'press', '', 0, 6, 1) + meths.nvim_input_mouse('right', 'release', '', 0, 6, 1) feed('<Down><CR>') eq(2, funcs.winnr()) eq('', funcs.getreg('"')) @@ -1922,12 +1922,12 @@ describe('ui/mouse/input', function() command('wincmd t') command('rightbelow vsplit') funcs.setreg('"', '') - meths.win_set_cursor(0, { 1, 9 }) + meths.nvim_win_set_cursor(0, { 1, 9 }) feed('vee') - meths.input_mouse('right', 'press', '', 0, 0, 52) - meths.input_mouse('right', 'release', '', 0, 0, 52) + meths.nvim_input_mouse('right', 'press', '', 0, 0, 52) + meths.nvim_input_mouse('right', 'release', '', 0, 0, 52) feed('<Down><CR>') - eq({ 1, 9 }, meths.win_get_cursor(0)) + eq({ 1, 9 }, meths.nvim_win_get_cursor(0)) eq('ran away', funcs.getreg('"')) -- Test for right click inside visual selection at bottom of window with winbar @@ -1935,10 +1935,10 @@ describe('ui/mouse/input', function() feed('2yyP') funcs.setreg('"', '') feed('G$vbb') - meths.input_mouse('right', 'press', '', 0, 4, 61) - meths.input_mouse('right', 'release', '', 0, 4, 61) + meths.nvim_input_mouse('right', 'press', '', 0, 4, 61) + meths.nvim_input_mouse('right', 'release', '', 0, 4, 61) feed('<Down><CR>') - eq({ 4, 20 }, meths.win_get_cursor(0)) + eq({ 4, 20 }, meths.nvim_win_get_cursor(0)) eq('the moon', funcs.getreg('"')) end) end) diff --git a/test/functional/ui/multibyte_spec.lua b/test/functional/ui/multibyte_spec.lua index bb65ea4cc4..72bb0b0174 100644 --- a/test/functional/ui/multibyte_spec.lua +++ b/test/functional/ui/multibyte_spec.lua @@ -118,7 +118,7 @@ describe('multibyte rendering', function() it('works with a lot of unicode (zalgo) text', function() screen:try_resize(65, 10) - meths.buf_set_lines( + meths.nvim_buf_set_lines( 0, 0, -1, @@ -156,7 +156,7 @@ describe('multibyte rendering', function() -- nvim will reset the zalgo text^W^W glyph cache if it gets too full. -- this should be exceedingly rare, but fake it to make sure it works - meths._invalidate_glyph_cache() + meths.nvim__invalidate_glyph_cache() screen:expect { grid = [[ ^L̓̉̑̒̌̚ơ̗̌̒̄̀ŕ̈̈̎̐̕è̇̅̄̄̐m̖̟̟̅̄̚ ̛̓̑̆̇̍i̗̟̞̜̅̐p̗̞̜̉̆̕s̟̜̘̍̑̏ū̟̞̎̃̉ḿ̘̙́́̐ ̖̍̌̇̉̚d̞̄̃̒̉̎ò́̌̌̂̐l̞̀̄̆̌̚ȯ̖̞̋̀̐r̓̇̌̃̃̚ ̗̘̀̏̍́s̜̀̎̎̑̕i̟̗̐̄̄̚t̝̎̆̓̐̒ ̘̇̔̓̊̚ȃ̛̟̗̏̅m̜̟̙̞̈̓é̘̞̟̔̆t̝̂̂̈̑̔,̜̜̖̅̄̍ ̛̗̊̓̆̚c̟̍̆̍̈̔ȯ̖̖̝̑̀n̜̟̎̊̃̚s̟̏̇̎̒̚e̙̐̈̓̌̚c̙̍̈̏̅̕ť̇̄̇̆̓e̛̓̌̈̓̈t̟̍̀̉̆̅u̝̞̎̂̄̚r̘̀̅̈̅̐ ̝̞̓́̇̉ã̏̀̆̅̕d̛̆̐̉̆̋ȉ̞̟̍̃̚p̛̜̊̍̂̓ȋ̏̅̃̋̚ṥ̛̏̃̕č̛̞̝̀̂í̗̘̌́̎n̔̎́̒̂̕ǧ̗̜̋̇̂ ̛̜̔̄̎̃ê̛̔̆̇̕l̘̝̏̐̊̏ĩ̛̍̏̏̄t̟̐́̀̐̎,̙̘̍̆̉̐ ̋̂̏̄̌̅s̙̓̌̈́̇e̛̗̋̒̎̏d̜̗̊̍̊̚ | @@ -227,7 +227,7 @@ describe('multibyte rendering', function() -- If we would increase the schar_t size, say from 32 to 64 bytes, we need to extend the -- test text with even more zalgo energy to still touch this edge case. - meths.buf_set_lines(0, 0, -1, true, { 'سلام့̀́̂̃̄̅̆̇̈̉̊̋̌' }) + meths.nvim_buf_set_lines(0, 0, -1, true, { 'سلام့̀́̂̃̄̅̆̇̈̉̊̋̌' }) command('set noarabicshape') screen:expect { diff --git a/test/functional/ui/multigrid_spec.lua b/test/functional/ui/multigrid_spec.lua index 0253b28cd5..094e27e69a 100644 --- a/test/functional/ui/multigrid_spec.lua +++ b/test/functional/ui/multigrid_spec.lua @@ -462,9 +462,9 @@ describe('ext_multigrid', function() end) it("'scroll' option works properly", function() - eq(10, meths.get_option_value('scroll', { win = 0 })) - meths.set_option_value('scroll', 15, { win = 0 }) - eq(15, meths.get_option_value('scroll', { win = 0 })) + eq(10, meths.nvim_get_option_value('scroll', { win = 0 })) + meths.nvim_set_option_value('scroll', 15, { win = 0 }) + eq(15, meths.nvim_get_option_value('scroll', { win = 0 })) end) it('gets written till grid width', function() @@ -592,8 +592,8 @@ describe('ext_multigrid', function() ## grid 3 | ]]} - local float_buf = meths.create_buf(false, false) - meths.open_win(float_buf, false, { + local float_buf = meths.nvim_create_buf(false, false) + meths.nvim_open_win(float_buf, false, { relative = 'win', win = curwin(), bufpos = {0, 1018}, @@ -984,7 +984,7 @@ describe('ext_multigrid', function() | ]]} - meths.input_mouse('left', 'press', '', 2, 0, 5) + meths.nvim_input_mouse('left', 'press', '', 2, 0, 5) screen:expect{grid=[[ ## grid 1 [2:-----------------------------------------------------]|*12 @@ -1020,7 +1020,7 @@ describe('ext_multigrid', function() {1:~ }|*4 ]]} - meths.input_mouse('left', 'press', '', 2, 1, 6) + meths.nvim_input_mouse('left', 'press', '', 2, 1, 6) screen:expect{grid=[[ ## grid 1 [4:-----------------------------------------------------]|*6 @@ -1040,7 +1040,7 @@ describe('ext_multigrid', function() {1:~ }|*4 ]]} - meths.input_mouse('left', 'press', '', 4, 1, 4) + meths.nvim_input_mouse('left', 'press', '', 4, 1, 4) screen:expect{grid=[[ ## grid 1 [4:-----------------------------------------------------]|*6 @@ -1079,7 +1079,7 @@ describe('ext_multigrid', function() {1:~ }| ]]} - meths.input_mouse('left', 'press', '', 4, 0, 64) + meths.nvim_input_mouse('left', 'press', '', 4, 0, 64) screen:expect{grid=[[ ## grid 1 [4:-----------------------------------------------------]|*6 @@ -1099,12 +1099,12 @@ describe('ext_multigrid', function() ]]} -- XXX: mouse_check_grid() doesn't work properly when clicking on grid 1 - meths.input_mouse('left', 'press', '', 1, 6, 20) + meths.nvim_input_mouse('left', 'press', '', 1, 6, 20) -- TODO(bfredl): "batching" input_mouse is formally not supported yet. -- Normally it should work fine in async context when nvim is not blocked, -- but add a poke_eventloop be sure. poke_eventloop() - meths.input_mouse('left', 'drag', '', 1, 4, 20) + meths.nvim_input_mouse('left', 'drag', '', 1, 4, 20) screen:expect{grid=[[ ## grid 1 [4:-----------------------------------------------------]|*4 @@ -1146,9 +1146,9 @@ describe('ext_multigrid', function() {1:~ }|*5 ]]} - meths.input_mouse('left', 'press', '', 1, 8, 26) + meths.nvim_input_mouse('left', 'press', '', 1, 8, 26) poke_eventloop() - meths.input_mouse('left', 'drag', '', 1, 6, 30) + meths.nvim_input_mouse('left', 'drag', '', 1, 6, 30) screen:expect{grid=[[ ## grid 1 [4:-----------------------------------------------------]|*4 @@ -1174,7 +1174,7 @@ describe('ext_multigrid', function() command('aunmenu PopUp | vmenu PopUp.Copy y') funcs.setreg('"', '') - meths.input_mouse('left', 'press', '2', 2, 1, 6) + meths.nvim_input_mouse('left', 'press', '2', 2, 1, 6) screen:expect{grid=[[ ## grid 1 [4:-----------------------------------------------------]|*4 @@ -1196,8 +1196,8 @@ describe('ext_multigrid', function() to be {20:clicked} | {1:~ }|*5 ]]} - meths.input_mouse('right', 'press', '', 2, 1, 6) - meths.input_mouse('right', 'release', '', 2, 1, 6) + meths.nvim_input_mouse('right', 'press', '', 2, 1, 6) + meths.nvim_input_mouse('right', 'release', '', 2, 1, 6) screen:expect{grid=[[ ## grid 1 [4:-----------------------------------------------------]|*4 @@ -1248,7 +1248,7 @@ describe('ext_multigrid', function() eq('clicked', funcs.getreg('"')) funcs.setreg('"', '') - meths.input_mouse('left', 'press', '2', 4, 0, 64) + meths.nvim_input_mouse('left', 'press', '2', 4, 0, 64) screen:expect{grid=[[ ## grid 1 [4:-----------------------------------------------------]|*4 @@ -1270,8 +1270,8 @@ describe('ext_multigrid', function() to be clicked | {1:~ }|*5 ]]} - meths.input_mouse('right', 'press', '', 4, 0, 64) - meths.input_mouse('right', 'release', '', 4, 0, 64) + meths.nvim_input_mouse('right', 'press', '', 4, 0, 64) + meths.nvim_input_mouse('right', 'release', '', 4, 0, 64) screen:expect{grid=[[ ## grid 1 [4:-----------------------------------------------------]|*4 @@ -1354,7 +1354,7 @@ describe('ext_multigrid', function() ]]} funcs.setreg('"', '') - meths.input_mouse('left', 'press', '2', 4, 9, 1) + meths.nvim_input_mouse('left', 'press', '2', 4, 9, 1) screen:expect{grid=[[ ## grid 1 [5:------------------------------]│[2:----------------------]|*5 @@ -1384,8 +1384,8 @@ describe('ext_multigrid', function() to be clicked | {1:~ }|*3 ]]} - meths.input_mouse('right', 'press', '', 4, 9, 1) - meths.input_mouse('right', 'release', '', 4, 9, 1) + meths.nvim_input_mouse('right', 'press', '', 4, 9, 1) + meths.nvim_input_mouse('right', 'release', '', 4, 9, 1) screen:expect{grid=[[ ## grid 1 [5:------------------------------]│[2:----------------------]|*5 @@ -1484,7 +1484,7 @@ describe('ext_multigrid', function() ]]} funcs.setreg('"', '') - meths.input_mouse('left', 'press', '2', 4, 9, 1) + meths.nvim_input_mouse('left', 'press', '2', 4, 9, 1) screen:expect{grid=[[ ## grid 1 [5:------------------------------]│[2:----------------------]|*5 @@ -1515,8 +1515,8 @@ describe('ext_multigrid', function() to be clicked | {1:~ }|*3 ]]} - meths.input_mouse('right', 'press', '', 4, 9, 1) - meths.input_mouse('right', 'release', '', 4, 9, 1) + meths.nvim_input_mouse('right', 'press', '', 4, 9, 1) + meths.nvim_input_mouse('right', 'release', '', 4, 9, 1) screen:expect{grid=[[ ## grid 1 [5:------------------------------]│[2:----------------------]|*5 @@ -1593,9 +1593,9 @@ describe('ext_multigrid', function() command('enew') feed('ifoo\nbar<esc>') - meths.input_mouse('left', 'press', '', 5, 0, 0) + meths.nvim_input_mouse('left', 'press', '', 5, 0, 0) poke_eventloop() - meths.input_mouse('left', 'drag', '', 5, 1, 2) + meths.nvim_input_mouse('left', 'drag', '', 5, 1, 2) screen:expect{grid=[[ ## grid 1 @@ -1752,7 +1752,7 @@ describe('ext_multigrid', function() }} -- handles non-current window - meths.win_set_cursor(1000, {1, 10}) + meths.nvim_win_set_cursor(1000, {1, 10}) screen:expect{grid=[[ ## grid 1 [4:------------------------------------------------]|*3 @@ -2257,9 +2257,9 @@ describe('ext_multigrid', function() [2] = {win = {id = 1000}, topline = 5, botline = 11, curline = 10, curcol = 7, linecount = 11, sum_scroll_delta = 5}, }} - meths.input_mouse('left', 'press', '', 1,5, 1) + meths.nvim_input_mouse('left', 'press', '', 1,5, 1) poke_eventloop() - meths.input_mouse('left', 'drag', '', 1, 6, 1) + meths.nvim_input_mouse('left', 'drag', '', 1, 6, 1) screen:expect{grid=[[ ## grid 1 @@ -2357,7 +2357,7 @@ describe('ext_multigrid', function() end) it('with winbar dragging statusline with mouse works correctly', function() - meths.set_option_value('winbar', 'Set Up The Bars', {}) + meths.nvim_set_option_value('winbar', 'Set Up The Bars', {}) command('split') screen:expect([[ ## grid 1 @@ -2378,9 +2378,9 @@ describe('ext_multigrid', function() {1:~ }|*4 ]]) - meths.input_mouse('left', 'press', '', 1, 6, 20) + meths.nvim_input_mouse('left', 'press', '', 1, 6, 20) poke_eventloop() - meths.input_mouse('left', 'drag', '', 1, 7, 20) + meths.nvim_input_mouse('left', 'drag', '', 1, 7, 20) screen:expect([[ ## grid 1 [4:-----------------------------------------------------]|*7 @@ -2400,7 +2400,7 @@ describe('ext_multigrid', function() {1:~ }|*5 ]]) - meths.input_mouse('left', 'drag', '', 1, 4, 20) + meths.nvim_input_mouse('left', 'drag', '', 1, 4, 20) screen:expect([[ ## grid 1 [4:-----------------------------------------------------]|*4 @@ -2420,9 +2420,9 @@ describe('ext_multigrid', function() {1:~ }|*2 ]]) - meths.input_mouse('left', 'press', '', 1, 12, 10) + meths.nvim_input_mouse('left', 'press', '', 1, 12, 10) poke_eventloop() - meths.input_mouse('left', 'drag', '', 1, 10, 10) + meths.nvim_input_mouse('left', 'drag', '', 1, 10, 10) screen:expect([[ ## grid 1 [4:-----------------------------------------------------]|*4 @@ -2441,9 +2441,9 @@ describe('ext_multigrid', function() ^ | {1:~ }|*2 ]]) - eq(3, meths.get_option_value('cmdheight', {})) + eq(3, meths.nvim_get_option_value('cmdheight', {})) - meths.input_mouse('left', 'drag', '', 1, 12, 10) + meths.nvim_input_mouse('left', 'drag', '', 1, 12, 10) screen:expect([[ ## grid 1 [4:-----------------------------------------------------]|*4 @@ -2462,6 +2462,6 @@ describe('ext_multigrid', function() ^ | {1:~ }|*2 ]]) - eq(1, meths.get_option_value('cmdheight', {})) + eq(1, meths.nvim_get_option_value('cmdheight', {})) end) end) diff --git a/test/functional/ui/popupmenu_spec.lua b/test/functional/ui/popupmenu_spec.lua index 94b4ead434..b4cfe39bc3 100644 --- a/test/functional/ui/popupmenu_spec.lua +++ b/test/functional/ui/popupmenu_spec.lua @@ -117,7 +117,7 @@ describe('ui/ext_popupmenu', function() }, } - meths.select_popupmenu_item(1, false, false, {}) + meths.nvim_select_popupmenu_item(1, false, false, {}) screen:expect { grid = [[ | @@ -132,7 +132,7 @@ describe('ui/ext_popupmenu', function() }, } - meths.select_popupmenu_item(2, true, false, {}) + meths.nvim_select_popupmenu_item(2, true, false, {}) screen:expect { grid = [[ | @@ -147,7 +147,7 @@ describe('ui/ext_popupmenu', function() }, } - meths.select_popupmenu_item(0, true, true, {}) + meths.nvim_select_popupmenu_item(0, true, true, {}) screen:expect([[ | foo^ | @@ -170,7 +170,7 @@ describe('ui/ext_popupmenu', function() }, } - meths.select_popupmenu_item(-1, false, false, {}) + meths.nvim_select_popupmenu_item(-1, false, false, {}) screen:expect { grid = [[ | @@ -185,7 +185,7 @@ describe('ui/ext_popupmenu', function() }, } - meths.select_popupmenu_item(1, true, false, {}) + meths.nvim_select_popupmenu_item(1, true, false, {}) screen:expect { grid = [[ | @@ -200,7 +200,7 @@ describe('ui/ext_popupmenu', function() }, } - meths.select_popupmenu_item(-1, true, false, {}) + meths.nvim_select_popupmenu_item(-1, true, false, {}) screen:expect { grid = [[ | @@ -215,7 +215,7 @@ describe('ui/ext_popupmenu', function() }, } - meths.select_popupmenu_item(0, true, false, {}) + meths.nvim_select_popupmenu_item(0, true, false, {}) screen:expect { grid = [[ | @@ -230,7 +230,7 @@ describe('ui/ext_popupmenu', function() }, } - meths.select_popupmenu_item(-1, true, true, {}) + meths.nvim_select_popupmenu_item(-1, true, true, {}) screen:expect([[ | ^ | @@ -262,7 +262,7 @@ describe('ui/ext_popupmenu', function() }, }) - meths.select_popupmenu_item(-1, true, false, {}) + meths.nvim_select_popupmenu_item(-1, true, false, {}) screen:expect({ grid = [[ |*2 @@ -276,7 +276,7 @@ describe('ui/ext_popupmenu', function() }, }) - meths.select_popupmenu_item(5, true, false, {}) + meths.nvim_select_popupmenu_item(5, true, false, {}) screen:expect({ grid = [[ |*2 @@ -290,7 +290,7 @@ describe('ui/ext_popupmenu', function() }, }) - meths.select_popupmenu_item(-1, true, true, {}) + meths.nvim_select_popupmenu_item(-1, true, true, {}) screen:expect({ grid = [[ |*2 @@ -313,7 +313,7 @@ describe('ui/ext_popupmenu', function() }, }) - meths.select_popupmenu_item(5, true, true, {}) + meths.nvim_select_popupmenu_item(5, true, true, {}) screen:expect({ grid = [[ |*2 @@ -608,7 +608,7 @@ describe('ui/ext_popupmenu', function() } local pum_height = 6 feed('o<C-r>=TestCompleteMonth()<CR>') - meths.ui_pum_set_height(pum_height) + meths.nvim_ui_pum_set_height(pum_height) feed('<PageDown>') -- pos becomes pum_height-2 because it is subtracting 2 to keep some -- context in ins_compl_key2count() @@ -628,14 +628,14 @@ describe('ui/ext_popupmenu', function() end) it('an error occurs if set 0 or less', function() - meths.ui_pum_set_height(1) - eq('Expected pum height > 0', pcall_err(meths.ui_pum_set_height, 0)) + meths.nvim_ui_pum_set_height(1) + eq('Expected pum height > 0', pcall_err(meths.nvim_ui_pum_set_height, 0)) end) it('an error occurs when ext_popupmenu is false', function() - meths.ui_pum_set_height(1) + meths.nvim_ui_pum_set_height(1) screen:set_option('ext_popupmenu', false) - eq('It must support the ext_popupmenu option', pcall_err(meths.ui_pum_set_height, 1)) + eq('It must support the ext_popupmenu option', pcall_err(meths.nvim_ui_pum_set_height, 1)) end) end) @@ -658,9 +658,9 @@ describe('ui/ext_popupmenu', function() } local pum_height = 6 feed('o<C-r>=TestCompleteMonth()<CR>') - meths.ui_pum_set_height(pum_height) + meths.nvim_ui_pum_set_height(pum_height) -- set bounds w h r c - meths.ui_pum_set_bounds(10.5, 5.2, 6.3, 7.4) + meths.nvim_ui_pum_set_bounds(10.5, 5.2, 6.3, 7.4) feed('<PageDown>') -- pos becomes pum_height-2 because it is subtracting 2 to keep some -- context in ins_compl_key2count() @@ -680,23 +680,23 @@ describe('ui/ext_popupmenu', function() end) it('no error occurs if row or col set less than 0', function() - meths.ui_pum_set_bounds(1.0, 1.0, 0.0, 1.5) - meths.ui_pum_set_bounds(1.0, 1.0, -1.0, 0.0) - meths.ui_pum_set_bounds(1.0, 1.0, 0.0, -1.0) + meths.nvim_ui_pum_set_bounds(1.0, 1.0, 0.0, 1.5) + meths.nvim_ui_pum_set_bounds(1.0, 1.0, -1.0, 0.0) + meths.nvim_ui_pum_set_bounds(1.0, 1.0, 0.0, -1.0) end) it('an error occurs if width or height set 0 or less', function() - meths.ui_pum_set_bounds(1.0, 1.0, 0.0, 1.5) - eq('Expected width > 0', pcall_err(meths.ui_pum_set_bounds, 0.0, 1.0, 1.0, 0.0)) - eq('Expected height > 0', pcall_err(meths.ui_pum_set_bounds, 1.0, -1.0, 1.0, 0.0)) + meths.nvim_ui_pum_set_bounds(1.0, 1.0, 0.0, 1.5) + eq('Expected width > 0', pcall_err(meths.nvim_ui_pum_set_bounds, 0.0, 1.0, 1.0, 0.0)) + eq('Expected height > 0', pcall_err(meths.nvim_ui_pum_set_bounds, 1.0, -1.0, 1.0, 0.0)) end) it('an error occurs when ext_popupmenu is false', function() - meths.ui_pum_set_bounds(1.0, 1.0, 0.0, 1.5) + meths.nvim_ui_pum_set_bounds(1.0, 1.0, 0.0, 1.5) screen:set_option('ext_popupmenu', false) eq( 'UI must support the ext_popupmenu option', - pcall_err(meths.ui_pum_set_bounds, 1.0, 1.0, 0.0, 1.5) + pcall_err(meths.nvim_ui_pum_set_bounds, 1.0, 1.0, 0.0, 1.5) ) end) end) @@ -1055,7 +1055,7 @@ describe("builtin popupmenu 'pumblend'", function() {20:-- Keyword Local completion (^N^P) }{21:match 1 of 65} | ]]) - meths.input_mouse('wheel', 'down', '', 0, 9, 40) + meths.nvim_input_mouse('wheel', 'down', '', 0, 9, 40) screen:expect([[ Lorem ipsum d{1:ol}or sit amet, consectetur | adipisicing elit, sed do eiusmod tempor | @@ -2014,7 +2014,7 @@ describe('builtin popupmenu', function() {2:-- Keyword Local completion (^N^P) }{5:match 1 of 65} | ]]) - meths.input_mouse('wheel', 'down', '', 0, 9, 40) + meths.nvim_input_mouse('wheel', 'down', '', 0, 9, 40) screen:expect([[ Est ^ | L{n: sunt }{s: }sit amet, consectetur | @@ -2050,7 +2050,7 @@ describe('builtin popupmenu', function() {2:-- Keyword Local completion (^N^P) }{5:match 1 of 65} | ]]) - meths.input_mouse('wheel', 'up', '', 0, 9, 40) + meths.nvim_input_mouse('wheel', 'up', '', 0, 9, 40) screen:expect([[ Est e^ | L{n: elit } sit amet, consectetur | @@ -2086,7 +2086,7 @@ describe('builtin popupmenu', function() {2:-- Keyword Local completion (^N^P) }{5:match 1 of 65} | ]]) - meths.input_mouse('wheel', 'down', '', 0, 9, 40) + meths.nvim_input_mouse('wheel', 'down', '', 0, 9, 40) screen:expect([[ Est es^ | L{n: esse } sit amet, consectetur | @@ -2140,7 +2140,7 @@ describe('builtin popupmenu', function() {2:-- Keyword Local completion (^N^P) }{5:match 22 of 65} | ]]) - meths.input_mouse('wheel', 'down', '', 0, 9, 40) + meths.nvim_input_mouse('wheel', 'down', '', 0, 9, 40) screen:expect([[ Est eu^ | L{n: elit } sit amet, consectetur | @@ -2663,7 +2663,7 @@ describe('builtin popupmenu', function() {2:-- INSERT --} | ]]) - meths.input_mouse('wheel', 'down', '', 0, 6, 15) + meths.nvim_input_mouse('wheel', 'down', '', 0, 6, 15) screen:expect { grid = [[ xx | @@ -3347,7 +3347,7 @@ describe('builtin popupmenu', function() it('wildoptions=pum with a wrapped line in buffer vim-patch:8.2.4655', function() screen:try_resize(32, 10) - meths.buf_set_lines(0, 0, -1, true, { ('a'):rep(100) }) + meths.nvim_buf_set_lines(0, 0, -1, true, { ('a'):rep(100) }) command('set wildoptions+=pum') feed('$') feed(':sign <Tab>') @@ -3631,7 +3631,7 @@ describe('builtin popupmenu', function() ]]) if multigrid then - meths.input_mouse('right', 'press', '', 2, 0, 4) + meths.nvim_input_mouse('right', 'press', '', 2, 0, 4) screen:expect({ grid = [[ ## grid 1 @@ -3739,10 +3739,10 @@ describe('builtin popupmenu', function() :let g:menustr = 'bar' | ]]) end - eq('bar', meths.get_var('menustr')) + eq('bar', meths.nvim_get_var('menustr')) if multigrid then - meths.input_mouse('right', 'press', '', 2, 2, 20) + meths.nvim_input_mouse('right', 'press', '', 2, 2, 20) screen:expect({ grid = [[ ## grid 1 @@ -3771,7 +3771,7 @@ describe('builtin popupmenu', function() ]]) end if multigrid then - meths.input_mouse('right', 'press', '', 2, 0, 18) + meths.nvim_input_mouse('right', 'press', '', 2, 0, 18) screen:expect { grid = [[ ## grid 1 @@ -3803,7 +3803,7 @@ describe('builtin popupmenu', function() ]]) end if multigrid then - meths.input_mouse('right', 'press', '', 4, 1, 3) + meths.nvim_input_mouse('right', 'press', '', 4, 1, 3) screen:expect({ grid = [[ ## grid 1 @@ -3832,7 +3832,7 @@ describe('builtin popupmenu', function() ]]) end if multigrid then - meths.input_mouse('left', 'press', '', 4, 2, 2) + meths.nvim_input_mouse('left', 'press', '', 4, 2, 2) screen:expect({ grid = [[ ## grid 1 @@ -3853,10 +3853,10 @@ describe('builtin popupmenu', function() :let g:menustr = 'baz' | ]]) end - eq('baz', meths.get_var('menustr')) + eq('baz', meths.nvim_get_var('menustr')) if multigrid then - meths.input_mouse('right', 'press', '', 2, 0, 4) + meths.nvim_input_mouse('right', 'press', '', 2, 0, 4) screen:expect({ grid = [[ ## grid 1 @@ -3886,7 +3886,7 @@ describe('builtin popupmenu', function() ]]) end if multigrid then - meths.input_mouse('right', 'drag', '', 2, 3, 6) + meths.nvim_input_mouse('right', 'drag', '', 2, 3, 6) screen:expect({ grid = [[ ## grid 1 @@ -3916,7 +3916,7 @@ describe('builtin popupmenu', function() ]]) end if multigrid then - meths.input_mouse('right', 'release', '', 2, 1, 6) + meths.nvim_input_mouse('right', 'release', '', 2, 1, 6) screen:expect({ grid = [[ ## grid 1 @@ -3937,11 +3937,11 @@ describe('builtin popupmenu', function() :let g:menustr = 'foo' | ]]) end - eq('foo', meths.get_var('menustr')) + eq('foo', meths.nvim_get_var('menustr')) eq(false, screen.options.mousemoveevent) if multigrid then - meths.input_mouse('right', 'press', '', 2, 0, 4) + meths.nvim_input_mouse('right', 'press', '', 2, 0, 4) screen:expect({ grid = [[ ## grid 1 @@ -3972,7 +3972,7 @@ describe('builtin popupmenu', function() end eq(true, screen.options.mousemoveevent) if multigrid then - meths.input_mouse('move', '', '', 2, 3, 6) + meths.nvim_input_mouse('move', '', '', 2, 3, 6) screen:expect({ grid = [[ ## grid 1 @@ -4003,7 +4003,7 @@ describe('builtin popupmenu', function() end eq(true, screen.options.mousemoveevent) if multigrid then - meths.input_mouse('left', 'press', '', 2, 2, 6) + meths.nvim_input_mouse('left', 'press', '', 2, 2, 6) screen:expect({ grid = [[ ## grid 1 @@ -4025,11 +4025,11 @@ describe('builtin popupmenu', function() ]]) end eq(false, screen.options.mousemoveevent) - eq('bar', meths.get_var('menustr')) + eq('bar', meths.nvim_get_var('menustr')) command('set laststatus=0 | botright split') if multigrid then - meths.input_mouse('right', 'press', '', 5, 1, 20) + meths.nvim_input_mouse('right', 'press', '', 5, 1, 20) screen:expect({ grid = [[ ## grid 1 @@ -4064,7 +4064,7 @@ describe('builtin popupmenu', function() ]]) end if multigrid then - meths.input_mouse('left', 'press', '', 4, 2, 2) + meths.nvim_input_mouse('left', 'press', '', 4, 2, 2) screen:expect({ grid = [[ ## grid 1 @@ -4093,11 +4093,11 @@ describe('builtin popupmenu', function() :let g:menustr = 'baz' | ]]) end - eq('baz', meths.get_var('menustr')) + eq('baz', meths.nvim_get_var('menustr')) command('set winwidth=1 | rightbelow vsplit') if multigrid then - meths.input_mouse('right', 'press', '', 6, 1, 14) + meths.nvim_input_mouse('right', 'press', '', 6, 1, 14) screen:expect({ grid = [[ ## grid 1 @@ -4135,7 +4135,7 @@ describe('builtin popupmenu', function() ]]) end if multigrid then - meths.input_mouse('left', 'press', '', 4, 0, 2) + meths.nvim_input_mouse('left', 'press', '', 4, 0, 2) screen:expect({ grid = [[ ## grid 1 @@ -4167,11 +4167,11 @@ describe('builtin popupmenu', function() :let g:menustr = 'foo' | ]]) end - eq('foo', meths.get_var('menustr')) + eq('foo', meths.nvim_get_var('menustr')) command('setlocal winbar=WINBAR') if multigrid then - meths.input_mouse('right', 'press', '', 6, 1, 14) + meths.nvim_input_mouse('right', 'press', '', 6, 1, 14) screen:expect({ grid = [[ ## grid 1 @@ -4209,7 +4209,7 @@ describe('builtin popupmenu', function() ]]) end if multigrid then - meths.input_mouse('left', 'press', '', 4, 1, 2) + meths.nvim_input_mouse('left', 'press', '', 4, 1, 2) screen:expect({ grid = [[ ## grid 1 @@ -4241,7 +4241,7 @@ describe('builtin popupmenu', function() :let g:menustr = 'bar' | ]]) end - eq('bar', meths.get_var('menustr')) + eq('bar', meths.nvim_get_var('menustr')) end) if not multigrid then diff --git a/test/functional/ui/quickfix_spec.lua b/test/functional/ui/quickfix_spec.lua index 612a2a947d..f8475acb68 100644 --- a/test/functional/ui/quickfix_spec.lua +++ b/test/functional/ui/quickfix_spec.lua @@ -26,7 +26,7 @@ describe('quickfix selection highlight', function() [12] = { foreground = Screen.colors.Brown, background = Screen.colors.Fuchsia }, }) - meths.set_option_value('errorformat', '%m %l', {}) + meths.nvim_set_option_value('errorformat', '%m %l', {}) command('syntax on') command('highlight Search guibg=Green') diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua index 4ee2438f88..3089690f0a 100644 --- a/test/functional/ui/screen_basic_spec.lua +++ b/test/functional/ui/screen_basic_spec.lua @@ -597,7 +597,7 @@ local function screen_tests(linegrid) command([[autocmd VimResized * redrawtabline]]) command([[autocmd VimResized * lua vim.api.nvim_echo({ { 'Hello' } }, false, {})]]) command([[autocmd VimResized * let g:echospace = v:echospace]]) - meths.set_option_value('showtabline', 2, {}) + meths.nvim_set_option_value('showtabline', 2, {}) screen:expect([[ {2: + [No Name] }{3: }| resiz^e | @@ -611,7 +611,7 @@ local function screen_tests(linegrid) {0:~ }|*3 | ]]) - eq(29, meths.get_var('echospace')) + eq(29, meths.nvim_get_var('echospace')) end) it('messages from the same Ex command as resize are visible #22225', function() @@ -779,9 +779,9 @@ it('CTRL-F or CTRL-B scrolls a page after UI attach/resize #20605', function() clear() local screen = Screen.new(100, 100) screen:attach() - eq(100, meths.get_option_value('lines', {})) - eq(99, meths.get_option_value('window', {})) - eq(99, meths.win_get_height(0)) + eq(100, meths.nvim_get_option_value('lines', {})) + eq(99, meths.nvim_get_option_value('window', {})) + eq(99, meths.nvim_win_get_height(0)) feed('1000o<Esc>') eq(903, funcs.line('w0')) feed('<C-B>') @@ -794,9 +794,9 @@ it('CTRL-F or CTRL-B scrolls a page after UI attach/resize #20605', function() eq(903, funcs.line('w0')) feed('G') screen:try_resize(50, 50) - eq(50, meths.get_option_value('lines', {})) - eq(49, meths.get_option_value('window', {})) - eq(49, meths.win_get_height(0)) + eq(50, meths.nvim_get_option_value('lines', {})) + eq(49, meths.nvim_get_option_value('window', {})) + eq(49, meths.nvim_win_get_height(0)) eq(953, funcs.line('w0')) feed('<C-B>') eq(906, funcs.line('w0')) diff --git a/test/functional/ui/sign_spec.lua b/test/functional/ui/sign_spec.lua index 53fa4b6d65..cade21a3e4 100644 --- a/test/functional/ui/sign_spec.lua +++ b/test/functional/ui/sign_spec.lua @@ -423,7 +423,7 @@ describe('Signs', function() {0:~ }|*7 | ]]) - meths.buf_set_extmark(0, meths.create_namespace('test'), 0, 0, { + meths.nvim_buf_set_extmark(0, meths.nvim_create_namespace('test'), 0, 0, { virt_lines = { { { 'VIRT LINES' } } }, virt_lines_above = true, }) @@ -468,7 +468,7 @@ describe('Signs', function() end) it('signcolumn width is updated when removing all signs after deleting lines', function() - meths.buf_set_lines(0, 0, 1, true, { 'a', 'b', 'c', 'd', 'e' }) + meths.nvim_buf_set_lines(0, 0, 1, true, { 'a', 'b', 'c', 'd', 'e' }) exec('sign define piet text=>>') exec('sign place 10001 line=1 name=piet') exec('sign place 10002 line=5 name=piet') @@ -494,7 +494,7 @@ describe('Signs', function() end) it('signcolumn width is updated when removing all signs after inserting lines', function() - meths.buf_set_lines(0, 0, 1, true, { 'a', 'b', 'c', 'd', 'e' }) + meths.nvim_buf_set_lines(0, 0, 1, true, { 'a', 'b', 'c', 'd', 'e' }) exec('sign define piet text=>>') exec('sign place 10001 line=1 name=piet') exec('sign place 10002 line=5 name=piet') diff --git a/test/functional/ui/spell_spec.lua b/test/functional/ui/spell_spec.lua index 13c3b24cc1..c9730cee97 100644 --- a/test/functional/ui/spell_spec.lua +++ b/test/functional/ui/spell_spec.lua @@ -260,7 +260,7 @@ describe("'spell'", function() {6:search hit BOTTOM, continuing at TOP} | ]]) exec('echo ""') - local ns = meths.create_namespace('spell') + local ns = meths.nvim_create_namespace('spell') -- extmark with spell=true enables spell local id = curbufmeths.set_extmark(ns, 1, 4, { end_row = 1, end_col = 10, spell = true }) screen:expect([[ @@ -368,7 +368,7 @@ describe("'spell'", function() syntax match Constant "^.*$" call setline(1, "This is some text without any spell errors.") ]]) - local ns = meths.create_namespace('spell') + local ns = meths.nvim_create_namespace('spell') curbufmeths.set_extmark(ns, 0, 0, { hl_group = 'WarningMsg', end_col = 43 }) screen:expect([[ {6:^This is some text without any spell errors.}| diff --git a/test/functional/ui/statuscolumn_spec.lua b/test/functional/ui/statuscolumn_spec.lua index a27524c9f2..7e0ba85500 100644 --- a/test/functional/ui/statuscolumn_spec.lua +++ b/test/functional/ui/statuscolumn_spec.lua @@ -543,56 +543,60 @@ describe('statuscolumn', function() end) it('clicks work with mousemodel=' .. model, function() - meths.set_option_value('statuscolumn', '%0@MyClickFunc@%=%l%T', {}) - meths.input_mouse('left', 'press', '', 0, 0, 0) + meths.nvim_set_option_value('statuscolumn', '%0@MyClickFunc@%=%l%T', {}) + meths.nvim_input_mouse('left', 'press', '', 0, 0, 0) eq('0 1 l 4', eval('g:testvar')) - meths.input_mouse('left', 'press', '', 0, 0, 0) + meths.nvim_input_mouse('left', 'press', '', 0, 0, 0) eq('0 2 l 4', eval('g:testvar')) - meths.input_mouse('left', 'press', '', 0, 0, 0) + meths.nvim_input_mouse('left', 'press', '', 0, 0, 0) eq('0 3 l 4', eval('g:testvar')) - meths.input_mouse('left', 'press', '', 0, 0, 0) + meths.nvim_input_mouse('left', 'press', '', 0, 0, 0) eq('0 4 l 4', eval('g:testvar')) - meths.input_mouse('right', 'press', '', 0, 3, 0) + meths.nvim_input_mouse('right', 'press', '', 0, 3, 0) eq('0 1 r 7', eval('g:testvar')) - meths.input_mouse('right', 'press', '', 0, 3, 0) + meths.nvim_input_mouse('right', 'press', '', 0, 3, 0) eq('0 2 r 7', eval('g:testvar')) - meths.input_mouse('right', 'press', '', 0, 3, 0) + meths.nvim_input_mouse('right', 'press', '', 0, 3, 0) eq('0 3 r 7', eval('g:testvar')) - meths.input_mouse('right', 'press', '', 0, 3, 0) + meths.nvim_input_mouse('right', 'press', '', 0, 3, 0) eq('0 4 r 7', eval('g:testvar')) command('rightbelow vsplit') - meths.input_mouse('left', 'press', '', 0, 0, 27) + meths.nvim_input_mouse('left', 'press', '', 0, 0, 27) eq('0 1 l 4', eval('g:testvar')) - meths.input_mouse('right', 'press', '', 0, 3, 27) + meths.nvim_input_mouse('right', 'press', '', 0, 3, 27) eq('0 1 r 7', eval('g:testvar')) command('setlocal rightleft') - meths.input_mouse('left', 'press', '', 0, 0, 52) + meths.nvim_input_mouse('left', 'press', '', 0, 0, 52) eq('0 1 l 4', eval('g:testvar')) - meths.input_mouse('right', 'press', '', 0, 3, 52) + meths.nvim_input_mouse('right', 'press', '', 0, 3, 52) eq('0 1 r 7', eval('g:testvar')) command('wincmd H') - meths.input_mouse('left', 'press', '', 0, 0, 25) + meths.nvim_input_mouse('left', 'press', '', 0, 0, 25) eq('0 1 l 4', eval('g:testvar')) - meths.input_mouse('right', 'press', '', 0, 3, 25) + meths.nvim_input_mouse('right', 'press', '', 0, 3, 25) eq('0 1 r 7', eval('g:testvar')) command('close') command('set laststatus=2 winbar=%f') command('let g:testvar = ""') -- Check that winbar click doesn't register as statuscolumn click - meths.input_mouse('right', 'press', '', 0, 0, 0) + meths.nvim_input_mouse('right', 'press', '', 0, 0, 0) eq('', eval('g:testvar')) -- Check that statusline click doesn't register as statuscolumn click - meths.input_mouse('right', 'press', '', 0, 12, 0) + meths.nvim_input_mouse('right', 'press', '', 0, 12, 0) eq('', eval('g:testvar')) -- Check that cmdline click doesn't register as statuscolumn click - meths.input_mouse('right', 'press', '', 0, 13, 0) + meths.nvim_input_mouse('right', 'press', '', 0, 13, 0) eq('', eval('g:testvar')) end) it('clicks and highlights work with control characters', function() - meths.set_option_value('statuscolumn', '\t%#NonText#\1%0@MyClickFunc@\t\1%T\t%##\1', {}) + meths.nvim_set_option_value( + 'statuscolumn', + '\t%#NonText#\1%0@MyClickFunc@\t\1%T\t%##\1', + {} + ) screen:expect { grid = [[ {1:^I}{0:^A^I^A^I}{1:^A}aaaaa |*4 @@ -605,13 +609,13 @@ describe('statuscolumn', function() [1] = { foreground = Screen.colors.Brown }, -- LineNr }, } - meths.input_mouse('right', 'press', '', 0, 4, 3) + meths.nvim_input_mouse('right', 'press', '', 0, 4, 3) eq('', eval('g:testvar')) - meths.input_mouse('left', 'press', '', 0, 5, 8) + meths.nvim_input_mouse('left', 'press', '', 0, 5, 8) eq('', eval('g:testvar')) - meths.input_mouse('right', 'press', '', 0, 6, 4) + meths.nvim_input_mouse('right', 'press', '', 0, 6, 4) eq('0 1 r 10', eval('g:testvar')) - meths.input_mouse('left', 'press', '', 0, 7, 7) + meths.nvim_input_mouse('left', 'press', '', 0, 7, 7) eq('0 1 l 11', eval('g:testvar')) end) @@ -621,7 +625,7 @@ describe('statuscolumn', function() [0] = { foreground = Screen.colors.Brown }, [1] = { background = Screen.colors.Plum1 }, }) - meths.set_option_value('statuscolumn', '%0@MyClickFunc@%l%T', {}) + meths.nvim_set_option_value('statuscolumn', '%0@MyClickFunc@%l%T', {}) exec([[ function! MyClickFunc(minwid, clicks, button, mods) let g:testvar = printf("%d %d %s %d", a:minwid, a:clicks, a:button, getmousepos().line) @@ -630,26 +634,26 @@ describe('statuscolumn', function() endfunction ]]) -- clicking an item does not drag mouse - meths.input_mouse('left', 'press', '', 0, 0, 0) + meths.nvim_input_mouse('left', 'press', '', 0, 0, 0) screen:expect([[ {0:8 }^aaaaa | {1: Echo } | ]]) - meths.input_mouse('left', 'press', '', 0, 1, 5) - meths.input_mouse('left', 'release', '', 0, 1, 5) + meths.nvim_input_mouse('left', 'press', '', 0, 1, 5) + meths.nvim_input_mouse('left', 'release', '', 0, 1, 5) screen:expect([[ {0:8 }^aaaaa | 0 1 l 8 | ]]) command('echo') -- clicking outside to close the menu does not drag mouse - meths.input_mouse('left', 'press', '', 0, 0, 0) + meths.nvim_input_mouse('left', 'press', '', 0, 0, 0) screen:expect([[ {0:8 }^aaaaa | {1: Echo } | ]]) - meths.input_mouse('left', 'press', '', 0, 0, 10) - meths.input_mouse('left', 'release', '', 0, 0, 10) + meths.nvim_input_mouse('left', 'press', '', 0, 0, 10) + meths.nvim_input_mouse('left', 'release', '', 0, 0, 10) screen:expect([[ {0:8 }^aaaaa | | diff --git a/test/functional/ui/statusline_spec.lua b/test/functional/ui/statusline_spec.lua index 7e6d336ff9..2d39312ea2 100644 --- a/test/functional/ui/statusline_spec.lua +++ b/test/functional/ui/statusline_spec.lua @@ -39,31 +39,35 @@ for _, model in ipairs(mousemodels) do end) it('works', function() - meths.set_option_value('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {}) - meths.input_mouse('left', 'press', '', 0, 6, 16) + meths.nvim_set_option_value( + 'statusline', + 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', + {} + ) + meths.nvim_input_mouse('left', 'press', '', 0, 6, 16) eq('', eval('g:testvar')) - meths.input_mouse('right', 'press', '', 0, 6, 29) + meths.nvim_input_mouse('right', 'press', '', 0, 6, 29) eq('', eval('g:testvar')) - meths.input_mouse('left', 'press', '', 0, 6, 17) + meths.nvim_input_mouse('left', 'press', '', 0, 6, 17) eq('0 1 l', eval('g:testvar')) - meths.input_mouse('left', 'press', '', 0, 6, 17) + meths.nvim_input_mouse('left', 'press', '', 0, 6, 17) eq('0 2 l', eval('g:testvar')) - meths.input_mouse('left', 'press', '', 0, 6, 17) + meths.nvim_input_mouse('left', 'press', '', 0, 6, 17) eq('0 3 l', eval('g:testvar')) - meths.input_mouse('left', 'press', '', 0, 6, 17) + meths.nvim_input_mouse('left', 'press', '', 0, 6, 17) eq('0 4 l', eval('g:testvar')) - meths.input_mouse('right', 'press', '', 0, 6, 28) + meths.nvim_input_mouse('right', 'press', '', 0, 6, 28) eq('0 1 r', eval('g:testvar')) - meths.input_mouse('right', 'press', '', 0, 6, 28) + meths.nvim_input_mouse('right', 'press', '', 0, 6, 28) eq('0 2 r', eval('g:testvar')) - meths.input_mouse('right', 'press', '', 0, 6, 28) + meths.nvim_input_mouse('right', 'press', '', 0, 6, 28) eq('0 3 r', eval('g:testvar')) - meths.input_mouse('right', 'press', '', 0, 6, 28) + meths.nvim_input_mouse('right', 'press', '', 0, 6, 28) eq('0 4 r', eval('g:testvar')) end) it('works with control characters and highlight', function() - meths.set_option_value('statusline', '\t%#NonText#\1%0@MyClickFunc@\t\1%T\t%##\1', {}) + meths.nvim_set_option_value('statusline', '\t%#NonText#\1%0@MyClickFunc@\t\1%T\t%##\1', {}) screen:expect { grid = [[ ^ | @@ -72,50 +76,54 @@ for _, model in ipairs(mousemodels) do | ]], } - meths.input_mouse('right', 'press', '', 0, 6, 3) + meths.nvim_input_mouse('right', 'press', '', 0, 6, 3) eq('', eval('g:testvar')) - meths.input_mouse('left', 'press', '', 0, 6, 8) + meths.nvim_input_mouse('left', 'press', '', 0, 6, 8) eq('', eval('g:testvar')) - meths.input_mouse('right', 'press', '', 0, 6, 4) + meths.nvim_input_mouse('right', 'press', '', 0, 6, 4) eq('0 1 r', eval('g:testvar')) - meths.input_mouse('left', 'press', '', 0, 6, 7) + meths.nvim_input_mouse('left', 'press', '', 0, 6, 7) eq('0 1 l', eval('g:testvar')) end) it('works for winbar', function() - meths.set_option_value('winbar', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {}) - meths.input_mouse('left', 'press', '', 0, 0, 17) + meths.nvim_set_option_value('winbar', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {}) + meths.nvim_input_mouse('left', 'press', '', 0, 0, 17) eq('0 1 l', eval('g:testvar')) - meths.input_mouse('right', 'press', '', 0, 0, 17) + meths.nvim_input_mouse('right', 'press', '', 0, 0, 17) eq('0 1 r', eval('g:testvar')) end) it('works for winbar in floating window', function() - meths.open_win( + meths.nvim_open_win( 0, true, { width = 30, height = 4, relative = 'editor', row = 1, col = 5, border = 'single' } ) - meths.set_option_value( + meths.nvim_set_option_value( 'winbar', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', { scope = 'local' } ) - meths.input_mouse('left', 'press', '', 0, 2, 23) + meths.nvim_input_mouse('left', 'press', '', 0, 2, 23) eq('0 1 l', eval('g:testvar')) end) it('works when there are multiple windows', function() command('split') - meths.set_option_value('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {}) - meths.set_option_value('winbar', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {}) - meths.input_mouse('left', 'press', '', 0, 0, 17) + meths.nvim_set_option_value( + 'statusline', + 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', + {} + ) + meths.nvim_set_option_value('winbar', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {}) + meths.nvim_input_mouse('left', 'press', '', 0, 0, 17) eq('0 1 l', eval('g:testvar')) - meths.input_mouse('right', 'press', '', 0, 4, 17) + meths.nvim_input_mouse('right', 'press', '', 0, 4, 17) eq('0 1 r', eval('g:testvar')) - meths.input_mouse('middle', 'press', '', 0, 3, 17) + meths.nvim_input_mouse('middle', 'press', '', 0, 3, 17) eq('0 1 m', eval('g:testvar')) - meths.input_mouse('left', 'press', '', 0, 6, 17) + meths.nvim_input_mouse('left', 'press', '', 0, 6, 17) eq('0 1 l', eval('g:testvar')) end) @@ -125,64 +133,72 @@ for _, model in ipairs(mousemodels) do vim.g.testvar = string.format("%d %d %s", minwid, clicks, button) end ]]) - meths.set_option_value( + meths.nvim_set_option_value( 'statusline', 'Not clicky stuff %0@v:lua.clicky_func@Clicky stuff%T', {} ) - meths.input_mouse('left', 'press', '', 0, 6, 17) + meths.nvim_input_mouse('left', 'press', '', 0, 6, 17) eq('0 1 l', eval('g:testvar')) end) it('ignores unsupported click items', function() command('tabnew | tabprevious') - meths.set_option_value('statusline', '%2TNot clicky stuff%T', {}) - meths.input_mouse('left', 'press', '', 0, 6, 0) - eq(1, meths.get_current_tabpage().id) - meths.set_option_value('statusline', '%2XNot clicky stuff%X', {}) - meths.input_mouse('left', 'press', '', 0, 6, 0) - eq(2, #meths.list_tabpages()) + meths.nvim_set_option_value('statusline', '%2TNot clicky stuff%T', {}) + meths.nvim_input_mouse('left', 'press', '', 0, 6, 0) + eq(1, meths.nvim_get_current_tabpage().id) + meths.nvim_set_option_value('statusline', '%2XNot clicky stuff%X', {}) + meths.nvim_input_mouse('left', 'press', '', 0, 6, 0) + eq(2, #meths.nvim_list_tabpages()) end) it("right click works when statusline isn't focused #18994", function() - meths.set_option_value('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {}) - meths.input_mouse('right', 'press', '', 0, 6, 17) + meths.nvim_set_option_value( + 'statusline', + 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', + {} + ) + meths.nvim_input_mouse('right', 'press', '', 0, 6, 17) eq('0 1 r', eval('g:testvar')) - meths.input_mouse('right', 'press', '', 0, 6, 17) + meths.nvim_input_mouse('right', 'press', '', 0, 6, 17) eq('0 2 r', eval('g:testvar')) end) it('works with modifiers #18994', function() - meths.set_option_value('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {}) + meths.nvim_set_option_value( + 'statusline', + 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', + {} + ) -- Note: alternate between left and right mouse buttons to avoid triggering multiclicks - meths.input_mouse('left', 'press', 'S', 0, 6, 17) + meths.nvim_input_mouse('left', 'press', 'S', 0, 6, 17) eq('0 1 l(s )', eval('g:testvar')) - meths.input_mouse('right', 'press', 'S', 0, 6, 17) + meths.nvim_input_mouse('right', 'press', 'S', 0, 6, 17) eq('0 1 r(s )', eval('g:testvar')) - meths.input_mouse('left', 'press', 'A', 0, 6, 17) + meths.nvim_input_mouse('left', 'press', 'A', 0, 6, 17) eq('0 1 l( a )', eval('g:testvar')) - meths.input_mouse('right', 'press', 'A', 0, 6, 17) + meths.nvim_input_mouse('right', 'press', 'A', 0, 6, 17) eq('0 1 r( a )', eval('g:testvar')) - meths.input_mouse('left', 'press', 'AS', 0, 6, 17) + meths.nvim_input_mouse('left', 'press', 'AS', 0, 6, 17) eq('0 1 l(s a )', eval('g:testvar')) - meths.input_mouse('right', 'press', 'AS', 0, 6, 17) + meths.nvim_input_mouse('right', 'press', 'AS', 0, 6, 17) eq('0 1 r(s a )', eval('g:testvar')) - meths.input_mouse('left', 'press', 'T', 0, 6, 17) + meths.nvim_input_mouse('left', 'press', 'T', 0, 6, 17) eq('0 1 l( m)', eval('g:testvar')) - meths.input_mouse('right', 'press', 'T', 0, 6, 17) + meths.nvim_input_mouse('right', 'press', 'T', 0, 6, 17) eq('0 1 r( m)', eval('g:testvar')) - meths.input_mouse('left', 'press', 'TS', 0, 6, 17) + meths.nvim_input_mouse('left', 'press', 'TS', 0, 6, 17) eq('0 1 l(s m)', eval('g:testvar')) - meths.input_mouse('right', 'press', 'TS', 0, 6, 17) + meths.nvim_input_mouse('right', 'press', 'TS', 0, 6, 17) eq('0 1 r(s m)', eval('g:testvar')) - meths.input_mouse('left', 'press', 'C', 0, 6, 17) + meths.nvim_input_mouse('left', 'press', 'C', 0, 6, 17) eq('0 1 l( c )', eval('g:testvar')) -- <C-RightMouse> is for tag jump end) it('works for global statusline with vertical splits #19186', function() command('set laststatus=3') - meths.set_option_value( + meths.nvim_set_option_value( 'statusline', '%0@MyClickFunc@Clicky stuff%T %= %0@MyClickFunc@Clicky stuff%T', {} @@ -198,15 +214,15 @@ for _, model in ipairs(mousemodels) do } -- clickable area on the right - meths.input_mouse('left', 'press', '', 0, 6, 35) + meths.nvim_input_mouse('left', 'press', '', 0, 6, 35) eq('0 1 l', eval('g:testvar')) - meths.input_mouse('right', 'press', '', 0, 6, 35) + meths.nvim_input_mouse('right', 'press', '', 0, 6, 35) eq('0 1 r', eval('g:testvar')) -- clickable area on the left - meths.input_mouse('left', 'press', '', 0, 6, 5) + meths.nvim_input_mouse('left', 'press', '', 0, 6, 5) eq('0 1 l', eval('g:testvar')) - meths.input_mouse('right', 'press', '', 0, 6, 5) + meths.nvim_input_mouse('right', 'press', '', 0, 6, 5) eq('0 1 r', eval('g:testvar')) end) @@ -214,9 +230,9 @@ for _, model in ipairs(mousemodels) do command([[ let &stl = '%@Test@%T%@MyClickFunc@%=%T%@Test@' ]]) - meths.input_mouse('left', 'press', '', 0, 6, 0) + meths.nvim_input_mouse('left', 'press', '', 0, 6, 0) eq('0 1 l', eval('g:testvar')) - meths.input_mouse('right', 'press', '', 0, 6, 39) + meths.nvim_input_mouse('right', 'press', '', 0, 6, 39) eq('0 1 r', eval('g:testvar')) end) @@ -224,7 +240,7 @@ for _, model in ipairs(mousemodels) do command([[ let &stl = '%@MyClickFunc@foo%X' .. repeat('a', 40) .. '%<t%@Test@bar%X%@Test@baz' ]]) - meths.input_mouse('left', 'press', '', 0, 6, 2) + meths.nvim_input_mouse('left', 'press', '', 0, 6, 2) eq('0 1 l', eval('g:testvar')) end) end) @@ -366,38 +382,38 @@ describe('global statusline', function() end) it('win_move_statusline() can reduce cmdheight to 1', function() - eq(1, meths.get_option_value('cmdheight', {})) + eq(1, meths.nvim_get_option_value('cmdheight', {})) funcs.win_move_statusline(0, -1) - eq(2, meths.get_option_value('cmdheight', {})) + eq(2, meths.nvim_get_option_value('cmdheight', {})) funcs.win_move_statusline(0, -1) - eq(3, meths.get_option_value('cmdheight', {})) + eq(3, meths.nvim_get_option_value('cmdheight', {})) funcs.win_move_statusline(0, 1) - eq(2, meths.get_option_value('cmdheight', {})) + eq(2, meths.nvim_get_option_value('cmdheight', {})) funcs.win_move_statusline(0, 1) - eq(1, meths.get_option_value('cmdheight', {})) + eq(1, meths.nvim_get_option_value('cmdheight', {})) end) it('mouse dragging can reduce cmdheight to 1', function() command('set mouse=a') - meths.input_mouse('left', 'press', '', 0, 14, 10) - eq(1, meths.get_option_value('cmdheight', {})) - meths.input_mouse('left', 'drag', '', 0, 13, 10) - eq(2, meths.get_option_value('cmdheight', {})) - meths.input_mouse('left', 'drag', '', 0, 12, 10) - eq(3, meths.get_option_value('cmdheight', {})) - meths.input_mouse('left', 'drag', '', 0, 13, 10) - eq(2, meths.get_option_value('cmdheight', {})) - meths.input_mouse('left', 'drag', '', 0, 14, 10) - eq(1, meths.get_option_value('cmdheight', {})) - meths.input_mouse('left', 'drag', '', 0, 15, 10) - eq(1, meths.get_option_value('cmdheight', {})) - meths.input_mouse('left', 'drag', '', 0, 14, 10) - eq(1, meths.get_option_value('cmdheight', {})) + meths.nvim_input_mouse('left', 'press', '', 0, 14, 10) + eq(1, meths.nvim_get_option_value('cmdheight', {})) + meths.nvim_input_mouse('left', 'drag', '', 0, 13, 10) + eq(2, meths.nvim_get_option_value('cmdheight', {})) + meths.nvim_input_mouse('left', 'drag', '', 0, 12, 10) + eq(3, meths.nvim_get_option_value('cmdheight', {})) + meths.nvim_input_mouse('left', 'drag', '', 0, 13, 10) + eq(2, meths.nvim_get_option_value('cmdheight', {})) + meths.nvim_input_mouse('left', 'drag', '', 0, 14, 10) + eq(1, meths.nvim_get_option_value('cmdheight', {})) + meths.nvim_input_mouse('left', 'drag', '', 0, 15, 10) + eq(1, meths.nvim_get_option_value('cmdheight', {})) + meths.nvim_input_mouse('left', 'drag', '', 0, 14, 10) + eq(1, meths.nvim_get_option_value('cmdheight', {})) end) it('cmdline row is correct after setting cmdheight #20514', function() command('botright split test/functional/fixtures/bigfile.txt') - meths.set_option_value('cmdheight', 1, {}) + meths.nvim_set_option_value('cmdheight', 1, {}) feed('L') screen:expect([[ | @@ -428,7 +444,7 @@ describe('global statusline', function() {2:test/functional/fixtures/bigfile.txt 8,1 0%}| | ]]) - meths.set_option_value('showtabline', 2, {}) + meths.nvim_set_option_value('showtabline', 2, {}) screen:expect([[ {3: }{5:2}{3: t/f/f/bigfile.txt }{4: }| | @@ -443,7 +459,7 @@ describe('global statusline', function() {2:test/functional/fixtures/bigfile.txt 8,1 0%}| | ]]) - meths.set_option_value('cmdheight', 0, {}) + meths.nvim_set_option_value('cmdheight', 0, {}) screen:expect([[ {3: }{5:2}{3: t/f/f/bigfile.txt }{4: }| | @@ -458,7 +474,7 @@ describe('global statusline', function() ^0007;<control>;Cc;0;BN;;;;;N;BELL;;;; | {2:test/functional/fixtures/bigfile.txt 8,1 0%}| ]]) - meths.set_option_value('cmdheight', 1, {}) + meths.nvim_set_option_value('cmdheight', 1, {}) screen:expect([[ {3: }{5:2}{3: t/f/f/bigfile.txt }{4: }| | @@ -478,8 +494,8 @@ end) it('statusline does not crash if it has Arabic characters #19447', function() clear() - meths.set_option_value('statusline', 'غً', {}) - meths.set_option_value('laststatus', 2, {}) + meths.nvim_set_option_value('statusline', 'غً', {}) + meths.nvim_set_option_value('laststatus', 2, {}) command('redraw!') assert_alive() end) diff --git a/test/functional/ui/tabline_spec.lua b/test/functional/ui/tabline_spec.lua index f270d298cb..9a75e6333b 100644 --- a/test/functional/ui/tabline_spec.lua +++ b/test/functional/ui/tabline_spec.lua @@ -138,7 +138,7 @@ describe('tabline', function() command('tabnew') insert('tab2') command('tabprev') - meths.set_option_value('tabline', '%1T口口%2Ta' .. ('b'):rep(38) .. '%999Xc', {}) + meths.nvim_set_option_value('tabline', '%1T口口%2Ta' .. ('b'):rep(38) .. '%999Xc', {}) screen:expect { grid = [[ {1:<abbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbc }| @@ -148,7 +148,7 @@ describe('tabline', function() ]], } assert_alive() - meths.input_mouse('left', 'press', '', 0, 0, 1) + meths.nvim_input_mouse('left', 'press', '', 0, 0, 1) screen:expect { grid = [[ {1:<abbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbc }| @@ -157,7 +157,7 @@ describe('tabline', function() | ]], } - meths.input_mouse('left', 'press', '', 0, 0, 0) + meths.nvim_input_mouse('left', 'press', '', 0, 0, 0) screen:expect { grid = [[ {1:<abbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbc }| @@ -166,7 +166,7 @@ describe('tabline', function() | ]], } - meths.input_mouse('left', 'press', '', 0, 0, 39) + meths.nvim_input_mouse('left', 'press', '', 0, 0, 39) screen:expect { grid = [[ {1:<abbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbc }| @@ -175,7 +175,7 @@ describe('tabline', function() | ]], } - meths.input_mouse('left', 'press', '', 0, 0, 40) + meths.nvim_input_mouse('left', 'press', '', 0, 0, 40) screen:expect { grid = [[ tab^1 | diff --git a/test/functional/ui/title_spec.lua b/test/functional/ui/title_spec.lua index 6f86b61431..222850ee42 100644 --- a/test/functional/ui/title_spec.lua +++ b/test/functional/ui/title_spec.lua @@ -58,7 +58,7 @@ describe('title', function() end) it('an RPC call to nvim_set_option_value in a hidden buffer', function() - meths.set_option_value('autoindent', true, { buf = buf2 }) + meths.nvim_set_option_value('autoindent', true, { buf = buf2 }) command('redraw!') screen:expect(function() eq(expected, screen.title) @@ -98,7 +98,7 @@ describe('title', function() it('setting the buffer of another window using RPC', function() local oldwin = curwin().id command('split') - meths.win_set_buf(oldwin, buf2) + meths.nvim_win_set_buf(oldwin, buf2) command('redraw!') screen:expect(function() eq(expected, screen.title) @@ -124,7 +124,7 @@ describe('title', function() end) it('creating a floating window using RPC', function() - meths.open_win(buf2, false, { + meths.nvim_open_win(buf2, false, { relative = 'editor', width = 5, height = 5, diff --git a/test/functional/ui/wildmode_spec.lua b/test/functional/ui/wildmode_spec.lua index 749ddf72f8..45eb9222c2 100644 --- a/test/functional/ui/wildmode_spec.lua +++ b/test/functional/ui/wildmode_spec.lua @@ -413,12 +413,12 @@ describe("'wildmenu'", function() } -- Wildcharm? where we are going we aint't no need no wildcharm. - eq(0, meths.get_option_value('wildcharm', {})) + eq(0, meths.nvim_get_option_value('wildcharm', {})) -- Don't mess the defaults yet (neovim is about backwards compatibility) - eq(9, meths.get_option_value('wildchar', {})) + eq(9, meths.nvim_get_option_value('wildchar', {})) -- Lol what is cnoremap? Some say it can define mappings. command 'set wildchar=0' - eq(0, meths.get_option_value('wildchar', {})) + eq(0, meths.nvim_get_option_value('wildchar', {})) command 'cnoremap <f2> <c-z>' feed(':syntax <f2>') @@ -525,9 +525,9 @@ describe('command line completion', function() end) it('does not leak memory with <S-Tab> with wildmenu and only one match #19874', function() - meths.set_option_value('wildmenu', true, {}) - meths.set_option_value('wildmode', 'full', {}) - meths.set_option_value('wildoptions', 'pum', {}) + meths.nvim_set_option_value('wildmenu', true, {}) + meths.nvim_set_option_value('wildmode', 'full', {}) + meths.nvim_set_option_value('wildoptions', 'pum', {}) feed(':sign unpla<S-Tab>') screen:expect([[ @@ -545,8 +545,8 @@ describe('command line completion', function() end) it('does not show matches with <S-Tab> without wildmenu with wildmode=full', function() - meths.set_option_value('wildmenu', false, {}) - meths.set_option_value('wildmode', 'full', {}) + meths.nvim_set_option_value('wildmenu', false, {}) + meths.nvim_set_option_value('wildmode', 'full', {}) feed(':sign <S-Tab>') screen:expect([[ @@ -557,8 +557,8 @@ describe('command line completion', function() end) it('shows matches with <S-Tab> without wildmenu with wildmode=list', function() - meths.set_option_value('wildmenu', false, {}) - meths.set_option_value('wildmode', 'list', {}) + meths.nvim_set_option_value('wildmenu', false, {}) + meths.nvim_set_option_value('wildmode', 'list', {}) feed(':sign <S-Tab>') screen:expect([[ diff --git a/test/functional/ui/winbar_spec.lua b/test/functional/ui/winbar_spec.lua index 502c61a31b..6a09d3a555 100644 --- a/test/functional/ui/winbar_spec.lua +++ b/test/functional/ui/winbar_spec.lua @@ -40,7 +40,7 @@ describe('winbar', function() foreground = Screen.colors.Magenta, }, }) - meths.set_option_value('winbar', 'Set Up The Bars', {}) + meths.nvim_set_option_value('winbar', 'Set Up The Bars', {}) end) it('works', function() @@ -185,7 +185,7 @@ describe('winbar', function() insert [[ just some random text]] - meths.set_option_value('winbar', 'Hello, I am a ruler: %l,%c', {}) + meths.nvim_set_option_value('winbar', 'Hello, I am a ruler: %l,%c', {}) screen:expect { grid = [[ {1:Hello, I am a ruler: 2,11 }| @@ -265,7 +265,7 @@ describe('winbar', function() line sin(theta) line 8]]) - meths.input_mouse('left', 'press', '', 0, 5, 1) + meths.nvim_input_mouse('left', 'press', '', 0, 5, 1) screen:expect([[ {1:Set Up The Bars }| line 1 | @@ -279,9 +279,9 @@ describe('winbar', function() {3:~ }|*3 | ]]) - eq({ 5, 1 }, meths.win_get_cursor(0)) + eq({ 5, 1 }, meths.nvim_win_get_cursor(0)) - meths.input_mouse('left', 'drag', '', 0, 6, 2) + meths.nvim_input_mouse('left', 'drag', '', 0, 6, 2) screen:expect([[ {1:Set Up The Bars }| line 1 | @@ -295,9 +295,9 @@ describe('winbar', function() {3:~ }|*3 {1:-- VISUAL --} | ]]) - eq({ 6, 2 }, meths.win_get_cursor(0)) + eq({ 6, 2 }, meths.nvim_win_get_cursor(0)) - meths.input_mouse('left', 'drag', '', 0, 1, 2) + meths.nvim_input_mouse('left', 'drag', '', 0, 1, 2) screen:expect([[ {1:Set Up The Bars }| li^n{7:e 1} | @@ -311,11 +311,11 @@ describe('winbar', function() {3:~ }|*3 {1:-- VISUAL --} | ]]) - eq({ 1, 2 }, meths.win_get_cursor(0)) + eq({ 1, 2 }, meths.nvim_win_get_cursor(0)) - meths.input_mouse('left', 'drag', '', 0, 0, 2) + meths.nvim_input_mouse('left', 'drag', '', 0, 0, 2) screen:expect_unchanged() - eq({ 1, 2 }, meths.win_get_cursor(0)) + eq({ 1, 2 }, meths.nvim_win_get_cursor(0)) end) it('dragging statusline with mouse works correctly', function() @@ -332,9 +332,9 @@ describe('winbar', function() | ]]) - meths.input_mouse('left', 'press', '', 1, 5, 10) + meths.nvim_input_mouse('left', 'press', '', 1, 5, 10) poke_eventloop() - meths.input_mouse('left', 'drag', '', 1, 6, 10) + meths.nvim_input_mouse('left', 'drag', '', 1, 6, 10) screen:expect([[ {1:Set Up The Bars }| ^ | @@ -347,7 +347,7 @@ describe('winbar', function() | ]]) - meths.input_mouse('left', 'drag', '', 1, 4, 10) + meths.nvim_input_mouse('left', 'drag', '', 1, 4, 10) screen:expect([[ {1:Set Up The Bars }| ^ | @@ -360,9 +360,9 @@ describe('winbar', function() | ]]) - meths.input_mouse('left', 'press', '', 1, 11, 10) + meths.nvim_input_mouse('left', 'press', '', 1, 11, 10) poke_eventloop() - meths.input_mouse('left', 'drag', '', 1, 9, 10) + meths.nvim_input_mouse('left', 'drag', '', 1, 9, 10) screen:expect([[ {1:Set Up The Bars }| ^ | @@ -374,9 +374,9 @@ describe('winbar', function() {2:[No Name] }| |*3 ]]) - eq(3, meths.get_option_value('cmdheight', {})) + eq(3, meths.nvim_get_option_value('cmdheight', {})) - meths.input_mouse('left', 'drag', '', 1, 11, 10) + meths.nvim_input_mouse('left', 'drag', '', 1, 11, 10) screen:expect([[ {1:Set Up The Bars }| ^ | @@ -388,7 +388,7 @@ describe('winbar', function() {2:[No Name] }| | ]]) - eq(1, meths.get_option_value('cmdheight', {})) + eq(1, meths.nvim_get_option_value('cmdheight', {})) end) it('properly equalizes window height for window-local value', function() @@ -413,9 +413,12 @@ describe('winbar', function() end) it('requires window-local value for floating windows', function() - local win = - meths.open_win(0, false, { relative = 'editor', row = 2, col = 10, height = 7, width = 30 }) - meths.set_option_value('winbar', 'bar', {}) + local win = meths.nvim_open_win( + 0, + false, + { relative = 'editor', row = 2, col = 10, height = 7, width = 30 } + ) + meths.nvim_set_option_value('winbar', 'bar', {}) screen:expect { grid = [[ {1:bar }| @@ -426,7 +429,7 @@ describe('winbar', function() | ]], } - meths.set_option_value('winbar', 'floaty bar', { scope = 'local', win = win.id }) + meths.nvim_set_option_value('winbar', 'floaty bar', { scope = 'local', win = win.id }) screen:expect { grid = [[ {1:bar }| @@ -529,7 +532,7 @@ describe('local winbar with tabs', function() [3] = { bold = true, foreground = Screen.colors.Blue }, [4] = { underline = true, background = Screen.colors.LightGray }, }) - meths.set_option_value('winbar', 'foo', { scope = 'local', win = 0 }) + meths.nvim_set_option_value('winbar', 'foo', { scope = 'local', win = 0 }) end) it('works', function() diff --git a/test/functional/vimscript/api_functions_spec.lua b/test/functional/vimscript/api_functions_spec.lua index 05876c43d1..6249dcc363 100644 --- a/test/functional/vimscript/api_functions_spec.lua +++ b/test/functional/vimscript/api_functions_spec.lua @@ -80,20 +80,20 @@ describe('eval-API', function() -- Text-changing functions gave a "Failed to save undo information" error when called from an -- <expr> mapping outside do_cmdline() (msg_list == NULL), so use feed() to test this. command("inoremap <expr> <f2> nvim_buf_set_text(0, 0, 0, 0, 0, ['hi'])") - meths.set_vvar('errmsg', '') + meths.nvim_set_vvar('errmsg', '') feed('i<f2><esc>') eq( 'E5555: API call: E565: Not allowed to change text or change window', - meths.get_vvar('errmsg') + meths.nvim_get_vvar('errmsg') ) -- Some functions checking textlock (usually those that may change the current window or buffer) -- also ought to not be usable in the cmdwin. - local old_win = meths.get_current_win() + local old_win = meths.nvim_get_current_win() feed('q:') eq( 'E11: Invalid in command-line window; <CR> executes, CTRL-C quits', - pcall_err(meths.set_current_win, old_win) + pcall_err(meths.nvim_set_current_win, old_win) ) -- But others, like nvim_buf_set_lines(), which just changes text, is OK. @@ -103,13 +103,13 @@ describe('eval-API', function() -- Turning the cmdwin buffer into a terminal buffer would be pretty weird. eq( 'E11: Invalid in command-line window; <CR> executes, CTRL-C quits', - pcall_err(meths.open_term, 0, {}) + pcall_err(meths.nvim_open_term, 0, {}) ) -- But turning a different buffer into a terminal from the cmdwin is OK. - local term_buf = meths.create_buf(false, true) - meths.open_term(term_buf, {}) - eq('terminal', meths.get_option_value('buftype', { buf = term_buf })) + local term_buf = meths.nvim_create_buf(false, true) + meths.nvim_open_term(term_buf, {}) + eq('terminal', meths.nvim_get_option_value('buftype', { buf = term_buf })) end) it('use buffer numbers and windows ids as handles', function() @@ -207,7 +207,7 @@ describe('eval-API', function() 'Vim(call):E48: Not allowed in sandbox', pcall_err(command, "sandbox call nvim_input('ievil')") ) - eq({ '' }, meths.buf_get_lines(0, 0, -1, true)) + eq({ '' }, meths.nvim_buf_get_lines(0, 0, -1, true)) end) it('converts blobs to API strings', function() diff --git a/test/functional/vimscript/buf_functions_spec.lua b/test/functional/vimscript/buf_functions_spec.lua index 1b722247a8..c93e55df5f 100644 --- a/test/functional/vimscript/buf_functions_spec.lua +++ b/test/functional/vimscript/buf_functions_spec.lua @@ -90,12 +90,12 @@ describe('bufname() function', function() local curdirname = funcs.fnamemodify(wd, ':t') for _, arg in ipairs({ '%', 1, 'X', wd }) do eq(fname, funcs.bufname(arg)) - meths.set_current_dir('..') + meths.nvim_set_current_dir('..') eq(curdirname .. sep .. fname, funcs.bufname(arg)) - meths.set_current_dir(curdirname) - meths.set_current_dir(dirname) + meths.nvim_set_current_dir(curdirname) + meths.nvim_set_current_dir(dirname) eq(wd .. sep .. fname, funcs.bufname(arg)) - meths.set_current_dir('..') + meths.nvim_set_current_dir('..') eq(fname, funcs.bufname(arg)) command('enew') end @@ -172,7 +172,7 @@ describe('bufwinnr() function', function() eq(2, funcs.bufwinnr(fname)) eq(1, funcs.bufwinnr(fname2)) eq(-1, funcs.bufwinnr(fname:sub(1, #fname - 1))) - meths.set_current_dir(dirname) + meths.nvim_set_current_dir(dirname) eq(2, funcs.bufwinnr(fname)) eq(1, funcs.bufwinnr(fname2)) eq(-1, funcs.bufwinnr(fname:sub(1, #fname - 1))) @@ -203,7 +203,7 @@ describe('getbufline() function', function() eq({}, funcs.getbufline(1, -1, 9999)) end) it('returns expected lines', function() - meths.set_option_value('hidden', true, {}) + meths.nvim_set_option_value('hidden', true, {}) command('file ' .. fname) curbufmeths.set_lines(0, 1, false, { 'foo\0', '\0bar', 'baz' }) command('edit ' .. fname2) @@ -284,29 +284,29 @@ describe('setbufvar() function', function() ) end) it('may set options, including window-local and global values', function() - local buf1 = meths.get_current_buf() - eq(false, meths.get_option_value('number', {})) + local buf1 = meths.nvim_get_current_buf() + eq(false, meths.nvim_get_option_value('number', {})) command('split') command('new') eq(2, bufmeths.get_number(curwinmeths.get_buf())) funcs.setbufvar(1, '&number', true) local windows = curtabmeths.list_wins() - eq(false, meths.get_option_value('number', { win = windows[1].id })) - eq(true, meths.get_option_value('number', { win = windows[2].id })) - eq(false, meths.get_option_value('number', { win = windows[3].id })) - eq(false, meths.get_option_value('number', { win = meths.get_current_win().id })) + eq(false, meths.nvim_get_option_value('number', { win = windows[1].id })) + eq(true, meths.nvim_get_option_value('number', { win = windows[2].id })) + eq(false, meths.nvim_get_option_value('number', { win = windows[3].id })) + eq(false, meths.nvim_get_option_value('number', { win = meths.nvim_get_current_win().id })) - eq(true, meths.get_option_value('hidden', {})) + eq(true, meths.nvim_get_option_value('hidden', {})) funcs.setbufvar(1, '&hidden', 0) - eq(false, meths.get_option_value('hidden', {})) + eq(false, meths.nvim_get_option_value('hidden', {})) - eq(false, meths.get_option_value('autoindent', { buf = buf1.id })) + eq(false, meths.nvim_get_option_value('autoindent', { buf = buf1.id })) funcs.setbufvar(1, '&autoindent', true) - eq(true, meths.get_option_value('autoindent', { buf = buf1.id })) + eq(true, meths.nvim_get_option_value('autoindent', { buf = buf1.id })) eq('Vim(call):E355: Unknown option: xxx', exc_exec('call setbufvar(1, "&xxx", 0)')) end) it('may set variables', function() - local buf1 = meths.get_current_buf() + local buf1 = meths.nvim_get_current_buf() command('split') command('new') eq(2, curbufmeths.get_number()) diff --git a/test/functional/vimscript/changedtick_spec.lua b/test/functional/vimscript/changedtick_spec.lua index 1ff580e570..04ebc9cdc9 100644 --- a/test/functional/vimscript/changedtick_spec.lua +++ b/test/functional/vimscript/changedtick_spec.lua @@ -41,7 +41,7 @@ describe('b:changedtick', function() it('is present in b: dictionary', function() eq(2, changedtick()) command('let d = b:') - eq(2, meths.get_var('d').changedtick) + eq(2, meths.nvim_get_var('d').changedtick) end) it('increments at bdel', function() command('new') @@ -142,7 +142,7 @@ describe('b:changedtick', function() end) it('is being completed', function() feed(':echo b:<Tab><Home>let cmdline="<End>"<CR>') - eq('echo b:changedtick', meths.get_var('cmdline')) + eq('echo b:changedtick', meths.nvim_get_var('cmdline')) end) it('cannot be changed by filter() or map()', function() eq(2, changedtick()) diff --git a/test/functional/vimscript/container_functions_spec.lua b/test/functional/vimscript/container_functions_spec.lua index cb5644cf2d..62e6efd7c2 100644 --- a/test/functional/vimscript/container_functions_spec.lua +++ b/test/functional/vimscript/container_functions_spec.lua @@ -9,16 +9,16 @@ before_each(clear) describe('extend()', function() it('succeeds to extend list with itself', function() - meths.set_var('l', { 1, {} }) + meths.nvim_set_var('l', { 1, {} }) eq({ 1, {}, 1, {} }, eval('extend(l, l)')) - eq({ 1, {}, 1, {} }, meths.get_var('l')) + eq({ 1, {}, 1, {} }, meths.nvim_get_var('l')) - meths.set_var('l', { 1, {} }) + meths.nvim_set_var('l', { 1, {} }) eq({ 1, {}, 1, {} }, eval('extend(l, l, 0)')) - eq({ 1, {}, 1, {} }, meths.get_var('l')) + eq({ 1, {}, 1, {} }, meths.nvim_get_var('l')) - meths.set_var('l', { 1, {} }) + meths.nvim_set_var('l', { 1, {} }) eq({ 1, 1, {}, {} }, eval('extend(l, l, 1)')) - eq({ 1, 1, {}, {} }, meths.get_var('l')) + eq({ 1, 1, {}, {} }, meths.nvim_get_var('l')) end) end) diff --git a/test/functional/vimscript/eval_spec.lua b/test/functional/vimscript/eval_spec.lua index da8be7e90c..180e6118fd 100644 --- a/test/functional/vimscript/eval_spec.lua +++ b/test/functional/vimscript/eval_spec.lua @@ -121,7 +121,7 @@ describe('List support code', function() let bl = range(%u) let dur = reltimestr(reltime(rt)) ]]):format(len)) - dur = tonumber(meths.get_var('dur')) + dur = tonumber(meths.nvim_get_var('dur')) if dur >= min_dur then -- print(('Using len %u, dur %g'):format(len, dur)) break @@ -136,7 +136,7 @@ describe('List support code', function() feed('<C-c>') poke_eventloop() command('let t_dur = reltimestr(reltime(t_rt))') - local t_dur = tonumber(meths.get_var('t_dur')) + local t_dur = tonumber(meths.nvim_get_var('t_dur')) if t_dur >= dur / 8 then eq(nil, ('Took too long to cancel: %g >= %g'):format(t_dur, dur / 8)) end @@ -147,7 +147,7 @@ describe('List support code', function() feed('<C-c>') poke_eventloop() command('let t_dur = reltimestr(reltime(t_rt))') - local t_dur = tonumber(meths.get_var('t_dur')) + local t_dur = tonumber(meths.nvim_get_var('t_dur')) print(('t_dur: %g'):format(t_dur)) if t_dur >= dur / 8 then eq(nil, ('Took too long to cancel: %g >= %g'):format(t_dur, dur / 8)) diff --git a/test/functional/vimscript/input_spec.lua b/test/functional/vimscript/input_spec.lua index 52c28869ff..2e1d0501cf 100644 --- a/test/functional/vimscript/input_spec.lua +++ b/test/functional/vimscript/input_spec.lua @@ -110,7 +110,7 @@ describe('input()', function() end) it('allows unequal numeric values when using {opts} dictionary', function() command('echohl Test') - meths.set_var('opts', { prompt = 1, default = 2, cancelreturn = 3 }) + meths.nvim_set_var('opts', { prompt = 1, default = 2, cancelreturn = 3 }) feed([[:echo input(opts)<CR>]]) screen:expect([[ | @@ -132,7 +132,7 @@ describe('input()', function() end) it('works with redraw', function() command('echohl Test') - meths.set_var('opts', { prompt = 'Foo>', default = 'Bar' }) + meths.nvim_set_var('opts', { prompt = 'Foo>', default = 'Bar' }) feed([[:echo inputdialog(opts)<CR>]]) screen:expect([[ | @@ -176,34 +176,34 @@ describe('input()', function() it('supports completion', function() feed(':let var = input("", "", "custom,CustomCompl")<CR>') feed('<Tab><CR>') - eq('TEST', meths.get_var('var')) + eq('TEST', meths.nvim_get_var('var')) feed(':let var = input({"completion": "customlist,CustomListCompl"})<CR>') feed('<Tab><CR>') - eq('FOO', meths.get_var('var')) + eq('FOO', meths.nvim_get_var('var')) end) it('supports cancelreturn', function() feed(':let var = input({"cancelreturn": "BAR"})<CR>') feed('<Esc>') - eq('BAR', meths.get_var('var')) + eq('BAR', meths.nvim_get_var('var')) feed(':let var = input({"cancelreturn": []})<CR>') feed('<Esc>') - eq({}, meths.get_var('var')) + eq({}, meths.nvim_get_var('var')) feed(':let var = input({"cancelreturn": v:false})<CR>') feed('<Esc>') - eq(false, meths.get_var('var')) + eq(false, meths.nvim_get_var('var')) feed(':let var = input({"cancelreturn": v:null})<CR>') feed('<Esc>') - eq(NIL, meths.get_var('var')) + eq(NIL, meths.nvim_get_var('var')) end) it('supports default string', function() feed(':let var = input("", "DEF1")<CR>') feed('<CR>') - eq('DEF1', meths.get_var('var')) + eq('DEF1', meths.nvim_get_var('var')) feed(':let var = input({"default": "DEF2"})<CR>') feed('<CR>') - eq('DEF2', meths.get_var('var')) + eq('DEF2', meths.nvim_get_var('var')) end) it('errors out on invalid inputs', function() eq('Vim(call):E730: Using a List as a String', exc_exec('call input([])')) @@ -292,7 +292,7 @@ describe('inputdialog()', function() end) it('allows unequal numeric values when using {opts} dictionary', function() command('echohl Test') - meths.set_var('opts', { prompt = 1, default = 2, cancelreturn = 3 }) + meths.nvim_set_var('opts', { prompt = 1, default = 2, cancelreturn = 3 }) feed([[:echo input(opts)<CR>]]) screen:expect([[ | @@ -314,7 +314,7 @@ describe('inputdialog()', function() end) it('works with redraw', function() command('echohl Test') - meths.set_var('opts', { prompt = 'Foo>', default = 'Bar' }) + meths.nvim_set_var('opts', { prompt = 'Foo>', default = 'Bar' }) feed([[:echo input(opts)<CR>]]) screen:expect([[ | @@ -358,25 +358,25 @@ describe('inputdialog()', function() it('supports completion', function() feed(':let var = inputdialog({"completion": "customlist,CustomListCompl"})<CR>') feed('<Tab><CR>') - eq('FOO', meths.get_var('var')) + eq('FOO', meths.nvim_get_var('var')) end) it('supports cancelreturn', function() feed(':let var = inputdialog("", "", "CR1")<CR>') feed('<Esc>') - eq('CR1', meths.get_var('var')) + eq('CR1', meths.nvim_get_var('var')) feed(':let var = inputdialog({"cancelreturn": "BAR"})<CR>') feed('<Esc>') - eq('BAR', meths.get_var('var')) + eq('BAR', meths.nvim_get_var('var')) end) it('supports default string', function() feed(':let var = inputdialog("", "DEF1")<CR>') feed('<CR>') - eq('DEF1', meths.get_var('var')) + eq('DEF1', meths.nvim_get_var('var')) feed(':let var = inputdialog({"default": "DEF2"})<CR>') feed('<CR>') - eq('DEF2', meths.get_var('var')) + eq('DEF2', meths.nvim_get_var('var')) end) it('errors out on invalid inputs', function() eq('Vim(call):E730: Using a List as a String', exc_exec('call inputdialog([])')) @@ -409,8 +409,8 @@ end) describe('confirm()', function() -- oldtest: Test_confirm() it('works', function() - meths.set_option_value('more', false, {}) -- Avoid hit-enter prompt - meths.set_option_value('laststatus', 2, {}) + meths.nvim_set_option_value('more', false, {}) -- Avoid hit-enter prompt + meths.nvim_set_option_value('laststatus', 2, {}) -- screen:expect() calls are needed to avoid feeding input too early screen:expect({ any = '%[No Name%]' }) @@ -418,19 +418,19 @@ describe('confirm()', function() screen:expect({ any = '{CONFIRM:.+: }' }) feed('o') screen:expect({ any = '%[No Name%]' }) - eq(1, meths.get_var('a')) + eq(1, meths.nvim_get_var('a')) async_meths.command([[let a = 'Are you sure?'->confirm("&Yes\n&No")]]) screen:expect({ any = '{CONFIRM:.+: }' }) feed('y') screen:expect({ any = '%[No Name%]' }) - eq(1, meths.get_var('a')) + eq(1, meths.nvim_get_var('a')) async_meths.command([[let a = confirm('Are you sure?', "&Yes\n&No")]]) screen:expect({ any = '{CONFIRM:.+: }' }) feed('n') screen:expect({ any = '%[No Name%]' }) - eq(2, meths.get_var('a')) + eq(2, meths.nvim_get_var('a')) -- Not possible to match Vim's CTRL-C test here as CTRL-C always sets got_int in Nvim. @@ -439,26 +439,26 @@ describe('confirm()', function() screen:expect({ any = '{CONFIRM:.+: }' }) feed('<Esc>') screen:expect({ any = '%[No Name%]' }) - eq(0, meths.get_var('a')) + eq(0, meths.nvim_get_var('a')) -- Default choice is returned when pressing <CR>. async_meths.command([[let a = confirm('Are you sure?', "&Yes\n&No")]]) screen:expect({ any = '{CONFIRM:.+: }' }) feed('<CR>') screen:expect({ any = '%[No Name%]' }) - eq(1, meths.get_var('a')) + eq(1, meths.nvim_get_var('a')) async_meths.command([[let a = confirm('Are you sure?', "&Yes\n&No", 2)]]) screen:expect({ any = '{CONFIRM:.+: }' }) feed('<CR>') screen:expect({ any = '%[No Name%]' }) - eq(2, meths.get_var('a')) + eq(2, meths.nvim_get_var('a')) async_meths.command([[let a = confirm('Are you sure?', "&Yes\n&No", 0)]]) screen:expect({ any = '{CONFIRM:.+: }' }) feed('<CR>') screen:expect({ any = '%[No Name%]' }) - eq(0, meths.get_var('a')) + eq(0, meths.nvim_get_var('a')) -- Test with the {type} 4th argument for _, type in ipairs({ 'Error', 'Question', 'Info', 'Warning', 'Generic' }) do @@ -466,7 +466,7 @@ describe('confirm()', function() screen:expect({ any = '{CONFIRM:.+: }' }) feed('y') screen:expect({ any = '%[No Name%]' }) - eq(1, meths.get_var('a')) + eq(1, meths.nvim_get_var('a')) end eq('Vim(call):E730: Using a List as a String', pcall_err(command, 'call confirm([])')) diff --git a/test/functional/vimscript/json_functions_spec.lua b/test/functional/vimscript/json_functions_spec.lua index e469b45b34..8f54cce444 100644 --- a/test/functional/vimscript/json_functions_spec.lua +++ b/test/functional/vimscript/json_functions_spec.lua @@ -494,7 +494,7 @@ describe('json_decode() function', function() end) local sp_decode_eq = function(expected, json) - meths.set_var('__json', json) + meths.nvim_set_var('__json', json) speq(expected, 'json_decode(g:__json)') command('unlet! g:__json') end @@ -892,7 +892,7 @@ describe('json_encode() function', function() end) it('ignores improper values in &isprint', function() - meths.set_option_value('isprint', '1', {}) + meths.nvim_set_option_value('isprint', '1', {}) eq(1, eval('"\1" =~# "\\\\p"')) eq('"\\u0001"', funcs.json_encode('\1')) end) diff --git a/test/functional/vimscript/let_spec.lua b/test/functional/vimscript/let_spec.lua index 6cb52badb6..7c632fc67e 100644 --- a/test/functional/vimscript/let_spec.lua +++ b/test/functional/vimscript/let_spec.lua @@ -15,12 +15,12 @@ before_each(clear) describe(':let', function() it('correctly lists variables with curly-braces', function() - meths.set_var('v', { 0 }) + meths.nvim_set_var('v', { 0 }) eq('v [0]', exec_capture('let {"v"}')) end) it('correctly lists variables with subscript', function() - meths.set_var('v', { 0 }) + meths.nvim_set_var('v', { 0 }) eq('v[0] #0', exec_capture('let v[0]')) eq('g:["v"][0] #0', exec_capture('let g:["v"][0]')) eq('{"g:"}["v"][0] #0', exec_capture('let {"g:"}["v"][0]')) @@ -100,17 +100,17 @@ describe(':let', function() end) it('can apply operator to boolean option', function() - eq(true, meths.get_option_value('equalalways', {})) + eq(true, meths.nvim_get_option_value('equalalways', {})) command('let &equalalways -= 1') - eq(false, meths.get_option_value('equalalways', {})) + eq(false, meths.nvim_get_option_value('equalalways', {})) command('let &equalalways += 1') - eq(true, meths.get_option_value('equalalways', {})) + eq(true, meths.nvim_get_option_value('equalalways', {})) command('let &equalalways *= 1') - eq(true, meths.get_option_value('equalalways', {})) + eq(true, meths.nvim_get_option_value('equalalways', {})) command('let &equalalways /= 1') - eq(true, meths.get_option_value('equalalways', {})) + eq(true, meths.nvim_get_option_value('equalalways', {})) command('let &equalalways %= 1') - eq(false, meths.get_option_value('equalalways', {})) + eq(false, meths.nvim_get_option_value('equalalways', {})) end) end) diff --git a/test/functional/vimscript/map_functions_spec.lua b/test/functional/vimscript/map_functions_spec.lua index b0c4a9747a..e11c8af157 100644 --- a/test/functional/vimscript/map_functions_spec.lua +++ b/test/functional/vimscript/map_functions_spec.lua @@ -181,31 +181,31 @@ describe('mapset()', function() before_each(clear) it('can restore mapping with backslash in lhs', function() - meths.set_keymap('n', '\\ab', 'a', {}) + meths.nvim_set_keymap('n', '\\ab', 'a', {}) eq('\nn \\ab a', exec_capture('nmap \\ab')) local mapargs = funcs.maparg('\\ab', 'n', false, true) - meths.set_keymap('n', '\\ab', 'b', {}) + meths.nvim_set_keymap('n', '\\ab', 'b', {}) eq('\nn \\ab b', exec_capture('nmap \\ab')) funcs.mapset('n', false, mapargs) eq('\nn \\ab a', exec_capture('nmap \\ab')) end) it('can restore mapping description from the dict returned by maparg()', function() - meths.set_keymap('n', 'lhs', 'rhs', { desc = 'map description' }) + meths.nvim_set_keymap('n', 'lhs', 'rhs', { desc = 'map description' }) eq('\nn lhs rhs\n map description', exec_capture('nmap lhs')) local mapargs = funcs.maparg('lhs', 'n', false, true) - meths.set_keymap('n', 'lhs', 'rhs', { desc = 'MAP DESCRIPTION' }) + meths.nvim_set_keymap('n', 'lhs', 'rhs', { desc = 'MAP DESCRIPTION' }) eq('\nn lhs rhs\n MAP DESCRIPTION', exec_capture('nmap lhs')) funcs.mapset('n', false, mapargs) eq('\nn lhs rhs\n map description', exec_capture('nmap lhs')) end) it('can restore "replace_keycodes" from the dict returned by maparg()', function() - meths.set_keymap('i', 'foo', [['<l' .. 't>']], { expr = true, replace_keycodes = true }) + meths.nvim_set_keymap('i', 'foo', [['<l' .. 't>']], { expr = true, replace_keycodes = true }) feed('Afoo') expect('<') local mapargs = funcs.maparg('foo', 'i', false, true) - meths.set_keymap('i', 'foo', [['<l' .. 't>']], { expr = true }) + meths.nvim_set_keymap('i', 'foo', [['<l' .. 't>']], { expr = true }) feed('foo') expect('<<lt>') funcs.mapset('i', false, mapargs) diff --git a/test/functional/vimscript/null_spec.lua b/test/functional/vimscript/null_spec.lua index acdd844aff..efc3c451f8 100644 --- a/test/functional/vimscript/null_spec.lua +++ b/test/functional/vimscript/null_spec.lua @@ -9,15 +9,15 @@ local funcs = helpers.funcs local eq = helpers.eq local function redir_exec(cmd) - meths.set_var('__redir_exec_cmd', cmd) + meths.nvim_set_var('__redir_exec_cmd', cmd) command([[ redir => g:__redir_exec_output silent! execute g:__redir_exec_cmd redir END ]]) - local ret = meths.get_var('__redir_exec_output') - meths.del_var('__redir_exec_output') - meths.del_var('__redir_exec_cmd') + local ret = meths.nvim_get_var('__redir_exec_output') + meths.nvim_del_var('__redir_exec_output') + meths.nvim_del_var('__redir_exec_cmd') return ret end @@ -44,7 +44,7 @@ describe('NULL', function() if val == nil then eq(0, funcs.exists('g:_var')) else - eq(val, meths.get_var('_var')) + eq(val, meths.nvim_get_var('_var')) end if after ~= nil then after() diff --git a/test/functional/vimscript/printf_spec.lua b/test/functional/vimscript/printf_spec.lua index 248a33c92b..f9a7199f11 100644 --- a/test/functional/vimscript/printf_spec.lua +++ b/test/functional/vimscript/printf_spec.lua @@ -65,12 +65,12 @@ describe('printf()', function() local seen_rets = {} -- Collect all args in an array to avoid possible allocation of the same -- address after freeing unreferenced values. - meths.set_var('__args', {}) + meths.nvim_set_var('__args', {}) local function check_printf(expr, is_null) eq(0, exc_exec('call add(__args, ' .. expr .. ')')) eq(0, exc_exec('let __result = printf("%p", __args[-1])')) local id_ret = eval('id(__args[-1])') - eq(id_ret, meths.get_var('__result')) + eq(id_ret, meths.nvim_get_var('__result')) if is_null then if null_ret then eq(null_ret, id_ret) @@ -81,7 +81,7 @@ describe('printf()', function() eq(nil, seen_rets[id_ret]) seen_rets[id_ret] = expr end - meths.del_var('__result') + meths.nvim_del_var('__result') end check_printf('v:_null_list', true) check_printf('v:_null_dict', true) diff --git a/test/functional/vimscript/screenchar_spec.lua b/test/functional/vimscript/screenchar_spec.lua index 5df9c480e8..f24aa87ff4 100644 --- a/test/functional/vimscript/screenchar_spec.lua +++ b/test/functional/vimscript/screenchar_spec.lua @@ -14,15 +14,15 @@ local setup_floating_windows = function() border = 'none', } - local bufnr_1 = meths.create_buf(false, true) - meths.buf_set_lines(bufnr_1, 0, -1, true, { 'aa' }) + local bufnr_1 = meths.nvim_create_buf(false, true) + meths.nvim_buf_set_lines(bufnr_1, 0, -1, true, { 'aa' }) local opts_1 = tbl_deep_extend('force', { row = 0, col = 0, zindex = 11 }, base_opts) - meths.open_win(bufnr_1, false, opts_1) + meths.nvim_open_win(bufnr_1, false, opts_1) - local bufnr_2 = meths.create_buf(false, true) - meths.buf_set_lines(bufnr_2, 0, -1, true, { 'bb' }) + local bufnr_2 = meths.nvim_create_buf(false, true) + meths.nvim_buf_set_lines(bufnr_2, 0, -1, true, { 'bb' }) local opts_2 = tbl_deep_extend('force', { row = 0, col = 1, zindex = 10 }, base_opts) - meths.open_win(bufnr_2, false, opts_2) + meths.nvim_open_win(bufnr_2, false, opts_2) command('redraw') end @@ -32,7 +32,7 @@ describe('screenchar() and family respect floating windows', function() clear() -- These commands result into visible text `aabc`. -- `aab` - from floating windows, `c` - from text in regular window. - meths.buf_set_lines(0, 0, -1, true, { 'cccc' }) + meths.nvim_buf_set_lines(0, 0, -1, true, { 'cccc' }) setup_floating_windows() end) diff --git a/test/functional/vimscript/screenpos_spec.lua b/test/functional/vimscript/screenpos_spec.lua index 934dd1cfe1..7edfcac28b 100644 --- a/test/functional/vimscript/screenpos_spec.lua +++ b/test/functional/vimscript/screenpos_spec.lua @@ -18,33 +18,33 @@ describe('screenpos() function', function() border = 'none', focusable = 1, } - local float = meths.open_win(meths.create_buf(false, true), false, opts) + local float = meths.nvim_open_win(meths.nvim_create_buf(false, true), false, opts) command('redraw') eq({ row = 7, col = 9, endcol = 9, curscol = 9 }, funcs.screenpos(float, 1, 1)) -- only left border opts.border = { '', '', '', '', '', '', '', '|' } - meths.win_set_config(float, opts) + meths.nvim_win_set_config(float, opts) command('redraw') eq({ row = 7, col = 10, endcol = 10, curscol = 10 }, funcs.screenpos(float, 1, 1)) -- only top border opts.border = { '', '_', '', '', '', '', '', '' } - meths.win_set_config(float, opts) + meths.nvim_win_set_config(float, opts) command('redraw') eq({ row = 8, col = 9, endcol = 9, curscol = 9 }, funcs.screenpos(float, 1, 1)) -- both left and top border opts.border = 'single' - meths.win_set_config(float, opts) + meths.nvim_win_set_config(float, opts) command('redraw') eq({ row = 8, col = 10, endcol = 10, curscol = 10 }, funcs.screenpos(float, 1, 1)) end) it('works for folded line with virt_lines attached to line above', function() - meths.buf_set_lines(0, 0, -1, true, { 'aaa', 'bbb', 'ccc', 'ddd' }) - local ns = meths.create_namespace('') - meths.buf_set_extmark( + meths.nvim_buf_set_lines(0, 0, -1, true, { 'aaa', 'bbb', 'ccc', 'ddd' }) + local ns = meths.nvim_create_namespace('') + meths.nvim_buf_set_extmark( 0, ns, 0, diff --git a/test/functional/vimscript/server_spec.lua b/test/functional/vimscript/server_spec.lua index 7b8a98d5fc..9d2bfbafc8 100644 --- a/test/functional/vimscript/server_spec.lua +++ b/test/functional/vimscript/server_spec.lua @@ -52,7 +52,7 @@ describe('server', function() it('sets v:servername at startup or if all servers were stopped', function() clear() - local initial_server = meths.get_vvar('servername') + local initial_server = meths.nvim_get_vvar('servername') assert(initial_server ~= nil and initial_server:len() > 0, 'v:servername was not initialized') -- v:servername is readonly so we cannot unset it--but we can test that it @@ -63,11 +63,11 @@ describe('server', function() -- serverstop() does _not_ modify v:servername... eq(1, funcs.serverstop(s)) - eq(initial_server, meths.get_vvar('servername')) + eq(initial_server, meths.nvim_get_vvar('servername')) -- ...unless we stop _all_ servers. eq(1, funcs.serverstop(funcs.serverlist()[1])) - eq('', meths.get_vvar('servername')) + eq('', meths.nvim_get_vvar('servername')) -- v:servername and $NVIM take the next available server. local servername = ( @@ -75,7 +75,7 @@ describe('server', function() or './Xtest-functional-server-socket' ) funcs.serverstart(servername) - eq(servername, meths.get_vvar('servername')) + eq(servername, meths.nvim_get_vvar('servername')) -- Not set in the current process, only in children. eq('', eval('$NVIM')) end) @@ -185,10 +185,10 @@ describe('startup --listen', function() it('sets v:servername, overrides $NVIM_LISTEN_ADDRESS', function() local addr = (is_os('win') and [[\\.\pipe\Xtest-listen-pipe]] or './Xtest-listen-pipe') clear({ env = { NVIM_LISTEN_ADDRESS = './Xtest-env-pipe' }, args = { '--listen', addr } }) - eq(addr, meths.get_vvar('servername')) + eq(addr, meths.nvim_get_vvar('servername')) -- Address without slashes is a "name" which is appended to a generated path. #8519 clear({ args = { '--listen', 'test-name' } }) - matches([[.*[/\\]test%-name[^/\\]*]], meths.get_vvar('servername')) + matches([[.*[/\\]test%-name[^/\\]*]], meths.nvim_get_vvar('servername')) end) end) diff --git a/test/functional/vimscript/sort_spec.lua b/test/functional/vimscript/sort_spec.lua index ca769b9f16..25242791c2 100644 --- a/test/functional/vimscript/sort_spec.lua +++ b/test/functional/vimscript/sort_spec.lua @@ -21,7 +21,7 @@ describe('sort()', function() end) it('sorts “wrong” values between -0.0001 and 0.0001, preserving order', function() - meths.set_var('list', { + meths.nvim_set_var('list', { true, false, NIL, diff --git a/test/functional/vimscript/special_vars_spec.lua b/test/functional/vimscript/special_vars_spec.lua index 80c3c45561..a76bb78b6f 100644 --- a/test/functional/vimscript/special_vars_spec.lua +++ b/test/functional/vimscript/special_vars_spec.lua @@ -107,8 +107,8 @@ describe('Special values', function() end) it('does not work with +=/-=/.=', function() - meths.set_var('true', true) - meths.set_var('false', false) + meths.nvim_set_var('true', true) + meths.nvim_set_var('false', false) command('let null = v:null') eq('Vim(let):E734: Wrong variable type for +=', exc_exec('let true += 1')) @@ -172,7 +172,7 @@ describe('Special values', function() 'Expected False but got v:null', 'Expected True but got v:false', 'Expected True but got v:null', - }, meths.get_vvar('errors')) + }, meths.nvim_get_vvar('errors')) end) describe('compat', function() diff --git a/test/functional/vimscript/state_spec.lua b/test/functional/vimscript/state_spec.lua index e93989ef80..f9a21c5881 100644 --- a/test/functional/vimscript/state_spec.lua +++ b/test/functional/vimscript/state_spec.lua @@ -12,7 +12,7 @@ before_each(clear) describe('state() function', function() -- oldtest: Test_state() it('works', function() - meths.ui_attach(80, 24, {}) -- Allow hit-enter-prompt + meths.nvim_ui_attach(80, 24, {}) -- Allow hit-enter-prompt exec_lua([[ function _G.Get_state_mode() @@ -48,7 +48,7 @@ describe('state() function', function() -- Halfway a mapping feed([[:call v:lua.Run_timer()<CR>;]]) - meths.get_mode() -- Process pending input and luv timer callback + meths.nvim_get_mode() -- Process pending input and luv timer callback feed(';') eq({ 'mS', 'n' }, exec_lua('return _G.res')) @@ -79,7 +79,7 @@ describe('state() function', function() -- messages scrolled feed([[:call v:lua.Run_timer() | echo "one\ntwo\nthree"<CR>]]) - meths.get_mode() -- Process pending input and luv timer callback + meths.nvim_get_mode() -- Process pending input and luv timer callback feed('<CR>') eq({ 'Ss', 'r' }, exec_lua('return _G.res')) end) diff --git a/test/functional/vimscript/string_spec.lua b/test/functional/vimscript/string_spec.lua index aa93ddb27f..cb63404c00 100644 --- a/test/functional/vimscript/string_spec.lua +++ b/test/functional/vimscript/string_spec.lua @@ -161,7 +161,7 @@ describe('string() function', function() end) it('does not crash or halt when dumping partials with reference cycles in self', function() - meths.set_var('d', { v = true }) + meths.nvim_set_var('d', { v = true }) eq( [[Vim(echo):E724: unable to correctly dump variable with self-referencing container]], pcall_err(command, 'echo string(extend(extend(g:d, {"f": g:Test2_f}), {"p": g:d.f}))') @@ -186,7 +186,7 @@ describe('string() function', function() end) it('does not crash or halt when dumping partials with reference cycles in arguments', function() - meths.set_var('l', {}) + meths.nvim_set_var('l', {}) eval('add(l, l)') -- Regression: the below line used to crash (add returns original list and -- there was error in dumping partials). Tested explicitly in @@ -201,8 +201,8 @@ describe('string() function', function() it( 'does not crash or halt when dumping partials with reference cycles in self and arguments', function() - meths.set_var('d', { v = true }) - meths.set_var('l', {}) + meths.nvim_set_var('d', { v = true }) + meths.nvim_set_var('l', {}) eval('add(l, l)') eval('add(l, function("Test1", l))') eval('add(l, function("Test1", d))') @@ -231,7 +231,7 @@ describe('string() function', function() end) it('errors when dumping recursive lists', function() - meths.set_var('l', {}) + meths.nvim_set_var('l', {}) eval('add(l, l)') eq( 'Vim(echo):E724: unable to correctly dump variable with self-referencing container', @@ -240,7 +240,7 @@ describe('string() function', function() end) it('dumps recursive lists despite the error', function() - meths.set_var('l', {}) + meths.nvim_set_var('l', {}) eval('add(l, l)') eq( 'Vim(echo):E724: unable to correctly dump variable with self-referencing container', @@ -270,7 +270,7 @@ describe('string() function', function() end) it('errors when dumping recursive dictionaries', function() - meths.set_var('d', { d = 1 }) + meths.nvim_set_var('d', { d = 1 }) eval('extend(d, {"d": d})') eq( 'Vim(echo):E724: unable to correctly dump variable with self-referencing container', @@ -279,7 +279,7 @@ describe('string() function', function() end) it('dumps recursive dictionaries despite the error', function() - meths.set_var('d', { d = 1 }) + meths.nvim_set_var('d', { d = 1 }) eval('extend(d, {"d": d})') eq( 'Vim(echo):E724: unable to correctly dump variable with self-referencing container', diff --git a/test/functional/vimscript/writefile_spec.lua b/test/functional/vimscript/writefile_spec.lua index f03baa6ddd..4de542f293 100644 --- a/test/functional/vimscript/writefile_spec.lua +++ b/test/functional/vimscript/writefile_spec.lua @@ -100,7 +100,7 @@ describe('writefile()', function() end) it('shows correct file name when supplied numbers', function() - meths.set_current_dir(dname) + meths.nvim_set_current_dir(dname) eq( "Vim(call):E482: Can't open file 2 for writing: illegal operation on a directory", pcall_err(command, ('call writefile([42], %s)'):format(ddname_tail)) |