aboutsummaryrefslogtreecommitdiff
path: root/test/functional/plugin
diff options
context:
space:
mode:
authorLewis Russell <lewis6991@gmail.com>2024-01-12 17:59:57 +0000
committerLewis Russell <lewis6991@gmail.com>2024-01-12 18:59:14 +0000
commit795f896a5772d5e0795f86642bdf90c82efac45c (patch)
tree308f04fbee18d2ec3f00c12a8bec96b84d8907f0 /test/functional/plugin
parent4f81f506f96f8b5bfcf00e952ceb492d3ce9dc6e (diff)
downloadrneovim-795f896a5772d5e0795f86642bdf90c82efac45c.tar.gz
rneovim-795f896a5772d5e0795f86642bdf90c82efac45c.tar.bz2
rneovim-795f896a5772d5e0795f86642bdf90c82efac45c.zip
test: rename (meths, funcs) -> (api, fn)
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/incremental_sync_spec.lua4
-rw-r--r--test/functional/plugin/lsp_spec.lua112
-rw-r--r--test/functional/plugin/man_spec.lua8
-rw-r--r--test/functional/plugin/matchparen_spec.lua4
-rw-r--r--test/functional/plugin/msgpack_spec.lua14
-rw-r--r--test/functional/plugin/shada_spec.lua102
9 files changed, 137 insertions, 143 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 0689cd09d3..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.nvim_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.nvim_set_var('editorconfig', false)
- meths.nvim_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.nvim_set_option_value('shiftwidth', 42, {})
- local bufnr = funcs.bufadd(testdir .. pathsep .. '3_space.txt')
- meths.nvim_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/incremental_sync_spec.lua b/test/functional/plugin/lsp/incremental_sync_spec.lua
index ec918ed514..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.nvim_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 43bfb89e81..252931eccb 100644
--- a/test/functional/plugin/lsp_spec.lua
+++ b/test/functional/plugin/lsp_spec.lua
@@ -13,14 +13,14 @@ local matches = helpers.matches
local pcall_err = helpers.pcall_err
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 = 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
@@ -363,9 +363,9 @@ describe('LSP', function()
end,
on_handler = function(_, _, ctx)
if ctx.method == 'finish' then
- eq('basic_init', meths.nvim_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.nvim_get_var('lsp_detached'))
+ eq('basic_init', api.nvim_get_var('lsp_detached'))
client.stop()
end
end,
@@ -1877,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'),
}
@@ -1889,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, ''),
@@ -1906,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, ''),
@@ -1919,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, ''),
}
@@ -1934,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, ''),
}
@@ -1954,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, ''),
}
@@ -1969,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)
@@ -2946,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)
@@ -3047,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)
diff --git a/test/functional/plugin/man_spec.lua b/test/functional/plugin/man_spec.lua
index 532210582a..5bfa566729 100644
--- a/test/functional/plugin/man_spec.lua
+++ b/test/functional/plugin/man_spec.lua
@@ -3,7 +3,7 @@ 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
@@ -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 2bda41359b..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.nvim_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 bc1182afd3..8511e6c703 100644
--- a/test/functional/plugin/msgpack_spec.lua
+++ b/test/functional/plugin/msgpack_spec.lua
@@ -1,6 +1,6 @@
local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
-local meths = helpers.meths
+local api = helpers.api
local eq = helpers.eq
local nvim_eval = helpers.eval
local nvim_command = helpers.command
@@ -526,17 +526,17 @@ describe('autoload/msgpack.vim', function()
end)
it('works for special v: values like v:true', function()
- meths.nvim_set_var('true', true)
- meths.nvim_set_var('false', false)
- meths.nvim_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.nvim_get_var('true'))
- eq(false, meths.nvim_get_var('false'))
- eq(NIL, meths.nvim_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 c037636025..1c20548321 100644
--- a/test/functional/plugin/shada_spec.lua
+++ b/test/functional/plugin/shada_spec.lua
@@ -1,14 +1,8 @@
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, exc_exec, funcs, nvim_feed =
- helpers.eq,
- helpers.meths,
- helpers.eval,
- helpers.command,
- helpers.exc_exec,
- helpers.funcs,
- helpers.feed
+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
@@ -122,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
@@ -1579,7 +1573,7 @@ describe('autoload/shada.vim', function()
describe('function shada#strings_to_sd', function()
local strings2sd_eq = function(expected, input)
- meths.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# \'_\' '
@@ -1587,7 +1581,7 @@ describe('autoload/shada.vim', function()
)
-- print()
if type(expected) == 'table' then
- meths.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)'))
@@ -2523,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
@@ -2532,7 +2526,7 @@ describe('autoload/shada.vim', function()
end
it('works', function()
- local version = meths.nvim_get_vvar('version')
+ local version = api.nvim_get_vvar('version')
getbstrings_eq({
{
timestamp = 'current',
@@ -2558,7 +2552,7 @@ describe('autoload/shada.vim', function()
' % Key______ Value',
' + generator "test"',
})
- meths.nvim_set_var('shada#add_own_header', 1)
+ api.nvim_set_var('shada#add_own_header', 1)
getbstrings_eq({
{
timestamp = 'current',
@@ -2584,14 +2578,14 @@ describe('autoload/shada.vim', function()
' % Key______ Value',
' + generator "test"',
})
- meths.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"',
})
- meths.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',
@@ -2643,7 +2637,7 @@ describe('plugin/shada.vim', function()
wshada_tmp('\004\000\009\147\000\196\002ab\196\001b')
local bufread_commands =
- meths.nvim_get_autocmds({ group = 'ShaDaCommands', event = 'BufReadCmd' })
+ 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
@@ -2659,8 +2653,8 @@ describe('plugin/shada.vim', function()
' - contents "ab"',
' - "a"',
}, nvim_eval('getline(1, "$")'))
- eq(false, meths.nvim_get_option_value('modified', {}))
- eq('shada', meths.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 .. ':',
@@ -2669,8 +2663,8 @@ describe('plugin/shada.vim', function()
' - contents "ab"',
' - "b"',
}, nvim_eval('getline(1, "$")'))
- eq(false, meths.nvim_get_option_value('modified', {}))
- eq('shada', meths.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 .. ':',
@@ -2679,7 +2673,7 @@ describe('plugin/shada.vim', function()
' - contents "ab"',
' - "a"',
}, nvim_eval('getline(1, "$")'))
- neq(true, meths.nvim_get_option_value('modified', {}))
+ neq(true, api.nvim_get_option_value('modified', {}))
end)
it('event FileReadCmd', function()
@@ -2695,8 +2689,8 @@ describe('plugin/shada.vim', function()
' - contents "ab"',
' - "a"',
}, nvim_eval('getline(1, "$")'))
- eq(true, meths.nvim_get_option_value('modified', {}))
- neq('shada', meths.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({
'',
@@ -2711,9 +2705,9 @@ describe('plugin/shada.vim', function()
' - contents "ab"',
' - "b"',
}, nvim_eval('getline(1, "$")'))
- eq(true, meths.nvim_get_option_value('modified', {}))
- neq('shada', meths.nvim_get_option_value('filetype', {}))
- meths.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({
'',
@@ -2728,13 +2722,13 @@ describe('plugin/shada.vim', function()
' - contents "ab"',
' - "b"',
}, nvim_eval('getline(1, "$")'))
- neq(true, meths.nvim_get_option_value('modified', {}))
+ neq(true, api.nvim_get_option_value('modified', {}))
end)
it('event BufWriteCmd', function()
reset()
- meths.nvim_set_var('shada#add_own_header', 0)
- meths.nvim_buf_set_lines(0, 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'",
@@ -2794,8 +2788,8 @@ describe('plugin/shada.vim', function()
it('event FileWriteCmd', function()
reset()
- meths.nvim_set_var('shada#add_own_header', 0)
- meths.nvim_buf_set_lines(0, 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'",
@@ -2838,8 +2832,8 @@ describe('plugin/shada.vim', function()
it('event FileAppendCmd', function()
reset()
- meths.nvim_set_var('shada#add_own_header', 0)
- meths.nvim_buf_set_lines(0, 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'",
@@ -2853,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)
@@ -2925,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)
@@ -2937,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'",
@@ -3009,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, meths.nvim_get_option_value('expandtab', {}))
- eq(2, meths.nvim_get_option_value('tabstop', {}))
- eq(2, meths.nvim_get_option_value('softtabstop', {}))
- eq(2, meths.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 .. ':', meths.nvim_buf_get_lines(0, 0, 1, true)[1])
+ eq('Replacement with timestamp ' .. epoch .. ':', api.nvim_buf_get_lines(0, 0, 1, true)[1])
nvim_feed('o-\027')
- eq({ ' -' }, meths.nvim_buf_get_lines(0, 1, 2, true))
+ eq({ ' -' }, api.nvim_buf_get_lines(0, 1, 2, true))
nvim_feed('ggO+\027')
- eq({ '+' }, meths.nvim_buf_get_lines(0, 0, 1, true))
+ eq({ '+' }, api.nvim_buf_get_lines(0, 0, 1, true))
nvim_feed('GO*\027')
- eq({ ' *' }, meths.nvim_buf_get_lines(0, 2, 3, true))
+ eq({ ' *' }, api.nvim_buf_get_lines(0, 2, 3, true))
nvim_feed('ggO /\027')
- eq({ ' /' }, meths.nvim_buf_get_lines(0, 0, 1, true))
+ eq({ ' /' }, api.nvim_buf_get_lines(0, 0, 1, true))
nvim_feed('ggOx\027')
- eq({ 'x' }, meths.nvim_buf_get_lines(0, 0, 1, true))
+ eq({ 'x' }, api.nvim_buf_get_lines(0, 0, 1, true))
end)
end)
@@ -3061,7 +3055,7 @@ describe('syntax/shada.vim', function()
}
screen:attach()
- meths.nvim_buf_set_lines(0, 0, 1, true, {
+ api.nvim_buf_set_lines(0, 0, 1, true, {
'Header with timestamp ' .. epoch .. ':',
' % Key Value',
' + t "test"',
@@ -3208,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' },