aboutsummaryrefslogtreecommitdiff
path: root/test/functional/plugin
diff options
context:
space:
mode:
authorLewis Russell <lewis6991@gmail.com>2024-01-12 19:40:58 +0000
committerGitHub <noreply@github.com>2024-01-12 19:40:58 +0000
commit07a7c0ec999102f223a6aca17e93d33e18c02b94 (patch)
tree221ea513b45596f8e63035955494167fc20bf826 /test/functional/plugin
parent7f249936a989dbc21ad03e394197afc07cb9c0bf (diff)
parent795f896a5772d5e0795f86642bdf90c82efac45c (diff)
downloadrneovim-07a7c0ec999102f223a6aca17e93d33e18c02b94.tar.gz
rneovim-07a7c0ec999102f223a6aca17e93d33e18c02b94.tar.bz2
rneovim-07a7c0ec999102f223a6aca17e93d33e18c02b94.zip
Merge pull request #26994 from lewis6991/vimhelpers
test: big cleanup
Diffstat (limited to 'test/functional/plugin')
-rw-r--r--test/functional/plugin/cfilter_spec.lua18
-rw-r--r--test/functional/plugin/editorconfig_spec.lua16
-rw-r--r--test/functional/plugin/health_spec.lua2
-rw-r--r--test/functional/plugin/lsp/helpers.lua2
-rw-r--r--test/functional/plugin/lsp/incremental_sync_spec.lua4
-rw-r--r--test/functional/plugin/lsp_spec.lua159
-rw-r--r--test/functional/plugin/man_spec.lua10
-rw-r--r--test/functional/plugin/matchparen_spec.lua4
-rw-r--r--test/functional/plugin/msgpack_spec.lua22
-rw-r--r--test/functional/plugin/shada_spec.lua109
10 files changed, 170 insertions, 176 deletions
diff --git a/test/functional/plugin/cfilter_spec.lua b/test/functional/plugin/cfilter_spec.lua
index 8b1e75b495..37261d59df 100644
--- a/test/functional/plugin/cfilter_spec.lua
+++ b/test/functional/plugin/cfilter_spec.lua
@@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
local command = helpers.command
local eq = helpers.eq
-local funcs = helpers.funcs
+local fn = helpers.fn
describe('cfilter.lua', function()
before_each(function()
@@ -13,16 +13,16 @@ describe('cfilter.lua', function()
for _, list in ipairs({
{
name = 'Cfilter',
- get = funcs.getqflist,
- set = funcs.setqflist,
+ get = fn.getqflist,
+ set = fn.setqflist,
},
{
name = 'Lfilter',
get = function()
- return funcs.getloclist(0)
+ return fn.getloclist(0)
end,
set = function(items)
- return funcs.setloclist(0, items)
+ return fn.setloclist(0, items)
end,
},
}) do
@@ -39,7 +39,7 @@ describe('cfilter.lua', function()
describe((':%s'):format(list.name), function()
it('does not error on empty list', function()
filter('nothing')
- eq({}, funcs.getqflist())
+ eq({}, fn.getqflist())
end)
it('requires an argument', function()
@@ -66,7 +66,7 @@ describe('cfilter.lua', function()
end
local toname = function(qflist)
- return funcs.map(qflist, 'v:val.text')
+ return fn.map(qflist, 'v:val.text')
end
test('filters with no matches', 'does not match', {})
@@ -83,7 +83,7 @@ describe('cfilter.lua', function()
{ filename = 'foo', lnum = 3, text = 'zed' },
})
- funcs.setreg('/', 'ba')
+ fn.setreg('/', 'ba')
filter('/')
eq({ 'bar', 'baz' }, toname(list.get()))
@@ -96,7 +96,7 @@ describe('cfilter.lua', function()
{ filename = 'foo', lnum = 3, text = 'zed' },
})
- funcs.setreg('/', 'ba')
+ fn.setreg('/', 'ba')
filter('/', true)
eq({ 'zed' }, toname(list.get()))
diff --git a/test/functional/plugin/editorconfig_spec.lua b/test/functional/plugin/editorconfig_spec.lua
index 2c9ce7ae1a..115c28fbf6 100644
--- a/test/functional/plugin/editorconfig_spec.lua
+++ b/test/functional/plugin/editorconfig_spec.lua
@@ -3,8 +3,8 @@ local clear = helpers.clear
local command = helpers.command
local eq = helpers.eq
local pathsep = helpers.get_pathsep()
-local funcs = helpers.funcs
-local meths = helpers.meths
+local fn = helpers.fn
+local api = helpers.api
local exec_lua = helpers.exec_lua
local testdir = 'Xtest-editorconfig'
@@ -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, api.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, {})
+ api.nvim_set_var('editorconfig', false)
+ api.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, {})
- local bufnr = funcs.bufadd(testdir .. pathsep .. '3_space.txt')
- meths.buf_set_var(bufnr, 'editorconfig', false)
+ api.nvim_set_option_value('shiftwidth', 42, {})
+ local bufnr = fn.bufadd(testdir .. pathsep .. '3_space.txt')
+ api.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/health_spec.lua b/test/functional/plugin/health_spec.lua
index f08f207d39..8564ec7c9b 100644
--- a/test/functional/plugin/health_spec.lua
+++ b/test/functional/plugin/health_spec.lua
@@ -5,7 +5,7 @@ local clear = helpers.clear
local curbuf_contents = helpers.curbuf_contents
local command = helpers.command
local eq, neq, matches = helpers.eq, helpers.neq, helpers.matches
-local getcompletion = helpers.funcs.getcompletion
+local getcompletion = helpers.fn.getcompletion
local insert = helpers.insert
local source = helpers.source
local exec_lua = helpers.exec_lua
diff --git a/test/functional/plugin/lsp/helpers.lua b/test/functional/plugin/lsp/helpers.lua
index f641b42727..97fa108500 100644
--- a/test/functional/plugin/lsp/helpers.lua
+++ b/test/functional/plugin/lsp/helpers.lua
@@ -4,7 +4,7 @@ local clear = helpers.clear
local exec_lua = helpers.exec_lua
local run = helpers.run
local stop = helpers.stop
-local NIL = helpers.NIL
+local NIL = vim.NIL
local M = {}
diff --git a/test/functional/plugin/lsp/incremental_sync_spec.lua b/test/functional/plugin/lsp/incremental_sync_spec.lua
index 9b33f4451e..bd1842ceb5 100644
--- a/test/functional/plugin/lsp/incremental_sync_spec.lua
+++ b/test/functional/plugin/lsp/incremental_sync_spec.lua
@@ -1,7 +1,7 @@
-- Test suite for testing interactions with the incremental sync algorithms powering the LSP client
local helpers = require('test.functional.helpers')(after_each)
-local meths = helpers.meths
+local api = helpers.api
local clear = helpers.clear
local eq = helpers.eq
local exec_lua = helpers.exec_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)
+ api.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 86b9be79e0..252931eccb 100644
--- a/test/functional/plugin/lsp_spec.lua
+++ b/test/functional/plugin/lsp_spec.lua
@@ -11,19 +11,20 @@ local eq = helpers.eq
local eval = helpers.eval
local matches = helpers.matches
local pcall_err = helpers.pcall_err
-local pesc = helpers.pesc
+local pesc = vim.pesc
local insert = helpers.insert
-local funcs = helpers.funcs
+local fn = helpers.fn
local retry = helpers.retry
local stop = helpers.stop
-local NIL = helpers.NIL
+local NIL = vim.NIL
local read_file = require('test.helpers').read_file
local write_file = require('test.helpers').write_file
local is_ci = helpers.is_ci
-local meths = helpers.meths
+local api = helpers.api
local is_os = helpers.is_os
local skip = helpers.skip
local mkdir = helpers.mkdir
+local tmpname = helpers.tmpname
local clear_notrace = lsp_helpers.clear_notrace
local create_server_definition = lsp_helpers.create_server_definition
@@ -362,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', api.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', api.nvim_get_var('lsp_detached'))
client.stop()
end
end,
@@ -728,8 +729,8 @@ describe('LSP', function()
on_handler = function(err, result, ctx)
eq(table.remove(expected_handlers), { err, result, ctx }, 'expected handler')
if ctx.method == 'start' then
- local tmpfile_old = helpers.tmpname()
- local tmpfile_new = helpers.tmpname()
+ local tmpfile_old = tmpname()
+ local tmpfile_new = tmpname()
os.remove(tmpfile_new)
exec_lua(
[=[
@@ -1876,7 +1877,7 @@ describe('LSP', function()
describe('cursor position', function()
it("don't fix the cursor if the range contains the cursor", function()
- funcs.nvim_win_set_cursor(0, { 2, 6 })
+ fn.nvim_win_set_cursor(0, { 2, 6 })
local edits = {
make_edit(1, 0, 1, 19, 'Second line of text'),
}
@@ -1888,11 +1889,11 @@ describe('LSP', function()
'Fourth line of text',
'å å ɧ 汉语 ↥ 🤦 🦄',
}, buf_lines(1))
- eq({ 2, 6 }, funcs.nvim_win_get_cursor(0))
+ eq({ 2, 6 }, fn.nvim_win_get_cursor(0))
end)
it('fix the cursor to the valid col if the content was removed', function()
- funcs.nvim_win_set_cursor(0, { 2, 6 })
+ fn.nvim_win_set_cursor(0, { 2, 6 })
local edits = {
make_edit(1, 0, 1, 6, ''),
make_edit(1, 6, 1, 19, ''),
@@ -1905,11 +1906,11 @@ describe('LSP', function()
'Fourth line of text',
'å å ɧ 汉语 ↥ 🤦 🦄',
}, buf_lines(1))
- eq({ 2, 0 }, funcs.nvim_win_get_cursor(0))
+ eq({ 2, 0 }, fn.nvim_win_get_cursor(0))
end)
it('fix the cursor to the valid row if the content was removed', function()
- funcs.nvim_win_set_cursor(0, { 2, 6 })
+ fn.nvim_win_set_cursor(0, { 2, 6 })
local edits = {
make_edit(1, 0, 1, 6, ''),
make_edit(0, 18, 5, 0, ''),
@@ -1918,11 +1919,11 @@ describe('LSP', function()
eq({
'First line of text',
}, buf_lines(1))
- eq({ 1, 17 }, funcs.nvim_win_get_cursor(0))
+ eq({ 1, 17 }, fn.nvim_win_get_cursor(0))
end)
it('fix the cursor row', function()
- funcs.nvim_win_set_cursor(0, { 3, 0 })
+ fn.nvim_win_set_cursor(0, { 3, 0 })
local edits = {
make_edit(1, 0, 2, 0, ''),
}
@@ -1933,14 +1934,14 @@ describe('LSP', function()
'Fourth line of text',
'å å ɧ 汉语 ↥ 🤦 🦄',
}, buf_lines(1))
- eq({ 2, 0 }, funcs.nvim_win_get_cursor(0))
+ eq({ 2, 0 }, fn.nvim_win_get_cursor(0))
end)
it('fix the cursor col', function()
-- append empty last line. See #22636
exec_lua('vim.api.nvim_buf_set_lines(...)', 1, -1, -1, true, { '' })
- funcs.nvim_win_set_cursor(0, { 2, 11 })
+ fn.nvim_win_set_cursor(0, { 2, 11 })
local edits = {
make_edit(1, 7, 1, 11, ''),
}
@@ -1953,11 +1954,11 @@ describe('LSP', function()
'å å ɧ 汉语 ↥ 🤦 🦄',
'',
}, buf_lines(1))
- eq({ 2, 7 }, funcs.nvim_win_get_cursor(0))
+ eq({ 2, 7 }, fn.nvim_win_get_cursor(0))
end)
it('fix the cursor row and col', function()
- funcs.nvim_win_set_cursor(0, { 2, 12 })
+ fn.nvim_win_set_cursor(0, { 2, 12 })
local edits = {
make_edit(0, 11, 1, 12, ''),
}
@@ -1968,7 +1969,7 @@ describe('LSP', function()
'Fourth line of text',
'å å ɧ 汉语 ↥ 🤦 🦄',
}, buf_lines(1))
- eq({ 1, 11 }, funcs.nvim_win_get_cursor(0))
+ eq({ 1, 11 }, fn.nvim_win_get_cursor(0))
end)
end)
@@ -2278,7 +2279,7 @@ describe('LSP', function()
)
end)
it('Supports file creation with CreateFile payload', function()
- local tmpfile = helpers.tmpname()
+ local tmpfile = tmpname()
os.remove(tmpfile) -- Should not exist, only interested in a tmpname
local uri = exec_lua('return vim.uri_from_fname(...)', tmpfile)
local edit = {
@@ -2295,7 +2296,7 @@ describe('LSP', function()
it(
'Supports file creation in folder that needs to be created with CreateFile payload',
function()
- local tmpfile = helpers.tmpname()
+ local tmpfile = tmpname()
os.remove(tmpfile) -- Should not exist, only interested in a tmpname
tmpfile = tmpfile .. '/dummy/x/'
local uri = exec_lua('return vim.uri_from_fname(...)', tmpfile)
@@ -2312,7 +2313,7 @@ describe('LSP', function()
end
)
it('createFile does not touch file if it exists and ignoreIfExists is set', function()
- local tmpfile = helpers.tmpname()
+ local tmpfile = tmpname()
write_file(tmpfile, 'Dummy content')
local uri = exec_lua('return vim.uri_from_fname(...)', tmpfile)
local edit = {
@@ -2331,7 +2332,7 @@ describe('LSP', function()
eq('Dummy content', read_file(tmpfile))
end)
it('createFile overrides file if overwrite is set', function()
- local tmpfile = helpers.tmpname()
+ local tmpfile = tmpname()
write_file(tmpfile, 'Dummy content')
local uri = exec_lua('return vim.uri_from_fname(...)', tmpfile)
local edit = {
@@ -2351,7 +2352,7 @@ describe('LSP', function()
eq('', read_file(tmpfile))
end)
it('DeleteFile delete file and buffer', function()
- local tmpfile = helpers.tmpname()
+ local tmpfile = tmpname()
write_file(tmpfile, 'Be gone')
local uri = exec_lua(
[[
@@ -2375,7 +2376,7 @@ describe('LSP', function()
eq(false, exec_lua('return vim.api.nvim_buf_is_loaded(vim.fn.bufadd(...))', tmpfile))
end)
it('DeleteFile fails if file does not exist and ignoreIfNotExists is false', function()
- local tmpfile = helpers.tmpname()
+ local tmpfile = tmpname()
os.remove(tmpfile)
local uri = exec_lua('return vim.uri_from_fname(...)', tmpfile)
local edit = {
@@ -2398,9 +2399,9 @@ describe('LSP', function()
local pathsep = helpers.get_pathsep()
it('Can rename an existing file', function()
- local old = helpers.tmpname()
+ local old = tmpname()
write_file(old, 'Test content')
- local new = helpers.tmpname()
+ local new = tmpname()
os.remove(new) -- only reserve the name, file must not exist for the test scenario
local lines = exec_lua(
[[
@@ -2424,9 +2425,9 @@ describe('LSP', function()
os.remove(new)
end)
it('Kills old buffer after renaming an existing file', function()
- local old = helpers.tmpname()
+ local old = tmpname()
write_file(old, 'Test content')
- local new = helpers.tmpname()
+ local new = tmpname()
os.remove(new) -- only reserve the name, file must not exist for the test scenario
local lines = exec_lua(
[[
@@ -2444,8 +2445,8 @@ describe('LSP', function()
end)
it('Can rename a directory', function()
-- only reserve the name, file must not exist for the test scenario
- local old_dir = helpers.tmpname()
- local new_dir = helpers.tmpname()
+ local old_dir = tmpname()
+ local new_dir = tmpname()
os.remove(old_dir)
os.remove(new_dir)
@@ -2479,9 +2480,9 @@ describe('LSP', function()
it(
'Does not rename file if target exists and ignoreIfExists is set or overwrite is false',
function()
- local old = helpers.tmpname()
+ local old = tmpname()
write_file(old, 'Old File')
- local new = helpers.tmpname()
+ local new = tmpname()
write_file(new, 'New file')
exec_lua(
@@ -2514,9 +2515,9 @@ describe('LSP', function()
end
)
it('Does override target if overwrite is true', function()
- local old = helpers.tmpname()
+ local old = tmpname()
write_file(old, 'Old file')
- local new = helpers.tmpname()
+ local new = tmpname()
write_file(new, 'New file')
exec_lua(
[[
@@ -2945,14 +2946,14 @@ describe('LSP', function()
end)
it('adds current position to jumplist before jumping', function()
- funcs.nvim_win_set_buf(0, target_bufnr)
- local mark = funcs.nvim_buf_get_mark(target_bufnr, "'")
+ fn.nvim_win_set_buf(0, target_bufnr)
+ local mark = fn.nvim_buf_get_mark(target_bufnr, "'")
eq({ 1, 0 }, mark)
- funcs.nvim_win_set_cursor(0, { 2, 3 })
+ fn.nvim_win_set_cursor(0, { 2, 3 })
jump(location(0, 9, 0, 9))
- mark = funcs.nvim_buf_get_mark(target_bufnr, "'")
+ mark = fn.nvim_buf_get_mark(target_bufnr, "'")
eq({ 2, 3 }, mark)
end)
end)
@@ -3046,101 +3047,101 @@ describe('LSP', function()
end)
it('does not add current position to jumplist if not focus', function()
- funcs.nvim_win_set_buf(0, target_bufnr)
- local mark = funcs.nvim_buf_get_mark(target_bufnr, "'")
+ fn.nvim_win_set_buf(0, target_bufnr)
+ local mark = fn.nvim_buf_get_mark(target_bufnr, "'")
eq({ 1, 0 }, mark)
- funcs.nvim_win_set_cursor(0, { 2, 3 })
+ fn.nvim_win_set_cursor(0, { 2, 3 })
show_document(location(0, 9, 0, 9), false, true)
show_document(location(0, 9, 0, 9, true), false, true)
- mark = funcs.nvim_buf_get_mark(target_bufnr, "'")
+ mark = fn.nvim_buf_get_mark(target_bufnr, "'")
eq({ 1, 0 }, mark)
end)
it('does not change cursor position if not focus and not reuse_win', function()
- funcs.nvim_win_set_buf(0, target_bufnr)
- local cursor = funcs.nvim_win_get_cursor(0)
+ fn.nvim_win_set_buf(0, target_bufnr)
+ local cursor = fn.nvim_win_get_cursor(0)
show_document(location(0, 9, 0, 9), false, false)
- eq(cursor, funcs.nvim_win_get_cursor(0))
+ eq(cursor, fn.nvim_win_get_cursor(0))
end)
it('does not change window if not focus', function()
- funcs.nvim_win_set_buf(0, target_bufnr)
- local win = funcs.nvim_get_current_win()
+ fn.nvim_win_set_buf(0, target_bufnr)
+ local win = fn.nvim_get_current_win()
-- same document/bufnr
show_document(location(0, 9, 0, 9), false, true)
- eq(win, funcs.nvim_get_current_win())
+ eq(win, fn.nvim_get_current_win())
-- different document/bufnr, new window/split
show_document(location(0, 9, 0, 9, true), false, true)
- eq(2, #funcs.nvim_list_wins())
- eq(win, funcs.nvim_get_current_win())
+ eq(2, #fn.nvim_list_wins())
+ eq(win, fn.nvim_get_current_win())
end)
it("respects 'reuse_win' parameter", function()
- funcs.nvim_win_set_buf(0, target_bufnr)
+ fn.nvim_win_set_buf(0, target_bufnr)
-- does not create a new window if the buffer is already open
show_document(location(0, 9, 0, 9), false, true)
- eq(1, #funcs.nvim_list_wins())
+ eq(1, #fn.nvim_list_wins())
-- creates a new window even if the buffer is already open
show_document(location(0, 9, 0, 9), false, false)
- eq(2, #funcs.nvim_list_wins())
+ eq(2, #fn.nvim_list_wins())
end)
it('correctly sets the cursor of the split if range is given without focus', function()
- funcs.nvim_win_set_buf(0, target_bufnr)
+ fn.nvim_win_set_buf(0, target_bufnr)
show_document(location(0, 9, 0, 9, true), false, true)
- local wins = funcs.nvim_list_wins()
+ local wins = fn.nvim_list_wins()
eq(2, #wins)
table.sort(wins)
- eq({ 1, 0 }, funcs.nvim_win_get_cursor(wins[1]))
- eq({ 1, 9 }, funcs.nvim_win_get_cursor(wins[2]))
+ eq({ 1, 0 }, fn.nvim_win_get_cursor(wins[1]))
+ eq({ 1, 9 }, fn.nvim_win_get_cursor(wins[2]))
end)
it('does not change cursor of the split if not range and not focus', function()
- funcs.nvim_win_set_buf(0, target_bufnr)
- funcs.nvim_win_set_cursor(0, { 2, 3 })
+ fn.nvim_win_set_buf(0, target_bufnr)
+ fn.nvim_win_set_cursor(0, { 2, 3 })
exec_lua([[vim.cmd.new()]])
- funcs.nvim_win_set_buf(0, target_bufnr2)
- funcs.nvim_win_set_cursor(0, { 2, 3 })
+ fn.nvim_win_set_buf(0, target_bufnr2)
+ fn.nvim_win_set_cursor(0, { 2, 3 })
show_document({ uri = 'file:///fake/uri2' }, false, true)
- local wins = funcs.nvim_list_wins()
+ local wins = fn.nvim_list_wins()
eq(2, #wins)
- eq({ 2, 3 }, funcs.nvim_win_get_cursor(wins[1]))
- eq({ 2, 3 }, funcs.nvim_win_get_cursor(wins[2]))
+ eq({ 2, 3 }, fn.nvim_win_get_cursor(wins[1]))
+ eq({ 2, 3 }, fn.nvim_win_get_cursor(wins[2]))
end)
it('respects existing buffers', function()
- funcs.nvim_win_set_buf(0, target_bufnr)
- local win = funcs.nvim_get_current_win()
+ fn.nvim_win_set_buf(0, target_bufnr)
+ local win = fn.nvim_get_current_win()
exec_lua([[vim.cmd.new()]])
- funcs.nvim_win_set_buf(0, target_bufnr2)
- funcs.nvim_win_set_cursor(0, { 2, 3 })
- local split = funcs.nvim_get_current_win()
+ fn.nvim_win_set_buf(0, target_bufnr2)
+ fn.nvim_win_set_cursor(0, { 2, 3 })
+ local split = fn.nvim_get_current_win()
-- reuse win for open document/bufnr if called from split
show_document(location(0, 9, 0, 9, true), false, true)
- eq({ 1, 9 }, funcs.nvim_win_get_cursor(split))
- eq(2, #funcs.nvim_list_wins())
+ eq({ 1, 9 }, fn.nvim_win_get_cursor(split))
+ eq(2, #fn.nvim_list_wins())
- funcs.nvim_set_current_win(win)
+ fn.nvim_set_current_win(win)
-- reuse win for open document/bufnr if called outside the split
show_document(location(0, 9, 0, 9, true), false, true)
- eq({ 1, 9 }, funcs.nvim_win_get_cursor(split))
- eq(2, #funcs.nvim_list_wins())
+ eq({ 1, 9 }, fn.nvim_win_get_cursor(split))
+ eq(2, #fn.nvim_list_wins())
end)
end)
@@ -4043,7 +4044,7 @@ describe('LSP', function()
if is_os('win') then
tmpfile = '\\\\.\\\\pipe\\pipe.test'
else
- tmpfile = helpers.tmpname()
+ tmpfile = tmpname()
os.remove(tmpfile)
end
local result = exec_lua(
@@ -4150,7 +4151,7 @@ describe('LSP', function()
describe('#dynamic vim.lsp._dynamic', function()
it('supports dynamic registration', function()
---@type string
- local root_dir = helpers.tmpname()
+ local root_dir = tmpname()
os.remove(root_dir)
mkdir(root_dir)
local tmpfile = root_dir .. '/dynamic.foo'
@@ -4261,7 +4262,7 @@ describe('LSP', function()
describe('vim.lsp._watchfiles', function()
it('sends notifications when files change', function()
skip(is_os('bsd'), 'bsd only reports rename on folders if file inside change')
- local root_dir = helpers.tmpname()
+ local root_dir = tmpname()
os.remove(root_dir)
mkdir(root_dir)
diff --git a/test/functional/plugin/man_spec.lua b/test/functional/plugin/man_spec.lua
index ed9f21edf3..5bfa566729 100644
--- a/test/functional/plugin/man_spec.lua
+++ b/test/functional/plugin/man_spec.lua
@@ -3,13 +3,13 @@ local Screen = require('test.functional.ui.screen')
local command, rawfeed = helpers.command, helpers.rawfeed
local clear = helpers.clear
local exec_lua = helpers.exec_lua
-local funcs = helpers.funcs
+local fn = helpers.fn
local nvim_prog = helpers.nvim_prog
local matches = helpers.matches
local write_file = helpers.write_file
local tmpname = helpers.tmpname
local eq = helpers.eq
-local pesc = helpers.pesc
+local pesc = vim.pesc
local skip = helpers.skip
local is_ci = helpers.is_ci
@@ -33,7 +33,7 @@ local function get_search_history(name)
end
clear()
-if funcs.executable('man') == 0 then
+if fn.executable('man') == 0 then
pending('missing "man" command', function() end)
return
end
@@ -192,7 +192,7 @@ describe(':Man', function()
'+Man!',
'+call nvim_input("q")',
}
- matches('quit works!!', funcs.system(args, { 'manpage contents' }))
+ matches('quit works!!', fn.system(args, { 'manpage contents' }))
end)
it('reports non-existent man pages for absolute paths', function()
@@ -206,7 +206,7 @@ describe(':Man', function()
('Error detected while processing command line:\r\n' .. 'man.lua: "no manual entry for %s"'):format(
pesc(actual_file)
),
- funcs.system(args, { '' })
+ fn.system(args, { '' })
)
os.remove(actual_file)
end)
diff --git a/test/functional/plugin/matchparen_spec.lua b/test/functional/plugin/matchparen_spec.lua
index 1c4e11d30b..530afd16e4 100644
--- a/test/functional/plugin/matchparen_spec.lua
+++ b/test/functional/plugin/matchparen_spec.lua
@@ -3,7 +3,7 @@ local Screen = require('test.functional.ui.screen')
local clear = helpers.clear
local command = helpers.command
-local meths = helpers.meths
+local api = helpers.api
local feed = helpers.feed
local eq = helpers.eq
@@ -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, api.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 01dd253384..8511e6c703 100644
--- a/test/functional/plugin/msgpack_spec.lua
+++ b/test/functional/plugin/msgpack_spec.lua
@@ -1,10 +1,12 @@
local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
-local meths = helpers.meths
-local eq, nvim_eval, nvim_command, exc_exec =
- helpers.eq, helpers.eval, helpers.command, helpers.exc_exec
+local api = helpers.api
+local eq = helpers.eq
+local nvim_eval = helpers.eval
+local nvim_command = helpers.command
+local exc_exec = helpers.exc_exec
local ok = helpers.ok
-local NIL = helpers.NIL
+local NIL = vim.NIL
describe('autoload/msgpack.vim', function()
before_each(function()
@@ -524,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)
+ api.nvim_set_var('true', true)
+ api.nvim_set_var('false', false)
+ api.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, api.nvim_get_var('true'))
+ eq(false, api.nvim_get_var('false'))
+ eq(NIL, api.nvim_get_var('nil'))
end)
end)
diff --git a/test/functional/plugin/shada_spec.lua b/test/functional/plugin/shada_spec.lua
index ef3fef1897..1c20548321 100644
--- a/test/functional/plugin/shada_spec.lua
+++ b/test/functional/plugin/shada_spec.lua
@@ -1,21 +1,11 @@
local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local clear = helpers.clear
-local eq, meths, nvim_eval, nvim_command, nvim, exc_exec, funcs, nvim_feed, curbuf =
- helpers.eq,
- helpers.meths,
- helpers.eval,
- helpers.command,
- helpers.nvim,
- helpers.exc_exec,
- helpers.funcs,
- helpers.feed,
- helpers.curbuf
+local eq, api, nvim_eval, nvim_command, exc_exec, fn, nvim_feed =
+ helpers.eq, helpers.api, helpers.eval, helpers.command, helpers.exc_exec, helpers.fn, helpers.feed
local neq = helpers.neq
local read_file = helpers.read_file
-local mpack = require('mpack')
-
local shada_helpers = require('test.functional.shada.helpers')
local get_shada_rw = shada_helpers.get_shada_rw
@@ -26,7 +16,7 @@ end
local mpack_eq = function(expected, mpack_result)
local mpack_keys = { 'type', 'timestamp', 'length', 'value' }
- local unpack = mpack.Unpacker()
+ local unpack = vim.mpack.Unpacker()
local actual = {}
local cur, val
local i = 0
@@ -126,7 +116,7 @@ describe('autoload/shada.vim', function()
describe('function shada#sd_to_strings', function()
local sd2strings_eq = function(expected, arg)
if type(arg) == 'table' then
- eq(expected, funcs['shada#sd_to_strings'](arg))
+ eq(expected, fn['shada#sd_to_strings'](arg))
else
eq(expected, nvim_eval(('shada#sd_to_strings(%s)'):format(arg)))
end
@@ -1583,7 +1573,7 @@ describe('autoload/shada.vim', function()
describe('function shada#strings_to_sd', function()
local strings2sd_eq = function(expected, input)
- nvim('set_var', '__input', input)
+ api.nvim_set_var('__input', input)
nvim_command(
'let g:__actual = map(shada#strings_to_sd(g:__input), '
.. '"filter(v:val, \\"v:key[0] isnot# \'_\' '
@@ -1591,7 +1581,7 @@ describe('autoload/shada.vim', function()
)
-- print()
if type(expected) == 'table' then
- nvim('set_var', '__expected', expected)
+ api.nvim_set_var('__expected', expected)
nvim_command('let g:__expected = ModifyVal(g:__expected)')
expected = 'g:__expected'
-- print(nvim_eval('msgpack#string(g:__expected)'))
@@ -2527,7 +2517,7 @@ describe('autoload/shada.vim', function()
describe('function shada#get_binstrings', function()
local getbstrings_eq = function(expected, input)
- local result = funcs['shada#get_binstrings'](input)
+ local result = fn['shada#get_binstrings'](input)
for i, s in ipairs(result) do
result[i] = s:gsub('\n', '\0')
end
@@ -2536,7 +2526,7 @@ describe('autoload/shada.vim', function()
end
it('works', function()
- local version = nvim('get_vvar', 'version')
+ local version = api.nvim_get_vvar('version')
getbstrings_eq({
{
timestamp = 'current',
@@ -2562,7 +2552,7 @@ describe('autoload/shada.vim', function()
' % Key______ Value',
' + generator "test"',
})
- nvim('set_var', 'shada#add_own_header', 1)
+ api.nvim_set_var('shada#add_own_header', 1)
getbstrings_eq({
{
timestamp = 'current',
@@ -2588,14 +2578,14 @@ describe('autoload/shada.vim', function()
' % Key______ Value',
' + generator "test"',
})
- nvim('set_var', 'shada#add_own_header', 0)
+ api.nvim_set_var('shada#add_own_header', 0)
getbstrings_eq({}, {})
getbstrings_eq({ { timestamp = 0, type = 1, value = { generator = 'test' } } }, {
'Header with timestamp ' .. epoch .. ':',
' % Key______ Value',
' + generator "test"',
})
- nvim('set_var', 'shada#keep_old_header', 0)
+ api.nvim_set_var('shada#keep_old_header', 0)
getbstrings_eq({}, {
'Header with timestamp ' .. epoch .. ':',
' % Key______ Value',
@@ -2646,7 +2636,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 =
+ api.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
@@ -2662,8 +2653,8 @@ describe('plugin/shada.vim', function()
' - contents "ab"',
' - "a"',
}, nvim_eval('getline(1, "$")'))
- eq(false, nvim('get_option_value', 'modified', {}))
- eq('shada', nvim('get_option_value', 'filetype', {}))
+ eq(false, api.nvim_get_option_value('modified', {}))
+ eq('shada', api.nvim_get_option_value('filetype', {}))
nvim_command('edit ' .. fname_tmp)
eq({
'History entry with timestamp ' .. epoch .. ':',
@@ -2672,8 +2663,8 @@ describe('plugin/shada.vim', function()
' - contents "ab"',
' - "b"',
}, nvim_eval('getline(1, "$")'))
- eq(false, nvim('get_option_value', 'modified', {}))
- eq('shada', nvim('get_option_value', 'filetype', {}))
+ eq(false, api.nvim_get_option_value('modified', {}))
+ eq('shada', api.nvim_get_option_value('filetype', {}))
eq('++opt not supported', exc_exec('edit ++enc=latin1 ' .. fname))
neq({
'History entry with timestamp ' .. epoch .. ':',
@@ -2682,7 +2673,7 @@ describe('plugin/shada.vim', function()
' - contents "ab"',
' - "a"',
}, nvim_eval('getline(1, "$")'))
- neq(true, nvim('get_option_value', 'modified', {}))
+ neq(true, api.nvim_get_option_value('modified', {}))
end)
it('event FileReadCmd', function()
@@ -2698,8 +2689,8 @@ describe('plugin/shada.vim', function()
' - contents "ab"',
' - "a"',
}, nvim_eval('getline(1, "$")'))
- eq(true, nvim('get_option_value', 'modified', {}))
- neq('shada', nvim('get_option_value', 'filetype', {}))
+ eq(true, api.nvim_get_option_value('modified', {}))
+ neq('shada', api.nvim_get_option_value('filetype', {}))
nvim_command('1,$read ' .. fname_tmp)
eq({
'',
@@ -2714,9 +2705,9 @@ describe('plugin/shada.vim', function()
' - contents "ab"',
' - "b"',
}, nvim_eval('getline(1, "$")'))
- eq(true, nvim('get_option_value', 'modified', {}))
- neq('shada', nvim('get_option_value', 'filetype', {}))
- nvim('set_option_value', 'modified', false, {})
+ eq(true, api.nvim_get_option_value('modified', {}))
+ neq('shada', api.nvim_get_option_value('filetype', {}))
+ api.nvim_set_option_value('modified', false, {})
eq('++opt not supported', exc_exec('$read ++enc=latin1 ' .. fname))
eq({
'',
@@ -2731,13 +2722,13 @@ describe('plugin/shada.vim', function()
' - contents "ab"',
' - "b"',
}, nvim_eval('getline(1, "$")'))
- neq(true, nvim('get_option_value', 'modified', {}))
+ neq(true, api.nvim_get_option_value('modified', {}))
end)
it('event BufWriteCmd', function()
reset()
- nvim('set_var', 'shada#add_own_header', 0)
- curbuf('set_lines', 0, 1, true, {
+ api.nvim_set_var('shada#add_own_header', 0)
+ api.nvim_buf_set_lines(0, 0, 1, true, {
'Jump with timestamp ' .. epoch .. ':',
' % Key________ Description Value',
" + n name 'A'",
@@ -2797,8 +2788,8 @@ describe('plugin/shada.vim', function()
it('event FileWriteCmd', function()
reset()
- nvim('set_var', 'shada#add_own_header', 0)
- curbuf('set_lines', 0, 1, true, {
+ api.nvim_set_var('shada#add_own_header', 0)
+ api.nvim_buf_set_lines(0, 0, 1, true, {
'Jump with timestamp ' .. epoch .. ':',
' % Key________ Description Value',
" + n name 'A'",
@@ -2841,8 +2832,8 @@ describe('plugin/shada.vim', function()
it('event FileAppendCmd', function()
reset()
- nvim('set_var', 'shada#add_own_header', 0)
- curbuf('set_lines', 0, 1, true, {
+ api.nvim_set_var('shada#add_own_header', 0)
+ api.nvim_buf_set_lines(0, 0, 1, true, {
'Jump with timestamp ' .. epoch .. ':',
' % Key________ Description Value',
" + n name 'A'",
@@ -2856,9 +2847,9 @@ describe('plugin/shada.vim', function()
' + l line number 2',
' + c column -200',
})
- funcs.writefile({ '' }, fname .. '.tst', 'b')
- funcs.writefile({ '' }, fname, 'b')
- funcs.writefile({ '' }, fname_tmp, 'b')
+ fn.writefile({ '' }, fname .. '.tst', 'b')
+ fn.writefile({ '' }, fname, 'b')
+ fn.writefile({ '' }, fname_tmp, 'b')
nvim_command('1,3w >> ' .. fname .. '.tst')
nvim_command('1,3w >> ' .. fname)
nvim_command('1,3w >> ' .. fname_tmp)
@@ -2928,8 +2919,8 @@ describe('plugin/shada.vim', function()
wshada_tmp('\004\001\006\146\000\196\002bc')
eq(0, exc_exec('source ' .. fname))
eq(0, exc_exec('source ' .. fname_tmp))
- eq('bc', funcs.histget(':', -1))
- eq('ab', funcs.histget(':', -2))
+ eq('bc', fn.histget(':', -1))
+ eq('ab', fn.histget(':', -2))
end)
end)
@@ -2940,7 +2931,7 @@ describe('ftplugin/shada.vim', function()
it('sets indentexpr correctly', function()
nvim_command('filetype plugin indent on')
nvim_command('setlocal filetype=shada')
- funcs.setline(1, {
+ fn.setline(1, {
'Jump with timestamp ' .. epoch .. ':',
'% Key________ Description Value',
"+ n name 'A'",
@@ -3012,34 +3003,34 @@ describe('ftplugin/shada.vim', function()
' + f file name 20',
' + l line number 1',
' + c column 0',
- }, funcs.getline(1, funcs.line('$')))
+ }, fn.getline(1, fn.line('$')))
end)
it('sets options correctly', function()
nvim_command('filetype plugin indent on')
nvim_command('setlocal filetype=shada')
- eq(true, nvim('get_option_value', 'expandtab', {}))
- eq(2, nvim('get_option_value', 'tabstop', {}))
- eq(2, nvim('get_option_value', 'softtabstop', {}))
- eq(2, nvim('get_option_value', 'shiftwidth', {}))
+ eq(true, api.nvim_get_option_value('expandtab', {}))
+ eq(2, api.nvim_get_option_value('tabstop', {}))
+ eq(2, api.nvim_get_option_value('softtabstop', {}))
+ eq(2, api.nvim_get_option_value('shiftwidth', {}))
end)
it('sets indentkeys correctly', function()
nvim_command('filetype plugin indent on')
nvim_command('setlocal filetype=shada')
- funcs.setline(1, ' Replacement with timestamp ' .. epoch)
+ fn.setline(1, ' Replacement with timestamp ' .. epoch)
nvim_feed('ggA:\027')
- eq('Replacement with timestamp ' .. epoch .. ':', curbuf('get_lines', 0, 1, true)[1])
+ eq('Replacement with timestamp ' .. epoch .. ':', api.nvim_buf_get_lines(0, 0, 1, true)[1])
nvim_feed('o-\027')
- eq({ ' -' }, curbuf('get_lines', 1, 2, true))
+ eq({ ' -' }, api.nvim_buf_get_lines(0, 1, 2, true))
nvim_feed('ggO+\027')
- eq({ '+' }, curbuf('get_lines', 0, 1, true))
+ eq({ '+' }, api.nvim_buf_get_lines(0, 0, 1, true))
nvim_feed('GO*\027')
- eq({ ' *' }, curbuf('get_lines', 2, 3, true))
+ eq({ ' *' }, api.nvim_buf_get_lines(0, 2, 3, true))
nvim_feed('ggO /\027')
- eq({ ' /' }, curbuf('get_lines', 0, 1, true))
+ eq({ ' /' }, api.nvim_buf_get_lines(0, 0, 1, true))
nvim_feed('ggOx\027')
- eq({ 'x' }, curbuf('get_lines', 0, 1, true))
+ eq({ 'x' }, api.nvim_buf_get_lines(0, 0, 1, true))
end)
end)
@@ -3064,7 +3055,7 @@ describe('syntax/shada.vim', function()
}
screen:attach()
- curbuf('set_lines', 0, 1, true, {
+ api.nvim_buf_set_lines(0, 0, 1, true, {
'Header with timestamp ' .. epoch .. ':',
' % Key Value',
' + t "test"',
@@ -3211,7 +3202,7 @@ describe('syntax/shada.vim', function()
s,
}
end
- local act = funcs.GetSyntax()
+ local act = fn.GetSyntax()
local ms = function(syn)
return {
{ 'ShaDaEntryMap' .. syn, 'ShaDaEntryMap' .. syn .. 'EntryStart' },