aboutsummaryrefslogtreecommitdiff
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
parent4f81f506f96f8b5bfcf00e952ceb492d3ce9dc6e (diff)
downloadrneovim-795f896a5772d5e0795f86642bdf90c82efac45c.tar.gz
rneovim-795f896a5772d5e0795f86642bdf90c82efac45c.tar.bz2
rneovim-795f896a5772d5e0795f86642bdf90c82efac45c.zip
test: rename (meths, funcs) -> (api, fn)
-rw-r--r--test/functional/api/autocmd_spec.lua431
-rw-r--r--test/functional/api/buffer_spec.lua610
-rw-r--r--test/functional/api/buffer_updates_spec.lua70
-rw-r--r--test/functional/api/command_spec.lua86
-rw-r--r--test/functional/api/extmark_spec.lua74
-rw-r--r--test/functional/api/highlight_spec.lua295
-rw-r--r--test/functional/api/keymap_spec.lua334
-rw-r--r--test/functional/api/proc_spec.lua14
-rw-r--r--test/functional/api/server_notifications_spec.lua20
-rw-r--r--test/functional/api/server_requests_spec.lua92
-rw-r--r--test/functional/api/tabpage_spec.lua62
-rw-r--r--test/functional/api/ui_spec.lua26
-rw-r--r--test/functional/api/version_spec.lua47
-rw-r--r--test/functional/api/vim_spec.lua1616
-rw-r--r--test/functional/api/window_spec.lua604
-rw-r--r--test/functional/autocmd/autocmd_oldtest_spec.lua30
-rw-r--r--test/functional/autocmd/autocmd_spec.lua40
-rw-r--r--test/functional/autocmd/cmdline_spec.lua6
-rw-r--r--test/functional/autocmd/cursorhold_spec.lua32
-rw-r--r--test/functional/autocmd/cursormoved_spec.lua6
-rw-r--r--test/functional/autocmd/safestate_spec.lua22
-rw-r--r--test/functional/autocmd/searchwrapped_spec.lua4
-rw-r--r--test/functional/autocmd/show_spec.lua10
-rw-r--r--test/functional/autocmd/signal_spec.lua10
-rw-r--r--test/functional/autocmd/tabclose_spec.lua36
-rw-r--r--test/functional/autocmd/tabnewentered_spec.lua20
-rw-r--r--test/functional/autocmd/termxx_spec.lua20
-rw-r--r--test/functional/autocmd/textyankpost_spec.lua6
-rw-r--r--test/functional/autocmd/win_scrolled_resized_spec.lua40
-rw-r--r--test/functional/core/channels_spec.lua28
-rw-r--r--test/functional/core/exit_spec.lua6
-rw-r--r--test/functional/core/fileio_spec.lua62
-rw-r--r--test/functional/core/job_spec.lua46
-rw-r--r--test/functional/core/main_spec.lua20
-rw-r--r--test/functional/core/path_spec.lua4
-rw-r--r--test/functional/core/remote_spec.lua22
-rw-r--r--test/functional/core/spellfile_spec.lua22
-rw-r--r--test/functional/core/startup_spec.lua102
-rw-r--r--test/functional/editor/K_spec.lua10
-rw-r--r--test/functional/editor/completion_spec.lua32
-rw-r--r--test/functional/editor/fold_spec.lua76
-rw-r--r--test/functional/editor/jump_spec.lua22
-rw-r--r--test/functional/editor/langmap_spec.lua4
-rw-r--r--test/functional/editor/macro_spec.lua44
-rw-r--r--test/functional/editor/mark_spec.lua72
-rw-r--r--test/functional/editor/meta_key_spec.lua8
-rw-r--r--test/functional/editor/mode_cmdline_spec.lua40
-rw-r--r--test/functional/editor/put_spec.lua82
-rw-r--r--test/functional/editor/tabpage_spec.lua38
-rw-r--r--test/functional/editor/undo_spec.lua4
-rw-r--r--test/functional/ex_cmds/append_spec.lua20
-rw-r--r--test/functional/ex_cmds/arg_spec.lua12
-rw-r--r--test/functional/ex_cmds/cmd_map_spec.lua36
-rw-r--r--test/functional/ex_cmds/dict_notifications_spec.lua6
-rw-r--r--test/functional/ex_cmds/echo_spec.lua98
-rw-r--r--test/functional/ex_cmds/edit_spec.lua12
-rw-r--r--test/functional/ex_cmds/excmd_spec.lua22
-rw-r--r--test/functional/ex_cmds/file_spec.lua4
-rw-r--r--test/functional/ex_cmds/help_spec.lua14
-rw-r--r--test/functional/ex_cmds/highlight_spec.lua18
-rw-r--r--test/functional/ex_cmds/ls_spec.lua4
-rw-r--r--test/functional/ex_cmds/make_spec.lua6
-rw-r--r--test/functional/ex_cmds/map_spec.lua26
-rw-r--r--test/functional/ex_cmds/menu_spec.lua14
-rw-r--r--test/functional/ex_cmds/mksession_spec.lua62
-rw-r--r--test/functional/ex_cmds/mkview_spec.lua8
-rw-r--r--test/functional/ex_cmds/normal_spec.lua10
-rw-r--r--test/functional/ex_cmds/oldfiles_spec.lua22
-rw-r--r--test/functional/ex_cmds/print_commands_spec.lua4
-rw-r--r--test/functional/ex_cmds/quickfix_commands_spec.lua22
-rw-r--r--test/functional/ex_cmds/script_spec.lua4
-rw-r--r--test/functional/ex_cmds/sign_spec.lua10
-rw-r--r--test/functional/ex_cmds/source_spec.lua28
-rw-r--r--test/functional/ex_cmds/swapfile_preserve_recover_spec.lua26
-rw-r--r--test/functional/ex_cmds/trust_spec.lua28
-rw-r--r--test/functional/ex_cmds/verbose_spec.lua2
-rw-r--r--test/functional/ex_cmds/wincmd_spec.lua6
-rw-r--r--test/functional/ex_cmds/write_spec.lua26
-rw-r--r--test/functional/helpers.lua45
-rw-r--r--test/functional/legacy/012_directory_spec.lua18
-rw-r--r--test/functional/legacy/039_visual_block_mode_commands_spec.lua2
-rw-r--r--test/functional/legacy/assert_spec.lua2
-rw-r--r--test/functional/legacy/autochdir_spec.lua4
-rw-r--r--test/functional/legacy/autocmd_option_spec.lua12
-rw-r--r--test/functional/legacy/buffer_spec.lua8
-rw-r--r--test/functional/legacy/cmdline_spec.lua16
-rw-r--r--test/functional/legacy/ex_mode_spec.lua4
-rw-r--r--test/functional/legacy/excmd_spec.lua8
-rw-r--r--test/functional/legacy/filechanged_spec.lua10
-rw-r--r--test/functional/legacy/fnamemodify_spec.lua2
-rw-r--r--test/functional/legacy/increment_spec.lua2
-rw-r--r--test/functional/legacy/mapping_spec.lua14
-rw-r--r--test/functional/legacy/messages_spec.lua8
-rw-r--r--test/functional/legacy/mksession_spec.lua6
-rw-r--r--test/functional/legacy/move_spec.lua4
-rw-r--r--test/functional/legacy/prompt_buffer_spec.lua20
-rw-r--r--test/functional/legacy/put_spec.lua4
-rw-r--r--test/functional/legacy/search_spec.lua20
-rw-r--r--test/functional/legacy/undolevels_spec.lua2
-rw-r--r--test/functional/legacy/vimscript_spec.lua4
-rw-r--r--test/functional/lua/api_spec.lua114
-rw-r--r--test/functional/lua/buffer_updates_spec.lua134
-rw-r--r--test/functional/lua/commands_spec.lua54
-rw-r--r--test/functional/lua/diagnostic_spec.lua60
-rw-r--r--test/functional/lua/filetype_spec.lua4
-rw-r--r--test/functional/lua/loop_spec.lua14
-rw-r--r--test/functional/lua/luaeval_spec.lua110
-rw-r--r--test/functional/lua/overrides_spec.lua24
-rw-r--r--test/functional/lua/runtime_spec.lua24
-rw-r--r--test/functional/lua/secure_spec.lua64
-rw-r--r--test/functional/lua/ui_event_spec.lua6
-rw-r--r--test/functional/lua/vim_spec.lua514
-rw-r--r--test/functional/options/autochdir_spec.lua18
-rw-r--r--test/functional/options/chars_spec.lua4
-rw-r--r--test/functional/options/defaults_spec.lua152
-rw-r--r--test/functional/options/num_options_spec.lua26
-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
-rw-r--r--test/functional/provider/clipboard_spec.lua6
-rw-r--r--test/functional/provider/define_spec.lua4
-rw-r--r--test/functional/provider/perl_spec.lua4
-rw-r--r--test/functional/provider/python3_spec.lua16
-rw-r--r--test/functional/provider/ruby_spec.lua18
-rw-r--r--test/functional/shada/buffers_spec.lua50
-rw-r--r--test/functional/shada/compatibility_spec.lua120
-rw-r--r--test/functional/shada/helpers.lua4
-rw-r--r--test/functional/shada/history_spec.lua108
-rw-r--r--test/functional/shada/marks_spec.lua40
-rw-r--r--test/functional/shada/merging_spec.lua102
-rw-r--r--test/functional/shada/registers_spec.lua8
-rw-r--r--test/functional/shada/shada_spec.lua60
-rw-r--r--test/functional/shada/variables_spec.lua79
-rw-r--r--test/functional/terminal/altscreen_spec.lua8
-rw-r--r--test/functional/terminal/buffer_spec.lua38
-rw-r--r--test/functional/terminal/channel_spec.lua26
-rw-r--r--test/functional/terminal/edit_spec.lua20
-rw-r--r--test/functional/terminal/ex_terminal_spec.lua46
-rw-r--r--test/functional/terminal/helpers.lua22
-rw-r--r--test/functional/terminal/highlight_spec.lua8
-rw-r--r--test/functional/terminal/mouse_spec.lua6
-rw-r--r--test/functional/terminal/scrollback_spec.lua58
-rw-r--r--test/functional/terminal/tui_spec.lua112
-rw-r--r--test/functional/terminal/window_split_tab_spec.lua8
-rw-r--r--test/functional/treesitter/highlight_spec.lua16
-rw-r--r--test/functional/ui/bufhl_spec.lua28
-rw-r--r--test/functional/ui/cmdline_highlight_spec.lua62
-rw-r--r--test/functional/ui/cmdline_spec.lua10
-rw-r--r--test/functional/ui/cursor_spec.lua8
-rw-r--r--test/functional/ui/decorations_spec.lua548
-rw-r--r--test/functional/ui/diff_spec.lua14
-rw-r--r--test/functional/ui/embed_spec.lua4
-rw-r--r--test/functional/ui/float_spec.lua820
-rw-r--r--test/functional/ui/fold_spec.lua126
-rw-r--r--test/functional/ui/highlight_spec.lua40
-rw-r--r--test/functional/ui/hlstate_spec.lua6
-rw-r--r--test/functional/ui/inccommand_spec.lua54
-rw-r--r--test/functional/ui/input_spec.lua10
-rw-r--r--test/functional/ui/linematch_spec.lua8
-rw-r--r--test/functional/ui/messages_spec.lua16
-rw-r--r--test/functional/ui/mouse_spec.lua356
-rw-r--r--test/functional/ui/multibyte_spec.lua12
-rw-r--r--test/functional/ui/multigrid_spec.lua106
-rw-r--r--test/functional/ui/popupmenu_spec.lua163
-rw-r--r--test/functional/ui/quickfix_spec.lua4
-rw-r--r--test/functional/ui/screen_basic_spec.lua38
-rw-r--r--test/functional/ui/searchhl_spec.lua8
-rw-r--r--test/functional/ui/sign_spec.lua8
-rw-r--r--test/functional/ui/spell_spec.lua16
-rw-r--r--test/functional/ui/statuscolumn_spec.lua66
-rw-r--r--test/functional/ui/statusline_spec.lua196
-rw-r--r--test/functional/ui/tabline_spec.lua12
-rw-r--r--test/functional/ui/title_spec.lua14
-rw-r--r--test/functional/ui/wildmode_spec.lua26
-rw-r--r--test/functional/ui/winbar_spec.lua52
-rw-r--r--test/functional/vimscript/api_functions_spec.lua28
-rw-r--r--test/functional/vimscript/buf_functions_spec.lua266
-rw-r--r--test/functional/vimscript/changedtick_spec.lua44
-rw-r--r--test/functional/vimscript/container_functions_spec.lua14
-rw-r--r--test/functional/vimscript/ctx_functions_spec.lua40
-rw-r--r--test/functional/vimscript/environ_spec.lua8
-rw-r--r--test/functional/vimscript/errorlist_spec.lua6
-rw-r--r--test/functional/vimscript/eval_spec.lua16
-rw-r--r--test/functional/vimscript/execute_spec.lua24
-rw-r--r--test/functional/vimscript/fnamemodify_spec.lua4
-rw-r--r--test/functional/vimscript/has_spec.lua108
-rw-r--r--test/functional/vimscript/input_spec.lua56
-rw-r--r--test/functional/vimscript/json_functions_spec.lua184
-rw-r--r--test/functional/vimscript/let_spec.lua18
-rw-r--r--test/functional/vimscript/map_functions_spec.lua76
-rw-r--r--test/functional/vimscript/match_functions_spec.lua70
-rw-r--r--test/functional/vimscript/minmax_functions_spec.lua8
-rw-r--r--test/functional/vimscript/msgpack_functions_spec.lua8
-rw-r--r--test/functional/vimscript/null_spec.lua22
-rw-r--r--test/functional/vimscript/printf_spec.lua48
-rw-r--r--test/functional/vimscript/reltime_spec.lua4
-rw-r--r--test/functional/vimscript/screenchar_spec.lua48
-rw-r--r--test/functional/vimscript/screenpos_spec.lua56
-rw-r--r--test/functional/vimscript/server_spec.lua65
-rw-r--r--test/functional/vimscript/setpos_spec.lua4
-rw-r--r--test/functional/vimscript/sort_spec.lua8
-rw-r--r--test/functional/vimscript/special_vars_spec.lua52
-rw-r--r--test/functional/vimscript/state_spec.lua8
-rw-r--r--test/functional/vimscript/string_spec.lua80
-rw-r--r--test/functional/vimscript/system_spec.lua16
-rw-r--r--test/functional/vimscript/timer_spec.lua8
-rw-r--r--test/functional/vimscript/wait_spec.lua12
-rw-r--r--test/functional/vimscript/writefile_spec.lua38
214 files changed, 6461 insertions, 6578 deletions
diff --git a/test/functional/api/autocmd_spec.lua b/test/functional/api/autocmd_spec.lua
index 47cb8bfd54..e89abf6c64 100644
--- a/test/functional/api/autocmd_spec.lua
+++ b/test/functional/api/autocmd_spec.lua
@@ -6,7 +6,7 @@ local eq = helpers.eq
local neq = helpers.neq
local exec_lua = helpers.exec_lua
local matches = helpers.matches
-local meths = helpers.meths
+local api = helpers.api
local source = helpers.source
local pcall_err = helpers.pcall_err
@@ -17,7 +17,7 @@ describe('autocmd api', function()
it('validation', function()
eq(
"Cannot use both 'callback' and 'command'",
- pcall_err(meths.nvim_create_autocmd, 'BufReadPost', {
+ pcall_err(api.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.nvim_create_autocmd, 'FileType', {
+ pcall_err(api.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.nvim_create_autocmd, {}, {
+ pcall_err(api.nvim_create_autocmd, {}, {
command = 'ls',
})
)
- eq("Required: 'command' or 'callback'", pcall_err(meths.nvim_create_autocmd, 'FileType', {}))
+ eq("Required: 'command' or 'callback'", pcall_err(api.nvim_create_autocmd, 'FileType', {}))
eq(
"Invalid 'desc': expected String, got Integer",
- pcall_err(meths.nvim_create_autocmd, 'FileType', {
+ pcall_err(api.nvim_create_autocmd, 'FileType', {
command = 'ls',
desc = 42,
})
)
eq(
"Invalid 'callback': expected Lua function or Vim function name, got Integer",
- pcall_err(meths.nvim_create_autocmd, 'FileType', {
+ pcall_err(api.nvim_create_autocmd, 'FileType', {
callback = 0,
})
)
eq(
"Invalid 'event' item: expected String, got Array",
- pcall_err(meths.nvim_create_autocmd, { 'FileType', {} }, {})
+ pcall_err(api.nvim_create_autocmd, { 'FileType', {} }, {})
)
eq(
"Invalid 'group': 0",
- pcall_err(meths.nvim_create_autocmd, 'FileType', {
+ pcall_err(api.nvim_create_autocmd, 'FileType', {
group = 0,
command = 'ls',
})
)
- eq("Invalid 'event': 'foo'", pcall_err(meths.nvim_create_autocmd, 'foo', { command = '' }))
+ eq("Invalid 'event': 'foo'", pcall_err(api.nvim_create_autocmd, 'foo', { command = '' }))
eq(
"Invalid 'event': 'VimEnter '",
- pcall_err(meths.nvim_create_autocmd, 'VimEnter ', { command = '' })
+ pcall_err(api.nvim_create_autocmd, 'VimEnter ', { command = '' })
)
eq(
"Invalid 'event': 'VimEnter foo'",
- pcall_err(meths.nvim_create_autocmd, 'VimEnter foo', { command = '' })
+ pcall_err(api.nvim_create_autocmd, 'VimEnter foo', { command = '' })
)
eq(
"Invalid 'event': 'BufAdd,BufDelete'",
- pcall_err(meths.nvim_create_autocmd, 'BufAdd,BufDelete', { command = '' })
+ pcall_err(api.nvim_create_autocmd, 'BufAdd,BufDelete', { command = '' })
)
end)
@@ -102,25 +102,25 @@ describe('autocmd api', function()
end)
it('allows passing buffer by key', function()
- meths.nvim_set_var('called', 0)
+ api.nvim_set_var('called', 0)
- meths.nvim_create_autocmd('FileType', {
+ api.nvim_create_autocmd('FileType', {
command = 'let g:called = g:called + 1',
buffer = 0,
})
command 'set filetype=txt'
- eq(1, meths.nvim_get_var('called'))
+ eq(1, api.nvim_get_var('called'))
-- switch to a new buffer
command 'new'
command 'set filetype=python'
- eq(1, meths.nvim_get_var('called'))
+ eq(1, api.nvim_get_var('called'))
end)
it('does not allow passing invalid buffers', function()
- local ok, msg = pcall(meths.nvim_create_autocmd, 'FileType', {
+ local ok, msg = pcall(api.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.nvim_create_autocmd, 'BufReadPost', {
+ local ok = pcall(api.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.nvim_create_autocmd('BufReadPost', {
+ api.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.nvim_get_autocmds { event = 'BufReadPost' })
+ eq(2, #api.nvim_get_autocmds { event = 'BufReadPost' })
end)
it('should handle multiple values as array', function()
- meths.nvim_create_autocmd('BufReadPost', {
+ api.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.nvim_get_autocmds { event = 'BufReadPost' })
+ eq(2, #api.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.nvim_create_autocmd('BufReadPost', {
+ api.nvim_create_autocmd('BufReadPost', {
pattern = '*.py',
command = cmd,
desc = desc,
})
- eq(desc, meths.nvim_get_autocmds { event = 'BufReadPost' }[1].desc)
- eq(cmd, meths.nvim_get_autocmds { event = 'BufReadPost' }[1].command)
+ eq(desc, api.nvim_get_autocmds { event = 'BufReadPost' }[1].desc)
+ eq(cmd, api.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.nvim_set_var('desc', desc)
+ api.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.nvim_get_autocmds({ event = 'BufReadPost' })[1].desc)
+ eq(nil, api.nvim_get_autocmds({ event = 'BufReadPost' })[1].desc)
end)
it('can add description to multiple autocmd', function()
- meths.nvim_create_autocmd('BufReadPost', {
+ api.nvim_create_autocmd('BufReadPost', {
pattern = { '*.py', '*.pyi' },
command = "echo 'Should Not Have Errored'",
desc = 'Can show description',
})
- local aus = meths.nvim_get_autocmds { event = 'BufReadPost' }
+ local aus = api.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.nvim_create_autocmd('BufReadPost', {
+ api.nvim_create_autocmd('BufReadPost', {
pattern = '*.py',
command = "echo 'Should Not Have Errored'",
desc = 'Can show description',
})
- local aus = meths.nvim_get_autocmds { event = 'BufReadPost' }
+ local aus = api.nvim_get_autocmds { event = 'BufReadPost' }
eq(1, #aus, aus)
end)
end)
it('removes an autocommand if the callback returns true', function()
- meths.nvim_set_var('some_condition', false)
+ api.nvim_set_var('some_condition', false)
exec_lua [[
vim.api.nvim_create_autocmd("User", {
@@ -261,21 +261,21 @@ describe('autocmd api', function()
})
]]
- meths.nvim_exec_autocmds('User', { pattern = 'Test' })
+ api.nvim_exec_autocmds('User', { pattern = 'Test' })
- local aus = meths.nvim_get_autocmds({ event = 'User', pattern = 'Test' })
+ local aus = api.nvim_get_autocmds({ event = 'User', pattern = 'Test' })
local first = aus[1]
eq(true, first.id > 0)
- meths.nvim_set_var('some_condition', true)
- meths.nvim_exec_autocmds('User', { pattern = 'Test' })
- eq({}, meths.nvim_get_autocmds({ event = 'User', pattern = 'Test' }))
+ api.nvim_set_var('some_condition', true)
+ api.nvim_exec_autocmds('User', { pattern = 'Test' })
+ eq({}, api.nvim_get_autocmds({ event = 'User', pattern = 'Test' }))
end)
it('receives an args table', function()
- local group_id = meths.nvim_create_augroup('TestGroup', {})
+ local group_id = api.nvim_create_augroup('TestGroup', {})
-- Having an existing autocmd calling expand("<afile>") shouldn't change args #18964
- meths.nvim_create_autocmd('User', {
+ api.nvim_create_autocmd('User', {
group = 'TestGroup',
pattern = 'Te*',
command = 'call expand("<afile>")',
@@ -291,7 +291,7 @@ describe('autocmd api', function()
})
]]
- meths.nvim_exec_autocmds('User', { pattern = 'Test pattern' })
+ api.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.nvim_get_var('autocmd_args'))
+ }, api.nvim_get_var('autocmd_args'))
-- Test without a group
autocmd_id = exec_lua [[
@@ -311,7 +311,7 @@ describe('autocmd api', function()
})
]]
- meths.nvim_exec_autocmds('User', { pattern = 'some_pat' })
+ api.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.nvim_get_var('autocmd_args'))
+ }, api.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.nvim_get_autocmds, {
+ pcall_err(api.nvim_get_autocmds, {
group = 9997999,
})
)
eq(
"Invalid 'group': 'bogus'",
- pcall_err(meths.nvim_get_autocmds, {
+ pcall_err(api.nvim_get_autocmds, {
group = 'bogus',
})
)
eq(
"Invalid 'group': 0",
- pcall_err(meths.nvim_get_autocmds, {
+ pcall_err(api.nvim_get_autocmds, {
group = 0,
})
)
eq(
"Invalid 'group': expected String or Integer, got Array",
- pcall_err(meths.nvim_get_autocmds, {
+ pcall_err(api.nvim_get_autocmds, {
group = {},
})
)
eq(
"Invalid 'buffer': expected Integer or Array, got Boolean",
- pcall_err(meths.nvim_get_autocmds, {
+ pcall_err(api.nvim_get_autocmds, {
buffer = true,
})
)
eq(
"Invalid 'event': expected String or Array",
- pcall_err(meths.nvim_get_autocmds, {
+ pcall_err(api.nvim_get_autocmds, {
event = true,
})
)
eq(
"Invalid 'pattern': expected String or Array, got Boolean",
- pcall_err(meths.nvim_get_autocmds, {
+ pcall_err(api.nvim_get_autocmds, {
pattern = true,
})
)
@@ -408,7 +408,7 @@ describe('autocmd api', function()
command [[au! InsertEnter]]
command [[au InsertEnter * :echo "1"]]
- local aus = meths.nvim_get_autocmds { event = 'InsertEnter' }
+ local aus = api.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.nvim_get_autocmds { event = 'InsertEnter' }
+ local aus = api.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.nvim_get_autocmds { event = 'InsertEnter' }
- local array_aus = meths.nvim_get_autocmds { event = { 'InsertEnter' } }
+ local string_aus = api.nvim_get_autocmds { event = 'InsertEnter' }
+ local array_aus = api.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.nvim_get_autocmds { event = { 'InsertEnter', 'InsertLeave' } }
+ local aus = api.nvim_get_autocmds { event = { 'InsertEnter', 'InsertLeave' } }
eq(2, #aus)
end)
@@ -451,7 +451,7 @@ describe('autocmd api', function()
\ })
]]
- local aus = meths.nvim_get_autocmds { event = { 'InsertEnter', 'InsertLeave' } }
+ local aus = api.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.nvim_del_autocmd(second.id)
- local new_aus = meths.nvim_get_autocmds { event = { 'InsertEnter', 'InsertLeave' } }
+ api.nvim_del_autocmd(second.id)
+ local new_aus = api.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.nvim_get_autocmds { event = 'InsertEnter' }
+ local aus = api.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.nvim_get_autocmds { event = 'InsertEnter', buffer = 0 }
+ local aus = api.nvim_get_autocmds { event = 'InsertEnter', buffer = 0 }
eq({
{
buffer = 2,
@@ -499,7 +499,7 @@ describe('autocmd api', function()
},
}, aus)
- aus = meths.nvim_get_autocmds { event = 'InsertEnter', buffer = 1 }
+ aus = api.nvim_get_autocmds { event = 'InsertEnter', buffer = 1 }
eq({
{
buffer = 1,
@@ -511,7 +511,7 @@ describe('autocmd api', function()
},
}, aus)
- aus = meths.nvim_get_autocmds { event = 'InsertEnter', buffer = { 1, 2 } }
+ aus = api.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.nvim_get_autocmds, { event = 'InsertEnter', buffer = 'foo' })
+ pcall_err(api.nvim_get_autocmds, { event = 'InsertEnter', buffer = 'foo' })
)
eq(
"Invalid 'buffer': expected Integer, got String",
- pcall_err(meths.nvim_get_autocmds, { event = 'InsertEnter', buffer = { 'foo', 42 } })
+ pcall_err(api.nvim_get_autocmds, { event = 'InsertEnter', buffer = { 'foo', 42 } })
)
eq(
'Invalid buffer id: 42',
- pcall_err(meths.nvim_get_autocmds, { event = 'InsertEnter', buffer = { 42 } })
+ pcall_err(api.nvim_get_autocmds, { event = 'InsertEnter', buffer = { 42 } })
)
local bufs = {}
for _ = 1, 257 do
- table.insert(bufs, meths.nvim_create_buf(true, false))
+ table.insert(bufs, api.nvim_create_buf(true, false))
end
eq(
'Too many buffers (maximum of 256)',
- pcall_err(meths.nvim_get_autocmds, { event = 'InsertEnter', buffer = bufs })
+ pcall_err(api.nvim_get_autocmds, { event = 'InsertEnter', buffer = bufs })
)
end)
it('returns autocmds when group is specified by id', function()
- 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 auid = api.nvim_create_augroup('nvim_test_augroup', { clear = true })
+ api.nvim_create_autocmd('FileType', { group = auid, command = 'echo "1"' })
+ api.nvim_create_autocmd('FileType', { group = auid, command = 'echo "2"' })
- local aus = meths.nvim_get_autocmds { group = auid }
+ local aus = api.nvim_get_autocmds { group = auid }
eq(2, #aus)
- local aus2 = meths.nvim_get_autocmds { group = auid, event = 'InsertEnter' }
+ local aus2 = api.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.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"' })
+ api.nvim_create_augroup(auname, { clear = true })
+ api.nvim_create_autocmd('FileType', { group = auname, command = 'echo "1"' })
+ api.nvim_create_autocmd('FileType', { group = auname, command = 'echo "2"' })
- local aus = meths.nvim_get_autocmds { group = auname }
+ local aus = api.nvim_get_autocmds { group = auname }
eq(2, #aus)
- local aus2 = meths.nvim_get_autocmds { group = auname, event = 'InsertEnter' }
+ local aus2 = api.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.nvim_set_var('content', content)
+ api.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.nvim_get_autocmds { event = 'InsertEnter' }
+ local aus = api.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.nvim_get_autocmds {
+ local aus = api.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.nvim_get_autocmds {
+ local aus = api.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.nvim_exec_lua(
+ local success, code = unpack(api.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.nvim_exec_lua(
+ local success, code = unpack(api.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.nvim_exec_lua(
+ local success, code = unpack(api.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.nvim_exec_lua(
+ local success, code = unpack(api.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.nvim_get_autocmds {
+ local aus = api.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.nvim_get_autocmds {
+ local aus = api.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.nvim_get_autocmds {
+ local normalized_aus = api.nvim_get_autocmds {
event = 'InsertEnter',
pattern = '<buffer=1>',
}
- local raw_aus = meths.nvim_get_autocmds {
+ local raw_aus = api.nvim_get_autocmds {
event = 'InsertEnter',
pattern = '<buffer>',
}
- local zero_aus = meths.nvim_get_autocmds {
+ local zero_aus = api.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.nvim_exec_autocmds, 'FileType', {
+ pcall_err(api.nvim_exec_autocmds, 'FileType', {
group = 9997999,
})
)
eq(
"Invalid 'group': 'bogus'",
- pcall_err(meths.nvim_exec_autocmds, 'FileType', {
+ pcall_err(api.nvim_exec_autocmds, 'FileType', {
group = 'bogus',
})
)
eq(
"Invalid 'group': expected String or Integer, got Array",
- pcall_err(meths.nvim_exec_autocmds, 'FileType', {
+ pcall_err(api.nvim_exec_autocmds, 'FileType', {
group = {},
})
)
eq(
"Invalid 'group': 0",
- pcall_err(meths.nvim_exec_autocmds, 'FileType', {
+ pcall_err(api.nvim_exec_autocmds, 'FileType', {
group = 0,
})
)
eq(
"Invalid 'buffer': expected Buffer, got Array",
- pcall_err(meths.nvim_exec_autocmds, 'FileType', {
+ pcall_err(api.nvim_exec_autocmds, 'FileType', {
buffer = {},
})
)
eq(
"Invalid 'event' item: expected String, got Array",
- pcall_err(meths.nvim_exec_autocmds, { 'FileType', {} }, {})
+ pcall_err(api.nvim_exec_autocmds, { 'FileType', {} }, {})
)
end)
it('can trigger builtin autocmds', function()
- meths.nvim_set_var('autocmd_executed', false)
+ api.nvim_set_var('autocmd_executed', false)
- meths.nvim_create_autocmd('BufReadPost', {
+ api.nvim_create_autocmd('BufReadPost', {
pattern = '*',
command = 'let g:autocmd_executed = v:true',
})
- eq(false, meths.nvim_get_var('autocmd_executed'))
- meths.nvim_exec_autocmds('BufReadPost', {})
- eq(true, meths.nvim_get_var('autocmd_executed'))
+ eq(false, api.nvim_get_var('autocmd_executed'))
+ api.nvim_exec_autocmds('BufReadPost', {})
+ eq(true, api.nvim_get_var('autocmd_executed'))
end)
it('can trigger multiple patterns', function()
- meths.nvim_set_var('autocmd_executed', 0)
+ api.nvim_set_var('autocmd_executed', 0)
- meths.nvim_create_autocmd('BufReadPost', {
+ api.nvim_create_autocmd('BufReadPost', {
pattern = '*',
command = 'let g:autocmd_executed += 1',
})
- meths.nvim_exec_autocmds('BufReadPost', { pattern = { '*.lua', '*.vim' } })
- eq(2, meths.nvim_get_var('autocmd_executed'))
+ api.nvim_exec_autocmds('BufReadPost', { pattern = { '*.lua', '*.vim' } })
+ eq(2, api.nvim_get_var('autocmd_executed'))
- meths.nvim_create_autocmd('BufReadPre', {
+ api.nvim_create_autocmd('BufReadPre', {
pattern = { 'bar', 'foo' },
command = 'let g:autocmd_executed += 10',
})
- meths.nvim_exec_autocmds('BufReadPre', { pattern = { 'foo', 'bar', 'baz', 'frederick' } })
- eq(22, meths.nvim_get_var('autocmd_executed'))
+ api.nvim_exec_autocmds('BufReadPre', { pattern = { 'foo', 'bar', 'baz', 'frederick' } })
+ eq(22, api.nvim_get_var('autocmd_executed'))
end)
it('can pass the buffer', function()
- meths.nvim_set_var('buffer_executed', -1)
- eq(-1, meths.nvim_get_var('buffer_executed'))
+ api.nvim_set_var('buffer_executed', -1)
+ eq(-1, api.nvim_get_var('buffer_executed'))
- meths.nvim_create_autocmd('BufLeave', {
+ api.nvim_create_autocmd('BufLeave', {
pattern = '*',
command = 'let g:buffer_executed = +expand("<abuf>")',
})
-- Doesn't execute for other non-matching events
- meths.nvim_exec_autocmds('CursorHold', { buffer = 1 })
- eq(-1, meths.nvim_get_var('buffer_executed'))
+ api.nvim_exec_autocmds('CursorHold', { buffer = 1 })
+ eq(-1, api.nvim_get_var('buffer_executed'))
- meths.nvim_exec_autocmds('BufLeave', { buffer = 1 })
- eq(1, meths.nvim_get_var('buffer_executed'))
+ api.nvim_exec_autocmds('BufLeave', { buffer = 1 })
+ eq(1, api.nvim_get_var('buffer_executed'))
end)
it('can pass the filename, pattern match', function()
- meths.nvim_set_var('filename_executed', 'none')
- eq('none', meths.nvim_get_var('filename_executed'))
+ api.nvim_set_var('filename_executed', 'none')
+ eq('none', api.nvim_get_var('filename_executed'))
- meths.nvim_create_autocmd('BufEnter', {
+ api.nvim_create_autocmd('BufEnter', {
pattern = '*.py',
command = 'let g:filename_executed = expand("<afile>")',
})
-- Doesn't execute for other non-matching events
- meths.nvim_exec_autocmds('CursorHold', { buffer = 1 })
- eq('none', meths.nvim_get_var('filename_executed'))
+ api.nvim_exec_autocmds('CursorHold', { buffer = 1 })
+ eq('none', api.nvim_get_var('filename_executed'))
command('edit __init__.py')
- eq('__init__.py', meths.nvim_get_var('filename_executed'))
+ eq('__init__.py', api.nvim_get_var('filename_executed'))
end)
it('cannot pass buf and fname', function()
local ok = pcall(
- meths.nvim_exec_autocmds,
+ api.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.nvim_set_var('filename_executed', 'none')
- eq('none', meths.nvim_get_var('filename_executed'))
+ api.nvim_set_var('filename_executed', 'none')
+ eq('none', api.nvim_get_var('filename_executed'))
command('edit other_file.txt')
command('edit __init__.py')
- eq('none', meths.nvim_get_var('filename_executed'))
+ eq('none', api.nvim_get_var('filename_executed'))
- meths.nvim_create_autocmd('CursorHoldI', {
+ api.nvim_create_autocmd('CursorHoldI', {
pattern = '__init__.py',
command = 'let g:filename_executed = expand("<afile>")',
})
-- Doesn't execute for other non-matching events
- meths.nvim_exec_autocmds('CursorHoldI', { buffer = 1 })
- eq('none', meths.nvim_get_var('filename_executed'))
+ api.nvim_exec_autocmds('CursorHoldI', { buffer = 1 })
+ eq('none', api.nvim_get_var('filename_executed'))
- meths.nvim_exec_autocmds('CursorHoldI', { buffer = meths.nvim_get_current_buf() })
- eq('__init__.py', meths.nvim_get_var('filename_executed'))
+ api.nvim_exec_autocmds('CursorHoldI', { buffer = api.nvim_get_current_buf() })
+ eq('__init__.py', api.nvim_get_var('filename_executed'))
-- Reset filename
- meths.nvim_set_var('filename_executed', 'none')
+ api.nvim_set_var('filename_executed', 'none')
- meths.nvim_exec_autocmds('CursorHoldI', { pattern = '__init__.py' })
- eq('__init__.py', meths.nvim_get_var('filename_executed'))
+ api.nvim_exec_autocmds('CursorHoldI', { pattern = '__init__.py' })
+ eq('__init__.py', api.nvim_get_var('filename_executed'))
end)
it('works with user autocmds', function()
- meths.nvim_set_var('matched', 'none')
+ api.nvim_set_var('matched', 'none')
- meths.nvim_create_autocmd('User', {
+ api.nvim_create_autocmd('User', {
pattern = 'TestCommand',
command = 'let g:matched = "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'))
+ api.nvim_exec_autocmds('User', { pattern = 'OtherCommand' })
+ eq('none', api.nvim_get_var('matched'))
+ api.nvim_exec_autocmds('User', { pattern = 'TestCommand' })
+ eq('matched', api.nvim_get_var('matched'))
end)
it('can pass group by id', function()
- meths.nvim_set_var('group_executed', false)
+ api.nvim_set_var('group_executed', false)
- local auid = meths.nvim_create_augroup('nvim_test_augroup', { clear = true })
- meths.nvim_create_autocmd('FileType', {
+ local auid = api.nvim_create_augroup('nvim_test_augroup', { clear = true })
+ api.nvim_create_autocmd('FileType', {
group = auid,
command = 'let g:group_executed = v:true',
})
- eq(false, meths.nvim_get_var('group_executed'))
- meths.nvim_exec_autocmds('FileType', { group = auid })
- eq(true, meths.nvim_get_var('group_executed'))
+ eq(false, api.nvim_get_var('group_executed'))
+ api.nvim_exec_autocmds('FileType', { group = auid })
+ eq(true, api.nvim_get_var('group_executed'))
end)
it('can pass group by name', function()
- meths.nvim_set_var('group_executed', false)
+ api.nvim_set_var('group_executed', false)
local auname = 'nvim_test_augroup'
- meths.nvim_create_augroup(auname, { clear = true })
- meths.nvim_create_autocmd('FileType', {
+ api.nvim_create_augroup(auname, { clear = true })
+ api.nvim_create_autocmd('FileType', {
group = auname,
command = 'let g:group_executed = v:true',
})
- eq(false, meths.nvim_get_var('group_executed'))
- meths.nvim_exec_autocmds('FileType', { group = auname })
- eq(true, meths.nvim_get_var('group_executed'))
+ eq(false, api.nvim_get_var('group_executed'))
+ api.nvim_exec_autocmds('FileType', { group = auname })
+ eq(true, api.nvim_get_var('group_executed'))
end)
end)
@@ -1026,7 +1026,7 @@ describe('autocmd api', function()
before_each(function()
clear()
- meths.nvim_set_var('executed', 0)
+ api.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.nvim_create_autocmd('FileType', resulting)
+ api.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.nvim_get_var('executed')
+ return api.nvim_get_var('executed')
end
it('can be added in a group', function()
local augroup = 'TestGroup'
- meths.nvim_create_augroup(augroup, { clear = true })
+ api.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.nvim_create_autocmd, 'FileType', {
+ local success, code = pcall(api.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.nvim_create_augroup(augroup, { clear = true })
- meths.nvim_create_autocmd('FileType', {
+ api.nvim_create_augroup(augroup, { clear = true })
+ api.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.nvim_create_augroup(augroup, { clear = true })
- eq({}, meths.nvim_get_autocmds { group = augroup })
+ api.nvim_create_augroup(augroup, { clear = true })
+ eq({}, api.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.nvim_del_augroup_by_name, 'noexist'))
+ eq('Vim:E367: No such group: "noexist"', pcall_err(api.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.nvim_del_augroup_by_id, -12312))
+ eq('Vim:E367: No such group: "--Deleted--"', pcall_err(api.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.nvim_del_augroup_by_id, 0))
+ eq('Vim:E367: No such group: "[NULL]"', pcall_err(api.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.nvim_del_augroup_by_id, 12312))
+ eq('Vim:E367: No such group: "[NULL]"', pcall_err(api.nvim_del_augroup_by_id, 12312))
end)
it('groups work with once', function()
local augroup = 'TestGroup'
- meths.nvim_create_augroup(augroup, { clear = true })
+ api.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.nvim_create_augroup(augroup, { clear = true })
+ api.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.nvim_create_augroup(augroup, { clear = true })
- meths.nvim_create_autocmd({ 'FileType' }, {
+ api.nvim_create_augroup(augroup, { clear = true })
+ api.nvim_create_autocmd({ 'FileType' }, {
pattern = '*',
command = "echo 'does not matter'",
})
-- Clears the augroup from before, which erases the autocmd
- meths.nvim_create_augroup(augroup, { clear = true })
+ api.nvim_create_augroup(augroup, { clear = true })
- local result = #meths.nvim_get_autocmds { group = augroup }
+ local result = #api.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.nvim_set_var('value_set', false)
+ api.nvim_set_var('value_set', false)
- meths.nvim_create_augroup(augroup, { clear = true })
- meths.nvim_create_autocmd('FileType', {
+ api.nvim_create_augroup(augroup, { clear = true })
+ api.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.nvim_get_var('value_set'))
+ eq(false, api.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.nvim_get_var('vimscript_executed'))
+ eq(2, api.nvim_get_var('vimscript_executed'))
end)
end)
@@ -1314,11 +1314,11 @@ describe('autocmd api', function()
command('augroup! TEMP_A')
- eq(false, pcall(meths.nvim_get_autocmds, { group = 'TEMP_A' }))
+ eq(false, pcall(api.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.nvim_get_autocmds { event = 'BufReadPost' })
+ eq(1, #api.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.nvim_get_autocmds, { group = 'TEMP_AB' }))
- eq(0, #meths.nvim_get_autocmds { event = 'BufReadPost' })
+ eq(false, pcall(api.nvim_get_autocmds, { group = 'TEMP_AB' }))
+ eq(0, #api.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.nvim_get_autocmds { event = 'BufReadPost' }
+ local aus = api.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.nvim_get_autocmds { event = 'BufReadPost' }
+ aus = api.nvim_get_autocmds { event = 'BufReadPost' }
eq(2, #aus, aus)
command('augroup! TEMP_ABC')
- eq(false, pcall(meths.nvim_get_autocmds, { group = 'TEMP_ABC' }))
- eq(2, #meths.nvim_get_autocmds { event = 'BufReadPost' })
+ eq(false, pcall(api.nvim_get_autocmds, { group = 'TEMP_ABC' }))
+ eq(2, #api.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.nvim_create_augroup('TEMP_ABCD', { clear = false })
- meths.nvim_del_augroup_by_id(augroup_id)
+ local augroup_id = api.nvim_create_augroup('TEMP_ABCD', { clear = false })
+ api.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.nvim_get_autocmds, { group = 'TEMP_ABCD' }))
- eq(0, #meths.nvim_get_autocmds { event = 'BufReadPost' })
+ eq(false, pcall(api.nvim_get_autocmds, { group = 'TEMP_ABCD' }))
+ eq(0, #api.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.nvim_del_augroup_by_name('TEMP_ABCDE')
+ api.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.nvim_get_autocmds, { group = 'TEMP_ABCDE' }))
- eq(0, #meths.nvim_get_autocmds { event = 'BufReadPost' })
+ eq(false, pcall(api.nvim_get_autocmds, { group = 'TEMP_ABCDE' }))
+ eq(0, #api.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.nvim_clear_autocmds, {
+ pcall_err(api.nvim_clear_autocmds, {
pattern = '*',
buffer = 42,
})
)
eq(
"Invalid 'event' item: expected String, got Array",
- pcall_err(meths.nvim_clear_autocmds, {
+ pcall_err(api.nvim_clear_autocmds, {
event = { 'FileType', {} },
})
)
- eq("Invalid 'group': 0", pcall_err(meths.nvim_clear_autocmds, { group = 0 }))
+ eq("Invalid 'group': 0", pcall_err(api.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.nvim_get_autocmds(search)
+ local before_delete = api.nvim_get_autocmds(search)
eq(1, #before_delete)
- local before_delete_all = meths.nvim_get_autocmds { event = search.event }
+ local before_delete_all = api.nvim_get_autocmds { event = search.event }
eq(2, #before_delete_all)
- meths.nvim_clear_autocmds(search)
- local after_delete = meths.nvim_get_autocmds(search)
+ api.nvim_clear_autocmds(search)
+ local after_delete = api.nvim_get_autocmds(search)
eq(0, #after_delete)
- local after_delete_all = meths.nvim_get_autocmds { event = search.event }
+ local after_delete_all = api.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.nvim_get_autocmds(search)
+ local before_delete = api.nvim_get_autocmds(search)
eq(2, #before_delete)
- meths.nvim_clear_autocmds(search)
- local after_delete = meths.nvim_get_autocmds(search)
+ api.nvim_clear_autocmds(search)
+ local after_delete = api.nvim_get_autocmds(search)
eq(0, #after_delete)
end)
@@ -1443,18 +1443,17 @@ describe('autocmd api', function()
command('autocmd InsertLeave *.TestPat2 :echo "Leave 2"')
local search = { pattern = '*.TestPat1' }
- local before_delete = meths.nvim_get_autocmds(search)
+ local before_delete = api.nvim_get_autocmds(search)
eq(2, #before_delete)
local before_delete_events =
- meths.nvim_get_autocmds { event = { 'InsertEnter', 'InsertLeave' } }
+ api.nvim_get_autocmds { event = { 'InsertEnter', 'InsertLeave' } }
eq(4, #before_delete_events)
- meths.nvim_clear_autocmds(search)
- local after_delete = meths.nvim_get_autocmds(search)
+ api.nvim_clear_autocmds(search)
+ local after_delete = api.nvim_get_autocmds(search)
eq(0, #after_delete)
- local after_delete_events =
- meths.nvim_get_autocmds { event = { 'InsertEnter', 'InsertLeave' } }
+ local after_delete_events = api.nvim_get_autocmds { event = { 'InsertEnter', 'InsertLeave' } }
eq(2, #after_delete_events)
end)
@@ -1464,11 +1463,11 @@ describe('autocmd api', function()
command('autocmd InsertEnter *.TestPat1 :echo "Enter Pattern"')
local search = { event = 'InsertEnter' }
- local before_delete = meths.nvim_get_autocmds(search)
+ local before_delete = api.nvim_get_autocmds(search)
eq(2, #before_delete)
- meths.nvim_clear_autocmds { buffer = 0 }
- local after_delete = meths.nvim_get_autocmds(search)
+ api.nvim_clear_autocmds { buffer = 0 }
+ local after_delete = api.nvim_get_autocmds(search)
eq(1, #after_delete)
eq('*.TestPat1', after_delete[1].pattern)
end)
@@ -1481,17 +1480,17 @@ describe('autocmd api', function()
command('augroup END')
local search = { event = 'InsertEnter', group = 'TestNvimClearAutocmds' }
- local before_delete = meths.nvim_get_autocmds(search)
+ local before_delete = api.nvim_get_autocmds(search)
eq(2, #before_delete)
-- Doesn't clear without passing group.
- meths.nvim_clear_autocmds { buffer = 0 }
- local without_group = meths.nvim_get_autocmds(search)
+ api.nvim_clear_autocmds { buffer = 0 }
+ local without_group = api.nvim_get_autocmds(search)
eq(2, #without_group)
-- Doesn't clear with passing group.
- meths.nvim_clear_autocmds { buffer = 0, group = search.group }
- local with_group = meths.nvim_get_autocmds(search)
+ api.nvim_clear_autocmds { buffer = 0, group = search.group }
+ local with_group = api.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 b1b4c9f583..10be4c56a7 100644
--- a/test/functional/api/buffer_spec.lua
+++ b/test/functional/api/buffer_spec.lua
@@ -4,8 +4,8 @@ local clear = helpers.clear
local eq = helpers.eq
local ok = helpers.ok
local describe_lua_and_rpc = helpers.describe_lua_and_rpc(describe)
-local meths = helpers.meths
-local funcs = helpers.funcs
+local api = helpers.api
+local fn = helpers.fn
local request = helpers.request
local exc_exec = helpers.exc_exec
local exec_lua = helpers.exec_lua
@@ -41,120 +41,114 @@ describe('api/buf', function()
end)
it("doesn't crash just after set undolevels=1 #24894", function()
- 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, {})
+ local buf = api.nvim_create_buf(false, true)
+ api.nvim_buf_set_option(buf, 'undolevels', -1)
+ api.nvim_buf_set_lines(buf, 0, 1, false, {})
assert_alive()
end)
it('cursor position is maintained after lines are inserted #9961', function()
-- replace the buffer contents with these three lines.
- meths.nvim_buf_set_lines(0, 0, -1, true, { 'line1', 'line2', 'line3', 'line4' })
+ api.nvim_buf_set_lines(0, 0, -1, true, { 'line1', 'line2', 'line3', 'line4' })
-- Set the current cursor to {3, 2}.
- meths.nvim_win_set_cursor(0, { 3, 2 })
+ api.nvim_win_set_cursor(0, { 3, 2 })
-- add 2 lines and delete 1 line above the current cursor position.
- meths.nvim_buf_set_lines(0, 1, 2, true, { 'line5', 'line6' })
+ api.nvim_buf_set_lines(0, 1, 2, true, { 'line5', 'line6' })
-- check the current set of lines in the buffer.
- eq({ 'line1', 'line5', 'line6', 'line3', 'line4' }, meths.nvim_buf_get_lines(0, 0, -1, true))
+ eq({ 'line1', 'line5', 'line6', 'line3', 'line4' }, api.nvim_buf_get_lines(0, 0, -1, true))
-- cursor should be moved below by 1 line.
- eq({ 4, 2 }, meths.nvim_win_get_cursor(0))
+ eq({ 4, 2 }, api.nvim_win_get_cursor(0))
-- add a line after the current cursor position.
- meths.nvim_buf_set_lines(0, 5, 5, true, { 'line7' })
+ api.nvim_buf_set_lines(0, 5, 5, true, { 'line7' })
-- check the current set of lines in the buffer.
eq(
{ 'line1', 'line5', 'line6', 'line3', 'line4', 'line7' },
- meths.nvim_buf_get_lines(0, 0, -1, true)
+ api.nvim_buf_get_lines(0, 0, -1, true)
)
-- cursor position is unchanged.
- eq({ 4, 2 }, meths.nvim_win_get_cursor(0))
+ eq({ 4, 2 }, api.nvim_win_get_cursor(0))
-- overwrite current cursor line.
- meths.nvim_buf_set_lines(0, 3, 5, true, { 'line8', 'line9' })
+ api.nvim_buf_set_lines(0, 3, 5, true, { 'line8', 'line9' })
-- check the current set of lines in the buffer.
eq(
{ 'line1', 'line5', 'line6', 'line8', 'line9', 'line7' },
- meths.nvim_buf_get_lines(0, 0, -1, true)
+ api.nvim_buf_get_lines(0, 0, -1, true)
)
-- cursor position is unchanged.
- eq({ 4, 2 }, meths.nvim_win_get_cursor(0))
+ eq({ 4, 2 }, api.nvim_win_get_cursor(0))
-- delete current cursor line.
- meths.nvim_buf_set_lines(0, 3, 5, true, {})
+ api.nvim_buf_set_lines(0, 3, 5, true, {})
-- check the current set of lines in the buffer.
- eq({ 'line1', 'line5', 'line6', 'line7' }, meths.nvim_buf_get_lines(0, 0, -1, true))
+ eq({ 'line1', 'line5', 'line6', 'line7' }, api.nvim_buf_get_lines(0, 0, -1, true))
-- cursor position is unchanged.
- eq({ 4, 2 }, meths.nvim_win_get_cursor(0))
+ eq({ 4, 2 }, api.nvim_win_get_cursor(0))
end)
it('cursor position is maintained in non-current window', function()
- meths.nvim_buf_set_lines(0, 0, -1, true, { '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()
+ api.nvim_buf_set_lines(0, 0, -1, true, { 'line1', 'line2', 'line3', 'line4' })
+ api.nvim_win_set_cursor(0, { 3, 2 })
+ local win = api.nvim_get_current_win()
+ local buf = api.nvim_get_current_buf()
command('new')
- meths.nvim_buf_set_lines(buf, 1, 2, true, { '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))
+ api.nvim_buf_set_lines(buf, 1, 2, true, { 'line5', 'line6' })
+ eq({ 'line1', 'line5', 'line6', 'line3', 'line4' }, api.nvim_buf_get_lines(buf, 0, -1, true))
+ eq({ 4, 2 }, api.nvim_win_get_cursor(win))
end)
it('cursor position is maintained in TWO non-current windows', function()
- meths.nvim_buf_set_lines(0, 0, -1, true, { '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()
+ api.nvim_buf_set_lines(0, 0, -1, true, { 'line1', 'line2', 'line3', 'line4' })
+ api.nvim_win_set_cursor(0, { 3, 2 })
+ local win = api.nvim_get_current_win()
+ local buf = api.nvim_get_current_buf()
command('split')
- meths.nvim_win_set_cursor(0, { 4, 2 })
- local win2 = meths.nvim_get_current_win()
+ api.nvim_win_set_cursor(0, { 4, 2 })
+ local win2 = api.nvim_get_current_win()
-- set current window to third one with another buffer
command('new')
- meths.nvim_buf_set_lines(buf, 1, 2, true, { '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))
+ api.nvim_buf_set_lines(buf, 1, 2, true, { 'line5', 'line6' })
+ eq({ 'line1', 'line5', 'line6', 'line3', 'line4' }, api.nvim_buf_get_lines(buf, 0, -1, true))
+ eq({ 4, 2 }, api.nvim_win_get_cursor(win))
+ eq({ 5, 2 }, api.nvim_win_get_cursor(win2))
end)
it('line_count has defined behaviour for unloaded buffers', function()
-- we'll need to know our bufnr for when it gets unloaded
- local bufnr = meths.nvim_buf_get_number(0)
+ local bufnr = api.nvim_buf_get_number(0)
-- replace the buffer contents with these three lines
- meths.nvim_buf_set_lines(bufnr, 0, -1, true, { 'line1', 'line2', 'line3', 'line4' })
+ api.nvim_buf_set_lines(bufnr, 0, -1, true, { 'line1', 'line2', 'line3', 'line4' })
-- check the line count is correct
- eq(4, meths.nvim_buf_line_count(bufnr))
+ eq(4, api.nvim_buf_line_count(bufnr))
-- force unload the buffer (this will discard changes)
command('new')
command('bunload! ' .. bufnr)
-- line count for an unloaded buffer should always be 0
- eq(0, meths.nvim_buf_line_count(bufnr))
+ eq(0, api.nvim_buf_line_count(bufnr))
end)
it('get_lines has defined behaviour for unloaded buffers', function()
-- we'll need to know our bufnr for when it gets unloaded
- local bufnr = meths.nvim_buf_get_number(0)
+ local bufnr = api.nvim_buf_get_number(0)
-- replace the buffer contents with these three lines
- meths.nvim_buf_set_lines(bufnr, 0, -1, true, { 'line1', 'line2', 'line3', 'line4' })
+ api.nvim_buf_set_lines(bufnr, 0, -1, true, { 'line1', 'line2', 'line3', 'line4' })
-- confirm that getting lines works
- eq({ 'line2', 'line3' }, meths.nvim_buf_get_lines(bufnr, 1, 3, true))
+ eq({ 'line2', 'line3' }, api.nvim_buf_get_lines(bufnr, 1, 3, true))
-- force unload the buffer (this will discard changes)
command('new')
command('bunload! ' .. bufnr)
-- attempting to get lines now always gives empty list
- eq({}, meths.nvim_buf_get_lines(bufnr, 1, 3, true))
+ eq({}, api.nvim_buf_get_lines(bufnr, 1, 3, true))
-- it's impossible to get out-of-bounds errors for an unloaded buffer
- eq({}, meths.nvim_buf_get_lines(bufnr, 8888, 9999, true))
+ eq({}, api.nvim_buf_get_lines(bufnr, 8888, 9999, true))
end)
describe('handles topline', function()
@@ -167,22 +161,22 @@ describe('api/buf', function()
[3] = { reverse = true },
}
screen:attach()
- meths.nvim_buf_set_lines(
+ api.nvim_buf_set_lines(
0,
0,
-1,
true,
{ 'aaa', 'bbb', 'ccc', 'ddd', 'www', 'xxx', 'yyy', 'zzz' }
)
- meths.nvim_set_option_value('modified', false, {})
+ api.nvim_set_option_value('modified', false, {})
end)
it('of current window', function()
- local win = meths.nvim_get_current_win()
- local buf = meths.nvim_get_current_buf()
+ local win = api.nvim_get_current_win()
+ local buf = api.nvim_get_current_buf()
command('new | wincmd w')
- meths.nvim_win_set_cursor(win, { 8, 0 })
+ api.nvim_win_set_cursor(win, { 8, 0 })
screen:expect {
grid = [[
@@ -198,7 +192,7 @@ describe('api/buf', function()
]],
}
- meths.nvim_buf_set_lines(buf, 0, 2, true, { 'aaabbb' })
+ api.nvim_buf_set_lines(buf, 0, 2, true, { 'aaabbb' })
screen:expect {
grid = [[
|
@@ -214,7 +208,7 @@ describe('api/buf', function()
}
-- replacing topline keeps it the topline
- meths.nvim_buf_set_lines(buf, 3, 4, true, { 'wwweeee' })
+ api.nvim_buf_set_lines(buf, 3, 4, true, { 'wwweeee' })
screen:expect {
grid = [[
|
@@ -230,7 +224,7 @@ describe('api/buf', function()
}
-- inserting just before topline does not scroll up if cursor would be moved
- meths.nvim_buf_set_lines(buf, 3, 3, true, { 'mmm' })
+ api.nvim_buf_set_lines(buf, 3, 3, true, { 'mmm' })
screen:expect {
grid = [[
|
@@ -246,7 +240,7 @@ describe('api/buf', function()
unchanged = true,
}
- meths.nvim_win_set_cursor(0, { 7, 0 })
+ api.nvim_win_set_cursor(0, { 7, 0 })
screen:expect {
grid = [[
|
@@ -261,7 +255,7 @@ describe('api/buf', function()
]],
}
- meths.nvim_buf_set_lines(buf, 4, 4, true, { 'mmmeeeee' })
+ api.nvim_buf_set_lines(buf, 4, 4, true, { 'mmmeeeee' })
screen:expect {
grid = [[
|
@@ -278,11 +272,11 @@ describe('api/buf', function()
end)
it('of non-current window', function()
- local win = meths.nvim_get_current_win()
- local buf = meths.nvim_get_current_buf()
+ local win = api.nvim_get_current_win()
+ local buf = api.nvim_get_current_buf()
command('new')
- meths.nvim_win_set_cursor(win, { 8, 0 })
+ api.nvim_win_set_cursor(win, { 8, 0 })
screen:expect {
grid = [[
@@ -298,7 +292,7 @@ describe('api/buf', function()
]],
}
- meths.nvim_buf_set_lines(buf, 0, 2, true, { 'aaabbb' })
+ api.nvim_buf_set_lines(buf, 0, 2, true, { 'aaabbb' })
screen:expect {
grid = [[
^ |
@@ -314,7 +308,7 @@ describe('api/buf', function()
}
-- replacing topline keeps it the topline
- meths.nvim_buf_set_lines(buf, 3, 4, true, { 'wwweeee' })
+ api.nvim_buf_set_lines(buf, 3, 4, true, { 'wwweeee' })
screen:expect {
grid = [[
^ |
@@ -330,7 +324,7 @@ describe('api/buf', function()
}
-- inserting just before topline scrolls up
- meths.nvim_buf_set_lines(buf, 3, 3, true, { 'mmm' })
+ api.nvim_buf_set_lines(buf, 3, 3, true, { 'mmm' })
screen:expect {
grid = [[
^ |
@@ -347,12 +341,12 @@ describe('api/buf', function()
end)
it('of split windows with same buffer', function()
- local win = meths.nvim_get_current_win()
- local buf = meths.nvim_get_current_buf()
+ local win = api.nvim_get_current_win()
+ local buf = api.nvim_get_current_buf()
command('split')
- meths.nvim_win_set_cursor(win, { 8, 0 })
- meths.nvim_win_set_cursor(0, { 1, 0 })
+ api.nvim_win_set_cursor(win, { 8, 0 })
+ api.nvim_win_set_cursor(0, { 1, 0 })
screen:expect {
grid = [[
@@ -370,7 +364,7 @@ describe('api/buf', function()
|
]],
}
- meths.nvim_buf_set_lines(buf, 0, 2, true, { 'aaabbb' })
+ api.nvim_buf_set_lines(buf, 0, 2, true, { 'aaabbb' })
screen:expect {
grid = [[
@@ -390,7 +384,7 @@ describe('api/buf', function()
}
-- replacing topline keeps it the topline
- meths.nvim_buf_set_lines(buf, 3, 4, true, { 'wwweeee' })
+ api.nvim_buf_set_lines(buf, 3, 4, true, { 'wwweeee' })
screen:expect {
grid = [[
^aaabbb |
@@ -409,7 +403,7 @@ describe('api/buf', function()
}
-- inserting just before topline scrolls up
- meths.nvim_buf_set_lines(buf, 3, 3, true, { 'mmm' })
+ api.nvim_buf_set_lines(buf, 3, 3, true, { 'mmm' })
screen:expect {
grid = [[
^aaabbb |
@@ -430,15 +424,15 @@ describe('api/buf', function()
end)
it('handles clearing out non-current buffer #24911', function()
- local buf = meths.nvim_get_current_buf()
- meths.nvim_buf_set_lines(buf, 0, -1, true, { 'aaa', 'bbb', 'ccc' })
+ local buf = api.nvim_get_current_buf()
+ api.nvim_buf_set_lines(buf, 0, -1, true, { 'aaa', 'bbb', 'ccc' })
command('new')
- meths.nvim_buf_set_lines(0, 0, -1, true, { 'xxx', 'yyy', 'zzz' })
+ api.nvim_buf_set_lines(0, 0, -1, true, { 'xxx', 'yyy', 'zzz' })
- 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))
+ api.nvim_buf_set_lines(buf, 0, -1, true, {})
+ eq({ 'xxx', 'yyy', 'zzz' }, api.nvim_buf_get_lines(0, 0, -1, true))
+ eq({ '' }, api.nvim_buf_get_lines(buf, 0, -1, true))
end)
end)
@@ -520,24 +514,24 @@ describe('api/buf', function()
end)
end)
- describe_lua_and_rpc('nvim_buf_get_lines, nvim_buf_set_lines', function(api)
+ describe_lua_and_rpc('nvim_buf_get_lines, nvim_buf_set_lines', function(lua_or_rpc)
local function get_lines(...)
- return api.meths.nvim_buf_get_lines(0, ...)
+ return lua_or_rpc.nvim_buf_get_lines(0, ...)
end
local function set_lines(...)
- return api.meths.nvim_buf_set_lines(0, ...)
+ return lua_or_rpc.nvim_buf_set_lines(0, ...)
end
local function line_count()
- return api.meths.nvim_buf_line_count(0)
+ return lua_or_rpc.nvim_buf_line_count(0)
end
it('fails correctly when input is not valid', function()
- eq(1, api.meths.nvim_buf_get_number(0))
+ eq(1, lua_or_rpc.nvim_buf_get_number(0))
eq(
[['replacement string' item contains newlines]],
- pcall_err(api.meths.nvim_buf_set_lines, 1, 1, 2, false, { 'b\na' })
+ pcall_err(lua_or_rpc.nvim_buf_set_lines, 1, 1, 2, false, { 'b\na' })
)
end)
@@ -545,7 +539,7 @@ describe('api/buf', function()
command('set nomodifiable')
eq(
[[Buffer is not 'modifiable']],
- pcall_err(api.meths.nvim_buf_set_lines, 1, 1, 2, false, { 'a', 'b' })
+ pcall_err(lua_or_rpc.nvim_buf_set_lines, 1, 1, 2, false, { 'a', 'b' })
)
end)
@@ -701,7 +695,7 @@ describe('api/buf', function()
Who would win?
A real window
with proper text]])
- local buf = api.meths.nvim_create_buf(false, true)
+ local buf = lua_or_rpc.nvim_create_buf(false, true)
screen:expect([[
Who would win? |
A real window |
@@ -710,7 +704,7 @@ describe('api/buf', function()
|
]])
- api.meths.nvim_buf_set_lines(buf, 0, -1, true, { 'or some', 'scratchy text' })
+ lua_or_rpc.nvim_buf_set_lines(buf, 0, -1, true, { 'or some', 'scratchy text' })
feed('i') -- provoke redraw
screen:expect([[
Who would win? |
@@ -726,41 +720,41 @@ describe('api/buf', function()
visible buffer line 1
line 2
]])
- local hiddenbuf = api.meths.nvim_create_buf(false, true)
+ local hiddenbuf = lua_or_rpc.nvim_create_buf(false, true)
command('vsplit')
command('vsplit')
feed('<c-w>l<c-w>l<c-w>l')
- eq(3, funcs.winnr())
+ eq(3, fn.winnr())
feed('<c-w>h')
- eq(2, funcs.winnr())
- api.meths.nvim_buf_set_lines(hiddenbuf, 0, -1, true, { 'hidden buffer line 1', 'line 2' })
+ eq(2, fn.winnr())
+ lua_or_rpc.nvim_buf_set_lines(hiddenbuf, 0, -1, true, { 'hidden buffer line 1', 'line 2' })
feed('<c-w>p')
- eq(3, funcs.winnr())
+ eq(3, fn.winnr())
end)
it('set_lines on unloaded buffer #8659 #22670', function()
- local bufnr = meths.nvim_buf_get_number(0)
- meths.nvim_buf_set_lines(bufnr, 0, -1, false, { 'a', 'b', 'c' })
- meths.nvim_buf_set_name(bufnr, 'set_lines')
+ local bufnr = api.nvim_get_current_buf().id
+ lua_or_rpc.nvim_buf_set_lines(bufnr, 0, -1, false, { 'a', 'b', 'c' })
+ lua_or_rpc.nvim_buf_set_name(bufnr, 'set_lines')
finally(function()
os.remove('set_lines')
end)
command('write!')
command('new')
command('bunload! ' .. bufnr)
- local new_bufnr = funcs.bufnr('set_lines', true)
- meths.nvim_buf_set_lines(new_bufnr, 0, -1, false, {})
- eq({ '' }, meths.nvim_buf_get_lines(new_bufnr, 0, -1, false))
+ local new_bufnr = fn.bufnr('set_lines', true)
+ lua_or_rpc.nvim_buf_set_lines(new_bufnr, 0, -1, false, {})
+ eq({ '' }, lua_or_rpc.nvim_buf_get_lines(new_bufnr, 0, -1, false))
end)
end)
describe('nvim_buf_set_text', function()
local function get_lines(...)
- return meths.nvim_buf_get_lines(0, ...)
+ return api.nvim_buf_get_lines(0, ...)
end
local function set_text(...)
- return meths.nvim_buf_set_text(0, ...)
+ return api.nvim_buf_set_text(0, ...)
end
it('works', function()
@@ -840,12 +834,12 @@ describe('api/buf', function()
]])
-- position the cursor on `!`
- meths.nvim_win_set_cursor(0, { 1, 11 })
+ api.nvim_win_set_cursor(0, { 1, 11 })
-- replace 'world' with 'foo'
set_text(0, 6, 0, 11, { 'foo' })
eq('hello foo!', curbuf_depr('get_line', 0))
-- cursor should be moved left by two columns (replacement is shorter by 2 chars)
- eq({ 1, 9 }, meths.nvim_win_get_cursor(0))
+ eq({ 1, 9 }, api.nvim_win_get_cursor(0))
end)
it('updates the cursor position in non-current window', function()
@@ -853,18 +847,18 @@ describe('api/buf', function()
hello world!]])
-- position the cursor on `!`
- meths.nvim_win_set_cursor(0, { 1, 11 })
+ api.nvim_win_set_cursor(0, { 1, 11 })
- local win = meths.nvim_get_current_win()
- local buf = meths.nvim_get_current_buf()
+ local win = api.nvim_get_current_win()
+ local buf = api.nvim_get_current_buf()
command('new')
-- replace 'world' with 'foo'
- meths.nvim_buf_set_text(buf, 0, 6, 0, 11, { 'foo' })
- eq({ 'hello foo!' }, meths.nvim_buf_get_lines(buf, 0, -1, true))
+ api.nvim_buf_set_text(buf, 0, 6, 0, 11, { 'foo' })
+ eq({ 'hello foo!' }, api.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.nvim_win_get_cursor(win))
+ eq({ 1, 9 }, api.nvim_win_get_cursor(win))
end)
it('updates the cursor position in TWO non-current windows', function()
@@ -872,24 +866,24 @@ describe('api/buf', function()
hello world!]])
-- position the cursor on `!`
- meths.nvim_win_set_cursor(0, { 1, 11 })
- local win = meths.nvim_get_current_win()
- local buf = meths.nvim_get_current_buf()
+ api.nvim_win_set_cursor(0, { 1, 11 })
+ local win = api.nvim_get_current_win()
+ local buf = api.nvim_get_current_buf()
command('split')
- local win2 = meths.nvim_get_current_win()
+ local win2 = api.nvim_get_current_win()
-- position the cursor on `w`
- meths.nvim_win_set_cursor(0, { 1, 6 })
+ api.nvim_win_set_cursor(0, { 1, 6 })
command('new')
-- replace 'hello' with 'foo'
- meths.nvim_buf_set_text(buf, 0, 0, 0, 5, { 'foo' })
- eq({ 'foo world!' }, meths.nvim_buf_get_lines(buf, 0, -1, true))
+ api.nvim_buf_set_text(buf, 0, 0, 0, 5, { 'foo' })
+ eq({ 'foo world!' }, api.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.nvim_win_get_cursor(win))
- eq({ 1, 4 }, meths.nvim_win_get_cursor(win2))
+ eq({ 1, 9 }, api.nvim_win_get_cursor(win))
+ eq({ 1, 4 }, api.nvim_win_get_cursor(win2))
end)
describe('when text is being added right at cursor position #22526', function()
@@ -898,12 +892,12 @@ describe('api/buf', function()
abcd]])
-- position the cursor on 'c'
- meths.nvim_win_set_cursor(0, { 1, 2 })
+ api.nvim_win_set_cursor(0, { 1, 2 })
-- add 'xxx' before 'c'
set_text(0, 2, 0, 2, { 'xxx' })
eq({ 'abxxxcd' }, get_lines(0, -1, true))
-- cursor should be on 'c'
- eq({ 1, 5 }, meths.nvim_win_get_cursor(0))
+ eq({ 1, 5 }, api.nvim_win_get_cursor(0))
end)
it('updates the cursor position only in non-current window when in INSERT mode', function()
@@ -911,7 +905,7 @@ describe('api/buf', function()
abcd]])
-- position the cursor on 'c'
- meths.nvim_win_set_cursor(0, { 1, 2 })
+ api.nvim_win_set_cursor(0, { 1, 2 })
-- open vertical split
feed('<c-w>v')
-- get into INSERT mode to treat cursor
@@ -921,13 +915,13 @@ describe('api/buf', function()
set_text(0, 2, 0, 2, { 'xxx' })
eq({ 'abxxxcd' }, get_lines(0, -1, true))
-- in the current window cursor should stay after 'b'
- eq({ 1, 2 }, meths.nvim_win_get_cursor(0))
+ eq({ 1, 2 }, api.nvim_win_get_cursor(0))
-- quit INSERT mode
feed('<esc>')
-- close current window
feed('<c-w>c')
-- in another window cursor should be on 'c'
- eq({ 1, 5 }, meths.nvim_win_get_cursor(0))
+ eq({ 1, 5 }, api.nvim_win_get_cursor(0))
end)
end)
@@ -937,12 +931,12 @@ describe('api/buf', function()
abcd]])
-- position the cursor on 'b'
- meths.nvim_win_set_cursor(0, { 1, 1 })
+ api.nvim_win_set_cursor(0, { 1, 1 })
-- delete 'b'
set_text(0, 1, 0, 2, {})
eq({ 'acd' }, get_lines(0, -1, true))
-- cursor is now on 'c'
- eq({ 1, 1 }, meths.nvim_win_get_cursor(0))
+ eq({ 1, 1 }, api.nvim_win_get_cursor(0))
end)
it('maintains INSERT-mode cursor position current/non-current window', function()
@@ -950,7 +944,7 @@ describe('api/buf', function()
abcd]])
-- position the cursor on 'b'
- meths.nvim_win_set_cursor(0, { 1, 1 })
+ api.nvim_win_set_cursor(0, { 1, 1 })
-- open vertical split
feed('<c-w>v')
-- get into INSERT mode to treat cursor
@@ -960,13 +954,13 @@ describe('api/buf', function()
set_text(0, 1, 0, 2, {})
eq({ 'acd' }, get_lines(0, -1, true))
-- cursor in the current window should stay after 'a'
- eq({ 1, 1 }, meths.nvim_win_get_cursor(0))
+ eq({ 1, 1 }, api.nvim_win_get_cursor(0))
-- quit INSERT mode
feed('<esc>')
-- close current window
feed('<c-w>c')
-- cursor in non-current window should stay on 'c'
- eq({ 1, 1 }, meths.nvim_win_get_cursor(0))
+ eq({ 1, 1 }, api.nvim_win_get_cursor(0))
end)
end)
@@ -978,7 +972,7 @@ describe('api/buf', function()
and finally the last one]])
-- position the cursor on ' ' before 'first'
- meths.nvim_win_set_cursor(0, { 1, 14 })
+ api.nvim_win_set_cursor(0, { 1, 14 })
set_text(0, 15, 2, 11, {
'the line we do not want',
@@ -990,7 +984,7 @@ describe('api/buf', function()
'but hopefully the last one',
}, get_lines(0, -1, true))
-- cursor should stay at the same position
- eq({ 1, 14 }, meths.nvim_win_get_cursor(0))
+ eq({ 1, 14 }, api.nvim_win_get_cursor(0))
end)
it('maintains cursor position if at start_row and column is still valid', function()
@@ -1000,7 +994,7 @@ describe('api/buf', function()
and finally the last one]])
-- position the cursor on 'f' in 'first'
- meths.nvim_win_set_cursor(0, { 1, 15 })
+ api.nvim_win_set_cursor(0, { 1, 15 })
set_text(0, 15, 2, 11, {
'the line we do not want',
@@ -1012,7 +1006,7 @@ describe('api/buf', function()
'but hopefully the last one',
}, get_lines(0, -1, true))
-- cursor should stay at the same position
- eq({ 1, 15 }, meths.nvim_win_get_cursor(0))
+ eq({ 1, 15 }, api.nvim_win_get_cursor(0))
end)
it('adjusts cursor column to keep it valid if start_row got smaller', function()
@@ -1022,7 +1016,7 @@ describe('api/buf', function()
and finally the last one]])
-- position the cursor on 't' in 'first'
- meths.nvim_win_set_cursor(0, { 1, 19 })
+ api.nvim_win_set_cursor(0, { 1, 19 })
local cursor = exec_lua([[
vim.api.nvim_buf_set_text(0, 0, 15, 2, 24, {'last'})
@@ -1031,7 +1025,7 @@ describe('api/buf', function()
eq({ 'This should be last' }, get_lines(0, -1, true))
-- cursor should end up on 't' in 'last'
- eq({ 1, 18 }, meths.nvim_win_get_cursor(0))
+ eq({ 1, 18 }, api.nvim_win_get_cursor(0))
-- immediate call to nvim_win_get_cursor should have returned the same position
eq({ 1, 18 }, cursor)
end)
@@ -1043,7 +1037,7 @@ describe('api/buf', function()
and finally the last one]])
-- position the cursor on 't' in 'first'
- meths.nvim_win_set_cursor(0, { 1, 19 })
+ api.nvim_win_set_cursor(0, { 1, 19 })
-- enter INSERT mode to treat cursor as being after 't'
feed('a')
@@ -1054,7 +1048,7 @@ describe('api/buf', function()
eq({ 'This should be last' }, get_lines(0, -1, true))
-- cursor should end up after 't' in 'last'
- eq({ 1, 19 }, meths.nvim_win_get_cursor(0))
+ eq({ 1, 19 }, api.nvim_win_get_cursor(0))
-- immediate call to nvim_win_get_cursor should have returned the same position
eq({ 1, 19 }, cursor)
end)
@@ -1066,7 +1060,7 @@ describe('api/buf', function()
and finally the last one]])
-- position the cursor on 'w' in 'want'
- meths.nvim_win_set_cursor(0, { 2, 31 })
+ api.nvim_win_set_cursor(0, { 2, 31 })
local cursor = exec_lua([[
vim.api.nvim_buf_set_text(0, 0, 15, 2, 11, {
@@ -1083,7 +1077,7 @@ describe('api/buf', function()
'and then the last one',
}, get_lines(0, -1, true))
-- cursor column should end up at the end of a row
- eq({ 2, 5 }, meths.nvim_win_get_cursor(0))
+ eq({ 2, 5 }, api.nvim_win_get_cursor(0))
-- immediate call to nvim_win_get_cursor should have returned the same position
eq({ 2, 5 }, cursor)
end)
@@ -1097,7 +1091,7 @@ describe('api/buf', function()
and finally the last one]])
-- position the cursor on 'w' in 'want'
- meths.nvim_win_set_cursor(0, { 2, 31 })
+ api.nvim_win_set_cursor(0, { 2, 31 })
-- enter INSERT mode
feed('a')
@@ -1116,7 +1110,7 @@ describe('api/buf', function()
'and then the last one',
}, get_lines(0, -1, true))
-- cursor column should end up at the end of a row
- eq({ 2, 6 }, meths.nvim_win_get_cursor(0))
+ eq({ 2, 6 }, api.nvim_win_get_cursor(0))
-- immediate call to nvim_win_get_cursor should have returned the same position
eq({ 2, 6 }, cursor)
end
@@ -1129,7 +1123,7 @@ describe('api/buf', function()
and finally the last one]])
-- position the cursor on 'n' in 'finally'
- meths.nvim_win_set_cursor(0, { 3, 6 })
+ api.nvim_win_set_cursor(0, { 3, 6 })
local cursor = exec_lua([[
vim.api.nvim_buf_set_text(0, 0, 15, 2, 11, {
@@ -1145,7 +1139,7 @@ describe('api/buf', function()
}, get_lines(0, -1, true))
-- cursor should end up on 'y' in 'hopefully'
-- to stay in the range, because it got smaller
- eq({ 2, 12 }, meths.nvim_win_get_cursor(0))
+ eq({ 2, 12 }, api.nvim_win_get_cursor(0))
-- immediate call to nvim_win_get_cursor should have returned the same position
eq({ 2, 12 }, cursor)
end)
@@ -1157,7 +1151,7 @@ describe('api/buf', function()
and finally the last one]])
-- position the cursor on 'r' in 'there'
- meths.nvim_win_set_cursor(0, { 2, 8 })
+ api.nvim_win_set_cursor(0, { 2, 8 })
local cursor = exec_lua([[
vim.api.nvim_buf_set_text(0, 0, 15, 2, 12, {})
@@ -1166,7 +1160,7 @@ describe('api/buf', function()
eq({ 'This should be the last one' }, get_lines(0, -1, true))
-- cursor should end up on the next column after deleted range
- eq({ 1, 15 }, meths.nvim_win_get_cursor(0))
+ eq({ 1, 15 }, api.nvim_win_get_cursor(0))
-- immediate call to nvim_win_get_cursor should have returned the same position
eq({ 1, 15 }, cursor)
end)
@@ -1178,7 +1172,7 @@ describe('api/buf', function()
and finally the last one]])
-- position the cursor on 'r' in 'there'
- meths.nvim_win_set_cursor(0, { 2, 8 })
+ api.nvim_win_set_cursor(0, { 2, 8 })
local cursor = exec_lua([[
vim.api.nvim_buf_set_text(0, 0, 0, 2, 4, {})
@@ -1187,7 +1181,7 @@ describe('api/buf', function()
eq({ 'finally the last one' }, get_lines(0, -1, true))
-- cursor should end up in column 0
- eq({ 1, 0 }, meths.nvim_win_get_cursor(0))
+ eq({ 1, 0 }, api.nvim_win_get_cursor(0))
-- immediate call to nvim_win_get_cursor should have returned the same position
eq({ 1, 0 }, cursor)
end)
@@ -1199,7 +1193,7 @@ describe('api/buf', function()
and finally the last one]])
-- position the cursor on 'y' in 'finally'
- meths.nvim_win_set_cursor(0, { 3, 10 })
+ api.nvim_win_set_cursor(0, { 3, 10 })
set_text(0, 15, 2, 11, { '1', 'this 2', 'and then' })
eq({
@@ -1208,7 +1202,7 @@ describe('api/buf', function()
'and then the last one',
}, get_lines(0, -1, true))
-- cursor should end up on 'n' in 'then'
- eq({ 3, 7 }, meths.nvim_win_get_cursor(0))
+ eq({ 3, 7 }, api.nvim_win_get_cursor(0))
end)
it(
@@ -1220,7 +1214,7 @@ describe('api/buf', function()
and finally the last one]])
-- position the cursor on 'y' at 'finally'
- meths.nvim_win_set_cursor(0, { 3, 10 })
+ api.nvim_win_set_cursor(0, { 3, 10 })
-- enter INSERT mode to treat cursor as being between 'l' and 'y'
feed('i')
set_text(0, 15, 2, 11, { '1', 'this 2', 'and then' })
@@ -1231,7 +1225,7 @@ describe('api/buf', function()
'and then the last one',
}, get_lines(0, -1, true))
-- cursor should end up after 'n' in 'then'
- eq({ 3, 8 }, meths.nvim_win_get_cursor(0))
+ eq({ 3, 8 }, api.nvim_win_get_cursor(0))
end
)
@@ -1242,7 +1236,7 @@ describe('api/buf', function()
and finally the last one]])
-- position the cursor on 'y' in 'finally'
- meths.nvim_win_set_cursor(0, { 3, 10 })
+ api.nvim_win_set_cursor(0, { 3, 10 })
set_text(2, 4, 2, 11, { 'then' })
eq({
@@ -1251,7 +1245,7 @@ describe('api/buf', function()
'and then the last one',
}, get_lines(0, -1, true))
-- cursor should end up on 'n' in 'then'
- eq({ 3, 7 }, meths.nvim_win_get_cursor(0))
+ eq({ 3, 7 }, api.nvim_win_get_cursor(0))
end)
it('does not move cursor column after end of a line', function()
@@ -1260,7 +1254,7 @@ describe('api/buf', function()
!!!]])
-- position cursor on the last '1'
- meths.nvim_win_set_cursor(0, { 2, 2 })
+ api.nvim_win_set_cursor(0, { 2, 2 })
local cursor = exec_lua([[
vim.api.nvim_buf_set_text(0, 0, 33, 1, 3, {})
@@ -1269,7 +1263,7 @@ describe('api/buf', function()
eq({ 'This should be the only line here' }, get_lines(0, -1, true))
-- cursor should end up on '!'
- eq({ 1, 32 }, meths.nvim_win_get_cursor(0))
+ eq({ 1, 32 }, api.nvim_win_get_cursor(0))
-- immediate call to nvim_win_get_cursor should have returned the same position
eq({ 1, 32 }, cursor)
end)
@@ -1278,7 +1272,7 @@ describe('api/buf', function()
insert('\n!!!')
-- position cursor on the last '1'
- meths.nvim_win_set_cursor(0, { 2, 2 })
+ api.nvim_win_set_cursor(0, { 2, 2 })
local cursor = exec_lua([[
vim.api.nvim_buf_set_text(0, 0, 0, 1, 3, {})
@@ -1287,7 +1281,7 @@ describe('api/buf', function()
eq({ '' }, get_lines(0, -1, true))
-- cursor should end up on '!'
- eq({ 1, 0 }, meths.nvim_win_get_cursor(0))
+ eq({ 1, 0 }, api.nvim_win_get_cursor(0))
-- immediate call to nvim_win_get_cursor should have returned the same position
eq({ 1, 0 }, cursor)
end)
@@ -1300,7 +1294,7 @@ describe('api/buf', function()
and finally the last one]])
-- position cursor on 't' in 'want'
- meths.nvim_win_set_cursor(0, { 2, 34 })
+ api.nvim_win_set_cursor(0, { 2, 34 })
-- turn on virtualedit
command('set virtualedit=all')
@@ -1318,7 +1312,7 @@ describe('api/buf', function()
}, get_lines(0, -1, true))
-- cursor should end up on 'y' in 'hopefully'
-- to stay in the range
- eq({ 2, 12 }, meths.nvim_win_get_cursor(0))
+ eq({ 2, 12 }, api.nvim_win_get_cursor(0))
-- immediate call to nvim_win_get_cursor should have returned the same position
eq({ 2, 12 }, cursor)
-- coladd should be 0
@@ -1337,7 +1331,7 @@ describe('api/buf', function()
and finally the last one]])
-- position cursor on 't' in 'want'
- meths.nvim_win_set_cursor(0, { 2, 34 })
+ api.nvim_win_set_cursor(0, { 2, 34 })
-- turn on virtualedit
command('set virtualedit=all')
-- move cursor after eol
@@ -1358,7 +1352,7 @@ describe('api/buf', function()
'but hopefully the last one',
}, get_lines(0, -1, true))
-- cursor should end up at eol of a new row
- eq({ 2, 26 }, meths.nvim_win_get_cursor(0))
+ eq({ 2, 26 }, api.nvim_win_get_cursor(0))
-- immediate call to nvim_win_get_cursor should have returned the same position
eq({ 2, 26 }, cursor)
-- coladd should be increased so that cursor stays in the same screen column
@@ -1379,7 +1373,7 @@ describe('api/buf', function()
and finally the last one]])
-- position cursor on 't' in 'first'
- meths.nvim_win_set_cursor(0, { 1, 19 })
+ api.nvim_win_set_cursor(0, { 1, 19 })
-- turn on virtualedit
command('set virtualedit=all')
-- move cursor after eol
@@ -1400,7 +1394,7 @@ describe('api/buf', function()
'but hopefully the last one',
}, get_lines(0, -1, true))
-- cursor should end up at eol of a new row
- eq({ 1, 38 }, meths.nvim_win_get_cursor(0))
+ eq({ 1, 38 }, api.nvim_win_get_cursor(0))
-- immediate call to nvim_win_get_cursor should have returned the same position
eq({ 1, 38 }, cursor)
-- coladd should be increased so that cursor stays in the same screen column
@@ -1422,7 +1416,7 @@ describe('api/buf', function()
and finally the last one]])
-- position cursor on 't' in 'first'
- meths.nvim_win_set_cursor(0, { 1, 19 })
+ api.nvim_win_set_cursor(0, { 1, 19 })
-- turn on virtualedit
command('set virtualedit=all')
-- move cursor after eol just a bit
@@ -1443,7 +1437,7 @@ describe('api/buf', function()
'but hopefully the last one',
}, get_lines(0, -1, true))
-- cursor should stay at the same screen column
- eq({ 1, 22 }, meths.nvim_win_get_cursor(0))
+ eq({ 1, 22 }, api.nvim_win_get_cursor(0))
-- immediate call to nvim_win_get_cursor should have returned the same position
eq({ 1, 22 }, cursor)
-- coladd should become 0
@@ -1466,7 +1460,7 @@ describe('api/buf', function()
and finally the last one]])
-- position cursor on 'e' in 'more'
- meths.nvim_win_set_cursor(0, { 3, 11 })
+ api.nvim_win_set_cursor(0, { 3, 11 })
-- turn on virtualedit
command('set virtualedit=all')
-- move cursor after eol
@@ -1487,7 +1481,7 @@ describe('api/buf', function()
'but hopefully the last one',
}, get_lines(0, -1, true))
-- cursor should end up at eol of a new row
- eq({ 2, 26 }, meths.nvim_win_get_cursor(0))
+ eq({ 2, 26 }, api.nvim_win_get_cursor(0))
-- immediate call to nvim_win_get_cursor should have returned the same position
eq({ 2, 26 }, cursor)
-- coladd should be increased so that cursor stays in the same screen column
@@ -1510,17 +1504,17 @@ describe('api/buf', function()
line]])
-- position the cursor on 'i'
- meths.nvim_win_set_cursor(0, { 3, 2 })
+ api.nvim_win_set_cursor(0, { 3, 2 })
set_text(1, 6, 2, 0, {})
eq({ 'first line', 'second line' }, get_lines(0, -1, true))
-- cursor should stay on 'i'
- eq({ 2, 8 }, meths.nvim_win_get_cursor(0))
+ eq({ 2, 8 }, api.nvim_win_get_cursor(0))
-- add a newline back
set_text(1, 6, 1, 6, { '', '' })
eq({ 'first line', 'second', ' line' }, get_lines(0, -1, true))
-- cursor should return back to the original position
- eq({ 3, 2 }, meths.nvim_win_get_cursor(0))
+ eq({ 3, 2 }, api.nvim_win_get_cursor(0))
end)
it(
@@ -1532,11 +1526,11 @@ describe('api/buf', function()
and finally the last one]])
-- position the cursor on 'h' in 'the'
- meths.nvim_win_set_cursor(0, { 3, 13 })
+ api.nvim_win_set_cursor(0, { 3, 13 })
set_text(0, 14, 2, 11, {})
eq({ 'This should be the last one' }, get_lines(0, -1, true))
-- cursor should stay on 'h'
- eq({ 1, 16 }, meths.nvim_win_get_cursor(0))
+ eq({ 1, 16 }, api.nvim_win_get_cursor(0))
-- add deleted lines back
set_text(0, 14, 0, 14, {
' first',
@@ -1549,7 +1543,7 @@ describe('api/buf', function()
'and finally the last one',
}, get_lines(0, -1, true))
-- cursor should return back to the original position
- eq({ 3, 13 }, meths.nvim_win_get_cursor(0))
+ eq({ 3, 13 }, api.nvim_win_get_cursor(0))
end
)
@@ -1562,7 +1556,7 @@ describe('api/buf', function()
and finally the last one]])
-- position the cursor on 's' in 'last'
- meths.nvim_win_set_cursor(0, { 3, 18 })
+ api.nvim_win_set_cursor(0, { 3, 18 })
set_text(0, 15, 2, 11, {
'the line we do not want',
'but hopefully',
@@ -1573,7 +1567,7 @@ describe('api/buf', function()
'but hopefully the last one',
}, get_lines(0, -1, true))
-- cursor should stay on 's'
- eq({ 2, 20 }, meths.nvim_win_get_cursor(0))
+ eq({ 2, 20 }, api.nvim_win_get_cursor(0))
set_text(0, 15, 1, 13, {
'first',
@@ -1587,7 +1581,7 @@ describe('api/buf', function()
'and finally the last one',
}, get_lines(0, -1, true))
-- cursor should return back to the original position
- eq({ 3, 18 }, meths.nvim_win_get_cursor(0))
+ eq({ 3, 18 }, api.nvim_win_get_cursor(0))
end
)
@@ -1597,7 +1591,7 @@ describe('api/buf', function()
]])
-- position cursor at the empty line
- meths.nvim_win_set_cursor(0, { 2, 0 })
+ api.nvim_win_set_cursor(0, { 2, 0 })
local cursor = exec_lua([[
vim.api.nvim_buf_set_text(0, 0, 33, 1, 0, {'!'})
@@ -1606,7 +1600,7 @@ describe('api/buf', function()
eq({ 'This should be the only line here!' }, get_lines(0, -1, true))
-- cursor should end up on '!'
- eq({ 1, 33 }, meths.nvim_win_get_cursor(0))
+ eq({ 1, 33 }, api.nvim_win_get_cursor(0))
-- immediate call to nvim_win_get_cursor should have returned the same position
eq({ 1, 33 }, cursor)
end)
@@ -1617,7 +1611,7 @@ describe('api/buf', function()
eq({ '', '' }, get_lines(0, -1, true))
-- position cursor on the last '1'
- meths.nvim_win_set_cursor(0, { 2, 2 })
+ api.nvim_win_set_cursor(0, { 2, 2 })
local cursor = exec_lua([[
vim.api.nvim_buf_set_text(0, 0, 0, 1, 0, {''})
@@ -1626,7 +1620,7 @@ describe('api/buf', function()
eq({ '' }, get_lines(0, -1, true))
-- cursor should end up on '!'
- eq({ 1, 0 }, meths.nvim_win_get_cursor(0))
+ eq({ 1, 0 }, api.nvim_win_get_cursor(0))
-- immediate call to nvim_win_get_cursor should have returned the same position
eq({ 1, 0 }, cursor)
end)
@@ -1638,46 +1632,46 @@ describe('api/buf', function()
end)
it('adjusts extmarks', function()
- local ns = meths.nvim_create_namespace('my-fancy-plugin')
+ local ns = api.nvim_create_namespace('my-fancy-plugin')
insert([[
foo bar
baz
]])
- local id1 = meths.nvim_buf_set_extmark(0, ns, 0, 1, {})
- local id2 = meths.nvim_buf_set_extmark(0, ns, 0, 7, {})
- local id3 = meths.nvim_buf_set_extmark(0, ns, 1, 1, {})
+ local id1 = api.nvim_buf_set_extmark(0, ns, 0, 1, {})
+ local id2 = api.nvim_buf_set_extmark(0, ns, 0, 7, {})
+ local id3 = api.nvim_buf_set_extmark(0, ns, 1, 1, {})
set_text(0, 4, 0, 7, { 'q' })
eq({ 'foo q', 'baz' }, get_lines(0, 2, true))
-- mark before replacement point is unaffected
- eq({ 0, 1 }, meths.nvim_buf_get_extmark_by_id(0, ns, id1, {}))
+ eq({ 0, 1 }, api.nvim_buf_get_extmark_by_id(0, ns, id1, {}))
-- mark gets shifted back because the replacement was shorter
- eq({ 0, 5 }, meths.nvim_buf_get_extmark_by_id(0, ns, id2, {}))
+ eq({ 0, 5 }, api.nvim_buf_get_extmark_by_id(0, ns, id2, {}))
-- mark on the next line is unaffected
- eq({ 1, 1 }, meths.nvim_buf_get_extmark_by_id(0, ns, id3, {}))
+ eq({ 1, 1 }, api.nvim_buf_get_extmark_by_id(0, ns, id3, {}))
-- replacing the text spanning two lines will adjust the mark on the next line
set_text(0, 3, 1, 3, { 'qux' })
eq({ 'fooqux', '' }, get_lines(0, 2, true))
- eq({ 0, 6 }, meths.nvim_buf_get_extmark_by_id(0, ns, id3, {}))
+ eq({ 0, 6 }, api.nvim_buf_get_extmark_by_id(0, ns, id3, {}))
-- but mark before replacement point is still unaffected
- eq({ 0, 1 }, meths.nvim_buf_get_extmark_by_id(0, ns, id1, {}))
+ eq({ 0, 1 }, api.nvim_buf_get_extmark_by_id(0, ns, id1, {}))
-- and the mark in the middle was shifted to the end of the insertion
- eq({ 0, 6 }, meths.nvim_buf_get_extmark_by_id(0, ns, id2, {}))
+ eq({ 0, 6 }, api.nvim_buf_get_extmark_by_id(0, ns, id2, {}))
-- marks should be put back into the same place after undoing
set_text(0, 0, 0, 2, { '' })
feed('u')
- eq({ 0, 1 }, meths.nvim_buf_get_extmark_by_id(0, ns, id1, {}))
- eq({ 0, 6 }, meths.nvim_buf_get_extmark_by_id(0, ns, id2, {}))
- eq({ 0, 6 }, meths.nvim_buf_get_extmark_by_id(0, ns, id3, {}))
+ eq({ 0, 1 }, api.nvim_buf_get_extmark_by_id(0, ns, id1, {}))
+ eq({ 0, 6 }, api.nvim_buf_get_extmark_by_id(0, ns, id2, {}))
+ eq({ 0, 6 }, api.nvim_buf_get_extmark_by_id(0, ns, id3, {}))
-- marks should be shifted over by the correct number of bytes for multibyte
-- chars
set_text(0, 0, 0, 0, { 'Ø' })
- eq({ 0, 3 }, meths.nvim_buf_get_extmark_by_id(0, ns, id1, {}))
- eq({ 0, 8 }, meths.nvim_buf_get_extmark_by_id(0, ns, id2, {}))
- eq({ 0, 8 }, meths.nvim_buf_get_extmark_by_id(0, ns, id3, {}))
+ eq({ 0, 3 }, api.nvim_buf_get_extmark_by_id(0, ns, id1, {}))
+ eq({ 0, 8 }, api.nvim_buf_get_extmark_by_id(0, ns, id2, {}))
+ eq({ 0, 8 }, api.nvim_buf_get_extmark_by_id(0, ns, id3, {}))
end)
it('correctly marks changed region for redraw #13890', function()
@@ -1689,7 +1683,7 @@ describe('api/buf', function()
BBB
]])
- meths.nvim_buf_set_text(0, 0, 0, 1, 3, { 'XXX', 'YYY' })
+ api.nvim_buf_set_text(0, 0, 0, 1, 3, { 'XXX', 'YYY' })
screen:expect([[
XXX |
@@ -1724,7 +1718,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.nvim_win_set_cursor(0, { 1, 0 })
+ api.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, {''})
@@ -1742,22 +1736,22 @@ describe('api/buf', function()
[3] = { reverse = true },
}
screen:attach()
- meths.nvim_buf_set_lines(
+ api.nvim_buf_set_lines(
0,
0,
-1,
true,
{ 'aaa', 'bbb', 'ccc', 'ddd', 'www', 'xxx', 'yyy', 'zzz' }
)
- meths.nvim_set_option_value('modified', false, {})
+ api.nvim_set_option_value('modified', false, {})
end)
it('of current window', function()
- local win = meths.nvim_get_current_win()
- local buf = meths.nvim_get_current_buf()
+ local win = api.nvim_get_current_win()
+ local buf = api.nvim_get_current_buf()
command('new | wincmd w')
- meths.nvim_win_set_cursor(win, { 8, 0 })
+ api.nvim_win_set_cursor(win, { 8, 0 })
screen:expect {
grid = [[
@@ -1772,7 +1766,7 @@ describe('api/buf', function()
|
]],
}
- meths.nvim_buf_set_text(buf, 0, 3, 1, 0, { 'X' })
+ api.nvim_buf_set_text(buf, 0, 3, 1, 0, { 'X' })
screen:expect {
grid = [[
@@ -1790,11 +1784,11 @@ describe('api/buf', function()
end)
it('of non-current window', function()
- local win = meths.nvim_get_current_win()
- local buf = meths.nvim_get_current_buf()
+ local win = api.nvim_get_current_win()
+ local buf = api.nvim_get_current_buf()
command('new')
- meths.nvim_win_set_cursor(win, { 8, 0 })
+ api.nvim_win_set_cursor(win, { 8, 0 })
screen:expect {
grid = [[
@@ -1810,7 +1804,7 @@ describe('api/buf', function()
]],
}
- meths.nvim_buf_set_text(buf, 0, 3, 1, 0, { 'X' })
+ api.nvim_buf_set_text(buf, 0, 3, 1, 0, { 'X' })
screen:expect {
grid = [[
^ |
@@ -1827,12 +1821,12 @@ describe('api/buf', function()
end)
it('of split windows with same buffer', function()
- local win = meths.nvim_get_current_win()
- local buf = meths.nvim_get_current_buf()
+ local win = api.nvim_get_current_win()
+ local buf = api.nvim_get_current_buf()
command('split')
- meths.nvim_win_set_cursor(win, { 8, 0 })
- meths.nvim_win_set_cursor(0, { 1, 1 })
+ api.nvim_win_set_cursor(win, { 8, 0 })
+ api.nvim_win_set_cursor(0, { 1, 1 })
screen:expect {
grid = [[
@@ -1850,7 +1844,7 @@ describe('api/buf', function()
|
]],
}
- meths.nvim_buf_set_text(buf, 0, 3, 1, 0, { 'X' })
+ api.nvim_buf_set_text(buf, 0, 3, 1, 0, { 'X' })
screen:expect {
grid = [[
@@ -1872,8 +1866,8 @@ describe('api/buf', function()
end)
end)
- describe_lua_and_rpc('nvim_buf_get_text', function(api)
- local get_text = api.meths.nvim_buf_get_text
+ describe_lua_and_rpc('nvim_buf_get_text', function(lua_or_rpc)
+ local get_text = lua_or_rpc.nvim_buf_get_text
before_each(function()
insert([[
hello foo!
@@ -1898,7 +1892,7 @@ describe('api/buf', function()
eq('Index out of bounds', pcall_err(get_text, 0, 0, 0, 3, 0, {}))
eq('Index out of bounds', pcall_err(get_text, 0, 0, 0, -4, 0, {}))
-- no ml_get errors should happen #19017
- eq('', meths.nvim_get_vvar('errmsg'))
+ eq('', api.nvim_get_vvar('errmsg'))
end)
it('errors when start is greater than end', function()
@@ -1908,10 +1902,10 @@ describe('api/buf', function()
end)
describe('nvim_buf_get_offset', function()
- local get_offset = meths.nvim_buf_get_offset
+ local get_offset = api.nvim_buf_get_offset
it('works', function()
- meths.nvim_buf_set_lines(0, 0, -1, true, { 'Some\r', 'exa\000mple', '', 'buf\rfer', 'text' })
- eq(5, meths.nvim_buf_line_count(0))
+ api.nvim_buf_set_lines(0, 0, -1, true, { 'Some\r', 'exa\000mple', '', 'buf\rfer', 'text' })
+ eq(5, api.nvim_buf_line_count(0))
eq(0, get_offset(0, 0))
eq(6, get_offset(0, 1))
eq(15, get_offset(0, 2))
@@ -1921,33 +1915,33 @@ describe('api/buf', function()
eq('Index out of bounds', pcall_err(get_offset, 0, 6))
eq('Index out of bounds', pcall_err(get_offset, 0, -1))
- meths.nvim_set_option_value('eol', false, {})
- meths.nvim_set_option_value('fixeol', false, {})
+ api.nvim_set_option_value('eol', false, {})
+ api.nvim_set_option_value('fixeol', false, {})
eq(28, get_offset(0, 5))
-- fileformat is ignored
- meths.nvim_set_option_value('fileformat', 'dos', {})
+ api.nvim_set_option_value('fileformat', 'dos', {})
eq(0, get_offset(0, 0))
eq(6, get_offset(0, 1))
eq(15, get_offset(0, 2))
eq(16, get_offset(0, 3))
eq(24, get_offset(0, 4))
eq(28, get_offset(0, 5))
- meths.nvim_set_option_value('eol', true, {})
+ api.nvim_set_option_value('eol', true, {})
eq(29, get_offset(0, 5))
command('set hidden')
command('enew')
- eq(6, meths.nvim_buf_get_offset(1, 1))
+ eq(6, api.nvim_buf_get_offset(1, 1))
command('bunload! 1')
- eq(-1, meths.nvim_buf_get_offset(1, 1))
- eq(-1, meths.nvim_buf_get_offset(1, 0))
+ eq(-1, api.nvim_buf_get_offset(1, 1))
+ eq(-1, api.nvim_buf_get_offset(1, 0))
end)
it('works in empty buffer', function()
eq(0, get_offset(0, 0))
eq(1, get_offset(0, 1))
- eq(-1, funcs.line2byte('$'))
+ eq(-1, fn.line2byte('$'))
end)
it('works in buffer with one line inserted', function()
@@ -1959,28 +1953,28 @@ describe('api/buf', function()
describe('nvim_buf_get_var, nvim_buf_set_var, nvim_buf_del_var', function()
it('works', function()
- meths.nvim_buf_set_var(0, 'lua', { 1, 2, { ['3'] = 1 } })
- eq({ 1, 2, { ['3'] = 1 } }, meths.nvim_buf_get_var(0, 'lua'))
- eq({ 1, 2, { ['3'] = 1 } }, meths.nvim_eval('b:lua'))
- eq(1, funcs.exists('b:lua'))
- meths.nvim_buf_del_var(0, 'lua')
- eq(0, funcs.exists('b:lua'))
- eq('Key not found: lua', pcall_err(meths.nvim_buf_del_var, 0, 'lua'))
- meths.nvim_buf_set_var(0, 'lua', 1)
+ api.nvim_buf_set_var(0, 'lua', { 1, 2, { ['3'] = 1 } })
+ eq({ 1, 2, { ['3'] = 1 } }, api.nvim_buf_get_var(0, 'lua'))
+ eq({ 1, 2, { ['3'] = 1 } }, api.nvim_eval('b:lua'))
+ eq(1, fn.exists('b:lua'))
+ api.nvim_buf_del_var(0, 'lua')
+ eq(0, fn.exists('b:lua'))
+ eq('Key not found: lua', pcall_err(api.nvim_buf_del_var, 0, 'lua'))
+ api.nvim_buf_set_var(0, 'lua', 1)
command('lockvar b:lua')
- eq('Key is locked: lua', pcall_err(meths.nvim_buf_del_var, 0, 'lua'))
- eq('Key is locked: lua', pcall_err(meths.nvim_buf_set_var, 0, 'lua', 1))
- eq('Key is read-only: changedtick', pcall_err(meths.nvim_buf_del_var, 0, 'changedtick'))
- eq('Key is read-only: changedtick', pcall_err(meths.nvim_buf_set_var, 0, 'changedtick', 1))
+ eq('Key is locked: lua', pcall_err(api.nvim_buf_del_var, 0, 'lua'))
+ eq('Key is locked: lua', pcall_err(api.nvim_buf_set_var, 0, 'lua', 1))
+ eq('Key is read-only: changedtick', pcall_err(api.nvim_buf_del_var, 0, 'changedtick'))
+ eq('Key is read-only: changedtick', pcall_err(api.nvim_buf_set_var, 0, 'changedtick', 1))
end)
end)
describe('nvim_buf_get_changedtick', function()
it('works', function()
- eq(2, meths.nvim_buf_get_changedtick(0))
- meths.nvim_buf_set_lines(0, 0, 1, false, { 'abc\0', '\0def', 'ghi' })
- eq(3, meths.nvim_buf_get_changedtick(0))
- eq(3, meths.nvim_buf_get_var(0, 'changedtick'))
+ eq(2, api.nvim_buf_get_changedtick(0))
+ api.nvim_buf_set_lines(0, 0, 1, false, { 'abc\0', '\0def', 'ghi' })
+ eq(3, api.nvim_buf_get_changedtick(0))
+ eq(3, api.nvim_buf_get_var(0, 'changedtick'))
end)
it('buffer_set_var returns the old value', function()
@@ -2001,33 +1995,33 @@ describe('api/buf', function()
describe('nvim_get_option_value, nvim_set_option_value', function()
it('works', function()
- eq(8, meths.nvim_get_option_value('shiftwidth', {}))
- meths.nvim_set_option_value('shiftwidth', 4, {})
- eq(4, meths.nvim_get_option_value('shiftwidth', {}))
+ eq(8, api.nvim_get_option_value('shiftwidth', {}))
+ api.nvim_set_option_value('shiftwidth', 4, {})
+ eq(4, api.nvim_get_option_value('shiftwidth', {}))
-- global-local option
- meths.nvim_set_option_value('define', 'test', { buf = 0 })
- eq('test', meths.nvim_get_option_value('define', { buf = 0 }))
+ api.nvim_set_option_value('define', 'test', { buf = 0 })
+ eq('test', api.nvim_get_option_value('define', { buf = 0 }))
-- Doesn't change the global value
- eq('', meths.nvim_get_option_value('define', { scope = 'global' }))
+ eq('', api.nvim_get_option_value('define', { scope = 'global' }))
end)
it('returns values for unset local options', function()
-- 'undolevels' is only set to its "unset" value when a new buffer is
-- created
command('enew')
- eq(-123456, meths.nvim_get_option_value('undolevels', { buf = 0 }))
+ eq(-123456, api.nvim_get_option_value('undolevels', { buf = 0 }))
end)
end)
describe('nvim_buf_get_name, nvim_buf_set_name', function()
it('works', function()
command('new')
- eq('', meths.nvim_buf_get_name(0))
- local new_name = meths.nvim_eval('resolve(tempname())')
- meths.nvim_buf_set_name(0, new_name)
- eq(new_name, meths.nvim_buf_get_name(0))
+ eq('', api.nvim_buf_get_name(0))
+ local new_name = api.nvim_eval('resolve(tempname())')
+ api.nvim_buf_set_name(0, new_name)
+ eq(new_name, api.nvim_buf_get_name(0))
command('w!')
- eq(1, funcs.filereadable(new_name))
+ eq(1, fn.filereadable(new_name))
os.remove(new_name)
end)
end)
@@ -2035,121 +2029,121 @@ describe('api/buf', function()
describe('nvim_buf_is_loaded', function()
it('works', function()
-- record our buffer number for when we unload it
- local bufnr = meths.nvim_buf_get_number(0)
+ local bufnr = api.nvim_buf_get_number(0)
-- api should report that the buffer is loaded
- ok(meths.nvim_buf_is_loaded(bufnr))
+ ok(api.nvim_buf_is_loaded(bufnr))
-- hide the current buffer by switching to a new empty buffer
-- Careful! we need to modify the buffer first or vim will just reuse it
- meths.nvim_buf_set_lines(bufnr, 0, -1, true, { 'line1' })
+ api.nvim_buf_set_lines(bufnr, 0, -1, true, { 'line1' })
command('hide enew')
-- confirm the buffer is hidden, but still loaded
- local infolist = meths.nvim_eval('getbufinfo(' .. bufnr .. ')')
+ local infolist = api.nvim_eval('getbufinfo(' .. bufnr .. ')')
eq(1, #infolist)
eq(1, infolist[1].hidden)
eq(1, infolist[1].loaded)
-- now force unload the buffer
command('bunload! ' .. bufnr)
-- confirm the buffer is unloaded
- infolist = meths.nvim_eval('getbufinfo(' .. bufnr .. ')')
+ infolist = api.nvim_eval('getbufinfo(' .. bufnr .. ')')
eq(0, infolist[1].loaded)
-- nvim_buf_is_loaded() should also report the buffer as unloaded
- eq(false, meths.nvim_buf_is_loaded(bufnr))
+ eq(false, api.nvim_buf_is_loaded(bufnr))
end)
end)
describe('nvim_buf_is_valid', function()
it('works', function()
command('new')
- local b = meths.nvim_get_current_buf()
- ok(meths.nvim_buf_is_valid(b))
+ local b = api.nvim_get_current_buf()
+ ok(api.nvim_buf_is_valid(b))
command('bw!')
- ok(not meths.nvim_buf_is_valid(b))
+ ok(not api.nvim_buf_is_valid(b))
end)
end)
describe('nvim_buf_delete', function()
it('allows for just deleting', function()
command('new')
- local b = meths.nvim_get_current_buf()
- ok(meths.nvim_buf_is_valid(b))
- meths.nvim_buf_delete(b, {})
- ok(not meths.nvim_buf_is_loaded(b))
- ok(not meths.nvim_buf_is_valid(b))
+ local b = api.nvim_get_current_buf()
+ ok(api.nvim_buf_is_valid(b))
+ api.nvim_buf_delete(b, {})
+ ok(not api.nvim_buf_is_loaded(b))
+ ok(not api.nvim_buf_is_valid(b))
end)
it('allows for just unloading', function()
command('new')
- local b = meths.nvim_get_current_buf()
- ok(meths.nvim_buf_is_valid(b))
- meths.nvim_buf_delete(b, { unload = true })
- ok(not meths.nvim_buf_is_loaded(b))
- ok(meths.nvim_buf_is_valid(b))
+ local b = api.nvim_get_current_buf()
+ ok(api.nvim_buf_is_valid(b))
+ api.nvim_buf_delete(b, { unload = true })
+ ok(not api.nvim_buf_is_loaded(b))
+ ok(api.nvim_buf_is_valid(b))
end)
end)
describe('nvim_buf_get_mark', function()
it('works', function()
- meths.nvim_buf_set_lines(0, -1, -1, true, { 'a', 'bit of', 'text' })
- meths.nvim_win_set_cursor(0, { 3, 4 })
+ api.nvim_buf_set_lines(0, -1, -1, true, { 'a', 'bit of', 'text' })
+ api.nvim_win_set_cursor(0, { 3, 4 })
command('mark v')
- eq({ 3, 0 }, meths.nvim_buf_get_mark(0, 'v'))
+ eq({ 3, 0 }, api.nvim_buf_get_mark(0, 'v'))
end)
end)
describe('nvim_buf_set_mark', function()
it('works with buffer local marks', function()
- meths.nvim_buf_set_lines(0, -1, -1, true, { 'a', 'bit of', 'text' })
- eq(true, meths.nvim_buf_set_mark(0, 'z', 1, 1, {}))
- eq({ 1, 1 }, meths.nvim_buf_get_mark(0, 'z'))
- eq({ 0, 1, 2, 0 }, funcs.getpos("'z"))
+ api.nvim_buf_set_lines(0, -1, -1, true, { 'a', 'bit of', 'text' })
+ eq(true, api.nvim_buf_set_mark(0, 'z', 1, 1, {}))
+ eq({ 1, 1 }, api.nvim_buf_get_mark(0, 'z'))
+ eq({ 0, 1, 2, 0 }, fn.getpos("'z"))
end)
it('works with file/uppercase marks', function()
- meths.nvim_buf_set_lines(0, -1, -1, true, { 'a', 'bit of', 'text' })
- eq(true, meths.nvim_buf_set_mark(0, 'Z', 3, 2, {}))
- eq({ 3, 2 }, meths.nvim_buf_get_mark(0, 'Z'))
- eq({ meths.nvim_get_current_buf().id, 3, 3, 0 }, funcs.getpos("'Z"))
+ api.nvim_buf_set_lines(0, -1, -1, true, { 'a', 'bit of', 'text' })
+ eq(true, api.nvim_buf_set_mark(0, 'Z', 3, 2, {}))
+ eq({ 3, 2 }, api.nvim_buf_get_mark(0, 'Z'))
+ eq({ api.nvim_get_current_buf().id, 3, 3, 0 }, fn.getpos("'Z"))
end)
it('fails when invalid marks names are used', function()
- eq(false, pcall(meths.nvim_buf_set_mark, 0, '!', 1, 0, {}))
- eq(false, pcall(meths.nvim_buf_set_mark, 0, 'fail', 1, 0, {}))
+ eq(false, pcall(api.nvim_buf_set_mark, 0, '!', 1, 0, {}))
+ eq(false, pcall(api.nvim_buf_set_mark, 0, 'fail', 1, 0, {}))
end)
it('fails when invalid buffer number is used', function()
- eq(false, pcall(meths.nvim_buf_set_mark, 99, 'a', 1, 1, {}))
+ eq(false, pcall(api.nvim_buf_set_mark, 99, 'a', 1, 1, {}))
end)
end)
describe('nvim_buf_del_mark', function()
it('works with buffer local marks', function()
- meths.nvim_buf_set_lines(0, -1, -1, true, { 'a', 'bit of', 'text' })
- meths.nvim_buf_set_mark(0, 'z', 3, 1, {})
- eq(true, meths.nvim_buf_del_mark(0, 'z'))
- eq({ 0, 0 }, meths.nvim_buf_get_mark(0, 'z'))
+ api.nvim_buf_set_lines(0, -1, -1, true, { 'a', 'bit of', 'text' })
+ api.nvim_buf_set_mark(0, 'z', 3, 1, {})
+ eq(true, api.nvim_buf_del_mark(0, 'z'))
+ eq({ 0, 0 }, api.nvim_buf_get_mark(0, 'z'))
end)
it('works with file/uppercase marks', function()
- meths.nvim_buf_set_lines(0, -1, -1, true, { 'a', 'bit of', 'text' })
- meths.nvim_buf_set_mark(0, 'Z', 3, 3, {})
- eq(true, meths.nvim_buf_del_mark(0, 'Z'))
- eq({ 0, 0 }, meths.nvim_buf_get_mark(0, 'Z'))
+ api.nvim_buf_set_lines(0, -1, -1, true, { 'a', 'bit of', 'text' })
+ api.nvim_buf_set_mark(0, 'Z', 3, 3, {})
+ eq(true, api.nvim_buf_del_mark(0, 'Z'))
+ eq({ 0, 0 }, api.nvim_buf_get_mark(0, 'Z'))
end)
it('returns false in marks not set in this buffer', function()
- local abuf = meths.nvim_create_buf(false, true)
- meths.nvim_buf_set_lines(abuf, -1, -1, true, { 'a', 'bit of', 'text' })
- meths.nvim_buf_set_mark(abuf, 'A', 2, 2, {})
- eq(false, meths.nvim_buf_del_mark(0, 'A'))
- eq({ 2, 2 }, meths.nvim_buf_get_mark(abuf, 'A'))
+ local abuf = api.nvim_create_buf(false, true)
+ api.nvim_buf_set_lines(abuf, -1, -1, true, { 'a', 'bit of', 'text' })
+ api.nvim_buf_set_mark(abuf, 'A', 2, 2, {})
+ eq(false, api.nvim_buf_del_mark(0, 'A'))
+ eq({ 2, 2 }, api.nvim_buf_get_mark(abuf, 'A'))
end)
it('returns false if mark was not deleted', function()
- meths.nvim_buf_set_lines(0, -1, -1, true, { 'a', 'bit of', 'text' })
- meths.nvim_buf_set_mark(0, 'z', 3, 1, {})
- eq(true, meths.nvim_buf_del_mark(0, 'z'))
- eq(false, meths.nvim_buf_del_mark(0, 'z')) -- Mark was already deleted
+ api.nvim_buf_set_lines(0, -1, -1, true, { 'a', 'bit of', 'text' })
+ api.nvim_buf_set_mark(0, 'z', 3, 1, {})
+ eq(true, api.nvim_buf_del_mark(0, 'z'))
+ eq(false, api.nvim_buf_del_mark(0, 'z')) -- Mark was already deleted
end)
it('fails when invalid marks names are used', function()
- eq(false, pcall(meths.nvim_buf_del_mark, 0, '!'))
- eq(false, pcall(meths.nvim_buf_del_mark, 0, 'fail'))
+ eq(false, pcall(api.nvim_buf_del_mark, 0, '!'))
+ eq(false, pcall(api.nvim_buf_del_mark, 0, 'fail'))
end)
it('fails when invalid buffer number is used', function()
- eq(false, pcall(meths.nvim_buf_del_mark, 99, 'a'))
+ eq(false, pcall(api.nvim_buf_del_mark, 99, 'a'))
end)
end)
end)
diff --git a/test/functional/api/buffer_updates_spec.lua b/test/functional/api/buffer_updates_spec.lua
index 254e7d4d42..050d4adfec 100644
--- a/test/functional/api/buffer_updates_spec.lua
+++ b/test/functional/api/buffer_updates_spec.lua
@@ -1,8 +1,8 @@
local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
local eq, ok = helpers.eq, helpers.ok
-local funcs = helpers.funcs
-local meths = helpers.meths
+local fn = helpers.fn
+local api = helpers.api
local command, eval, next_msg = helpers.command, helpers.eval, helpers.next_msg
local nvim_prog = helpers.nvim_prog
local pcall_err = helpers.pcall_err
@@ -24,7 +24,7 @@ local function expectn(name, args)
end
local function sendkeys(keys)
- meths.nvim_input(keys)
+ api.nvim_input(keys)
-- give nvim some time to process msgpack requests before possibly sending
-- more key presses - otherwise they all pile up in the queue and get
-- processed at once
@@ -37,7 +37,7 @@ local function open(activate, lines)
local filename = helpers.tmpname()
write_file(filename, table.concat(lines, '\n') .. '\n', true)
command('edit ' .. filename)
- local b = meths.nvim_get_current_buf()
+ local b = api.nvim_get_current_buf()
-- what is the value of b:changedtick?
local tick = eval('b:changedtick')
@@ -45,7 +45,7 @@ local function open(activate, lines)
-- arrive as expected
if activate then
local firstline = 0
- ok(meths.nvim_buf_attach(b, true, {}))
+ ok(api.nvim_buf_attach(b, true, {}))
expectn('nvim_buf_lines_event', { b, tick, firstline, -1, lines, false })
end
@@ -62,12 +62,12 @@ local function editoriginal(activate, lines)
end
local function reopen(buf, expectedlines)
- ok(meths.nvim_buf_detach(buf))
+ ok(api.nvim_buf_detach(buf))
expectn('nvim_buf_detach_event', { buf })
-- for some reason the :edit! increments tick by 2
command('edit!')
local tick = eval('b:changedtick')
- ok(meths.nvim_buf_attach(buf, true, {}))
+ ok(api.nvim_buf_attach(buf, true, {}))
local firstline = 0
expectn('nvim_buf_lines_event', { buf, tick, firstline, -1, expectedlines, false })
command('normal! gg')
@@ -197,21 +197,21 @@ describe('API: buffer events:', function()
-- add a line at the start of an empty file
command('enew')
tick = eval('b:changedtick')
- local b2 = meths.nvim_get_current_buf()
- ok(meths.nvim_buf_attach(b2, true, {}))
+ local b2 = api.nvim_get_current_buf()
+ ok(api.nvim_buf_attach(b2, true, {}))
expectn('nvim_buf_lines_event', { b2, tick, 0, -1, { '' }, false })
eval('append(0, ["new line 1"])')
tick = tick + 1
expectn('nvim_buf_lines_event', { b2, tick, 0, 0, { 'new line 1' }, false })
-- turn off buffer events manually
- meths.nvim_buf_detach(b2)
+ api.nvim_buf_detach(b2)
expectn('nvim_buf_detach_event', { b2 })
-- add multiple lines to a blank file
command('enew!')
- local b3 = meths.nvim_get_current_buf()
- ok(meths.nvim_buf_attach(b3, true, {}))
+ local b3 = api.nvim_get_current_buf()
+ ok(api.nvim_buf_attach(b3, true, {}))
tick = eval('b:changedtick')
expectn('nvim_buf_lines_event', { b3, tick, 0, -1, { '' }, false })
eval('append(0, ["new line 1", "new line 2", "new line 3"])')
@@ -222,7 +222,7 @@ describe('API: buffer events:', function()
)
-- use the API itself to add a line to the start of the buffer
- meths.nvim_buf_set_lines(b3, 0, 0, true, { 'New First Line' })
+ api.nvim_buf_set_lines(b3, 0, 0, true, { 'New First Line' })
tick = tick + 1
expectn('nvim_buf_lines_event', { b3, tick, 0, 0, { 'New First Line' }, false })
end)
@@ -306,8 +306,8 @@ describe('API: buffer events:', function()
command('bdelete!')
tick = 2
expectn('nvim_buf_detach_event', { b })
- local bnew = meths.nvim_get_current_buf()
- ok(meths.nvim_buf_attach(bnew, true, {}))
+ local bnew = api.nvim_get_current_buf()
+ ok(api.nvim_buf_attach(bnew, true, {}))
expectn('nvim_buf_lines_event', { bnew, tick, 0, -1, { '' }, false })
sendkeys('i')
sendkeys('h')
@@ -472,25 +472,25 @@ describe('API: buffer events:', function()
end)
it('does not get confused if enabled/disabled many times', function()
- local channel = meths.nvim_get_api_info()[1]
+ local channel = api.nvim_get_api_info()[1]
local b, tick = editoriginal(false)
-- Enable buffer events many times.
- ok(meths.nvim_buf_attach(b, true, {}))
- ok(meths.nvim_buf_attach(b, true, {}))
- ok(meths.nvim_buf_attach(b, true, {}))
- ok(meths.nvim_buf_attach(b, true, {}))
- ok(meths.nvim_buf_attach(b, true, {}))
+ ok(api.nvim_buf_attach(b, true, {}))
+ ok(api.nvim_buf_attach(b, true, {}))
+ ok(api.nvim_buf_attach(b, true, {}))
+ ok(api.nvim_buf_attach(b, true, {}))
+ ok(api.nvim_buf_attach(b, true, {}))
expectn('nvim_buf_lines_event', { b, tick, 0, -1, origlines, false })
eval('rpcnotify(' .. channel .. ', "Hello There")')
expectn('Hello There', {})
-- Disable buffer events many times.
- ok(meths.nvim_buf_detach(b))
- ok(meths.nvim_buf_detach(b))
- ok(meths.nvim_buf_detach(b))
- ok(meths.nvim_buf_detach(b))
- ok(meths.nvim_buf_detach(b))
+ ok(api.nvim_buf_detach(b))
+ ok(api.nvim_buf_detach(b))
+ ok(api.nvim_buf_detach(b))
+ ok(api.nvim_buf_detach(b))
+ ok(api.nvim_buf_detach(b))
expectn('nvim_buf_detach_event', { b })
eval('rpcnotify(' .. channel .. ', "Hello Again")')
expectn('Hello Again', {})
@@ -573,7 +573,7 @@ describe('API: buffer events:', function()
it('works with :diffput and :diffget', function()
local b1, tick1 = editoriginal(true, { 'AAA', 'BBB' })
- local channel = meths.nvim_get_api_info()[1]
+ local channel = api.nvim_get_api_info()[1]
command('diffthis')
command('rightbelow vsplit')
local b2, tick2 = open(true, { 'BBB', 'CCC' })
@@ -690,7 +690,7 @@ describe('API: buffer events:', function()
it('detaches if the buffer is closed', function()
local b, tick = editoriginal(true, { 'AAA' })
- local channel = meths.nvim_get_api_info()[1]
+ local channel = api.nvim_get_api_info()[1]
-- Test that buffer events are working.
command('normal! x')
@@ -729,7 +729,7 @@ describe('API: buffer events:', function()
it(':enew! does not detach hidden buffer', function()
local b, tick = editoriginal(true, { 'AAA', 'BBB' })
- local channel = meths.nvim_get_api_info()[1]
+ local channel = api.nvim_get_api_info()[1]
command('set undoreload=1 hidden')
command('normal! x')
@@ -743,7 +743,7 @@ describe('API: buffer events:', function()
it('stays attached if the buffer is hidden', function()
local b, tick = editoriginal(true, { 'AAA' })
- local channel = meths.nvim_get_api_info()[1]
+ local channel = api.nvim_get_api_info()[1]
-- Test that buffer events are working.
command('normal! x')
@@ -790,14 +790,14 @@ describe('API: buffer events:', function()
it('does not send the buffer content if not requested', function()
clear()
local b, tick = editoriginal(false)
- ok(meths.nvim_buf_attach(b, false, {}))
+ ok(api.nvim_buf_attach(b, false, {}))
expectn('nvim_buf_changedtick_event', { b, tick })
end)
it('returns a proper error on nonempty options dict', function()
clear()
local b = editoriginal(false)
- eq("Invalid key: 'builtin'", pcall_err(meths.nvim_buf_attach, b, false, { builtin = 'asfd' }))
+ eq("Invalid key: 'builtin'", pcall_err(api.nvim_buf_attach, b, false, { builtin = 'asfd' }))
end)
it('nvim_buf_attach returns response after delay #8634', function()
@@ -869,12 +869,12 @@ describe('API: buffer events:', function()
it('when :terminal lines change', function()
local buffer_lines = {}
local expected_lines = {}
- funcs.termopen({ nvim_prog, '-u', 'NONE', '-i', 'NONE', '-n', '-c', 'set shortmess+=A' }, {
+ fn.termopen({ nvim_prog, '-u', 'NONE', '-i', 'NONE', '-n', '-c', 'set shortmess+=A' }, {
env = { VIMRUNTIME = os.getenv('VIMRUNTIME') },
})
- local b = meths.nvim_get_current_buf()
- ok(meths.nvim_buf_attach(b, true, {}))
+ local b = api.nvim_get_current_buf()
+ ok(api.nvim_buf_attach(b, true, {}))
for _ = 1, 22 do
table.insert(expected_lines, '~')
diff --git a/test/functional/api/command_spec.lua b/test/functional/api/command_spec.lua
index dc6a68da03..f73b9c8b13 100644
--- a/test/functional/api/command_spec.lua
+++ b/test/functional/api/command_spec.lua
@@ -4,14 +4,14 @@ local NIL = vim.NIL
local clear = helpers.clear
local command = helpers.command
local eq = helpers.eq
-local meths = helpers.meths
+local api = helpers.api
local matches = helpers.matches
local source = helpers.source
local pcall_err = helpers.pcall_err
local exec_lua = helpers.exec_lua
local assert_alive = helpers.assert_alive
local feed = helpers.feed
-local funcs = helpers.funcs
+local fn = helpers.fn
describe('nvim_get_commands', function()
local cmd_dict = {
@@ -49,39 +49,39 @@ describe('nvim_get_commands', function()
before_each(clear)
it('gets empty list if no commands were defined', function()
- eq({}, meths.nvim_get_commands({ builtin = false }))
+ eq({}, api.nvim_get_commands({ builtin = false }))
end)
it('validation', function()
- 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' }))
+ eq('builtin=true not implemented', pcall_err(api.nvim_get_commands, { builtin = true }))
+ eq("Invalid key: 'foo'", pcall_err(api.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.nvim_get_commands({ builtin = false }))
+ eq({ Hello = cmd_dict }, api.nvim_get_commands({ builtin = false }))
-- Define another command.
command('command -nargs=? Pwd pwd')
- eq({ Hello = cmd_dict, Pwd = cmd_dict2 }, meths.nvim_get_commands({ builtin = false }))
+ eq({ Hello = cmd_dict, Pwd = cmd_dict2 }, api.nvim_get_commands({ builtin = false }))
-- Delete a command.
command('delcommand Pwd')
- eq({ Hello = cmd_dict }, meths.nvim_get_commands({ builtin = false }))
+ eq({ Hello = cmd_dict }, api.nvim_get_commands({ builtin = false }))
end)
it('gets buffer-local user-defined commands', function()
-- Define a buffer-local command.
command('command -buffer -nargs=1 Hello echo "Hello World"')
- eq({ Hello = cmd_dict }, meths.nvim_buf_get_commands(0, { builtin = false }))
+ eq({ Hello = cmd_dict }, api.nvim_buf_get_commands(0, { builtin = false }))
-- Define another buffer-local command.
command('command -buffer -nargs=? Pwd pwd')
- eq({ Hello = cmd_dict, Pwd = cmd_dict2 }, meths.nvim_buf_get_commands(0, { builtin = false }))
+ eq({ Hello = cmd_dict, Pwd = cmd_dict2 }, api.nvim_buf_get_commands(0, { builtin = false }))
-- Delete a command.
command('delcommand Pwd')
- eq({ Hello = cmd_dict }, meths.nvim_buf_get_commands(0, { builtin = false }))
+ eq({ Hello = cmd_dict }, api.nvim_buf_get_commands(0, { builtin = false }))
-- {builtin=true} always returns empty for buffer-local case.
- eq({}, meths.nvim_buf_get_commands(0, { builtin = true }))
+ eq({}, api.nvim_buf_get_commands(0, { builtin = true }))
end)
it('gets various command attributes', function()
@@ -169,9 +169,9 @@ describe('nvim_get_commands', function()
let s:foo = 1
command -complete=custom,ListUsers -nargs=+ Finger !finger <args>
]])
- eq({ Finger = cmd1 }, meths.nvim_get_commands({ builtin = false }))
+ eq({ Finger = cmd1 }, api.nvim_get_commands({ builtin = false }))
command('command -nargs=1 -complete=dir -addr=arguments -count=10 TestCmd pwd <args>')
- eq({ Finger = cmd1, TestCmd = cmd0 }, meths.nvim_get_commands({ builtin = false }))
+ eq({ Finger = cmd1, TestCmd = cmd0 }, api.nvim_get_commands({ builtin = false }))
source([[
function! s:foo() abort
@@ -191,7 +191,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.nvim_get_commands({ builtin = false })
+ api.nvim_get_commands({ builtin = false })
)
end)
end)
@@ -200,9 +200,9 @@ describe('nvim_create_user_command', function()
before_each(clear)
it('works with strings', function()
- meths.nvim_create_user_command('SomeCommand', 'let g:command_fired = <args>', { nargs = 1 })
+ api.nvim_create_user_command('SomeCommand', 'let g:command_fired = <args>', { nargs = 1 })
command('SomeCommand 42')
- eq(42, meths.nvim_eval('g:command_fired'))
+ eq(42, api.nvim_eval('g:command_fired'))
end)
it('works with Lua functions', function()
@@ -644,10 +644,10 @@ describe('nvim_create_user_command', function()
end)
it('can define buffer-local commands', function()
- local bufnr = meths.nvim_create_buf(false, false)
- meths.nvim_buf_create_user_command(bufnr, 'Hello', '', {})
+ local bufnr = api.nvim_create_buf(false, false)
+ api.nvim_buf_create_user_command(bufnr, 'Hello', '', {})
matches('Not an editor command: Hello', pcall_err(command, 'Hello'))
- meths.nvim_set_current_buf(bufnr)
+ api.nvim_set_current_buf(bufnr)
command('Hello')
assert_alive()
end)
@@ -670,9 +670,9 @@ describe('nvim_create_user_command', function()
]]
feed(':Test a<Tab>')
- eq('Test aaa', funcs.getcmdline())
+ eq('Test aaa', fn.getcmdline())
feed('<C-U>Test b<Tab>')
- eq('Test bbb', funcs.getcmdline())
+ eq('Test bbb', fn.getcmdline())
end)
it('does not allow invalid command names', function()
@@ -729,29 +729,29 @@ describe('nvim_create_user_command', function()
vim.api.nvim_cmd({ cmd = 'echo', args = { '&verbose' }, mods = opts.smods }, {})
end, {})
]]
- eq('3', meths.nvim_cmd({ cmd = 'MyEcho', mods = { verbose = 3 } }, { output = true }))
+ eq('3', api.nvim_cmd({ cmd = 'MyEcho', mods = { verbose = 3 } }, { output = true }))
- eq(1, #meths.nvim_list_tabpages())
+ eq(1, #api.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.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.nvim_cmd({ cmd = 'MySplit', mods = { tab = 1 } }, {})
- eq(3, #meths.nvim_list_tabpages())
- eq(2, funcs.tabpagenr())
- meths.nvim_cmd({ cmd = 'MySplit', mods = { tab = 3 } }, {})
- eq(4, #meths.nvim_list_tabpages())
- eq(4, funcs.tabpagenr())
- meths.nvim_cmd({ cmd = 'MySplit', mods = { tab = 0 } }, {})
- eq(5, #meths.nvim_list_tabpages())
- eq(1, funcs.tabpagenr())
+ api.nvim_cmd({ cmd = 'MySplit' }, {})
+ eq(1, #api.nvim_list_tabpages())
+ eq(2, #api.nvim_list_wins())
+ api.nvim_cmd({ cmd = 'MySplit', mods = { tab = 1 } }, {})
+ eq(2, #api.nvim_list_tabpages())
+ eq(2, fn.tabpagenr())
+ api.nvim_cmd({ cmd = 'MySplit', mods = { tab = 1 } }, {})
+ eq(3, #api.nvim_list_tabpages())
+ eq(2, fn.tabpagenr())
+ api.nvim_cmd({ cmd = 'MySplit', mods = { tab = 3 } }, {})
+ eq(4, #api.nvim_list_tabpages())
+ eq(4, fn.tabpagenr())
+ api.nvim_cmd({ cmd = 'MySplit', mods = { tab = 0 } }, {})
+ eq(5, #api.nvim_list_tabpages())
+ eq(1, fn.tabpagenr())
end)
end)
@@ -759,16 +759,16 @@ describe('nvim_del_user_command', function()
before_each(clear)
it('can delete global commands', function()
- meths.nvim_create_user_command('Hello', 'echo "Hi"', {})
+ api.nvim_create_user_command('Hello', 'echo "Hi"', {})
command('Hello')
- meths.nvim_del_user_command('Hello')
+ api.nvim_del_user_command('Hello')
matches('Not an editor command: Hello', pcall_err(command, 'Hello'))
end)
it('can delete buffer-local commands', function()
- meths.nvim_buf_create_user_command(0, 'Hello', 'echo "Hi"', {})
+ api.nvim_buf_create_user_command(0, 'Hello', 'echo "Hi"', {})
command('Hello')
- meths.nvim_buf_del_user_command(0, 'Hello')
+ api.nvim_buf_del_user_command(0, 'Hello')
matches('Not an editor command: Hello', pcall_err(command, 'Hello'))
end)
end)
diff --git a/test/functional/api/extmark_spec.lua b/test/functional/api/extmark_spec.lua
index 668ce43588..ed7c52971d 100644
--- a/test/functional/api/extmark_spec.lua
+++ b/test/functional/api/extmark_spec.lua
@@ -10,7 +10,7 @@ local feed = helpers.feed
local clear = helpers.clear
local command = helpers.command
local exec = helpers.exec
-local meths = helpers.meths
+local api = helpers.api
local assert_alive = helpers.assert_alive
local function expect(contents)
@@ -24,21 +24,21 @@ local function set_extmark(ns_id, id, line, col, opts)
if id ~= nil and id ~= 0 then
opts.id = id
end
- return meths.nvim_buf_set_extmark(0, ns_id, line, col, opts)
+ return api.nvim_buf_set_extmark(0, ns_id, line, col, opts)
end
local function get_extmarks(ns_id, start, end_, opts)
if opts == nil then
opts = {}
end
- return meths.nvim_buf_get_extmarks(0, ns_id, start, end_, opts)
+ return api.nvim_buf_get_extmarks(0, ns_id, start, end_, opts)
end
local function get_extmark_by_id(ns_id, id, opts)
if opts == nil then
opts = {}
end
- return meths.nvim_buf_get_extmark_by_id(0, ns_id, id, opts)
+ return api.nvim_buf_get_extmark_by_id(0, ns_id, id, opts)
end
local function check_undo_redo(ns, mark, sr, sc, er, ec) --s = start, e = end
@@ -196,11 +196,11 @@ describe('API/extmarks', function()
eq({ row, col }, rv)
-- remove the test marks
- eq(true, meths.nvim_buf_del_extmark(0, ns, marks[1]))
- eq(false, meths.nvim_buf_del_extmark(0, ns, marks[1]))
- eq(true, meths.nvim_buf_del_extmark(0, ns, marks[2]))
- eq(false, meths.nvim_buf_del_extmark(0, ns, marks[3]))
- eq(false, meths.nvim_buf_del_extmark(0, ns, 1000))
+ eq(true, api.nvim_buf_del_extmark(0, ns, marks[1]))
+ eq(false, api.nvim_buf_del_extmark(0, ns, marks[1]))
+ eq(true, api.nvim_buf_del_extmark(0, ns, marks[2]))
+ eq(false, api.nvim_buf_del_extmark(0, ns, marks[3]))
+ eq(false, api.nvim_buf_del_extmark(0, ns, 1000))
end)
it('can clear a specific namespace range', function()
@@ -208,7 +208,7 @@ describe('API/extmarks', function()
set_extmark(ns2, 1, 0, 1)
-- force a new undo buffer
feed('o<esc>')
- meths.nvim_buf_clear_namespace(0, ns2, 0, -1)
+ api.nvim_buf_clear_namespace(0, ns2, 0, -1)
eq({ { 1, 0, 1 } }, get_extmarks(ns, { 0, 0 }, { -1, -1 }))
eq({}, get_extmarks(ns2, { 0, 0 }, { -1, -1 }))
feed('u')
@@ -224,7 +224,7 @@ describe('API/extmarks', function()
set_extmark(ns2, 1, 0, 1)
-- force a new undo buffer
feed('o<esc>')
- meths.nvim_buf_clear_namespace(0, -1, 0, -1)
+ api.nvim_buf_clear_namespace(0, -1, 0, -1)
eq({}, get_extmarks(ns, { 0, 0 }, { -1, -1 }))
eq({}, get_extmarks(ns2, { 0, 0 }, { -1, -1 }))
feed('u')
@@ -242,14 +242,14 @@ describe('API/extmarks', function()
eq({ { 1, 0, 0 }, { 2, 1, 0 } }, get_extmarks(ns, { 0, 0 }, { -1, -1 }))
feed('dd')
eq({ { 1, 1, 0 }, { 2, 1, 0 } }, get_extmarks(ns, { 0, 0 }, { -1, -1 }))
- meths.nvim_buf_clear_namespace(0, ns, 0, -1)
+ api.nvim_buf_clear_namespace(0, ns, 0, -1)
eq({}, get_extmarks(ns, { 0, 0 }, { -1, -1 }))
set_extmark(ns, 1, 0, 0, { right_gravity = false })
set_extmark(ns, 2, 1, 0, { right_gravity = false })
eq({ { 1, 0, 0 }, { 2, 1, 0 } }, get_extmarks(ns, { 0, 0 }, { -1, -1 }))
feed('u')
eq({ { 1, 0, 0 }, { 2, 1, 0 } }, get_extmarks(ns, { 0, 0 }, { -1, -1 }))
- meths.nvim_buf_clear_namespace(0, ns, 0, -1)
+ api.nvim_buf_clear_namespace(0, ns, 0, -1)
end)
it('querying for information and ranges', function()
@@ -931,7 +931,7 @@ describe('API/extmarks', function()
-- Test unset
feed('o<esc>')
- meths.nvim_buf_del_extmark(0, ns, marks[3])
+ api.nvim_buf_del_extmark(0, ns, marks[3])
feed('u')
rv = get_extmarks(ns, { 0, 0 }, { -1, -1 })
-- undo does NOT restore deleted marks
@@ -987,10 +987,10 @@ describe('API/extmarks', function()
rv = get_extmarks(ns2, positions[2], positions[1])
eq(2, #rv)
- meths.nvim_buf_del_extmark(0, ns, marks[1])
+ api.nvim_buf_del_extmark(0, ns, marks[1])
rv = get_extmarks(ns, { 0, 0 }, { -1, -1 })
eq(2, #rv)
- meths.nvim_buf_del_extmark(0, ns2, marks[1])
+ api.nvim_buf_del_extmark(0, ns2, marks[1])
rv = get_extmarks(ns2, { 0, 0 }, { -1, -1 })
eq(2, #rv)
end)
@@ -1427,7 +1427,7 @@ describe('API/extmarks', function()
"Invalid 'ns_id': 3",
pcall_err(set_extmark, ns_invalid, marks[1], positions[1][1], positions[1][2])
)
- eq("Invalid 'ns_id': 3", pcall_err(meths.nvim_buf_del_extmark, 0, ns_invalid, marks[1]))
+ eq("Invalid 'ns_id': 3", pcall_err(api.nvim_buf_del_extmark, 0, ns_invalid, marks[1]))
eq("Invalid 'ns_id': 3", pcall_err(get_extmarks, ns_invalid, positions[1], positions[2]))
eq("Invalid 'ns_id': 3", pcall_err(get_extmark_by_id, ns_invalid, marks[1]))
end)
@@ -1470,7 +1470,7 @@ describe('API/extmarks', function()
it('in read-only buffer', function()
command('view! runtime/doc/help.txt')
- eq(true, meths.nvim_get_option_value('ro', {}))
+ eq(true, api.nvim_get_option_value('ro', {}))
local id = set_extmark(ns, 0, 0, 2)
eq({ { id, 0, 2 } }, get_extmarks(ns, 0, -1))
end)
@@ -1478,8 +1478,8 @@ describe('API/extmarks', function()
it('can set a mark to other buffer', function()
local buf = request('nvim_create_buf', 0, 1)
request('nvim_buf_set_lines', buf, 0, -1, 1, { '', '' })
- local id = meths.nvim_buf_set_extmark(buf, ns, 1, 0, {})
- eq({ { id, 1, 0 } }, meths.nvim_buf_get_extmarks(buf, ns, 0, -1, {}))
+ local id = api.nvim_buf_set_extmark(buf, ns, 1, 0, {})
+ eq({ { id, 1, 0 } }, api.nvim_buf_get_extmarks(buf, ns, 0, -1, {}))
end)
it('does not crash with append/delete/undo sequence', function()
@@ -1495,30 +1495,30 @@ describe('API/extmarks', function()
it('works with left and right gravity', function()
-- right gravity should move with inserted text, while
-- left gravity should stay in place.
- meths.nvim_buf_set_extmark(0, ns, 0, 5, { right_gravity = false })
- meths.nvim_buf_set_extmark(0, ns, 0, 5, { right_gravity = true })
+ api.nvim_buf_set_extmark(0, ns, 0, 5, { right_gravity = false })
+ api.nvim_buf_set_extmark(0, ns, 0, 5, { right_gravity = true })
feed([[Aasdfasdf]])
- eq({ { 1, 0, 5 }, { 2, 0, 13 } }, meths.nvim_buf_get_extmarks(0, ns, 0, -1, {}))
+ eq({ { 1, 0, 5 }, { 2, 0, 13 } }, api.nvim_buf_get_extmarks(0, ns, 0, -1, {}))
-- but both move when text is inserted before
feed([[<esc>Iasdf<esc>]])
- -- eq({}, meths.nvim_buf_get_lines(0, 0, -1, true))
- eq({ { 1, 0, 9 }, { 2, 0, 17 } }, meths.nvim_buf_get_extmarks(0, ns, 0, -1, {}))
+ -- eq({}, api.nvim_buf_get_lines(0, 0, -1, true))
+ eq({ { 1, 0, 9 }, { 2, 0, 17 } }, api.nvim_buf_get_extmarks(0, ns, 0, -1, {}))
-- clear text
- meths.nvim_buf_set_text(0, 0, 0, 0, 17, {})
+ api.nvim_buf_set_text(0, 0, 0, 0, 17, {})
-- handles set_text correctly as well
- eq({ { 1, 0, 0 }, { 2, 0, 0 } }, meths.nvim_buf_get_extmarks(0, ns, 0, -1, {}))
- meths.nvim_buf_set_text(0, 0, 0, 0, 0, { 'asdfasdf' })
- eq({ { 1, 0, 0 }, { 2, 0, 8 } }, meths.nvim_buf_get_extmarks(0, ns, 0, -1, {}))
+ eq({ { 1, 0, 0 }, { 2, 0, 0 } }, api.nvim_buf_get_extmarks(0, ns, 0, -1, {}))
+ api.nvim_buf_set_text(0, 0, 0, 0, 0, { 'asdfasdf' })
+ eq({ { 1, 0, 0 }, { 2, 0, 8 } }, api.nvim_buf_get_extmarks(0, ns, 0, -1, {}))
feed('u')
-- handles pasting
exec([[let @a='asdfasdf']])
feed([["ap]])
- eq({ { 1, 0, 0 }, { 2, 0, 8 } }, meths.nvim_buf_get_extmarks(0, ns, 0, -1, {}))
+ eq({ { 1, 0, 0 }, { 2, 0, 8 } }, api.nvim_buf_get_extmarks(0, ns, 0, -1, {}))
end)
it('can accept "end_row" or "end_line" #16548', function()
@@ -1545,7 +1545,7 @@ describe('API/extmarks', function()
it('in prompt buffer', function()
feed('dd')
local id = set_extmark(ns, marks[1], 0, 0, {})
- meths.nvim_set_option_value('buftype', 'prompt', {})
+ api.nvim_set_option_value('buftype', 'prompt', {})
feed('i<esc>')
eq({ { id, 0, 2 } }, get_extmarks(ns, 0, -1))
end)
@@ -1639,7 +1639,7 @@ describe('API/extmarks', function()
right_gravity = true,
},
}, get_extmark_by_id(ns, marks[3], { details = true }))
- meths.nvim_buf_clear_namespace(0, ns, 0, -1)
+ api.nvim_buf_clear_namespace(0, ns, 0, -1)
-- legacy sign mark includes sign name
command('sign define sign1 text=s1 texthl=Title linehl=LineNR numhl=Normal culhl=CursorLine')
command('sign place 1 name=sign1 line=1')
@@ -1693,7 +1693,7 @@ describe('API/extmarks', function()
screen = Screen.new(40, 6)
screen:attach()
feed('dd6iaaa bbb ccc<CR><ESC>gg')
- meths.nvim_set_option_value('signcolumn', 'auto:2', {})
+ api.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
@@ -1768,7 +1768,7 @@ describe('Extmarks buffer api with many marks', function()
for i = 1, 30 do
lines[#lines + 1] = string.rep('x ', i)
end
- meths.nvim_buf_set_lines(0, 0, -1, true, lines)
+ api.nvim_buf_set_lines(0, 0, -1, true, lines)
local ns = ns1
local q = 0
for i = 0, 29 do
@@ -1802,16 +1802,16 @@ describe('Extmarks buffer api with many marks', function()
end)
it('can clear all marks in ns', function()
- meths.nvim_buf_clear_namespace(0, ns1, 0, -1)
+ api.nvim_buf_clear_namespace(0, ns1, 0, -1)
eq({}, get_marks(ns1))
eq(ns_marks[ns2], get_marks(ns2))
- meths.nvim_buf_clear_namespace(0, ns2, 0, -1)
+ api.nvim_buf_clear_namespace(0, ns2, 0, -1)
eq({}, get_marks(ns1))
eq({}, get_marks(ns2))
end)
it('can clear line range', function()
- meths.nvim_buf_clear_namespace(0, ns1, 10, 20)
+ api.nvim_buf_clear_namespace(0, ns1, 10, 20)
for id, mark in pairs(ns_marks[ns1]) do
if 10 <= mark[1] and mark[1] < 20 then
ns_marks[ns1][id] = nil
diff --git a/test/functional/api/highlight_spec.lua b/test/functional/api/highlight_spec.lua
index b86fe550a1..1973d3e1c7 100644
--- a/test/functional/api/highlight_spec.lua
+++ b/test/functional/api/highlight_spec.lua
@@ -4,8 +4,8 @@ local Screen = require('test.functional.ui.screen')
local eq, eval = helpers.eq, helpers.eval
local command = helpers.command
local exec_capture = helpers.exec_capture
-local meths = helpers.meths
-local funcs = helpers.funcs
+local api = helpers.api
+local fn = helpers.fn
local pcall_err = helpers.pcall_err
local ok = helpers.ok
local assert_alive = helpers.assert_alive
@@ -52,128 +52,125 @@ describe('API: highlight', function()
it('nvim_get_hl_by_id', function()
local hl_id = eval("hlID('NewHighlight')")
- eq(expected_cterm, meths.nvim_get_hl_by_id(hl_id, false))
+ eq(expected_cterm, api.nvim_get_hl_by_id(hl_id, false))
hl_id = eval("hlID('NewHighlight')")
-- Test valid id.
- eq(expected_rgb, meths.nvim_get_hl_by_id(hl_id, true))
+ eq(expected_rgb, api.nvim_get_hl_by_id(hl_id, true))
-- Test invalid id.
- eq('Invalid highlight id: 30000', pcall_err(meths.nvim_get_hl_by_id, 30000, false))
+ eq('Invalid highlight id: 30000', pcall_err(api.nvim_get_hl_by_id, 30000, false))
-- Test all highlight properties.
command('hi NewHighlight gui=underline,bold,italic,reverse,strikethrough,altfont,nocombine')
- eq(expected_rgb2, meths.nvim_get_hl_by_id(hl_id, true))
+ eq(expected_rgb2, api.nvim_get_hl_by_id(hl_id, true))
-- Test undercurl
command('hi NewHighlight gui=undercurl')
- eq(expected_undercurl, meths.nvim_get_hl_by_id(hl_id, true))
+ eq(expected_undercurl, api.nvim_get_hl_by_id(hl_id, true))
-- Test nil argument.
eq(
'Wrong type for argument 1 when calling nvim_get_hl_by_id, expecting Integer',
- pcall_err(meths.nvim_get_hl_by_id, { nil }, false)
+ pcall_err(api.nvim_get_hl_by_id, { nil }, false)
)
-- Test 0 argument.
- eq('Invalid highlight id: 0', pcall_err(meths.nvim_get_hl_by_id, 0, false))
+ eq('Invalid highlight id: 0', pcall_err(api.nvim_get_hl_by_id, 0, false))
-- Test -1 argument.
- eq('Invalid highlight id: -1', pcall_err(meths.nvim_get_hl_by_id, -1, false))
+ eq('Invalid highlight id: -1', pcall_err(api.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.nvim_get_hl_by_id(hl_id, false))
+ eq({ foreground = 10 }, api.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.nvim_get_hl_by_id(hl_id, false))
+ eq({ background = 13 }, api.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.nvim_get_hl_by_id(hl_id, false))
+ eq({ foreground = 10, background = 13 }, api.nvim_get_hl_by_id(hl_id, false))
end)
it('nvim_get_hl_by_name', function()
local expected_normal = { background = Screen.colors.Yellow, foreground = Screen.colors.Red }
-- Test `Normal` default values.
- eq({}, meths.nvim_get_hl_by_name('Normal', true))
+ eq({}, api.nvim_get_hl_by_name('Normal', true))
- eq(expected_cterm, meths.nvim_get_hl_by_name('NewHighlight', false))
- eq(expected_rgb, meths.nvim_get_hl_by_name('NewHighlight', true))
+ eq(expected_cterm, api.nvim_get_hl_by_name('NewHighlight', false))
+ eq(expected_rgb, api.nvim_get_hl_by_name('NewHighlight', true))
-- Test `Normal` modified values.
command('hi Normal guifg=red guibg=yellow')
- eq(expected_normal, meths.nvim_get_hl_by_name('Normal', true))
+ eq(expected_normal, api.nvim_get_hl_by_name('Normal', true))
-- Test invalid name.
eq(
"Invalid highlight name: 'unknown_highlight'",
- pcall_err(meths.nvim_get_hl_by_name, 'unknown_highlight', false)
+ pcall_err(api.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.nvim_get_hl_by_name, { nil }, false)
+ pcall_err(api.nvim_get_hl_by_name, { nil }, false)
)
-- Test empty string argument.
- eq('Invalid highlight name', pcall_err(meths.nvim_get_hl_by_name, '', false))
+ eq('Invalid highlight name', pcall_err(api.nvim_get_hl_by_name, '', false))
-- Test "standout" attribute. #8054
- eq({ underline = true }, meths.nvim_get_hl_by_name('cursorline', 0))
+ eq({ underline = true }, api.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.nvim_get_hl_by_name('cursorline', 0))
+ eq({ underline = true, standout = true }, api.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.nvim_set_hl(0, 'Normal', { ctermfg = 17, ctermbg = 213 })
- meths.nvim_set_hl(0, 'NotNormal', { ctermfg = 17, ctermbg = 213, nocombine = true })
+ api.nvim_set_hl(0, 'Normal', { ctermfg = 17, ctermbg = 213 })
+ api.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 }, meths.nvim_get_hl_by_name('Normal', false))
+ eq({ foreground = 17, background = 213 }, api.nvim_get_hl_by_name('Normal', false))
eq(
{ foreground = 17, background = 213, nocombine = true },
- meths.nvim_get_hl_by_name('NotNormal', false)
+ api.nvim_get_hl_by_name('NotNormal', false)
)
end)
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.nvim_get_hl_by_name, 'Shrubbery', true)
- )
- eq(0, funcs.hlID('Shrubbery'))
+ eq("Invalid highlight name: 'Shrubbery'", pcall_err(api.nvim_get_hl_by_name, 'Shrubbery', true))
+ eq(0, fn.hlID('Shrubbery'))
- local hl_id = meths.nvim_get_hl_id_by_name('Shrubbery')
+ local hl_id = api.nvim_get_hl_id_by_name('Shrubbery')
ok(hl_id > 0)
- eq(hl_id, funcs.hlID('Shrubbery'))
+ eq(hl_id, fn.hlID('Shrubbery'))
command('hi Shrubbery guifg=#888888 guibg=#888888')
eq(
{ foreground = tonumber('0x888888'), background = tonumber('0x888888') },
- meths.nvim_get_hl_by_id(hl_id, true)
+ api.nvim_get_hl_by_id(hl_id, true)
)
eq(
{ foreground = tonumber('0x888888'), background = tonumber('0x888888') },
- meths.nvim_get_hl_by_name('Shrubbery', true)
+ api.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.nvim_set_option_value, 'undofile', false, { buf = 1 })
+ local err, _ = pcall(api.nvim_set_option_value, 'undofile', false, { buf = 1 })
eq(true, err)
- err, _ = pcall(meths.nvim_set_option_value, 'undolevels', -1, { buf = 1 })
+ err, _ = pcall(api.nvim_set_option_value, 'undolevels', -1, { buf = 1 })
eq(true, err)
- err, _ = pcall(meths.nvim_buf_add_highlight, 1, -1, 'Question', 0, 0, -1)
+ err, _ = pcall(api.nvim_buf_add_highlight, 1, -1, 'Question', 0, 0, -1)
eq(true, err)
assert_alive()
end)
@@ -244,8 +241,8 @@ describe('API: set highlight', function()
}
local function get_ns()
- local ns = meths.nvim_create_namespace('Test_set_hl')
- meths.nvim_set_hl_ns(ns)
+ local ns = api.nvim_create_namespace('Test_set_hl')
+ api.nvim_set_hl_ns(ns)
return ns
end
@@ -254,51 +251,51 @@ describe('API: set highlight', function()
it('validation', function()
eq(
"Invalid 'blend': out of range",
- pcall_err(meths.nvim_set_hl, 0, 'Test_hl3', { fg = '#FF00FF', blend = 999 })
+ pcall_err(api.nvim_set_hl, 0, 'Test_hl3', { fg = '#FF00FF', blend = 999 })
)
eq(
"Invalid 'blend': expected Integer, got Array",
- pcall_err(meths.nvim_set_hl, 0, 'Test_hl3', { fg = '#FF00FF', blend = {} })
+ pcall_err(api.nvim_set_hl, 0, 'Test_hl3', { fg = '#FF00FF', blend = {} })
)
end)
it('can set gui highlight', function()
local ns = get_ns()
- meths.nvim_set_hl(ns, 'Test_hl', highlight1)
- eq(highlight1, meths.nvim_get_hl_by_name('Test_hl', true))
+ api.nvim_set_hl(ns, 'Test_hl', highlight1)
+ eq(highlight1, api.nvim_get_hl_by_name('Test_hl', true))
end)
it('can set cterm highlight', function()
local ns = get_ns()
- meths.nvim_set_hl(ns, 'Test_hl', highlight2_config)
- eq(highlight2_result, meths.nvim_get_hl_by_name('Test_hl', false))
+ api.nvim_set_hl(ns, 'Test_hl', highlight2_config)
+ eq(highlight2_result, api.nvim_get_hl_by_name('Test_hl', false))
end)
it('can set empty cterm attr', function()
local ns = get_ns()
- meths.nvim_set_hl(ns, 'Test_hl', { cterm = {} })
- eq({}, meths.nvim_get_hl_by_name('Test_hl', false))
+ api.nvim_set_hl(ns, 'Test_hl', { cterm = {} })
+ eq({}, api.nvim_get_hl_by_name('Test_hl', false))
end)
it('cterm attr defaults to gui attr', function()
local ns = get_ns()
- meths.nvim_set_hl(ns, 'Test_hl', highlight1)
+ api.nvim_set_hl(ns, 'Test_hl', highlight1)
eq({
bold = true,
italic = true,
- }, meths.nvim_get_hl_by_name('Test_hl', false))
+ }, api.nvim_get_hl_by_name('Test_hl', false))
end)
it('can overwrite attr for cterm', function()
local ns = get_ns()
- 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))
+ api.nvim_set_hl(ns, 'Test_hl', highlight3_config)
+ eq(highlight3_result_gui, api.nvim_get_hl_by_name('Test_hl', true))
+ eq(highlight3_result_cterm, api.nvim_get_hl_by_name('Test_hl', false))
end)
it('only allows one underline attribute #22371', function()
local ns = get_ns()
- meths.nvim_set_hl(ns, 'Test_hl', {
+ api.nvim_set_hl(ns, 'Test_hl', {
underdouble = true,
underdotted = true,
cterm = {
@@ -306,21 +303,21 @@ describe('API: set highlight', function()
undercurl = 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))
+ eq({ undercurl = true }, api.nvim_get_hl_by_name('Test_hl', false))
+ eq({ underdotted = true }, api.nvim_get_hl_by_name('Test_hl', true))
end)
it('can set a highlight in the global namespace', function()
- meths.nvim_set_hl(0, 'Test_hl', highlight2_config)
+ api.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.nvim_set_hl(0, 'Test_hl', { background = highlight_color.bg })
+ api.nvim_set_hl(0, 'Test_hl', { background = highlight_color.bg })
eq('Test_hl xxx guibg=#0032aa', exec_capture('highlight Test_hl'))
- meths.nvim_set_hl(0, 'Test_hl2', highlight3_config)
+ api.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')
@@ -328,63 +325,63 @@ describe('API: set highlight', function()
-- Colors are stored with the name they are defined, but
-- with canonical casing
- meths.nvim_set_hl(0, 'Test_hl3', { bg = 'reD', fg = 'bLue' })
+ api.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.nvim_set_hl(0, 'Test_hl3', { bg = 'red', fg = 'blue' })
+ api.nvim_set_hl(0, 'Test_hl3', { bg = 'red', fg = 'blue' })
eq('Test_hl3 xxx guifg=Blue guibg=Red', exec_capture('highlight Test_hl3'))
- meths.nvim_set_hl(0, 'Test_hl3', { bg = 'red' })
+ api.nvim_set_hl(0, 'Test_hl3', { bg = 'red' })
eq('Test_hl3 xxx guibg=Red', exec_capture('highlight Test_hl3'))
- meths.nvim_set_hl(0, 'Test_hl3', { ctermbg = 9, ctermfg = 12 })
+ api.nvim_set_hl(0, 'Test_hl3', { ctermbg = 9, ctermfg = 12 })
eq('Test_hl3 xxx ctermfg=12 ctermbg=9', exec_capture('highlight Test_hl3'))
- meths.nvim_set_hl(0, 'Test_hl3', { ctermbg = 'red', ctermfg = 'blue' })
+ api.nvim_set_hl(0, 'Test_hl3', { ctermbg = 'red', ctermfg = 'blue' })
eq('Test_hl3 xxx ctermfg=12 ctermbg=9', exec_capture('highlight Test_hl3'))
- meths.nvim_set_hl(0, 'Test_hl3', { ctermbg = 9 })
+ api.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.nvim_set_hl, 0, 'Test_hl3', { fg = 'redd' })
+ pcall_err(api.nvim_set_hl, 0, 'Test_hl3', { fg = 'redd' })
)
eq(
"Invalid highlight color: 'bleu'",
- pcall_err(meths.nvim_set_hl, 0, 'Test_hl3', { ctermfg = 'bleu' })
+ pcall_err(api.nvim_set_hl, 0, 'Test_hl3', { ctermfg = 'bleu' })
)
- meths.nvim_set_hl(0, 'Test_hl3', { fg = '#FF00FF' })
+ api.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.nvim_set_hl, 0, 'Test_hl3', { ctermfg = '#FF00FF' })
+ pcall_err(api.nvim_set_hl, 0, 'Test_hl3', { ctermfg = '#FF00FF' })
)
for _, fg_val in ipairs { nil, 'NONE', 'nOnE', '', -1 } do
- meths.nvim_set_hl(0, 'Test_hl3', { fg = fg_val })
+ api.nvim_set_hl(0, 'Test_hl3', { fg = fg_val })
eq('Test_hl3 xxx cleared', exec_capture('highlight Test_hl3'))
end
- meths.nvim_set_hl(0, 'Test_hl3', { fg = '#FF00FF', blend = 50 })
+ api.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.nvim_set_hl(0, 'Normal', { fg = '#000083', bg = '#0000F3' })
- eq({ foreground = 131, background = 243 }, meths.nvim_get_hl_by_name('Normal', true))
+ api.nvim_set_hl(0, 'Normal', { fg = '#000083', bg = '#0000F3' })
+ eq({ foreground = 131, background = 243 }, api.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.nvim_set_hl, 0, 'foo bar', { bold = true })
+ pcall_err(api.nvim_set_hl, 0, 'foo bar', { bold = true })
)
assert_alive()
end)
@@ -452,14 +449,14 @@ describe('API: get highlight', function()
local function get_ns()
-- Test namespace filtering behavior
- 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 ns2 = api.nvim_create_namespace('Another_namespace')
+ api.nvim_set_hl(ns2, 'Test_hl', { ctermfg = 23 })
+ api.nvim_set_hl(ns2, 'Test_another_hl', { link = 'Test_hl' })
+ api.nvim_set_hl(ns2, 'Test_hl_link', { link = 'Test_another_hl' })
+ api.nvim_set_hl(ns2, 'Test_another_hl_link', { link = 'Test_hl_link' })
- local ns = meths.nvim_create_namespace('Test_set_hl')
- meths.nvim_set_hl_ns(ns)
+ local ns = api.nvim_create_namespace('Test_set_hl')
+ api.nvim_set_hl_ns(ns)
return ns
end
@@ -469,24 +466,24 @@ describe('API: get highlight', function()
it('validation', function()
eq(
"Invalid 'name': expected String, got Integer",
- pcall_err(meths.nvim_get_hl, 0, { name = 177 })
+ pcall_err(api.nvim_get_hl, 0, { name = 177 })
)
- eq('Highlight id out of bounds', pcall_err(meths.nvim_get_hl, 0, { name = 'Test set hl' }))
+ eq('Highlight id out of bounds', pcall_err(api.nvim_get_hl, 0, { name = 'Test set hl' }))
end)
it('nvim_get_hl with create flag', function()
- eq({}, meths.nvim_get_hl(0, { name = 'Foo', create = false }))
- eq(0, funcs.hlexists('Foo'))
- meths.nvim_get_hl(0, { name = 'Bar', create = true })
- eq(1, funcs.hlexists('Bar'))
- meths.nvim_get_hl(0, { name = 'FooBar' })
- eq(1, funcs.hlexists('FooBar'))
+ eq({}, api.nvim_get_hl(0, { name = 'Foo', create = false }))
+ eq(0, fn.hlexists('Foo'))
+ api.nvim_get_hl(0, { name = 'Bar', create = true })
+ eq(1, fn.hlexists('Bar'))
+ api.nvim_get_hl(0, { name = 'FooBar' })
+ eq(1, fn.hlexists('FooBar'))
end)
it('can get all highlights in current namespace', function()
local ns = get_ns()
- meths.nvim_set_hl(ns, 'Test_hl', { bg = '#B4BEFE' })
- meths.nvim_set_hl(ns, 'Test_hl_link', { link = 'Test_hl' })
+ api.nvim_set_hl(ns, 'Test_hl', { bg = '#B4BEFE' })
+ api.nvim_set_hl(ns, 'Test_hl_link', { link = 'Test_hl' })
eq({
Test_hl = {
bg = 11845374,
@@ -494,42 +491,42 @@ describe('API: get highlight', function()
Test_hl_link = {
link = 'Test_hl',
},
- }, meths.nvim_get_hl(ns, {}))
+ }, api.nvim_get_hl(ns, {}))
end)
it('can get gui highlight', function()
local ns = get_ns()
- meths.nvim_set_hl(ns, 'Test_hl', highlight1)
- eq(highlight1, meths.nvim_get_hl(ns, { name = 'Test_hl' }))
+ api.nvim_set_hl(ns, 'Test_hl', highlight1)
+ eq(highlight1, api.nvim_get_hl(ns, { name = 'Test_hl' }))
end)
it('can get cterm highlight', function()
local ns = get_ns()
- meths.nvim_set_hl(ns, 'Test_hl', highlight2)
- eq(highlight2, meths.nvim_get_hl(ns, { name = 'Test_hl' }))
+ api.nvim_set_hl(ns, 'Test_hl', highlight2)
+ eq(highlight2, api.nvim_get_hl(ns, { name = 'Test_hl' }))
end)
it('can get empty cterm attr', function()
local ns = get_ns()
- meths.nvim_set_hl(ns, 'Test_hl', { cterm = {} })
- eq({}, meths.nvim_get_hl(ns, { name = 'Test_hl' }))
+ api.nvim_set_hl(ns, 'Test_hl', { cterm = {} })
+ eq({}, api.nvim_get_hl(ns, { name = 'Test_hl' }))
end)
it('cterm attr defaults to gui attr', function()
local ns = get_ns()
- meths.nvim_set_hl(ns, 'Test_hl', highlight1)
- eq(highlight1, meths.nvim_get_hl(ns, { name = 'Test_hl' }))
+ api.nvim_set_hl(ns, 'Test_hl', highlight1)
+ eq(highlight1, api.nvim_get_hl(ns, { name = 'Test_hl' }))
end)
it('can overwrite attr for cterm', function()
local ns = get_ns()
- meths.nvim_set_hl(ns, 'Test_hl', highlight3_config)
- eq(highlight3_result, meths.nvim_get_hl(ns, { name = 'Test_hl' }))
+ api.nvim_set_hl(ns, 'Test_hl', highlight3_config)
+ eq(highlight3_result, api.nvim_get_hl(ns, { name = 'Test_hl' }))
end)
it('only allows one underline attribute #22371', function()
local ns = get_ns()
- meths.nvim_set_hl(ns, 'Test_hl', {
+ api.nvim_set_hl(ns, 'Test_hl', {
underdouble = true,
underdotted = true,
cterm = {
@@ -539,33 +536,33 @@ describe('API: get highlight', function()
})
eq(
{ underdotted = true, cterm = { undercurl = true } },
- meths.nvim_get_hl(ns, { name = 'Test_hl' })
+ api.nvim_get_hl(ns, { name = 'Test_hl' })
)
end)
it('can get a highlight in the global namespace', function()
- meths.nvim_set_hl(0, 'Test_hl', highlight2)
- eq(highlight2, meths.nvim_get_hl(0, { name = 'Test_hl' }))
+ api.nvim_set_hl(0, 'Test_hl', highlight2)
+ eq(highlight2, api.nvim_get_hl(0, { name = 'Test_hl' }))
- meths.nvim_set_hl(0, 'Test_hl', { background = highlight_color.bg })
+ api.nvim_set_hl(0, 'Test_hl', { background = highlight_color.bg })
eq({
bg = 12970,
- }, meths.nvim_get_hl(0, { name = 'Test_hl' }))
+ }, api.nvim_get_hl(0, { name = 'Test_hl' }))
- meths.nvim_set_hl(0, 'Test_hl2', highlight3_config)
- eq(highlight3_result, meths.nvim_get_hl(0, { name = 'Test_hl2' }))
+ api.nvim_set_hl(0, 'Test_hl2', highlight3_config)
+ eq(highlight3_result, api.nvim_get_hl(0, { name = 'Test_hl2' }))
-- Colors are stored with the name they are defined, but
-- with canonical casing
- meths.nvim_set_hl(0, 'Test_hl3', { bg = 'reD', fg = 'bLue' })
+ api.nvim_set_hl(0, 'Test_hl3', { bg = 'reD', fg = 'bLue' })
eq({
bg = 16711680,
fg = 255,
- }, meths.nvim_get_hl(0, { name = 'Test_hl3' }))
+ }, api.nvim_get_hl(0, { name = 'Test_hl3' }))
end)
it('nvim_get_hl by id', function()
- local hl_id = meths.nvim_get_hl_id_by_name('NewHighlight')
+ local hl_id = api.nvim_get_hl_id_by_name('NewHighlight')
command(
'hi NewHighlight cterm=underline ctermbg=green guifg=red guibg=yellow guisp=blue gui=bold'
@@ -577,14 +574,14 @@ describe('API: get highlight', function()
bold = true,
ctermbg = 10,
cterm = { underline = true },
- }, meths.nvim_get_hl(0, { id = hl_id }))
+ }, api.nvim_get_hl(0, { id = hl_id }))
-- Test 0 argument
- eq('Highlight id out of bounds', pcall_err(meths.nvim_get_hl, 0, { id = 0 }))
+ eq('Highlight id out of bounds', pcall_err(api.nvim_get_hl, 0, { id = 0 }))
eq(
"Invalid 'id': expected Integer, got String",
- pcall_err(meths.nvim_get_hl, 0, { id = 'Test_set_hl' })
+ pcall_err(api.nvim_get_hl, 0, { id = 'Test_set_hl' })
)
-- Test all highlight properties.
@@ -602,7 +599,7 @@ describe('API: get highlight', function()
underline = true,
ctermbg = 10,
cterm = { underline = true },
- }, meths.nvim_get_hl(0, { id = hl_id }))
+ }, api.nvim_get_hl(0, { id = hl_id }))
-- Test undercurl
command('hi NewHighlight gui=undercurl')
@@ -613,16 +610,16 @@ describe('API: get highlight', function()
undercurl = true,
ctermbg = 10,
cterm = { underline = true },
- }, meths.nvim_get_hl(0, { id = hl_id }))
+ }, api.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.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 }))
+ eq({ fg = 10937249 }, api.nvim_get_hl(0, { name = 'String' }))
+ eq({ link = 'String' }, api.nvim_get_hl(0, { name = '@string' }))
+ eq({ fg = 10937249 }, api.nvim_get_hl(0, { name = '@string.cpp', link = false }))
end)
it('can get all attributes for a linked group', function()
@@ -631,55 +628,55 @@ describe('API: get highlight', function()
command('hi! link Foo Bar')
eq(
{ link = 'Bar', fg = tonumber('00ff00', 16), bold = true, underline = true },
- meths.nvim_get_hl(0, { name = 'Foo', link = true })
+ api.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.nvim_set_hl(0, 'Foo', hl)
- eq(hl, meths.nvim_get_hl(0, { name = 'Foo', link = true }))
+ api.nvim_set_hl(0, 'Foo', hl)
+ eq(hl, api.nvim_get_hl(0, { name = 'Foo', link = true }))
end)
it("doesn't contain unset groups", function()
- local id = meths.nvim_get_hl_id_by_name '@foobar.hubbabubba'
+ local id = api.nvim_get_hl_id_by_name '@foobar.hubbabubba'
ok(id > 0)
- local data = meths.nvim_get_hl(0, {})
+ local data = api.nvim_get_hl(0, {})
eq(nil, data['@foobar.hubbabubba'])
eq(nil, data['@foobar'])
command 'hi @foobar.hubbabubba gui=bold'
- data = meths.nvim_get_hl(0, {})
+ data = api.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.nvim_get_hl(0, {})
+ data = api.nvim_get_hl(0, {})
eq({}, data['@foobar.hubbabubba'])
eq(nil, data['@foobar'])
end)
it('should return default flag', function()
- meths.nvim_set_hl(0, 'Tried', { fg = '#00ff00', default = true })
- eq({ fg = tonumber('00ff00', 16), default = true }, meths.nvim_get_hl(0, { name = 'Tried' }))
+ api.nvim_set_hl(0, 'Tried', { fg = '#00ff00', default = true })
+ eq({ fg = tonumber('00ff00', 16), default = true }, api.nvim_get_hl(0, { name = 'Tried' }))
end)
it('should not output empty gui and cterm #23474', function()
- 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(
+ api.nvim_set_hl(0, 'Foo', { default = true })
+ api.nvim_set_hl(0, 'Bar', { default = true, fg = '#ffffff' })
+ api.nvim_set_hl(0, 'FooBar', { default = true, fg = '#ffffff', cterm = { bold = true } })
+ api.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.nvim_get_hl(0, { name = 'Foo' }))
+ eq({ default = true }, api.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'))
@@ -688,27 +685,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.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' }))
+ api.nvim_set_hl(0, 'Foo', { fg = white })
+ api.nvim_set_hl(0, 'Foo', { fg = green, force = true })
+ eq({ fg = green }, api.nvim_get_hl(0, { name = 'Foo' }))
+ api.nvim_set_hl(0, 'Bar', { link = 'Comment', default = true })
+ api.nvim_set_hl(0, 'Bar', { link = 'Foo', default = true, force = true })
+ eq({ link = 'Foo', default = true }, api.nvim_get_hl(0, { name = 'Bar' }))
end)
end)
describe('API: set/get highlight namespace', function()
it('set/get highlight namespace', function()
- 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({}))
+ eq(0, api.nvim_get_hl_ns({}))
+ local ns = api.nvim_create_namespace('')
+ api.nvim_set_hl_ns(ns)
+ eq(ns, api.nvim_get_hl_ns({}))
end)
it('set/get window highlight namespace', function()
- 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 }))
+ eq(-1, api.nvim_get_hl_ns({ winid = 0 }))
+ local ns = api.nvim_create_namespace('')
+ api.nvim_win_set_hl_ns(0, ns)
+ eq(ns, api.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 b7de7732e8..4f57f6d0bd 100644
--- a/test/functional/api/keymap_spec.lua
+++ b/test/functional/api/keymap_spec.lua
@@ -6,8 +6,8 @@ local eq, neq = helpers.eq, helpers.neq
local exec_lua = helpers.exec_lua
local exec = helpers.exec
local feed = helpers.feed
-local funcs = helpers.funcs
-local meths = helpers.meths
+local fn = helpers.fn
+local api = helpers.api
local source = helpers.source
local pcall_err = helpers.pcall_err
@@ -55,7 +55,7 @@ describe('nvim_get_keymap', function()
}
it('returns empty list when no map', function()
- eq({}, meths.nvim_get_keymap('n'))
+ eq({}, api.nvim_get_keymap('n'))
end)
it('returns list of all applicable mappings', function()
@@ -64,8 +64,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.nvim_get_keymap('n'))
- eq({ funcs.maparg('foo', 'n', false, true) }, meths.nvim_get_keymap('n'))
+ eq({ foo_bar_map_table }, api.nvim_get_keymap('n'))
+ eq({ fn.maparg('foo', 'n', false, true) }, api.nvim_get_keymap('n'))
-- Add another mapping
command('nnoremap foo_longer bar_longer')
@@ -74,11 +74,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.nvim_get_keymap('n'))
+ eq({ foolong_bar_map_table, foo_bar_map_table }, api.nvim_get_keymap('n'))
-- Remove a mapping
command('unmap foo_longer')
- eq({ foo_bar_map_table }, meths.nvim_get_keymap('n'))
+ eq({ foo_bar_map_table }, api.nvim_get_keymap('n'))
end)
it('works for other modes', function()
@@ -92,7 +92,7 @@ describe('nvim_get_keymap', function()
insert_table['mode'] = 'i'
insert_table['mode_bits'] = 0x10
- eq({ insert_table }, meths.nvim_get_keymap('i'))
+ eq({ insert_table }, api.nvim_get_keymap('i'))
end)
it('considers scope', function()
@@ -109,8 +109,8 @@ describe('nvim_get_keymap', function()
command('nnoremap <buffer> foo bar')
-- The buffer mapping should not show up
- eq({ foolong_bar_map_table }, meths.nvim_get_keymap('n'))
- eq({ buffer_table }, meths.nvim_buf_get_keymap(0, 'n'))
+ eq({ foolong_bar_map_table }, api.nvim_get_keymap('n'))
+ eq({ buffer_table }, api.nvim_buf_get_keymap(0, 'n'))
end)
it('considers scope for overlapping maps', function()
@@ -121,12 +121,12 @@ describe('nvim_get_keymap', function()
command('nnoremap <buffer> foo bar')
- eq({ foo_bar_map_table }, meths.nvim_get_keymap('n'))
- eq({ buffer_table }, meths.nvim_buf_get_keymap(0, 'n'))
+ eq({ foo_bar_map_table }, api.nvim_get_keymap('n'))
+ eq({ buffer_table }, api.nvim_buf_get_keymap(0, 'n'))
end)
it('can retrieve mapping for different buffers', function()
- local original_buffer = meths.nvim_buf_get_number(0)
+ local original_buffer = api.nvim_buf_get_number(0)
-- Place something in each of the buffers to make sure they stick around
-- and set hidden so we can leave them
command('set hidden')
@@ -135,21 +135,21 @@ describe('nvim_get_keymap', function()
command('new')
command('normal! ihello 3')
- local final_buffer = meths.nvim_buf_get_number(0)
+ local final_buffer = api.nvim_buf_get_number(0)
command('nnoremap <buffer> foo bar')
-- Final buffer will have buffer mappings
local buffer_table = shallowcopy(foo_bar_map_table)
buffer_table['buffer'] = final_buffer
- eq({ buffer_table }, meths.nvim_buf_get_keymap(final_buffer, 'n'))
- eq({ buffer_table }, meths.nvim_buf_get_keymap(0, 'n'))
+ eq({ buffer_table }, api.nvim_buf_get_keymap(final_buffer, 'n'))
+ eq({ buffer_table }, api.nvim_buf_get_keymap(0, 'n'))
command('buffer ' .. original_buffer)
- eq(original_buffer, meths.nvim_buf_get_number(0))
+ eq(original_buffer, api.nvim_buf_get_number(0))
-- Original buffer won't have any mappings
- eq({}, meths.nvim_get_keymap('n'))
- eq({}, meths.nvim_buf_get_keymap(0, 'n'))
- eq({ buffer_table }, meths.nvim_buf_get_keymap(final_buffer, 'n'))
+ eq({}, api.nvim_get_keymap('n'))
+ eq({}, api.nvim_buf_get_keymap(0, 'n'))
+ eq({ buffer_table }, api.nvim_buf_get_keymap(final_buffer, 'n'))
end)
-- Test toggle switches for basic options
@@ -189,7 +189,7 @@ describe('nvim_get_keymap', function()
function()
make_new_windows(new_windows)
command(map .. ' ' .. option_token .. ' foo bar')
- local result = meths.nvim_get_keymap(mode)[1][option]
+ local result = api.nvim_get_keymap(mode)[1][option]
eq(global_on_result, result)
end
)
@@ -207,7 +207,7 @@ describe('nvim_get_keymap', function()
function()
make_new_windows(new_windows)
command(map .. ' <buffer> ' .. option_token .. ' foo bar')
- local result = meths.nvim_buf_get_keymap(0, mode)[1][option]
+ local result = api.nvim_buf_get_keymap(0, mode)[1][option]
eq(buffer_on_result, result)
end
)
@@ -226,7 +226,7 @@ describe('nvim_get_keymap', function()
function()
make_new_windows(new_windows)
command(map .. ' baz bat')
- local result = meths.nvim_get_keymap(mode)[1][option]
+ local result = api.nvim_get_keymap(mode)[1][option]
eq(global_off_result, result)
end
)
@@ -244,7 +244,7 @@ describe('nvim_get_keymap', function()
make_new_windows(new_windows)
command(map .. ' <buffer> foo bar')
- local result = meths.nvim_buf_get_keymap(0, mode)[1][option]
+ local result = api.nvim_buf_get_keymap(0, mode)[1][option]
eq(buffer_off_result, result)
end
)
@@ -275,9 +275,9 @@ describe('nvim_get_keymap', function()
nnoremap fizz :call <SID>maparg_test_function()<CR>
]])
- local sid_result = meths.nvim_get_keymap('n')[1]['sid']
+ local sid_result = api.nvim_get_keymap('n')[1]['sid']
eq(1, sid_result)
- eq('testing', meths.nvim_call_function('<SNR>' .. sid_result .. '_maparg_test_function', {}))
+ eq('testing', api.nvim_call_function('<SNR>' .. sid_result .. '_maparg_test_function', {}))
end)
it('returns script numbers for buffer maps', function()
@@ -288,15 +288,15 @@ describe('nvim_get_keymap', function()
nnoremap <buffer> fizz :call <SID>maparg_test_function()<CR>
]])
- local sid_result = meths.nvim_buf_get_keymap(0, 'n')[1]['sid']
+ local sid_result = api.nvim_buf_get_keymap(0, 'n')[1]['sid']
eq(1, sid_result)
- eq('testing', meths.nvim_call_function('<SNR>' .. sid_result .. '_maparg_test_function', {}))
+ eq('testing', api.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.nvim_get_keymap('n')[1]['lhs'])
- eq(':let g:maparg_test_var = 1<CR>', meths.nvim_get_keymap('n')[1]['rhs'])
+ eq('<F12>', api.nvim_get_keymap('n')[1]['lhs'])
+ eq(':let g:maparg_test_var = 1<CR>', api.nvim_get_keymap('n')[1]['rhs'])
end)
it('works correctly despite various &cpo settings', function()
@@ -339,7 +339,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.nvim_get_keymap(...)
+ local ret = api.nvim_get_keymap(...)
for _, item in ipairs(ret) do
item.lhsraw = nil
item.lhsrawalt = nil
@@ -390,7 +390,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.nvim_get_keymap('n'))
+ eq({ space_table }, api.nvim_get_keymap('n'))
end)
it('can handle lua mappings', function()
@@ -419,7 +419,7 @@ describe('nvim_get_keymap', function()
]])
eq(3, exec_lua([[return GlobalCount]]))
- local mapargs = meths.nvim_get_keymap('n')
+ local mapargs = api.nvim_get_keymap('n')
mapargs[1].callback = nil
eq({
lhs = 'asdf',
@@ -440,7 +440,7 @@ describe('nvim_get_keymap', function()
end)
it('can handle map descriptions', function()
- meths.nvim_set_keymap('n', 'lhs', 'rhs', { desc = 'map description' })
+ api.nvim_set_keymap('n', 'lhs', 'rhs', { desc = 'map description' })
eq({
lhs = 'lhs',
lhsraw = 'lhs',
@@ -458,7 +458,7 @@ describe('nvim_get_keymap', function()
noremap = 0,
lnum = 0,
desc = 'map description',
- }, meths.nvim_get_keymap('n')[1])
+ }, api.nvim_get_keymap('n')[1])
end)
end)
@@ -511,7 +511,7 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
-- Gets a maparg() dict from Nvim, if one exists.
local function get_mapargs(mode, lhs)
- local mapargs = funcs.maparg(lhs, normalize_mapmode(mode), mode:sub(-1) == 'a', true)
+ local mapargs = fn.maparg(lhs, normalize_mapmode(mode), mode:sub(-1) == 'a', true)
-- drop "lhsraw" and "lhsrawalt" which are hard to check
mapargs.lhsraw = nil
mapargs.lhsrawalt = nil
@@ -520,9 +520,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.nvim_set_keymap, '', '', 'rhs', {}))
- eq('Invalid (empty) LHS', pcall_err(meths.nvim_set_keymap, '', '', '', {}))
- eq('Invalid (empty) LHS', pcall_err(meths.nvim_del_keymap, '', ''))
+ eq('Invalid (empty) LHS', pcall_err(api.nvim_set_keymap, '', '', 'rhs', {}))
+ eq('Invalid (empty) LHS', pcall_err(api.nvim_set_keymap, '', '', '', {}))
+ eq('Invalid (empty) LHS', pcall_err(api.nvim_del_keymap, '', ''))
end)
it('error if LHS longer than MAXMAPLEN', function()
@@ -534,19 +534,19 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
end
-- exactly 50 chars should be fine
- meths.nvim_set_keymap('', lhs, 'rhs', {})
+ api.nvim_set_keymap('', lhs, 'rhs', {})
-- del_keymap should unmap successfully
- meths.nvim_del_keymap('', lhs)
+ api.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.nvim_set_keymap, '', lhs, 'rhs', {})
+ pcall_err(api.nvim_set_keymap, '', lhs, 'rhs', {})
)
- eq('LHS exceeds maximum map length: ' .. lhs, pcall_err(meths.nvim_del_keymap, '', lhs))
+ eq('LHS exceeds maximum map length: ' .. lhs, pcall_err(api.nvim_del_keymap, '', lhs))
end)
it('does not throw errors when rhs is longer than MAXMAPLEN', function()
@@ -556,65 +556,65 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
rhs = rhs .. (i % 10)
end
rhs = rhs .. '1'
- meths.nvim_set_keymap('', 'lhs', rhs, {})
+ api.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.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: " "', pcall_err(api.nvim_set_keymap, ' ', 'lhs', 'rhs', {}))
+ eq('Invalid mode shortname: "m"', pcall_err(api.nvim_set_keymap, 'm', 'lhs', 'rhs', {}))
+ eq('Invalid mode shortname: "?"', pcall_err(api.nvim_set_keymap, '?', 'lhs', 'rhs', {}))
+ eq('Invalid mode shortname: "y"', pcall_err(api.nvim_set_keymap, 'y', 'lhs', 'rhs', {}))
+ eq('Invalid mode shortname: "p"', pcall_err(api.nvim_set_keymap, 'p', 'lhs', 'rhs', {}))
+ eq('Invalid mode shortname: "a"', pcall_err(api.nvim_set_keymap, 'a', 'lhs', 'rhs', {}))
+ eq('Invalid mode shortname: "oa"', pcall_err(api.nvim_set_keymap, 'oa', 'lhs', 'rhs', {}))
+ eq('Invalid mode shortname: "!o"', pcall_err(api.nvim_set_keymap, '!o', 'lhs', 'rhs', {}))
+ eq('Invalid mode shortname: "!i"', pcall_err(api.nvim_set_keymap, '!i', 'lhs', 'rhs', {}))
+ eq('Invalid mode shortname: "!!"', pcall_err(api.nvim_set_keymap, '!!', 'lhs', 'rhs', {}))
+ eq('Invalid mode shortname: "map"', pcall_err(api.nvim_set_keymap, 'map', 'lhs', 'rhs', {}))
+ eq('Invalid mode shortname: "vmap"', pcall_err(api.nvim_set_keymap, 'vmap', 'lhs', 'rhs', {}))
eq(
'Invalid mode shortname: "xnoremap"',
- pcall_err(meths.nvim_set_keymap, 'xnoremap', 'lhs', 'rhs', {})
+ pcall_err(api.nvim_set_keymap, 'xnoremap', 'lhs', 'rhs', {})
)
- 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'))
+ eq('Invalid mode shortname: " "', pcall_err(api.nvim_del_keymap, ' ', 'lhs'))
+ eq('Invalid mode shortname: "m"', pcall_err(api.nvim_del_keymap, 'm', 'lhs'))
+ eq('Invalid mode shortname: "?"', pcall_err(api.nvim_del_keymap, '?', 'lhs'))
+ eq('Invalid mode shortname: "y"', pcall_err(api.nvim_del_keymap, 'y', 'lhs'))
+ eq('Invalid mode shortname: "p"', pcall_err(api.nvim_del_keymap, 'p', 'lhs'))
+ eq('Invalid mode shortname: "a"', pcall_err(api.nvim_del_keymap, 'a', 'lhs'))
+ eq('Invalid mode shortname: "oa"', pcall_err(api.nvim_del_keymap, 'oa', 'lhs'))
+ eq('Invalid mode shortname: "!o"', pcall_err(api.nvim_del_keymap, '!o', 'lhs'))
+ eq('Invalid mode shortname: "!i"', pcall_err(api.nvim_del_keymap, '!i', 'lhs'))
+ eq('Invalid mode shortname: "!!"', pcall_err(api.nvim_del_keymap, '!!', 'lhs'))
+ eq('Invalid mode shortname: "map"', pcall_err(api.nvim_del_keymap, 'map', 'lhs'))
+ eq('Invalid mode shortname: "vmap"', pcall_err(api.nvim_del_keymap, 'vmap', 'lhs'))
+ eq('Invalid mode shortname: "xnoremap"', pcall_err(api.nvim_del_keymap, 'xnoremap', 'lhs'))
end)
it('error on invalid optnames', function()
eq(
"Invalid key: 'silentt'",
- pcall_err(meths.nvim_set_keymap, 'n', 'lhs', 'rhs', { silentt = true })
+ pcall_err(api.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: 'sidd'", pcall_err(api.nvim_set_keymap, 'n', 'lhs', 'rhs', { sidd = false }))
eq(
"Invalid key: 'nowaiT'",
- pcall_err(meths.nvim_set_keymap, 'n', 'lhs', 'rhs', { nowaiT = false })
+ pcall_err(api.nvim_set_keymap, 'n', 'lhs', 'rhs', { nowaiT = false })
)
end)
it('error on <buffer> option key', function()
eq(
"Invalid key: 'buffer'",
- pcall_err(meths.nvim_set_keymap, 'n', 'lhs', 'rhs', { buffer = true })
+ pcall_err(api.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.nvim_set_keymap, 'n', 'lhs', 'rhs', { replace_keycodes = true })
+ pcall_err(api.nvim_set_keymap, 'n', 'lhs', 'rhs', { replace_keycodes = true })
)
end)
@@ -624,45 +624,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.nvim_set_keymap, 'n', 'lhs', 'rhs', opts))
+ eq(opt .. ' is not a boolean', pcall_err(api.nvim_set_keymap, 'n', 'lhs', 'rhs', opts))
end)
end
-- Perform tests of basic functionality
it('sets ordinary mappings', function()
- meths.nvim_set_keymap('n', 'lhs', 'rhs', {})
+ api.nvim_set_keymap('n', 'lhs', 'rhs', {})
eq(generate_mapargs('n', 'lhs', 'rhs'), get_mapargs('n', 'lhs'))
- meths.nvim_set_keymap('v', 'lhs', 'rhs', {})
+ api.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.nvim_set_keymap('n', ' lhs', 'rhs', {})
+ api.nvim_set_keymap('n', ' lhs', 'rhs', {})
eq(generate_mapargs('n', '<Space><Space><Space>lhs', 'rhs'), get_mapargs('n', ' lhs'))
- meths.nvim_set_keymap('n', 'lhs ', 'rhs', {})
+ api.nvim_set_keymap('n', 'lhs ', 'rhs', {})
eq(generate_mapargs('n', 'lhs<Space><Space><Space><Space>', 'rhs'), get_mapargs('n', 'lhs '))
- meths.nvim_set_keymap('v', ' lhs ', '\trhs\t\f', {})
+ api.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.nvim_set_keymap('x', 'lhs', 'rhs', { noremap = true })
+ api.nvim_set_keymap('x', 'lhs', 'rhs', { noremap = true })
eq(generate_mapargs('x', 'lhs', 'rhs', { noremap = true }), get_mapargs('x', 'lhs'))
- meths.nvim_set_keymap('t', 'lhs', 'rhs', { noremap = true })
+ api.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.nvim_set_keymap('v', 'lhs', 'rhs', {})
- meths.nvim_del_keymap('v', 'lhs')
+ api.nvim_set_keymap('v', 'lhs', 'rhs', {})
+ api.nvim_del_keymap('v', 'lhs')
eq({}, get_mapargs('v', 'lhs'))
- meths.nvim_set_keymap('t', 'lhs', 'rhs', { noremap = true })
- meths.nvim_del_keymap('t', 'lhs')
+ api.nvim_set_keymap('t', 'lhs', 'rhs', { noremap = true })
+ api.nvim_del_keymap('t', 'lhs')
eq({}, get_mapargs('t', 'lhs'))
end)
@@ -670,8 +670,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.nvim_set_keymap(name, 'lhs', 'rhs', {})
- meths.nvim_del_keymap(name, 'lhs')
+ api.nvim_set_keymap(name, 'lhs', 'rhs', {})
+ api.nvim_del_keymap(name, 'lhs')
eq({}, get_mapargs(name, 'lhs'))
end
end)
@@ -681,48 +681,48 @@ 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.nvim_set_keymap(mapmode, lhs, rhs, {})
+ api.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.nvim_set_keymap('n', '\n\r\n', 'rhs', {})
+ api.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.nvim_set_keymap('i', 'lhs', '<Nop>', {})
+ api.nvim_set_keymap('i', 'lhs', '<Nop>', {})
command('normal ilhs')
- eq({ '' }, meths.nvim_buf_get_lines(0, 0, -1, 0)) -- imap to <Nop> does nothing
+ eq({ '' }, api.nvim_buf_get_lines(0, 0, -1, 0)) -- imap to <Nop> does nothing
eq(generate_mapargs('i', 'lhs', '<Nop>', {}), get_mapargs('i', 'lhs'))
-- also test for case insensitivity
- meths.nvim_set_keymap('i', 'lhs', '<nOp>', {})
+ api.nvim_set_keymap('i', 'lhs', '<nOp>', {})
command('normal ilhs')
- eq({ '' }, meths.nvim_buf_get_lines(0, 0, -1, 0))
+ eq({ '' }, api.nvim_buf_get_lines(0, 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.nvim_set_keymap('i', 'lhs', '<NOP>', {})
+ api.nvim_set_keymap('i', 'lhs', '<NOP>', {})
command('normal ilhs')
- eq({ '' }, meths.nvim_buf_get_lines(0, 0, -1, 0))
+ eq({ '' }, api.nvim_buf_get_lines(0, 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.nvim_set_keymap('i', 'lhs', '\022', {})
+ api.nvim_set_keymap('i', 'lhs', '\022', {})
command('normal ilhs')
- eq({ '' }, meths.nvim_buf_get_lines(0, 0, -1, 0))
+ eq({ '' }, api.nvim_buf_get_lines(0, 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.nvim_set_keymap('i', 'lhs', '', {})
+ api.nvim_set_keymap('i', 'lhs', '', {})
command('normal ilhs')
- eq({ '' }, meths.nvim_buf_get_lines(0, 0, -1, 0))
+ eq({ '' }, api.nvim_buf_get_lines(0, 0, -1, 0))
eq(generate_mapargs('i', 'lhs', '', {}), get_mapargs('i', 'lhs'))
end)
@@ -730,8 +730,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.nvim_set_keymap('i', '<M-">', 'foo', {})
- meths.nvim_del_keymap('i', '<M-">')
+ api.nvim_set_keymap('i', '<M-">', 'foo', {})
+ api.nvim_del_keymap('i', '<M-">')
eq({}, get_mapargs('i', '<M-">'))
end)
@@ -741,18 +741,18 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
command([[call nvim_set_keymap('i', "\<space>", "\<tab>", {})]])
eq(generate_mapargs('i', '<Space>', '\t', { sid = 0 }), get_mapargs('i', '<Space>'))
feed('i ')
- eq({ '\t' }, meths.nvim_buf_get_lines(0, 0, -1, 0))
+ eq({ '\t' }, api.nvim_buf_get_lines(0, 0, -1, 0))
end
)
it('throws appropriate error messages when setting <unique> maps', function()
- meths.nvim_set_keymap('l', 'lhs', 'rhs', {})
+ api.nvim_set_keymap('l', 'lhs', 'rhs', {})
eq(
'E227: mapping already exists for lhs',
- pcall_err(meths.nvim_set_keymap, 'l', 'lhs', 'rhs', { unique = true })
+ pcall_err(api.nvim_set_keymap, 'l', 'lhs', 'rhs', { unique = true })
)
-- different mapmode, no error should be thrown
- meths.nvim_set_keymap('t', 'lhs', 'rhs', { unique = true })
+ api.nvim_set_keymap('t', 'lhs', 'rhs', { unique = true })
end)
it('can set <expr> mappings whose RHS change dynamically', function()
@@ -763,50 +763,50 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
return g:flip
endfunction
]])
- 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', {}))
+ eq(1, api.nvim_call_function('FlipFlop', {}))
+ eq(0, api.nvim_call_function('FlipFlop', {}))
+ eq(1, api.nvim_call_function('FlipFlop', {}))
+ eq(0, api.nvim_call_function('FlipFlop', {}))
- meths.nvim_set_keymap('i', 'lhs', 'FlipFlop()', { expr = true })
+ api.nvim_set_keymap('i', 'lhs', 'FlipFlop()', { expr = true })
command('normal ilhs')
- eq({ '1' }, meths.nvim_buf_get_lines(0, 0, -1, 0))
+ eq({ '1' }, api.nvim_buf_get_lines(0, 0, -1, 0))
command('normal! ggVGd')
command('normal ilhs')
- eq({ '0' }, meths.nvim_buf_get_lines(0, 0, -1, 0))
+ eq({ '0' }, api.nvim_buf_get_lines(0, 0, -1, 0))
end)
it('can set mappings that do trigger other mappings', function()
- meths.nvim_set_keymap('i', 'mhs', 'rhs', {})
- meths.nvim_set_keymap('i', 'lhs', 'mhs', {})
+ api.nvim_set_keymap('i', 'mhs', 'rhs', {})
+ api.nvim_set_keymap('i', 'lhs', 'mhs', {})
command('normal imhs')
- eq({ 'rhs' }, meths.nvim_buf_get_lines(0, 0, -1, 0))
+ eq({ 'rhs' }, api.nvim_buf_get_lines(0, 0, -1, 0))
command('normal! ggVGd')
command('normal ilhs')
- eq({ 'rhs' }, meths.nvim_buf_get_lines(0, 0, -1, 0))
+ eq({ 'rhs' }, api.nvim_buf_get_lines(0, 0, -1, 0))
end)
it("can set noremap mappings that don't trigger other mappings", function()
- meths.nvim_set_keymap('i', 'mhs', 'rhs', {})
- meths.nvim_set_keymap('i', 'lhs', 'mhs', { noremap = true })
+ api.nvim_set_keymap('i', 'mhs', 'rhs', {})
+ api.nvim_set_keymap('i', 'lhs', 'mhs', { noremap = true })
command('normal imhs')
- eq({ 'rhs' }, meths.nvim_buf_get_lines(0, 0, -1, 0))
+ eq({ 'rhs' }, api.nvim_buf_get_lines(0, 0, -1, 0))
command('normal! ggVGd')
command('normal ilhs') -- shouldn't trigger mhs-to-rhs mapping
- eq({ 'mhs' }, meths.nvim_buf_get_lines(0, 0, -1, 0))
+ eq({ 'mhs' }, api.nvim_buf_get_lines(0, 0, -1, 0))
end)
it('can set nowait mappings that fire without waiting', function()
- meths.nvim_set_keymap('i', '123456', 'longer', {})
- meths.nvim_set_keymap('i', '123', 'shorter', { nowait = true })
+ api.nvim_set_keymap('i', '123456', 'longer', {})
+ api.nvim_set_keymap('i', '123', 'shorter', { nowait = true })
-- feed keys one at a time; if all keys arrive atomically, the longer
-- mapping will trigger
@@ -815,29 +815,29 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
feed(c)
sleep(5)
end
- eq({ 'shorter456' }, meths.nvim_buf_get_lines(0, 0, -1, 0))
+ eq({ 'shorter456' }, api.nvim_buf_get_lines(0, 0, -1, 0))
end)
-- Perform exhaustive tests of basic functionality
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.nvim_set_keymap(mapmode, 'lhs', 'rhs', {})
+ api.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.nvim_del_keymap(mapmode, 'lhs')
+ api.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.nvim_set_keymap(mapmode, 'lhs', 'rhs', { noremap = true })
+ api.nvim_set_keymap(mapmode, 'lhs', 'rhs', { noremap = true })
eq(generate_mapargs(mapmode, 'lhs', 'rhs', { noremap = true }), get_mapargs(mapmode, 'lhs'))
- meths.nvim_del_keymap(mapmode, 'lhs')
+ api.nvim_del_keymap(mapmode, 'lhs')
eq({}, get_mapargs(mapmode, 'lhs'))
end)
end
@@ -849,12 +849,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.nvim_set_keymap(mapmode, 'lhs', 'rhs', { [maparg] = true })
+ api.nvim_set_keymap(mapmode, 'lhs', 'rhs', { [maparg] = true })
eq(
generate_mapargs(mapmode, 'lhs', 'rhs', { [maparg] = true }),
get_mapargs(mapmode, 'lhs')
)
- meths.nvim_del_keymap(mapmode, 'lhs')
+ api.nvim_del_keymap(mapmode, 'lhs')
eq({}, get_mapargs(mapmode, 'lhs'))
end)
it(
@@ -864,9 +864,9 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
.. maparg
.. ', whose value is false',
function()
- meths.nvim_set_keymap(mapmode, 'lhs', 'rhs', { [maparg] = false })
+ api.nvim_set_keymap(mapmode, 'lhs', 'rhs', { [maparg] = false })
eq(generate_mapargs(mapmode, 'lhs', 'rhs'), get_mapargs(mapmode, 'lhs'))
- meths.nvim_del_keymap(mapmode, 'lhs')
+ api.nvim_del_keymap(mapmode, 'lhs')
eq({}, get_mapargs(mapmode, 'lhs'))
end
)
@@ -886,9 +886,9 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
.. opt3,
function()
local opts = { [opt1] = true, [opt2] = false, [opt3] = true }
- meths.nvim_set_keymap(mapmode, 'lhs', 'rhs', opts)
+ api.nvim_set_keymap(mapmode, 'lhs', 'rhs', opts)
eq(generate_mapargs(mapmode, 'lhs', 'rhs', opts), get_mapargs(mapmode, 'lhs'))
- meths.nvim_del_keymap(mapmode, 'lhs')
+ api.nvim_del_keymap(mapmode, 'lhs')
eq({}, get_mapargs(mapmode, 'lhs'))
end
)
@@ -926,7 +926,7 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
exec_lua [[
vim.api.nvim_set_keymap('n', 'asdf', '', {callback = function() print('jkl;') end })
]]
- assert.truthy(string.match(funcs.mapcheck('asdf', 'n'), '^<Lua %d+>'))
+ assert.truthy(string.match(fn.mapcheck('asdf', 'n'), '^<Lua %d+>'))
end)
it('maparg() returns lua mapping correctly', function()
@@ -939,9 +939,9 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
]])
)
- assert.truthy(string.match(funcs.maparg('asdf', 'n'), '^<Lua %d+>'))
+ assert.truthy(string.match(fn.maparg('asdf', 'n'), '^<Lua %d+>'))
- local mapargs = funcs.maparg('asdf', 'n', false, true)
+ local mapargs = fn.maparg('asdf', 'n', false, true)
mapargs.callback = nil
mapargs.lhsraw = nil
mapargs.lhsrawalt = nil
@@ -968,7 +968,7 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
feed('aa')
- eq({ 'π<M-π>foo<' }, meths.nvim_buf_get_lines(0, 0, -1, false))
+ eq({ 'π<M-π>foo<' }, api.nvim_buf_get_lines(0, 0, -1, false))
end)
it('can make lua expr mappings without replacing keycodes', function()
@@ -978,7 +978,7 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
feed('iaa<esc>')
- eq({ '<space>' }, meths.nvim_buf_get_lines(0, 0, -1, false))
+ eq({ '<space>' }, api.nvim_buf_get_lines(0, 0, -1, false))
end)
it('lua expr mapping returning nil is equivalent to returning an empty string', function()
@@ -988,7 +988,7 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
feed('iaa<esc>')
- eq({ '' }, meths.nvim_buf_get_lines(0, 0, -1, false))
+ eq({ '' }, api.nvim_buf_get_lines(0, 0, -1, false))
end)
it('does not reset pum in lua mapping', function()
@@ -1091,7 +1091,7 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
end)
it('can set descriptions on mappings', function()
- meths.nvim_set_keymap('n', 'lhs', 'rhs', { desc = 'map description' })
+ api.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)
@@ -1106,10 +1106,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.nvim_get_current_line())
+ eq('The 1 and the bar and the 2 again', api.nvim_get_current_line())
feed ':let x = "The foo is the one"<cr>'
- eq('The 3 is the one', meths.nvim_eval 'x')
+ eq('The 3 is the one', api.nvim_eval 'x')
end)
it('can define insert mode abbreviations with lua callbacks', function()
@@ -1122,10 +1122,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.nvim_get_current_line())
+ eq('The 1 and the bar and the 2 again', api.nvim_get_current_line())
feed ':let x = "The foo is the one"<cr>'
- eq('The foo is the one', meths.nvim_eval 'x')
+ eq('The foo is the one', api.nvim_eval 'x')
end)
it('can define cmdline mode abbreviations with lua callbacks', function()
@@ -1138,10 +1138,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.nvim_get_current_line())
+ eq('The foo and the bar and the foo again', api.nvim_get_current_line())
feed ':let x = "The foo is the one"<cr>'
- eq('The 1 is the one', meths.nvim_eval 'x')
+ eq('The 1 is the one', api.nvim_eval 'x')
end)
end)
@@ -1164,9 +1164,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.nvim_call_function('bufnr', { '%' })
+ local first_buf = api.nvim_call_function('bufnr', { '%' })
command('new')
- local second_buf = meths.nvim_call_function('bufnr', { '%' })
+ local second_buf = api.nvim_call_function('bufnr', { '%' })
neq(second_buf, first_buf) -- sanity check
if start_from_first then
@@ -1179,66 +1179,66 @@ describe('nvim_buf_set_keymap, nvim_buf_del_keymap', function()
it('rejects negative bufnr values', function()
eq(
'Wrong type for argument 1 when calling nvim_buf_set_keymap, expecting Buffer',
- pcall_err(meths.nvim_buf_set_keymap, -1, '', 'lhs', 'rhs', {})
+ pcall_err(api.nvim_buf_set_keymap, -1, '', 'lhs', 'rhs', {})
)
end)
it('can set mappings active in the current buffer but not others', function()
local first, second = make_two_buffers(true)
- meths.nvim_buf_set_keymap(0, '', 'lhs', 'irhs<Esc>', {})
+ api.nvim_buf_set_keymap(0, '', 'lhs', 'irhs<Esc>', {})
command('normal lhs')
- eq({ 'rhs' }, meths.nvim_buf_get_lines(0, 0, 1, 1))
+ eq({ 'rhs' }, api.nvim_buf_get_lines(0, 0, 1, 1))
-- mapping should have no effect in new buffer
switch_to_buf(second)
command('normal lhs')
- eq({ '' }, meths.nvim_buf_get_lines(0, 0, 1, 1))
+ eq({ '' }, api.nvim_buf_get_lines(0, 0, 1, 1))
-- mapping should remain active in old buffer
switch_to_buf(first)
command('normal ^lhs')
- eq({ 'rhsrhs' }, meths.nvim_buf_get_lines(0, 0, 1, 1))
+ eq({ 'rhsrhs' }, api.nvim_buf_get_lines(0, 0, 1, 1))
end)
it('can set local mappings in buffer other than current', function()
local first = make_two_buffers(false)
- meths.nvim_buf_set_keymap(first, '', 'lhs', 'irhs<Esc>', {})
+ api.nvim_buf_set_keymap(first, '', 'lhs', 'irhs<Esc>', {})
-- shouldn't do anything
command('normal lhs')
- eq({ '' }, meths.nvim_buf_get_lines(0, 0, 1, 1))
+ eq({ '' }, api.nvim_buf_get_lines(0, 0, 1, 1))
-- should take effect
switch_to_buf(first)
command('normal lhs')
- eq({ 'rhs' }, meths.nvim_buf_get_lines(0, 0, 1, 1))
+ eq({ 'rhs' }, api.nvim_buf_get_lines(0, 0, 1, 1))
end)
it('can disable mappings made in another buffer, inside that buffer', function()
local first = make_two_buffers(false)
- meths.nvim_buf_set_keymap(first, '', 'lhs', 'irhs<Esc>', {})
- meths.nvim_buf_del_keymap(first, '', 'lhs')
+ api.nvim_buf_set_keymap(first, '', 'lhs', 'irhs<Esc>', {})
+ api.nvim_buf_del_keymap(first, '', 'lhs')
switch_to_buf(first)
-- shouldn't do anything
command('normal lhs')
- eq({ '' }, meths.nvim_buf_get_lines(0, 0, 1, 1))
+ eq({ '' }, api.nvim_buf_get_lines(0, 0, 1, 1))
end)
it("can't disable mappings given wrong buffer handle", function()
local first, second = make_two_buffers(false)
- meths.nvim_buf_set_keymap(first, '', 'lhs', 'irhs<Esc>', {})
- eq('E31: No such mapping', pcall_err(meths.nvim_buf_del_keymap, second, '', 'lhs'))
+ api.nvim_buf_set_keymap(first, '', 'lhs', 'irhs<Esc>', {})
+ eq('E31: No such mapping', pcall_err(api.nvim_buf_del_keymap, second, '', 'lhs'))
-- should still work
switch_to_buf(first)
command('normal lhs')
- eq({ 'rhs' }, meths.nvim_buf_get_lines(0, 0, 1, 1))
+ eq({ 'rhs' }, api.nvim_buf_get_lines(0, 0, 1, 1))
end)
it('does not crash when setting mapping in a non-existing buffer #13541', function()
- pcall_err(meths.nvim_buf_set_keymap, 100, '', 'lsh', 'irhs<Esc>', {})
+ pcall_err(api.nvim_buf_set_keymap, 100, '', 'lsh', 'irhs<Esc>', {})
helpers.assert_alive()
end)
@@ -1264,7 +1264,7 @@ describe('nvim_buf_set_keymap, nvim_buf_del_keymap', function()
feed('aa')
- eq({ 'π<M-π>foo<' }, meths.nvim_buf_get_lines(0, 0, -1, false))
+ eq({ 'π<M-π>foo<' }, api.nvim_buf_get_lines(0, 0, -1, false))
end)
it('can make lua expr mappings without replacing keycodes', function()
@@ -1274,7 +1274,7 @@ describe('nvim_buf_set_keymap, nvim_buf_del_keymap', function()
feed('iaa<esc>')
- eq({ '<space>' }, meths.nvim_buf_get_lines(0, 0, -1, false))
+ eq({ '<space>' }, api.nvim_buf_get_lines(0, 0, -1, false))
end)
it('can overwrite lua mappings', function()
diff --git a/test/functional/api/proc_spec.lua b/test/functional/api/proc_spec.lua
index 82a3968ab7..50c441792c 100644
--- a/test/functional/api/proc_spec.lua
+++ b/test/functional/api/proc_spec.lua
@@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
local eq = helpers.eq
-local funcs = helpers.funcs
+local fn = helpers.fn
local neq = helpers.neq
local nvim_argv = helpers.nvim_argv
local request = helpers.request
@@ -15,28 +15,28 @@ describe('API', function()
describe('nvim_get_proc_children', function()
it('returns child process ids', function()
- local this_pid = funcs.getpid()
+ local this_pid = fn.getpid()
-- Might be non-zero already (left-over from some other test?),
-- but this is not what is tested here.
local initial_children = request('nvim_get_proc_children', this_pid)
- local job1 = funcs.jobstart(nvim_argv)
+ local job1 = fn.jobstart(nvim_argv)
retry(nil, nil, function()
eq(#initial_children + 1, #request('nvim_get_proc_children', this_pid))
end)
- local job2 = funcs.jobstart(nvim_argv)
+ local job2 = fn.jobstart(nvim_argv)
retry(nil, nil, function()
eq(#initial_children + 2, #request('nvim_get_proc_children', this_pid))
end)
- funcs.jobstop(job1)
+ fn.jobstop(job1)
retry(nil, nil, function()
eq(#initial_children + 1, #request('nvim_get_proc_children', this_pid))
end)
- funcs.jobstop(job2)
+ fn.jobstop(job2)
retry(nil, nil, function()
eq(#initial_children, #request('nvim_get_proc_children', this_pid))
end)
@@ -60,7 +60,7 @@ describe('API', function()
describe('nvim_get_proc', function()
it('returns process info', function()
- local pid = funcs.getpid()
+ local pid = fn.getpid()
local pinfo = request('nvim_get_proc', pid)
eq((is_os('win') and 'nvim.exe' or 'nvim'), pinfo.name)
eq(pid, pinfo.pid)
diff --git a/test/functional/api/server_notifications_spec.lua b/test/functional/api/server_notifications_spec.lua
index c80f7f4f7b..f6058b14ee 100644
--- a/test/functional/api/server_notifications_spec.lua
+++ b/test/functional/api/server_notifications_spec.lua
@@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')(after_each)
local assert_log = helpers.assert_log
local eq, clear, eval, command, next_msg =
helpers.eq, helpers.clear, helpers.eval, helpers.command, helpers.next_msg
-local meths = helpers.meths
+local api = helpers.api
local exec_lua = helpers.exec_lua
local retry = helpers.retry
local assert_alive = helpers.assert_alive
@@ -14,7 +14,7 @@ describe('notify', function()
before_each(function()
clear()
- channel = meths.nvim_get_api_info()[1]
+ channel = api.nvim_get_api_info()[1]
end)
after_each(function()
@@ -33,21 +33,21 @@ describe('notify', function()
describe('passing 0 as the channel id', function()
it('sends the notification/args to all subscribed channels', function()
- meths.nvim_subscribe('event2')
+ api.nvim_subscribe('event2')
eval('rpcnotify(0, "event1", 1, 2, 3)')
eval('rpcnotify(0, "event2", 4, 5, 6)')
eval('rpcnotify(0, "event2", 7, 8, 9)')
eq({ 'notification', 'event2', { 4, 5, 6 } }, next_msg())
eq({ 'notification', 'event2', { 7, 8, 9 } }, next_msg())
- meths.nvim_unsubscribe('event2')
- meths.nvim_subscribe('event1')
+ api.nvim_unsubscribe('event2')
+ api.nvim_subscribe('event1')
eval('rpcnotify(0, "event2", 10, 11, 12)')
eval('rpcnotify(0, "event1", 13, 14, 15)')
eq({ 'notification', 'event1', { 13, 14, 15 } }, next_msg())
end)
it('does not crash for deeply nested variable', function()
- meths.nvim_set_var('l', {})
+ api.nvim_set_var('l', {})
local nest_level = 1000
command(('call map(range(%u), "extend(g:, {\'l\': [g:l]})")'):format(nest_level - 1))
eval('rpcnotify(' .. channel .. ', "event", g:l)')
@@ -79,10 +79,10 @@ describe('notify', function()
clear { env = {
NVIM_LOG_FILE = testlog,
} }
- meths.nvim_subscribe('event1')
- meths.nvim_unsubscribe('doesnotexist')
+ api.nvim_subscribe('event1')
+ api.nvim_unsubscribe('doesnotexist')
assert_log("tried to unsubscribe unknown event 'doesnotexist'", testlog, 10)
- meths.nvim_unsubscribe('event1')
+ api.nvim_unsubscribe('event1')
assert_alive()
end)
@@ -106,7 +106,7 @@ describe('notify', function()
exec_lua([[ return {pcall(vim.rpcrequest, ..., 'nvim_eval', '1+1')}]], catchan)
)
retry(nil, 3000, function()
- eq({}, meths.nvim_get_chan_info(catchan))
+ eq({}, api.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 e06d32f656..5e508e7513 100644
--- a/test/functional/api/server_requests_spec.lua
+++ b/test/functional/api/server_requests_spec.lua
@@ -4,10 +4,10 @@ local helpers = require('test.functional.helpers')(after_each)
local clear, eval = helpers.clear, helpers.eval
local eq, neq, run, stop = helpers.eq, helpers.neq, helpers.run, helpers.stop
-local nvim_prog, command, funcs = helpers.nvim_prog, helpers.command, helpers.funcs
+local nvim_prog, command, fn = helpers.nvim_prog, helpers.command, helpers.fn
local source, next_msg = helpers.source, helpers.next_msg
local ok = helpers.ok
-local meths = helpers.meths
+local api = helpers.api
local spawn, merge_args = helpers.spawn, helpers.merge_args
local set_session = helpers.set_session
local pcall_err = helpers.pcall_err
@@ -18,7 +18,7 @@ describe('server -> client', function()
before_each(function()
clear()
- cid = meths.nvim_get_api_info()[1]
+ cid = api.nvim_get_api_info()[1]
end)
it('handles unexpected closed stream while preparing RPC response', function()
@@ -77,15 +77,15 @@ describe('server -> client', function()
describe('recursive call', function()
it('works', function()
local function on_setup()
- meths.nvim_set_var('result1', 0)
- meths.nvim_set_var('result2', 0)
- meths.nvim_set_var('result3', 0)
- meths.nvim_set_var('result4', 0)
+ api.nvim_set_var('result1', 0)
+ api.nvim_set_var('result2', 0)
+ api.nvim_set_var('result3', 0)
+ api.nvim_set_var('result4', 0)
command('let g:result1 = rpcrequest(' .. cid .. ', "rcall", 2)')
- eq(4, meths.nvim_get_var('result1'))
- eq(8, meths.nvim_get_var('result2'))
- eq(16, meths.nvim_get_var('result3'))
- eq(32, meths.nvim_get_var('result4'))
+ eq(4, api.nvim_get_var('result1'))
+ eq(8, api.nvim_get_var('result2'))
+ eq(16, api.nvim_get_var('result3'))
+ eq(32, api.nvim_get_var('result4'))
stop()
end
@@ -113,12 +113,12 @@ describe('server -> client', function()
it('does not delay notifications during pending request', function()
local received = false
local function on_setup()
- eq('retval', funcs.rpcrequest(cid, 'doit'))
+ eq('retval', fn.rpcrequest(cid, 'doit'))
stop()
end
local function on_request(method)
if method == 'doit' then
- funcs.rpcnotify(cid, 'headsup')
+ fn.rpcnotify(cid, 'headsup')
eq(true, received)
return 'retval'
end
@@ -231,8 +231,8 @@ describe('server -> client', function()
describe('jobstart()', function()
local jobid
before_each(function()
- local channel = meths.nvim_get_api_info()[1]
- meths.nvim_set_var('channel', channel)
+ local channel = api.nvim_get_api_info()[1]
+ api.nvim_set_var('channel', channel)
source([[
function! s:OnEvent(id, data, event)
call rpcnotify(g:channel, a:event, 0, a:data)
@@ -244,7 +244,7 @@ describe('server -> client', function()
\ 'rpc': v:true
\ }
]])
- meths.nvim_set_var('args', {
+ api.nvim_set_var('args', {
nvim_prog,
'-ll',
'test/functional/api/rpc_fixture.lua',
@@ -256,7 +256,7 @@ describe('server -> client', function()
end)
after_each(function()
- pcall(funcs.jobstop, jobid)
+ pcall(fn.jobstop, jobid)
end)
if helpers.skip(helpers.is_os('win')) then
@@ -264,16 +264,16 @@ describe('server -> client', function()
end
it('rpc and text stderr can be combined', function()
- local status, rv = pcall(funcs.rpcrequest, jobid, 'poll')
+ local status, rv = pcall(fn.rpcrequest, jobid, 'poll')
if not status then
error(string.format('missing nvim Lua module? (%s)', rv))
end
eq('ok', rv)
- funcs.rpcnotify(jobid, 'ping')
+ fn.rpcnotify(jobid, 'ping')
eq({ 'notification', 'pong', {} }, next_msg())
- eq('done!', funcs.rpcrequest(jobid, 'write_stderr', 'fluff\n'))
+ eq('done!', fn.rpcrequest(jobid, 'write_stderr', 'fluff\n'))
eq({ 'notification', 'stderr', { 0, { 'fluff', '' } } }, next_msg())
- pcall(funcs.rpcrequest, jobid, 'exit')
+ pcall(fn.rpcrequest, jobid, 'exit')
eq({ 'notification', 'stderr', { 0, { '' } } }, next_msg())
eq({ 'notification', 'exit', { 0, 0 } }, next_msg())
end)
@@ -282,29 +282,29 @@ describe('server -> client', function()
describe('connecting to another (peer) nvim', function()
local nvim_argv = merge_args(helpers.nvim_argv, { '--headless' })
local function connect_test(server, mode, address)
- local serverpid = funcs.getpid()
+ local serverpid = fn.getpid()
local client = spawn(nvim_argv, false, nil, true)
set_session(client)
- local clientpid = funcs.getpid()
+ local clientpid = fn.getpid()
neq(serverpid, clientpid)
- local id = funcs.sockconnect(mode, address, { rpc = true })
+ local id = fn.sockconnect(mode, address, { rpc = true })
ok(id > 0)
- funcs.rpcrequest(id, 'nvim_set_current_line', 'hello')
- local client_id = funcs.rpcrequest(id, 'nvim_get_api_info')[1]
+ fn.rpcrequest(id, 'nvim_set_current_line', 'hello')
+ local client_id = fn.rpcrequest(id, 'nvim_get_api_info')[1]
set_session(server)
- eq(serverpid, funcs.getpid())
- eq('hello', meths.nvim_get_current_line())
+ eq(serverpid, fn.getpid())
+ eq('hello', api.nvim_get_current_line())
-- method calls work both ways
- funcs.rpcrequest(client_id, 'nvim_set_current_line', 'howdy!')
- eq(id, funcs.rpcrequest(client_id, 'nvim_get_api_info')[1])
+ fn.rpcrequest(client_id, 'nvim_set_current_line', 'howdy!')
+ eq(id, fn.rpcrequest(client_id, 'nvim_get_api_info')[1])
set_session(client)
- eq(clientpid, funcs.getpid())
- eq('howdy!', meths.nvim_get_current_line())
+ eq(clientpid, fn.getpid())
+ eq('howdy!', api.nvim_get_current_line())
server:close()
client:close()
@@ -313,7 +313,7 @@ describe('server -> client', function()
it('via named pipe', function()
local server = spawn(nvim_argv)
set_session(server)
- local address = funcs.serverlist()[1]
+ local address = fn.serverlist()[1]
local first = string.sub(address, 1, 1)
ok(first == '/' or first == '\\')
connect_test(server, 'pipe', address)
@@ -322,7 +322,7 @@ describe('server -> client', function()
it('via ipv4 address', function()
local server = spawn(nvim_argv)
set_session(server)
- local status, address = pcall(funcs.serverstart, '127.0.0.1:')
+ local status, address = pcall(fn.serverstart, '127.0.0.1:')
if not status then
pending('no ipv4 stack')
end
@@ -333,7 +333,7 @@ describe('server -> client', function()
it('via ipv6 address', function()
local server = spawn(nvim_argv)
set_session(server)
- local status, address = pcall(funcs.serverstart, '::1:')
+ local status, address = pcall(fn.serverstart, '::1:')
if not status then
pending('no ipv6 stack')
end
@@ -344,7 +344,7 @@ describe('server -> client', function()
it('via hostname', function()
local server = spawn(nvim_argv)
set_session(server)
- local address = funcs.serverstart('localhost:')
+ local address = fn.serverstart('localhost:')
eq('localhost:', string.sub(address, 1, 10))
connect_test(server, 'tcp', address)
end)
@@ -352,12 +352,12 @@ describe('server -> client', function()
it('does not crash on receiving UI events', function()
local server = spawn(nvim_argv)
set_session(server)
- local address = funcs.serverlist()[1]
+ local address = fn.serverlist()[1]
local client = spawn(nvim_argv, false, nil, true)
set_session(client)
- local id = funcs.sockconnect('pipe', address, { rpc = true })
- funcs.rpcrequest(id, 'nvim_ui_attach', 80, 24, {})
+ local id = fn.sockconnect('pipe', address, { rpc = true })
+ fn.rpcrequest(id, 'nvim_ui_attach', 80, 24, {})
assert_alive()
server:close()
@@ -367,18 +367,18 @@ describe('server -> client', function()
describe('connecting to its own pipe address', function()
it('does not deadlock', function()
- local address = funcs.serverlist()[1]
+ local address = fn.serverlist()[1]
local first = string.sub(address, 1, 1)
ok(first == '/' or first == '\\')
- local serverpid = funcs.getpid()
+ local serverpid = fn.getpid()
- local id = funcs.sockconnect('pipe', address, { rpc = true })
+ local id = fn.sockconnect('pipe', address, { rpc = true })
- funcs.rpcrequest(id, 'nvim_set_current_line', 'hello')
- eq('hello', meths.nvim_get_current_line())
- eq(serverpid, funcs.rpcrequest(id, 'nvim_eval', 'getpid()'))
+ fn.rpcrequest(id, 'nvim_set_current_line', 'hello')
+ eq('hello', api.nvim_get_current_line())
+ eq(serverpid, fn.rpcrequest(id, 'nvim_eval', 'getpid()'))
- eq(id, funcs.rpcrequest(id, 'nvim_get_api_info')[1])
+ eq(id, fn.rpcrequest(id, 'nvim_get_api_info')[1])
end)
end)
end)
diff --git a/test/functional/api/tabpage_spec.lua b/test/functional/api/tabpage_spec.lua
index 830b547da5..65b030fc60 100644
--- a/test/functional/api/tabpage_spec.lua
+++ b/test/functional/api/tabpage_spec.lua
@@ -1,7 +1,7 @@
local helpers = require('test.functional.helpers')(after_each)
local clear, eq, ok = helpers.clear, helpers.eq, helpers.ok
-local meths = helpers.meths
-local funcs = helpers.funcs
+local api = helpers.api
+local fn = helpers.fn
local request = helpers.request
local NIL = vim.NIL
local pcall_err = helpers.pcall_err
@@ -14,33 +14,33 @@ describe('api/tabpage', function()
it('works', function()
helpers.command('tabnew')
helpers.command('vsplit')
- local tab1, tab2 = unpack(meths.nvim_list_tabpages())
- local win1, win2, win3 = unpack(meths.nvim_list_wins())
- eq({ win1 }, meths.nvim_tabpage_list_wins(tab1))
- eq({ win2, win3 }, meths.nvim_tabpage_list_wins(tab2))
- eq(win2, meths.nvim_tabpage_get_win(tab2))
- meths.nvim_set_current_win(win3)
- eq(win3, meths.nvim_tabpage_get_win(tab2))
+ local tab1, tab2 = unpack(api.nvim_list_tabpages())
+ local win1, win2, win3 = unpack(api.nvim_list_wins())
+ eq({ win1 }, api.nvim_tabpage_list_wins(tab1))
+ eq({ win2, win3 }, api.nvim_tabpage_list_wins(tab2))
+ eq(win2, api.nvim_tabpage_get_win(tab2))
+ api.nvim_set_current_win(win3)
+ eq(win3, api.nvim_tabpage_get_win(tab2))
end)
it('validates args', function()
- eq('Invalid tabpage id: 23', pcall_err(meths.nvim_tabpage_list_wins, 23))
+ eq('Invalid tabpage id: 23', pcall_err(api.nvim_tabpage_list_wins, 23))
end)
end)
describe('{get,set,del}_var', function()
it('works', function()
- meths.nvim_tabpage_set_var(0, 'lua', { 1, 2, { ['3'] = 1 } })
- eq({ 1, 2, { ['3'] = 1 } }, meths.nvim_tabpage_get_var(0, 'lua'))
- eq({ 1, 2, { ['3'] = 1 } }, meths.nvim_eval('t:lua'))
- eq(1, funcs.exists('t:lua'))
- meths.nvim_tabpage_del_var(0, 'lua')
- eq(0, funcs.exists('t:lua'))
- eq('Key not found: lua', pcall_err(meths.nvim_tabpage_del_var, 0, 'lua'))
- meths.nvim_tabpage_set_var(0, 'lua', 1)
+ api.nvim_tabpage_set_var(0, 'lua', { 1, 2, { ['3'] = 1 } })
+ eq({ 1, 2, { ['3'] = 1 } }, api.nvim_tabpage_get_var(0, 'lua'))
+ eq({ 1, 2, { ['3'] = 1 } }, api.nvim_eval('t:lua'))
+ eq(1, fn.exists('t:lua'))
+ api.nvim_tabpage_del_var(0, 'lua')
+ eq(0, fn.exists('t:lua'))
+ eq('Key not found: lua', pcall_err(api.nvim_tabpage_del_var, 0, 'lua'))
+ api.nvim_tabpage_set_var(0, 'lua', 1)
command('lockvar t:lua')
- eq('Key is locked: lua', pcall_err(meths.nvim_tabpage_del_var, 0, 'lua'))
- eq('Key is locked: lua', pcall_err(meths.nvim_tabpage_set_var, 0, 'lua', 1))
+ eq('Key is locked: lua', pcall_err(api.nvim_tabpage_del_var, 0, 'lua'))
+ eq('Key is locked: lua', pcall_err(api.nvim_tabpage_set_var, 0, 'lua', 1))
end)
it('tabpage_set_var returns the old value', function()
@@ -61,28 +61,28 @@ describe('api/tabpage', function()
describe('get_number', function()
it('works', function()
- local tabs = meths.nvim_list_tabpages()
- eq(1, meths.nvim_tabpage_get_number(tabs[1]))
+ local tabs = api.nvim_list_tabpages()
+ eq(1, api.nvim_tabpage_get_number(tabs[1]))
helpers.command('tabnew')
- local tab1, tab2 = unpack(meths.nvim_list_tabpages())
- eq(1, meths.nvim_tabpage_get_number(tab1))
- eq(2, meths.nvim_tabpage_get_number(tab2))
+ local tab1, tab2 = unpack(api.nvim_list_tabpages())
+ eq(1, api.nvim_tabpage_get_number(tab1))
+ eq(2, api.nvim_tabpage_get_number(tab2))
helpers.command('-tabmove')
- eq(2, meths.nvim_tabpage_get_number(tab1))
- eq(1, meths.nvim_tabpage_get_number(tab2))
+ eq(2, api.nvim_tabpage_get_number(tab1))
+ eq(1, api.nvim_tabpage_get_number(tab2))
end)
end)
describe('is_valid', function()
it('works', function()
helpers.command('tabnew')
- local tab = meths.nvim_list_tabpages()[2]
- meths.nvim_set_current_tabpage(tab)
- ok(meths.nvim_tabpage_is_valid(tab))
+ local tab = api.nvim_list_tabpages()[2]
+ api.nvim_set_current_tabpage(tab)
+ ok(api.nvim_tabpage_is_valid(tab))
helpers.command('tabclose')
- ok(not meths.nvim_tabpage_is_valid(tab))
+ ok(not api.nvim_tabpage_is_valid(tab))
end)
end)
end)
diff --git a/test/functional/api/ui_spec.lua b/test/functional/api/ui_spec.lua
index e74a35e97e..3e1f1ec965 100644
--- a/test/functional/api/ui_spec.lua
+++ b/test/functional/api/ui_spec.lua
@@ -6,7 +6,7 @@ local eq = helpers.eq
local eval = helpers.eval
local exec = helpers.exec
local feed = helpers.feed
-local meths = helpers.meths
+local api = helpers.api
local request = helpers.request
local pcall_err = helpers.pcall_err
@@ -23,39 +23,39 @@ describe('nvim_ui_attach()', function()
end)
it('validation', function()
- eq('No such UI option: foo', pcall_err(meths.nvim_ui_attach, 80, 24, { foo = { 'foo' } }))
+ eq('No such UI option: foo', pcall_err(api.nvim_ui_attach, 80, 24, { foo = { 'foo' } }))
eq(
"Invalid 'ext_linegrid': expected Boolean, got Array",
- pcall_err(meths.nvim_ui_attach, 80, 24, { ext_linegrid = {} })
+ pcall_err(api.nvim_ui_attach, 80, 24, { ext_linegrid = {} })
)
eq(
"Invalid 'override': expected Boolean, got Array",
- pcall_err(meths.nvim_ui_attach, 80, 24, { override = {} })
+ pcall_err(api.nvim_ui_attach, 80, 24, { override = {} })
)
eq(
"Invalid 'rgb': expected Boolean, got Array",
- pcall_err(meths.nvim_ui_attach, 80, 24, { rgb = {} })
+ pcall_err(api.nvim_ui_attach, 80, 24, { rgb = {} })
)
eq(
"Invalid 'term_name': expected String, got Boolean",
- pcall_err(meths.nvim_ui_attach, 80, 24, { term_name = true })
+ pcall_err(api.nvim_ui_attach, 80, 24, { term_name = true })
)
eq(
"Invalid 'term_colors': expected Integer, got Boolean",
- pcall_err(meths.nvim_ui_attach, 80, 24, { term_colors = true })
+ pcall_err(api.nvim_ui_attach, 80, 24, { term_colors = true })
)
eq(
"Invalid 'stdin_fd': expected Integer, got String",
- pcall_err(meths.nvim_ui_attach, 80, 24, { stdin_fd = 'foo' })
+ pcall_err(api.nvim_ui_attach, 80, 24, { stdin_fd = 'foo' })
)
eq(
"Invalid 'stdin_tty': expected Boolean, got String",
- pcall_err(meths.nvim_ui_attach, 80, 24, { stdin_tty = 'foo' })
+ pcall_err(api.nvim_ui_attach, 80, 24, { stdin_tty = 'foo' })
)
eq(
"Invalid 'stdout_tty': expected Boolean, got String",
- pcall_err(meths.nvim_ui_attach, 80, 24, { stdout_tty = 'foo' })
+ pcall_err(api.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.nvim_input_mouse('move', '', '', 0, 0, 0)
+ api.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.nvim_ui_set_focus(false)
+ api.nvim_ui_set_focus(false)
eq({ 's', 'r', 's', 'r', 's' }, eval('g:ev'))
screen.suspended = false
- meths.nvim_ui_set_focus(true)
+ api.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 fefafb8f98..c304f1aa88 100644
--- a/test/functional/api/version_spec.lua
+++ b/test/functional/api/version_spec.lua
@@ -1,7 +1,6 @@
local helpers = require('test.functional.helpers')(after_each)
-local clear, funcs, eq = helpers.clear, helpers.funcs, helpers.eq
-local call = helpers.call
-local meths = helpers.meths
+local clear, fn, eq = helpers.clear, helpers.fn, helpers.eq
+local api = helpers.api
local function read_mpack_file(fname)
local fd = io.open(fname, 'rb')
@@ -19,7 +18,7 @@ describe("api_info()['version']", function()
before_each(clear)
it('returns API level', function()
- local version = call('api_info')['version']
+ local version = fn.api_info()['version']
local current = version['api_level']
local compat = version['api_compatible']
eq('number', type(current))
@@ -28,7 +27,7 @@ describe("api_info()['version']", function()
end)
it('returns Nvim version', function()
- local version = call('api_info')['version']
+ local version = fn.api_info()['version']
local major = version['major']
local minor = version['minor']
local patch = version['patch']
@@ -38,10 +37,10 @@ describe("api_info()['version']", function()
eq('number', type(minor))
eq('number', type(patch))
eq('boolean', type(prerelease))
- eq(1, funcs.has('nvim-' .. major .. '.' .. minor .. '.' .. patch))
- eq(0, funcs.has('nvim-' .. major .. '.' .. minor .. '.' .. (patch + 1)))
- eq(0, funcs.has('nvim-' .. major .. '.' .. (minor + 1) .. '.' .. patch))
- eq(0, funcs.has('nvim-' .. (major + 1) .. '.' .. minor .. '.' .. patch))
+ eq(1, fn.has('nvim-' .. major .. '.' .. minor .. '.' .. patch))
+ eq(0, fn.has('nvim-' .. major .. '.' .. minor .. '.' .. (patch + 1)))
+ eq(0, fn.has('nvim-' .. major .. '.' .. (minor + 1) .. '.' .. patch))
+ eq(0, fn.has('nvim-' .. (major + 1) .. '.' .. minor .. '.' .. patch))
assert(build == nil or type(build) == 'string')
end)
end)
@@ -90,14 +89,14 @@ describe('api metadata', function()
end
end
- local api, compat, stable, api_level
+ local api_info, compat, stable, api_level
local old_api = {}
setup(function()
clear() -- Ensure a session before requesting api_info.
- api = meths.nvim_get_api_info()[2]
- compat = api.version.api_compatible
- api_level = api.version.api_level
- if api.version.api_prerelease then
+ api_info = api.nvim_get_api_info()[2]
+ compat = api_info.version.api_compatible
+ api_level = api_info.version.api_level
+ if api_info.version.api_prerelease then
stable = api_level - 1
else
stable = api_level
@@ -108,7 +107,7 @@ describe('api metadata', function()
old_api[level] = read_mpack_file(path)
if old_api[level] == nil then
local errstr = 'missing metadata fixture for stable level ' .. level .. '. '
- if level == api_level and not api.version.api_prerelease then
+ if level == api_level and not api_info.version.api_prerelease then
errstr = (
errstr
.. 'If NVIM_API_CURRENT was bumped, '
@@ -125,7 +124,7 @@ describe('api metadata', function()
end)
it('functions are compatible with old metadata or have new level', function()
- local funcs_new = name_table(api.functions)
+ local funcs_new = name_table(api_info.functions)
local funcs_compat = {}
for level = compat, stable do
for _, f in ipairs(old_api[level].functions) do
@@ -146,7 +145,7 @@ describe('api metadata', function()
funcs_compat[level] = name_table(old_api[level].functions)
end
- for _, f in ipairs(api.functions) do
+ for _, f in ipairs(api_info.functions) do
if f.since <= stable then
local f_old = funcs_compat[f.since][f.name]
if f_old == nil then
@@ -159,7 +158,7 @@ describe('api metadata', function()
.. (stable + 1)
.. '.'
)
- if not api.version.api_prerelease then
+ if not api_info.version.api_prerelease then
errstr = (
errstr
.. ' Also bump NVIM_API_CURRENT and set '
@@ -172,7 +171,7 @@ describe('api metadata', function()
end
end
elseif f.since > api_level then
- if api.version.api_prerelease then
+ if api_info.version.api_prerelease then
error('New function ' .. f.name .. ' should use since value ' .. api_level)
else
error(
@@ -188,7 +187,7 @@ describe('api metadata', function()
end)
it('UI events are compatible with old metadata or have new level', function()
- local ui_events_new = name_table(api.ui_events)
+ local ui_events_new = name_table(api_info.ui_events)
local ui_events_compat = {}
-- UI events were formalized in level 3
@@ -202,7 +201,7 @@ describe('api metadata', function()
ui_events_compat[level] = name_table(old_api[level].ui_events)
end
- for _, e in ipairs(api.ui_events) do
+ for _, e in ipairs(api_info.ui_events) do
if e.since <= stable then
local e_old = ui_events_compat[e.since][e.name]
if e_old == nil then
@@ -214,7 +213,7 @@ describe('api metadata', function()
.. (stable + 1)
.. '.'
)
- if not api.version.api_prerelease then
+ if not api_info.version.api_prerelease then
errstr = (
errstr
.. ' Also bump NVIM_API_CURRENT and set '
@@ -224,7 +223,7 @@ describe('api metadata', function()
error(errstr)
end
elseif e.since > api_level then
- if api.version.api_prerelease then
+ if api_info.version.api_prerelease then
error('New UI event ' .. e.name .. ' should use since value ' .. api_level)
else
error(
@@ -241,7 +240,7 @@ describe('api metadata', function()
it('ui_options are preserved from older levels', function()
local available_options = {}
- for _, option in ipairs(api.ui_options) do
+ for _, option in ipairs(api_info.ui_options) do
available_options[option] = true
end
-- UI options were versioned from level 4
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua
index ba2042d585..aa3b4419cc 100644
--- a/test/functional/api/vim_spec.lua
+++ b/test/functional/api/vim_spec.lua
@@ -8,13 +8,13 @@ local assert_alive = helpers.assert_alive
local NIL = vim.NIL
local clear, eq, neq = helpers.clear, helpers.eq, helpers.neq
local command = helpers.command
-local command_output = helpers.meths.command_output
+local command_output = helpers.api.command_output
local exec = helpers.exec
local exec_capture = helpers.exec_capture
local eval = helpers.eval
local expect = helpers.expect
-local funcs = helpers.funcs
-local meths = helpers.meths
+local fn = helpers.fn
+local api = helpers.api
local matches = helpers.matches
local pesc = vim.pesc
local mkdir_p = helpers.mkdir_p
@@ -71,7 +71,7 @@ describe('API', function()
end)
it('handles errors in async requests', function()
- local error_types = meths.nvim_get_api_info()[2].error_types
+ local error_types = api.nvim_get_api_info()[2].error_types
nvim_async('bogus')
eq({
'notification',
@@ -83,7 +83,7 @@ describe('API', function()
end)
it('failed async request emits nvim_error_event', function()
- local error_types = meths.nvim_get_api_info()[2].error_types
+ local error_types = api.nvim_get_api_info()[2].error_types
nvim_async('command', 'bogus')
eq({
'notification',
@@ -98,37 +98,37 @@ describe('API', function()
command('split')
command('autocmd WinEnter * startinsert')
command('wincmd w')
- eq({ mode = 'i', blocking = false }, meths.nvim_get_mode())
+ eq({ mode = 'i', blocking = false }, api.nvim_get_mode())
end)
describe('nvim_exec2', function()
it('always returns table', function()
-- In built version this results into `vim.empty_dict()`
- eq({}, meths.nvim_exec2('echo "Hello"', {}))
- eq({}, meths.nvim_exec2('echo "Hello"', { output = false }))
- eq({ output = 'Hello' }, meths.nvim_exec2('echo "Hello"', { output = true }))
+ eq({}, api.nvim_exec2('echo "Hello"', {}))
+ eq({}, api.nvim_exec2('echo "Hello"', { output = false }))
+ eq({ output = 'Hello' }, api.nvim_exec2('echo "Hello"', { output = true }))
end)
it('default options', function()
-- Should be equivalent to { output = false }
- meths.nvim_exec2("let x0 = 'a'", {})
- eq('a', meths.nvim_get_var('x0'))
+ api.nvim_exec2("let x0 = 'a'", {})
+ eq('a', api.nvim_get_var('x0'))
end)
it('one-line input', function()
- meths.nvim_exec2("let x1 = 'a'", { output = false })
- eq('a', meths.nvim_get_var('x1'))
+ api.nvim_exec2("let x1 = 'a'", { output = false })
+ eq('a', api.nvim_get_var('x1'))
end)
it(':verbose set {option}?', function()
- meths.nvim_exec2('set nowrap', { output = false })
+ api.nvim_exec2('set nowrap', { output = false })
eq(
{ output = 'nowrap\n\tLast set from anonymous :source' },
- meths.nvim_exec2('verbose set wrap?', { output = true })
+ api.nvim_exec2('verbose set wrap?', { output = true })
)
-- Using script var to force creation of a script item
- meths.nvim_exec2(
+ api.nvim_exec2(
[[
let s:a = 1
set nowrap
@@ -137,39 +137,39 @@ describe('API', function()
)
eq(
{ output = 'nowrap\n\tLast set from anonymous :source (script id 1)' },
- meths.nvim_exec2('verbose set wrap?', { output = true })
+ api.nvim_exec2('verbose set wrap?', { output = true })
)
end)
it('multiline input', function()
-- Heredoc + empty lines.
- meths.nvim_exec2("let x2 = 'a'\n", { output = false })
- eq('a', meths.nvim_get_var('x2'))
- meths.nvim_exec2('lua <<EOF\n\n\n\ny=3\n\n\nEOF', { output = false })
- eq(3, meths.nvim_eval("luaeval('y')"))
+ api.nvim_exec2("let x2 = 'a'\n", { output = false })
+ eq('a', api.nvim_get_var('x2'))
+ api.nvim_exec2('lua <<EOF\n\n\n\ny=3\n\n\nEOF', { output = false })
+ eq(3, api.nvim_eval("luaeval('y')"))
- eq({}, meths.nvim_exec2('lua <<EOF\ny=3\nEOF', { output = false }))
- eq(3, meths.nvim_eval("luaeval('y')"))
+ eq({}, api.nvim_exec2('lua <<EOF\ny=3\nEOF', { output = false }))
+ eq(3, api.nvim_eval("luaeval('y')"))
-- Multiple statements
- meths.nvim_exec2('let x1=1\nlet x2=2\nlet x3=3\n', { output = false })
- eq(1, meths.nvim_eval('x1'))
- eq(2, meths.nvim_eval('x2'))
- eq(3, meths.nvim_eval('x3'))
+ api.nvim_exec2('let x1=1\nlet x2=2\nlet x3=3\n', { output = false })
+ eq(1, api.nvim_eval('x1'))
+ eq(2, api.nvim_eval('x2'))
+ eq(3, api.nvim_eval('x3'))
-- Functions
- meths.nvim_exec2('function Foo()\ncall setline(1,["xxx"])\nendfunction', { output = false })
- eq('', meths.nvim_get_current_line())
- meths.nvim_exec2('call Foo()', { output = false })
- eq('xxx', meths.nvim_get_current_line())
+ api.nvim_exec2('function Foo()\ncall setline(1,["xxx"])\nendfunction', { output = false })
+ eq('', api.nvim_get_current_line())
+ api.nvim_exec2('call Foo()', { output = false })
+ eq('xxx', api.nvim_get_current_line())
-- Autocmds
- meths.nvim_exec2('autocmd BufAdd * :let x1 = "Hello"', { output = false })
+ api.nvim_exec2('autocmd BufAdd * :let x1 = "Hello"', { output = false })
command('new foo')
eq('Hello', request('nvim_eval', 'g:x1'))
-- Line continuations
- meths.nvim_exec2(
+ api.nvim_exec2(
[[
let abc = #{
\ a: 1,
@@ -181,13 +181,13 @@ describe('API', function()
eq({ a = 1, c = 3 }, request('nvim_eval', 'g:abc'))
-- try no spaces before continuations to catch off-by-one error
- meths.nvim_exec2('let ab = #{\n\\a: 98,\n"\\ b: 2\n\\}', { output = false })
+ api.nvim_exec2('let ab = #{\n\\a: 98,\n"\\ b: 2\n\\}', { output = false })
eq({ a = 98 }, request('nvim_eval', 'g:ab'))
-- Script scope (s:)
eq(
{ output = 'ahoy! script-scoped varrrrr' },
- meths.nvim_exec2(
+ api.nvim_exec2(
[[
let s:pirate = 'script-scoped varrrrr'
function! s:avast_ye_hades(s) abort
@@ -201,7 +201,7 @@ describe('API', function()
eq(
{ output = "{'output': 'ahoy! script-scoped varrrrr'}" },
- meths.nvim_exec2(
+ api.nvim_exec2(
[[
let s:pirate = 'script-scoped varrrrr'
function! Avast_ye_hades(s) abort
@@ -229,7 +229,7 @@ describe('API', function()
-- Script items are created only on script var access
eq(
{ output = '1\n0' },
- meths.nvim_exec2(
+ api.nvim_exec2(
[[
echo expand("<SID>")->empty()
let s:a = 123
@@ -241,7 +241,7 @@ describe('API', function()
eq(
{ output = '1\n0' },
- meths.nvim_exec2(
+ api.nvim_exec2(
[[
echo expand("<SID>")->empty()
function s:a() abort
@@ -254,7 +254,7 @@ describe('API', function()
end)
it('non-ASCII input', function()
- meths.nvim_exec2(
+ api.nvim_exec2(
[=[
new
exe "normal! i ax \n Ax "
@@ -263,11 +263,11 @@ describe('API', function()
{ output = false }
)
command('1')
- eq(' --a1234-- ', meths.nvim_get_current_line())
+ eq(' --a1234-- ', api.nvim_get_current_line())
command('2')
- eq(' --A1234-- ', meths.nvim_get_current_line())
+ eq(' --A1234-- ', api.nvim_get_current_line())
- meths.nvim_exec2(
+ api.nvim_exec2(
[[
new
call setline(1,['xxx'])
@@ -276,7 +276,7 @@ describe('API', function()
]],
{ output = false }
)
- eq('ñxx', meths.nvim_get_current_line())
+ eq('ñxx', api.nvim_get_current_line())
end)
it('execution error', function()
@@ -284,7 +284,7 @@ describe('API', function()
'nvim_exec2(): Vim:E492: Not an editor command: bogus_command',
pcall_err(request, 'nvim_exec2', 'bogus_command', {})
)
- eq('', meths.nvim_eval('v:errmsg')) -- v:errmsg was not updated.
+ eq('', api.nvim_eval('v:errmsg')) -- v:errmsg was not updated.
eq('', eval('v:exception'))
eq(
@@ -319,7 +319,7 @@ describe('API', function()
write_file(fname, 'echo "hello"\n')
local sourcing_fname = tmpname()
write_file(sourcing_fname, 'call nvim_exec2("source ' .. fname .. '", {"output": v:false})\n')
- meths.nvim_exec2('set verbose=2', { output = false })
+ api.nvim_exec2('set verbose=2', { output = false })
local traceback_output = dedent([[
line 0: sourcing "%s"
line 0: sourcing "%s"
@@ -336,7 +336,7 @@ describe('API', function()
)
eq(
{ output = traceback_output },
- meths.nvim_exec2(
+ api.nvim_exec2(
'call nvim_exec2("source ' .. sourcing_fname .. '", {"output": v:false})',
{ output = true }
)
@@ -348,10 +348,10 @@ describe('API', function()
it('returns output', function()
eq(
{ output = 'this is spinal tap' },
- meths.nvim_exec2('lua <<EOF\n\n\nprint("this is spinal tap")\n\n\nEOF', { output = true })
+ api.nvim_exec2('lua <<EOF\n\n\nprint("this is spinal tap")\n\n\nEOF', { output = true })
)
- eq({ output = '' }, meths.nvim_exec2('echo', { output = true }))
- eq({ output = 'foo 42' }, meths.nvim_exec2('echo "foo" 42', { output = true }))
+ eq({ output = '' }, api.nvim_exec2('echo', { output = true }))
+ eq({ output = 'foo 42' }, api.nvim_exec2('echo "foo" 42', { output = true }))
end)
it('displays messages when opts.output=false', function()
@@ -360,7 +360,7 @@ describe('API', function()
screen:set_default_attr_ids({
[0] = { bold = true, foreground = Screen.colors.Blue },
})
- meths.nvim_exec2("echo 'hello'", { output = false })
+ api.nvim_exec2("echo 'hello'", { output = false })
screen:expect {
grid = [[
^ |
@@ -376,7 +376,7 @@ describe('API', function()
screen:set_default_attr_ids({
[0] = { bold = true, foreground = Screen.colors.Blue },
})
- meths.nvim_exec2("echo 'hello'", { output = true })
+ api.nvim_exec2("echo 'hello'", { output = true })
screen:expect {
grid = [[
^ |
@@ -421,7 +421,7 @@ describe('API', function()
local status, rv = pcall(command, 'bogus_command')
eq(false, status) -- nvim_command() failed.
eq('E492:', string.match(rv, 'E%d*:')) -- Vimscript error was returned.
- eq('', meths.nvim_eval('v:errmsg')) -- v:errmsg was not updated.
+ eq('', api.nvim_eval('v:errmsg')) -- v:errmsg was not updated.
eq('', eval('v:exception'))
end)
@@ -444,18 +444,18 @@ describe('API', function()
describe('nvim_command_output', function()
it('does not induce hit-enter prompt', function()
- meths.nvim_ui_attach(80, 20, {})
+ api.nvim_ui_attach(80, 20, {})
-- Induce a hit-enter prompt use nvim_input (non-blocking).
command('set cmdheight=1')
- meths.nvim_input([[:echo "hi\nhi2"<CR>]])
+ api.nvim_input([[:echo "hi\nhi2"<CR>]])
-- Verify hit-enter prompt.
- eq({ mode = 'r', blocking = true }, meths.nvim_get_mode())
- meths.nvim_input([[<C-c>]])
+ eq({ mode = 'r', blocking = true }, api.nvim_get_mode())
+ api.nvim_input([[<C-c>]])
-- Verify NO hit-enter prompt.
command_output([[echo "hi\nhi2"]])
- eq({ mode = 'n', blocking = false }, meths.nvim_get_mode())
+ eq({ mode = 'n', blocking = false }, api.nvim_get_mode())
end)
it('captures command output', function()
@@ -500,7 +500,7 @@ describe('API', function()
eq('E492: Not an editor command: bogus commannnd', string.match(rv, 'E%d*:.*'))
eq('', eval('v:errmsg')) -- v:errmsg was not updated.
-- Verify NO hit-enter prompt.
- eq({ mode = 'n', blocking = false }, meths.nvim_get_mode())
+ eq({ mode = 'n', blocking = false }, api.nvim_get_mode())
end)
it('Vimscript execution error: fails with specific error', function()
@@ -509,7 +509,7 @@ describe('API', function()
eq('E86: Buffer 42 does not exist', string.match(rv, 'E%d*:.*'))
eq('', eval('v:errmsg')) -- v:errmsg was not updated.
-- Verify NO hit-enter prompt.
- eq({ mode = 'n', blocking = false }, meths.nvim_get_mode())
+ eq({ mode = 'n', blocking = false }, api.nvim_get_mode())
end)
it('does not cause heap buffer overflow with large output', function()
@@ -521,12 +521,12 @@ describe('API', function()
it('works', function()
command('let g:v1 = "a"')
command('let g:v2 = [1, 2, {"v3": 3}]')
- eq({ v1 = 'a', v2 = { 1, 2, { v3 = 3 } } }, meths.nvim_eval('g:'))
+ eq({ v1 = 'a', v2 = { 1, 2, { v3 = 3 } } }, api.nvim_eval('g:'))
end)
it('handles NULL-initialized strings correctly', function()
- eq(1, meths.nvim_eval("matcharg(1) == ['', '']"))
- eq({ '', '' }, meths.nvim_eval('matcharg(1)'))
+ eq(1, api.nvim_eval("matcharg(1) == ['', '']"))
+ eq({ '', '' }, api.nvim_eval('matcharg(1)'))
end)
it('works under deprecated name', function()
@@ -541,10 +541,10 @@ describe('API', function()
describe('nvim_call_function', function()
it('works', function()
- meths.nvim_call_function('setqflist', { { { filename = 'something', lnum = 17 } }, 'r' })
- eq(17, meths.nvim_call_function('getqflist', {})[1].lnum)
- eq(17, meths.nvim_call_function('eval', { 17 }))
- eq('foo', meths.nvim_call_function('simplify', { 'this/./is//redundant/../../../foo' }))
+ api.nvim_call_function('setqflist', { { { filename = 'something', lnum = 17 } }, 'r' })
+ eq(17, api.nvim_call_function('getqflist', {})[1].lnum)
+ eq(17, api.nvim_call_function('eval', { 17 }))
+ eq('foo', api.nvim_call_function('simplify', { 'this/./is//redundant/../../../foo' }))
end)
it('Vimscript validation error: returns specific error, does NOT update v:errmsg', function()
@@ -619,18 +619,18 @@ describe('API', function()
]])
-- :help Dictionary-function
- eq('Hello, World!', meths.nvim_call_dict_function('g:test_dict_fn', 'F', { 'World' }))
+ eq('Hello, World!', api.nvim_call_dict_function('g:test_dict_fn', 'F', { 'World' }))
-- Funcref is sent as NIL over RPC.
- eq({ greeting = 'Hello', F = NIL }, meths.nvim_get_var('test_dict_fn'))
+ eq({ greeting = 'Hello', F = NIL }, api.nvim_get_var('test_dict_fn'))
-- :help numbered-function
- eq('Hi, Moon ...', meths.nvim_call_dict_function('g:test_dict_fn2', 'F2', { 'Moon' }))
+ eq('Hi, Moon ...', api.nvim_call_dict_function('g:test_dict_fn2', 'F2', { 'Moon' }))
-- Funcref is sent as NIL over RPC.
- eq({ greeting = 'Hi', F2 = NIL }, meths.nvim_get_var('test_dict_fn2'))
+ eq({ greeting = 'Hi', F2 = NIL }, api.nvim_get_var('test_dict_fn2'))
-- Function specified via RPC dict.
source('function! G() dict\n return "@".(self.result)."@"\nendfunction')
- eq('@it works@', meths.nvim_call_dict_function({ result = 'it works', G = 'G' }, 'G', {}))
+ eq('@it works@', api.nvim_call_dict_function({ result = 'it works', G = 'G' }, 'G', {}))
end)
it('validation', function()
@@ -675,8 +675,8 @@ describe('API', function()
local start_dir
before_each(function()
- funcs.mkdir('Xtestdir')
- start_dir = funcs.getcwd()
+ fn.mkdir('Xtestdir')
+ start_dir = fn.getcwd()
end)
after_each(function()
@@ -684,84 +684,84 @@ describe('API', function()
end)
it('works', function()
- meths.nvim_set_current_dir('Xtestdir')
- eq(funcs.getcwd(), start_dir .. helpers.get_pathsep() .. 'Xtestdir')
+ api.nvim_set_current_dir('Xtestdir')
+ eq(fn.getcwd(), start_dir .. helpers.get_pathsep() .. 'Xtestdir')
end)
it('sets previous directory', function()
- meths.nvim_set_current_dir('Xtestdir')
+ api.nvim_set_current_dir('Xtestdir')
command('cd -')
- eq(funcs.getcwd(), start_dir)
+ eq(fn.getcwd(), start_dir)
end)
end)
describe('nvim_exec_lua', function()
it('works', function()
- meths.nvim_exec_lua('vim.api.nvim_set_var("test", 3)', {})
- eq(3, meths.nvim_get_var('test'))
+ api.nvim_exec_lua('vim.api.nvim_set_var("test", 3)', {})
+ eq(3, api.nvim_get_var('test'))
- eq(17, meths.nvim_exec_lua('a, b = ...\nreturn a + b', { 10, 7 }))
+ eq(17, api.nvim_exec_lua('a, b = ...\nreturn a + b', { 10, 7 }))
- eq(NIL, meths.nvim_exec_lua('function xx(a,b)\nreturn a..b\nend', {}))
- eq('xy', meths.nvim_exec_lua('return xx(...)', { 'x', 'y' }))
+ eq(NIL, api.nvim_exec_lua('function xx(a,b)\nreturn a..b\nend', {}))
+ eq('xy', api.nvim_exec_lua('return xx(...)', { 'x', 'y' }))
-- Deprecated name: nvim_execute_lua.
- eq('xy', meths.nvim_execute_lua('return xx(...)', { 'x', 'y' }))
+ eq('xy', api.nvim_execute_lua('return xx(...)', { 'x', 'y' }))
end)
it('reports errors', function()
eq(
[[Error loading lua: [string "<nvim>"]:0: '=' expected near '+']],
- pcall_err(meths.nvim_exec_lua, 'a+*b', {})
+ pcall_err(api.nvim_exec_lua, 'a+*b', {})
)
eq(
[[Error loading lua: [string "<nvim>"]:0: unexpected symbol near '1']],
- pcall_err(meths.nvim_exec_lua, '1+2', {})
+ pcall_err(api.nvim_exec_lua, '1+2', {})
)
eq(
[[Error loading lua: [string "<nvim>"]:0: unexpected symbol]],
- pcall_err(meths.nvim_exec_lua, 'aa=bb\0', {})
+ pcall_err(api.nvim_exec_lua, 'aa=bb\0', {})
)
eq(
[[attempt to call global 'bork' (a nil value)]],
- pcall_err(meths.nvim_exec_lua, 'bork()', {})
+ pcall_err(api.nvim_exec_lua, 'bork()', {})
)
- eq('did\nthe\nfail', pcall_err(meths.nvim_exec_lua, 'error("did\\nthe\\nfail")', {}))
+ eq('did\nthe\nfail', pcall_err(api.nvim_exec_lua, 'error("did\\nthe\\nfail")', {}))
end)
it('uses native float values', function()
- eq(2.5, meths.nvim_exec_lua('return select(1, ...)', { 2.5 }))
- eq('2.5', meths.nvim_exec_lua('return vim.inspect(...)', { 2.5 }))
+ eq(2.5, api.nvim_exec_lua('return select(1, ...)', { 2.5 }))
+ eq('2.5', api.nvim_exec_lua('return vim.inspect(...)', { 2.5 }))
-- "special" float values are still accepted as return values.
- eq(2.5, meths.nvim_exec_lua("return vim.api.nvim_eval('2.5')", {}))
+ eq(2.5, api.nvim_exec_lua("return vim.api.nvim_eval('2.5')", {}))
eq(
'{\n [false] = 2.5,\n [true] = 3\n}',
- meths.nvim_exec_lua("return vim.inspect(vim.api.nvim_eval('2.5'))", {})
+ api.nvim_exec_lua("return vim.inspect(vim.api.nvim_eval('2.5'))", {})
)
end)
end)
describe('nvim_notify', function()
it('can notify a info message', function()
- meths.nvim_notify('hello world', 2, {})
+ api.nvim_notify('hello world', 2, {})
end)
it('can be overridden', function()
command('lua vim.notify = function(...) return 42 end')
- eq(42, meths.nvim_exec_lua("return vim.notify('Hello world')", {}))
- meths.nvim_notify('hello world', 4, {})
+ eq(42, api.nvim_exec_lua("return vim.notify('Hello world')", {}))
+ api.nvim_notify('hello world', 4, {})
end)
end)
describe('nvim_input', function()
it('Vimscript error: does NOT fail, updates v:errmsg', function()
- local status, _ = pcall(meths.nvim_input, ':call bogus_fn()<CR>')
- local v_errnum = string.match(meths.nvim_eval('v:errmsg'), 'E%d*:')
+ local status, _ = pcall(api.nvim_input, ':call bogus_fn()<CR>')
+ local v_errnum = string.match(api.nvim_eval('v:errmsg'), 'E%d*:')
eq(true, status) -- nvim_input() did not fail.
eq('E117:', v_errnum) -- v:errmsg was updated.
end)
@@ -779,23 +779,23 @@ describe('API', function()
end)
local function run_streamed_paste_tests()
it('stream: multiple chunks form one undo-block', function()
- meths.nvim_paste('1/chunk 1 (start)\n', true, 1)
- meths.nvim_paste('1/chunk 2 (end)\n', true, 3)
+ api.nvim_paste('1/chunk 1 (start)\n', true, 1)
+ api.nvim_paste('1/chunk 2 (end)\n', true, 3)
local expected1 = [[
1/chunk 1 (start)
1/chunk 2 (end)
]]
expect(expected1)
- meths.nvim_paste('2/chunk 1 (start)\n', true, 1)
- meths.nvim_paste('2/chunk 2\n', true, 2)
+ api.nvim_paste('2/chunk 1 (start)\n', true, 1)
+ api.nvim_paste('2/chunk 2\n', true, 2)
expect([[
1/chunk 1 (start)
1/chunk 2 (end)
2/chunk 1 (start)
2/chunk 2
]])
- meths.nvim_paste('2/chunk 3\n', true, 2)
- meths.nvim_paste('2/chunk 4 (end)\n', true, 3)
+ api.nvim_paste('2/chunk 3\n', true, 2)
+ api.nvim_paste('2/chunk 4 (end)\n', true, 3)
expect([[
1/chunk 1 (start)
1/chunk 2 (end)
@@ -811,10 +811,10 @@ describe('API', function()
-- If nvim_paste() calls :undojoin without making any changes, this makes it an error.
feed('afoo<Esc>u')
feed('i')
- meths.nvim_paste('aaaaaa', false, 1)
- meths.nvim_paste('bbbbbb', false, 2)
- meths.nvim_paste('cccccc', false, 2)
- meths.nvim_paste('dddddd', false, 3)
+ api.nvim_paste('aaaaaa', false, 1)
+ api.nvim_paste('bbbbbb', false, 2)
+ api.nvim_paste('cccccc', false, 2)
+ api.nvim_paste('dddddd', false, 3)
expect('aaaaaabbbbbbccccccdddddd')
feed('<Esc>u')
expect('')
@@ -830,17 +830,17 @@ describe('API', function()
expect('')
end)
it('pasting one line', function()
- meths.nvim_paste('aaaaaa', false, 1)
- meths.nvim_paste('bbbbbb', false, 2)
- meths.nvim_paste('cccccc', false, 2)
- meths.nvim_paste('dddddd', false, 3)
+ api.nvim_paste('aaaaaa', false, 1)
+ api.nvim_paste('bbbbbb', false, 2)
+ api.nvim_paste('cccccc', false, 2)
+ api.nvim_paste('dddddd', false, 3)
expect('aaaaaabbbbbbccccccdddddd')
end)
it('pasting multiple lines', function()
- meths.nvim_paste('aaaaaa\n', false, 1)
- meths.nvim_paste('bbbbbb\n', false, 2)
- meths.nvim_paste('cccccc\n', false, 2)
- meths.nvim_paste('dddddd', false, 3)
+ api.nvim_paste('aaaaaa\n', false, 1)
+ api.nvim_paste('bbbbbb\n', false, 2)
+ api.nvim_paste('cccccc\n', false, 2)
+ api.nvim_paste('dddddd', false, 3)
expect([[
aaaaaa
bbbbbb
@@ -860,17 +860,17 @@ describe('API', function()
expect('||')
end)
it('pasting one line', function()
- meths.nvim_paste('aaaaaa', false, 1)
- meths.nvim_paste('bbbbbb', false, 2)
- meths.nvim_paste('cccccc', false, 2)
- meths.nvim_paste('dddddd', false, 3)
+ api.nvim_paste('aaaaaa', false, 1)
+ api.nvim_paste('bbbbbb', false, 2)
+ api.nvim_paste('cccccc', false, 2)
+ api.nvim_paste('dddddd', false, 3)
expect('|aaaaaabbbbbbccccccdddddd|')
end)
it('pasting multiple lines', function()
- meths.nvim_paste('aaaaaa\n', false, 1)
- meths.nvim_paste('bbbbbb\n', false, 2)
- meths.nvim_paste('cccccc\n', false, 2)
- meths.nvim_paste('dddddd', false, 3)
+ api.nvim_paste('aaaaaa\n', false, 1)
+ api.nvim_paste('bbbbbb\n', false, 2)
+ api.nvim_paste('cccccc\n', false, 2)
+ api.nvim_paste('dddddd', false, 3)
expect([[
|aaaaaa
bbbbbb
@@ -890,17 +890,17 @@ describe('API', function()
expect('||')
end)
it('pasting one line', function()
- meths.nvim_paste('aaaaaa', false, 1)
- meths.nvim_paste('bbbbbb', false, 2)
- meths.nvim_paste('cccccc', false, 2)
- meths.nvim_paste('dddddd', false, 3)
+ api.nvim_paste('aaaaaa', false, 1)
+ api.nvim_paste('bbbbbb', false, 2)
+ api.nvim_paste('cccccc', false, 2)
+ api.nvim_paste('dddddd', false, 3)
expect('||aaaaaabbbbbbccccccdddddd')
end)
it('pasting multiple lines', function()
- meths.nvim_paste('aaaaaa\n', false, 1)
- meths.nvim_paste('bbbbbb\n', false, 2)
- meths.nvim_paste('cccccc\n', false, 2)
- meths.nvim_paste('dddddd', false, 3)
+ api.nvim_paste('aaaaaa\n', false, 1)
+ api.nvim_paste('bbbbbb\n', false, 2)
+ api.nvim_paste('cccccc\n', false, 2)
+ api.nvim_paste('dddddd', false, 3)
expect([[
||aaaaaa
bbbbbb
@@ -924,24 +924,24 @@ describe('API', function()
xxx|]])
end)
it('with non-empty chunks', function()
- meths.nvim_paste('aaaaaa', false, 1)
- meths.nvim_paste('bbbbbb', false, 2)
- meths.nvim_paste('cccccc', false, 2)
- meths.nvim_paste('dddddd', false, 3)
+ api.nvim_paste('aaaaaa', false, 1)
+ api.nvim_paste('bbbbbb', false, 2)
+ api.nvim_paste('cccccc', false, 2)
+ api.nvim_paste('dddddd', false, 3)
expect('|aaaaaabbbbbbccccccdddddd|')
end)
it('with empty first chunk', function()
- meths.nvim_paste('', false, 1)
- meths.nvim_paste('bbbbbb', false, 2)
- meths.nvim_paste('cccccc', false, 2)
- meths.nvim_paste('dddddd', false, 3)
+ api.nvim_paste('', false, 1)
+ api.nvim_paste('bbbbbb', false, 2)
+ api.nvim_paste('cccccc', false, 2)
+ api.nvim_paste('dddddd', false, 3)
expect('|bbbbbbccccccdddddd|')
end)
it('with all chunks empty', function()
- meths.nvim_paste('', false, 1)
- meths.nvim_paste('', false, 2)
- meths.nvim_paste('', false, 2)
- meths.nvim_paste('', false, 3)
+ api.nvim_paste('', false, 1)
+ api.nvim_paste('', false, 2)
+ api.nvim_paste('', false, 2)
+ api.nvim_paste('', false, 3)
expect('||')
end)
end)
@@ -959,17 +959,17 @@ describe('API', function()
xxx]])
end)
it('with non-empty chunks', function()
- meths.nvim_paste('aaaaaa', false, 1)
- meths.nvim_paste('bbbbbb', false, 2)
- meths.nvim_paste('cccccc', false, 2)
- meths.nvim_paste('dddddd', false, 3)
+ api.nvim_paste('aaaaaa', false, 1)
+ api.nvim_paste('bbbbbb', false, 2)
+ api.nvim_paste('cccccc', false, 2)
+ api.nvim_paste('dddddd', false, 3)
expect('||aaaaaabbbbbbccccccdddddd')
end)
it('with empty first chunk', function()
- meths.nvim_paste('', false, 1)
- meths.nvim_paste('bbbbbb', false, 2)
- meths.nvim_paste('cccccc', false, 2)
- meths.nvim_paste('dddddd', false, 3)
+ api.nvim_paste('', false, 1)
+ api.nvim_paste('bbbbbb', false, 2)
+ api.nvim_paste('cccccc', false, 2)
+ api.nvim_paste('dddddd', false, 3)
expect('||bbbbbbccccccdddddd')
end)
end)
@@ -987,17 +987,17 @@ describe('API', function()
xxx]])
end)
it('with non-empty chunks', function()
- meths.nvim_paste('aaaaaa', false, 1)
- meths.nvim_paste('bbbbbb', false, 2)
- meths.nvim_paste('cccccc', false, 2)
- meths.nvim_paste('dddddd', false, 3)
+ api.nvim_paste('aaaaaa', false, 1)
+ api.nvim_paste('bbbbbb', false, 2)
+ api.nvim_paste('cccccc', false, 2)
+ api.nvim_paste('dddddd', false, 3)
expect('||aaaaaabbbbbbccccccdddddd')
end)
it('with empty first chunk', function()
- meths.nvim_paste('', false, 1)
- meths.nvim_paste('bbbbbb', false, 2)
- meths.nvim_paste('cccccc', false, 2)
- meths.nvim_paste('dddddd', false, 3)
+ api.nvim_paste('', false, 1)
+ api.nvim_paste('bbbbbb', false, 2)
+ api.nvim_paste('cccccc', false, 2)
+ api.nvim_paste('dddddd', false, 3)
expect('||bbbbbbccccccdddddd')
end)
end)
@@ -1020,10 +1020,10 @@ describe('API', function()
feed('ggV')
end)
it('pasting text without final new line', function()
- meths.nvim_paste('aaaaaa\n', false, 1)
- meths.nvim_paste('bbbbbb\n', false, 2)
- meths.nvim_paste('cccccc\n', false, 2)
- meths.nvim_paste('dddddd', false, 3)
+ api.nvim_paste('aaaaaa\n', false, 1)
+ api.nvim_paste('bbbbbb\n', false, 2)
+ api.nvim_paste('cccccc\n', false, 2)
+ api.nvim_paste('dddddd', false, 3)
expect([[
aaaaaa
bbbbbb
@@ -1032,10 +1032,10 @@ describe('API', function()
123456789]])
end)
it('pasting text with final new line', function()
- meths.nvim_paste('aaaaaa\n', false, 1)
- meths.nvim_paste('bbbbbb\n', false, 2)
- meths.nvim_paste('cccccc\n', false, 2)
- meths.nvim_paste('dddddd\n', false, 3)
+ api.nvim_paste('aaaaaa\n', false, 1)
+ api.nvim_paste('bbbbbb\n', false, 2)
+ api.nvim_paste('cccccc\n', false, 2)
+ api.nvim_paste('dddddd\n', false, 3)
expect([[
aaaaaa
bbbbbb
@@ -1050,10 +1050,10 @@ describe('API', function()
feed('2ggV')
end)
it('pasting text without final new line', function()
- meths.nvim_paste('aaaaaa\n', false, 1)
- meths.nvim_paste('bbbbbb\n', false, 2)
- meths.nvim_paste('cccccc\n', false, 2)
- meths.nvim_paste('dddddd', false, 3)
+ api.nvim_paste('aaaaaa\n', false, 1)
+ api.nvim_paste('bbbbbb\n', false, 2)
+ api.nvim_paste('cccccc\n', false, 2)
+ api.nvim_paste('dddddd', false, 3)
expect([[
123456789
aaaaaa
@@ -1062,10 +1062,10 @@ describe('API', function()
dddddd123456789]])
end)
it('pasting text with final new line', function()
- meths.nvim_paste('aaaaaa\n', false, 1)
- meths.nvim_paste('bbbbbb\n', false, 2)
- meths.nvim_paste('cccccc\n', false, 2)
- meths.nvim_paste('dddddd\n', false, 3)
+ api.nvim_paste('aaaaaa\n', false, 1)
+ api.nvim_paste('bbbbbb\n', false, 2)
+ api.nvim_paste('cccccc\n', false, 2)
+ api.nvim_paste('dddddd\n', false, 3)
expect([[
123456789
aaaaaa
@@ -1080,10 +1080,10 @@ describe('API', function()
feed('3ggV')
end)
it('pasting text without final new line', function()
- meths.nvim_paste('aaaaaa\n', false, 1)
- meths.nvim_paste('bbbbbb\n', false, 2)
- meths.nvim_paste('cccccc\n', false, 2)
- meths.nvim_paste('dddddd', false, 3)
+ api.nvim_paste('aaaaaa\n', false, 1)
+ api.nvim_paste('bbbbbb\n', false, 2)
+ api.nvim_paste('cccccc\n', false, 2)
+ api.nvim_paste('dddddd', false, 3)
expect([[
123456789
987654321
@@ -1093,10 +1093,10 @@ describe('API', function()
dddddd]])
end)
it('pasting text with final new line', function()
- meths.nvim_paste('aaaaaa\n', false, 1)
- meths.nvim_paste('bbbbbb\n', false, 2)
- meths.nvim_paste('cccccc\n', false, 2)
- meths.nvim_paste('dddddd\n', false, 3)
+ api.nvim_paste('aaaaaa\n', false, 1)
+ api.nvim_paste('bbbbbb\n', false, 2)
+ api.nvim_paste('cccccc\n', false, 2)
+ api.nvim_paste('dddddd\n', false, 3)
expect([[
123456789
987654321
@@ -1112,10 +1112,10 @@ describe('API', function()
feed('ggVG')
end)
it('pasting text without final new line', function()
- meths.nvim_paste('aaaaaa\n', false, 1)
- meths.nvim_paste('bbbbbb\n', false, 2)
- meths.nvim_paste('cccccc\n', false, 2)
- meths.nvim_paste('dddddd', false, 3)
+ api.nvim_paste('aaaaaa\n', false, 1)
+ api.nvim_paste('bbbbbb\n', false, 2)
+ api.nvim_paste('cccccc\n', false, 2)
+ api.nvim_paste('dddddd', false, 3)
expect([[
aaaaaa
bbbbbb
@@ -1123,10 +1123,10 @@ describe('API', function()
dddddd]])
end)
it('pasting text with final new line', function()
- meths.nvim_paste('aaaaaa\n', false, 1)
- meths.nvim_paste('bbbbbb\n', false, 2)
- meths.nvim_paste('cccccc\n', false, 2)
- meths.nvim_paste('dddddd\n', false, 3)
+ api.nvim_paste('aaaaaa\n', false, 1)
+ api.nvim_paste('bbbbbb\n', false, 2)
+ api.nvim_paste('cccccc\n', false, 2)
+ api.nvim_paste('dddddd\n', false, 3)
expect([[
aaaaaa
bbbbbb
@@ -1148,71 +1148,71 @@ describe('API', function()
end)
it('non-streaming', function()
-- With final "\n".
- meths.nvim_paste('line 1\nline 2\nline 3\n', true, -1)
+ api.nvim_paste('line 1\nline 2\nline 3\n', true, -1)
expect([[
line 1
line 2
line 3
]])
- eq({ 0, 4, 1, 0 }, funcs.getpos('.')) -- Cursor follows the paste.
- eq(false, meths.nvim_get_option_value('paste', {}))
+ eq({ 0, 4, 1, 0 }, fn.getpos('.')) -- Cursor follows the paste.
+ eq(false, api.nvim_get_option_value('paste', {}))
command('%delete _')
-- Without final "\n".
- meths.nvim_paste('line 1\nline 2\nline 3', true, -1)
+ api.nvim_paste('line 1\nline 2\nline 3', true, -1)
expect([[
line 1
line 2
line 3]])
- eq({ 0, 3, 6, 0 }, funcs.getpos('.'))
+ eq({ 0, 3, 6, 0 }, fn.getpos('.'))
command('%delete _')
-- CRLF #10872
- meths.nvim_paste('line 1\r\nline 2\r\nline 3\r\n', true, -1)
+ api.nvim_paste('line 1\r\nline 2\r\nline 3\r\n', true, -1)
expect([[
line 1
line 2
line 3
]])
- eq({ 0, 4, 1, 0 }, funcs.getpos('.'))
+ eq({ 0, 4, 1, 0 }, fn.getpos('.'))
command('%delete _')
-- CRLF without final "\n".
- meths.nvim_paste('line 1\r\nline 2\r\nline 3\r', true, -1)
+ api.nvim_paste('line 1\r\nline 2\r\nline 3\r', true, -1)
expect([[
line 1
line 2
line 3
]])
- eq({ 0, 4, 1, 0 }, funcs.getpos('.'))
+ eq({ 0, 4, 1, 0 }, fn.getpos('.'))
command('%delete _')
-- CRLF without final "\r\n".
- meths.nvim_paste('line 1\r\nline 2\r\nline 3', true, -1)
+ api.nvim_paste('line 1\r\nline 2\r\nline 3', true, -1)
expect([[
line 1
line 2
line 3]])
- eq({ 0, 3, 6, 0 }, funcs.getpos('.'))
+ eq({ 0, 3, 6, 0 }, fn.getpos('.'))
command('%delete _')
-- Various other junk.
- meths.nvim_paste('line 1\r\n\r\rline 2\nline 3\rline 4\r', true, -1)
+ api.nvim_paste('line 1\r\n\r\rline 2\nline 3\rline 4\r', true, -1)
expect('line 1\n\n\nline 2\nline 3\nline 4\n')
- eq({ 0, 7, 1, 0 }, funcs.getpos('.'))
- eq(false, meths.nvim_get_option_value('paste', {}))
+ eq({ 0, 7, 1, 0 }, fn.getpos('.'))
+ eq(false, api.nvim_get_option_value('paste', {}))
end)
it('Replace-mode', function()
-- Within single line
- meths.nvim_put({ 'aabbccdd', 'eeffgghh', 'iijjkkll' }, 'c', true, false)
+ api.nvim_put({ 'aabbccdd', 'eeffgghh', 'iijjkkll' }, 'c', true, false)
command('normal l')
command('startreplace')
- meths.nvim_paste('123456', true, -1)
+ api.nvim_paste('123456', true, -1)
expect([[
a123456d
eeffgghh
iijjkkll]])
command('%delete _')
-- Across lines
- meths.nvim_put({ 'aabbccdd', 'eeffgghh', 'iijjkkll' }, 'c', true, false)
+ api.nvim_put({ 'aabbccdd', 'eeffgghh', 'iijjkkll' }, 'c', true, false)
command('normal l')
command('startreplace')
- meths.nvim_paste('123\n456', true, -1)
+ api.nvim_paste('123\n456', true, -1)
expect([[
a123
456d
@@ -1221,30 +1221,30 @@ describe('API', function()
end)
it('when searching in Visual mode', function()
feed('v/')
- meths.nvim_paste('aabbccdd', true, -1)
- eq('aabbccdd', funcs.getcmdline())
+ api.nvim_paste('aabbccdd', true, -1)
+ eq('aabbccdd', fn.getcmdline())
expect('')
end)
it('mappings are disabled in Cmdline mode', function()
command('cnoremap a b')
feed(':')
- meths.nvim_paste('a', true, -1)
- eq('a', funcs.getcmdline())
+ api.nvim_paste('a', true, -1)
+ eq('a', fn.getcmdline())
end)
it('pasted text is saved in cmdline history when <CR> comes from mapping #20957', function()
command('cnoremap <CR> <CR>')
feed(':')
- meths.nvim_paste('echo', true, -1)
- eq('', funcs.histget(':'))
+ api.nvim_paste('echo', true, -1)
+ eq('', fn.histget(':'))
feed('<CR>')
- eq('echo', funcs.histget(':'))
+ eq('echo', fn.histget(':'))
end)
it('pasting with empty last chunk in Cmdline mode', function()
local screen = Screen.new(20, 4)
screen:attach()
feed(':')
- meths.nvim_paste('Foo', true, 1)
- meths.nvim_paste('', true, 3)
+ api.nvim_paste('Foo', true, 1)
+ api.nvim_paste('', true, 3)
screen:expect([[
|
~ |*2
@@ -1255,7 +1255,7 @@ describe('API', function()
local screen = Screen.new(20, 4)
screen:attach()
feed(':')
- meths.nvim_paste('normal! \023\022\006\027', true, -1)
+ api.nvim_paste('normal! \023\022\006\027', true, -1)
screen:expect([[
|
~ |*2
@@ -1263,12 +1263,12 @@ describe('API', function()
]])
end)
it('crlf=false does not break lines at CR, CRLF', function()
- meths.nvim_paste('line 1\r\n\r\rline 2\nline 3\rline 4\r', false, -1)
+ api.nvim_paste('line 1\r\n\r\rline 2\nline 3\rline 4\r', false, -1)
expect('line 1\r\n\r\rline 2\nline 3\rline 4\r')
- eq({ 0, 3, 14, 0 }, funcs.getpos('.'))
+ eq({ 0, 3, 14, 0 }, fn.getpos('.'))
end)
it('vim.paste() failure', function()
- meths.nvim_exec_lua('vim.paste = (function(lines, phase) error("fake fail") end)', {})
+ api.nvim_exec_lua('vim.paste = (function(lines, phase) error("fake fail") end)', {})
eq('fake fail', pcall_err(request, 'nvim_paste', 'line 1\nline 2\nline 3', false, 1))
end)
end)
@@ -1290,78 +1290,78 @@ describe('API', function()
end)
it('inserts text', function()
-- linewise
- meths.nvim_put({ 'line 1', 'line 2', 'line 3' }, 'l', true, true)
+ api.nvim_put({ 'line 1', 'line 2', 'line 3' }, 'l', true, true)
expect([[
line 1
line 2
line 3]])
- eq({ 0, 4, 1, 0 }, funcs.getpos('.'))
+ eq({ 0, 4, 1, 0 }, fn.getpos('.'))
command('%delete _')
-- charwise
- meths.nvim_put({ 'line 1', 'line 2', 'line 3' }, 'c', true, false)
+ api.nvim_put({ 'line 1', 'line 2', 'line 3' }, 'c', true, false)
expect([[
line 1
line 2
line 3]])
- eq({ 0, 1, 1, 0 }, funcs.getpos('.')) -- follow=false
+ eq({ 0, 1, 1, 0 }, fn.getpos('.')) -- follow=false
-- blockwise
- meths.nvim_put({ 'AA', 'BB' }, 'b', true, true)
+ api.nvim_put({ 'AA', 'BB' }, 'b', true, true)
expect([[
lAAine 1
lBBine 2
line 3]])
- eq({ 0, 2, 4, 0 }, funcs.getpos('.'))
+ eq({ 0, 2, 4, 0 }, fn.getpos('.'))
command('%delete _')
-- Empty lines list.
- meths.nvim_put({}, 'c', true, true)
- eq({ 0, 1, 1, 0 }, funcs.getpos('.'))
+ api.nvim_put({}, 'c', true, true)
+ eq({ 0, 1, 1, 0 }, fn.getpos('.'))
expect([[]])
-- Single empty line.
- meths.nvim_put({ '' }, 'c', true, true)
- eq({ 0, 1, 1, 0 }, funcs.getpos('.'))
+ api.nvim_put({ '' }, 'c', true, true)
+ eq({ 0, 1, 1, 0 }, fn.getpos('.'))
expect([[
]])
- meths.nvim_put({ 'AB' }, 'c', true, true)
+ api.nvim_put({ 'AB' }, 'c', true, true)
-- after=false, follow=true
- meths.nvim_put({ 'line 1', 'line 2' }, 'c', false, true)
+ api.nvim_put({ 'line 1', 'line 2' }, 'c', false, true)
expect([[
Aline 1
line 2B]])
- eq({ 0, 2, 7, 0 }, funcs.getpos('.'))
+ eq({ 0, 2, 7, 0 }, fn.getpos('.'))
command('%delete _')
- meths.nvim_put({ 'AB' }, 'c', true, true)
+ api.nvim_put({ 'AB' }, 'c', true, true)
-- after=false, follow=false
- meths.nvim_put({ 'line 1', 'line 2' }, 'c', false, false)
+ api.nvim_put({ 'line 1', 'line 2' }, 'c', false, false)
expect([[
Aline 1
line 2B]])
- eq({ 0, 1, 2, 0 }, funcs.getpos('.'))
- eq('', meths.nvim_eval('v:errmsg'))
+ eq({ 0, 1, 2, 0 }, fn.getpos('.'))
+ eq('', api.nvim_eval('v:errmsg'))
end)
it('detects charwise/linewise text (empty {type})', function()
-- linewise (final item is empty string)
- meths.nvim_put({ 'line 1', 'line 2', 'line 3', '' }, '', true, true)
+ api.nvim_put({ 'line 1', 'line 2', 'line 3', '' }, '', true, true)
expect([[
line 1
line 2
line 3]])
- eq({ 0, 4, 1, 0 }, funcs.getpos('.'))
+ eq({ 0, 4, 1, 0 }, fn.getpos('.'))
command('%delete _')
-- charwise (final item is non-empty)
- meths.nvim_put({ 'line 1', 'line 2', 'line 3' }, '', true, true)
+ api.nvim_put({ 'line 1', 'line 2', 'line 3' }, '', true, true)
expect([[
line 1
line 2
line 3]])
- eq({ 0, 3, 6, 0 }, funcs.getpos('.'))
+ eq({ 0, 3, 6, 0 }, fn.getpos('.'))
end)
it('allows block width', function()
-- behave consistently with setreg(); support "\022{NUM}" return by getregtype()
- meths.nvim_put({ 'line 1', 'line 2', 'line 3' }, 'l', false, false)
+ api.nvim_put({ 'line 1', 'line 2', 'line 3' }, 'l', false, false)
expect([[
line 1
line 2
@@ -1369,69 +1369,69 @@ describe('API', function()
]])
-- larger width create spaces
- meths.nvim_put({ 'a', 'bc' }, 'b3', false, false)
+ api.nvim_put({ 'a', 'bc' }, 'b3', false, false)
expect([[
a line 1
bc line 2
line 3
]])
-- smaller width is ignored
- meths.nvim_put({ 'xxx', 'yyy' }, '\0221', false, true)
+ api.nvim_put({ 'xxx', 'yyy' }, '\0221', false, true)
expect([[
xxxa line 1
yyybc line 2
line 3
]])
- 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))
+ eq("Invalid 'type': 'bx'", pcall_err(api.nvim_put, { 'xxx', 'yyy' }, 'bx', false, true))
+ eq("Invalid 'type': 'b3x'", pcall_err(api.nvim_put, { 'xxx', 'yyy' }, 'b3x', false, true))
end)
end)
describe('nvim_strwidth', function()
it('works', function()
- eq(3, meths.nvim_strwidth('abc'))
+ eq(3, api.nvim_strwidth('abc'))
-- 6 + (neovim)
-- 19 * 2 (each japanese character occupies two cells)
- eq(44, meths.nvim_strwidth('neovimのデザインかなりまともなのになってる。'))
+ eq(44, api.nvim_strwidth('neovimのデザインかなりまともなのになってる。'))
end)
it('cannot handle NULs', function()
- eq(0, meths.nvim_strwidth('\0abc'))
+ eq(0, api.nvim_strwidth('\0abc'))
end)
end)
describe('nvim_get_current_line, nvim_set_current_line', function()
it('works', function()
- eq('', meths.nvim_get_current_line())
- meths.nvim_set_current_line('abc')
- eq('abc', meths.nvim_get_current_line())
+ eq('', api.nvim_get_current_line())
+ api.nvim_set_current_line('abc')
+ eq('abc', api.nvim_get_current_line())
end)
end)
describe('set/get/del variables', function()
it('validation', function()
- eq('Key not found: bogus', pcall_err(meths.nvim_get_var, 'bogus'))
- eq('Key not found: bogus', pcall_err(meths.nvim_del_var, 'bogus'))
+ eq('Key not found: bogus', pcall_err(api.nvim_get_var, 'bogus'))
+ eq('Key not found: bogus', pcall_err(api.nvim_del_var, 'bogus'))
end)
it('nvim_get_var, nvim_set_var, nvim_del_var', function()
- meths.nvim_set_var('lua', { 1, 2, { ['3'] = 1 } })
- eq({ 1, 2, { ['3'] = 1 } }, meths.nvim_get_var('lua'))
- eq({ 1, 2, { ['3'] = 1 } }, meths.nvim_eval('g:lua'))
- eq(1, funcs.exists('g:lua'))
- meths.nvim_del_var('lua')
- eq(0, funcs.exists('g:lua'))
- eq('Key not found: lua', pcall_err(meths.nvim_del_var, 'lua'))
- meths.nvim_set_var('lua', 1)
+ api.nvim_set_var('lua', { 1, 2, { ['3'] = 1 } })
+ eq({ 1, 2, { ['3'] = 1 } }, api.nvim_get_var('lua'))
+ eq({ 1, 2, { ['3'] = 1 } }, api.nvim_eval('g:lua'))
+ eq(1, fn.exists('g:lua'))
+ api.nvim_del_var('lua')
+ eq(0, fn.exists('g:lua'))
+ eq('Key not found: lua', pcall_err(api.nvim_del_var, 'lua'))
+ api.nvim_set_var('lua', 1)
-- Empty keys are allowed in Vim dicts (and msgpack).
- meths.nvim_set_var('dict_empty_key', { [''] = 'empty key' })
- eq({ [''] = 'empty key' }, meths.nvim_get_var('dict_empty_key'))
+ api.nvim_set_var('dict_empty_key', { [''] = 'empty key' })
+ eq({ [''] = 'empty key' }, api.nvim_get_var('dict_empty_key'))
-- Set locked g: var.
command('lockvar lua')
- 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))
+ eq('Key is locked: lua', pcall_err(api.nvim_del_var, 'lua'))
+ eq('Key is locked: lua', pcall_err(api.nvim_set_var, 'lua', 1))
exec([[
function Test()
@@ -1441,8 +1441,8 @@ describe('API', function()
let g:Unknown_func = function('Test')
let g:Unknown_script_func = function('s:Test')
]])
- eq(NIL, meths.nvim_get_var('Unknown_func'))
- eq(NIL, meths.nvim_get_var('Unknown_script_func'))
+ eq(NIL, api.nvim_get_var('Unknown_func'))
+ eq(NIL, api.nvim_get_var('Unknown_script_func'))
-- Check if autoload works properly
local pathsep = helpers.get_pathsep()
@@ -1454,40 +1454,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.nvim_get_var('testload#value'))
+ eq(2, api.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.nvim_set_vvar('errmsg', 'set by API')
- eq('set by API', meths.nvim_get_vvar('errmsg'))
- meths.nvim_set_vvar('errmsg', 42)
+ api.nvim_set_vvar('errmsg', 'set by API')
+ eq('set by API', api.nvim_get_vvar('errmsg'))
+ api.nvim_set_vvar('errmsg', 42)
eq('42', eval('v:errmsg'))
- meths.nvim_set_vvar('oldfiles', { 'one', 'two' })
+ api.nvim_set_vvar('oldfiles', { 'one', 'two' })
eq({ 'one', 'two' }, eval('v:oldfiles'))
- meths.nvim_set_vvar('oldfiles', {})
+ api.nvim_set_vvar('oldfiles', {})
eq({}, eval('v:oldfiles'))
eq(
'Setting v:oldfiles to value with wrong type',
- pcall_err(meths.nvim_set_vvar, 'oldfiles', 'a')
+ pcall_err(api.nvim_set_vvar, 'oldfiles', 'a')
)
eq({}, eval('v:oldfiles'))
feed('i foo foo foo<Esc>0/foo<CR>')
- eq({ 1, 1 }, meths.nvim_win_get_cursor(0))
+ eq({ 1, 1 }, api.nvim_win_get_cursor(0))
eq(1, eval('v:searchforward'))
feed('n')
- eq({ 1, 5 }, meths.nvim_win_get_cursor(0))
- meths.nvim_set_vvar('searchforward', 0)
+ eq({ 1, 5 }, api.nvim_win_get_cursor(0))
+ api.nvim_set_vvar('searchforward', 0)
eq(0, eval('v:searchforward'))
feed('n')
- eq({ 1, 1 }, meths.nvim_win_get_cursor(0))
- meths.nvim_set_vvar('searchforward', 1)
+ eq({ 1, 1 }, api.nvim_win_get_cursor(0))
+ api.nvim_set_vvar('searchforward', 1)
eq(1, eval('v:searchforward'))
feed('n')
- eq({ 1, 5 }, meths.nvim_win_get_cursor(0))
+ eq({ 1, 5 }, api.nvim_win_get_cursor(0))
local screen = Screen.new(60, 3)
screen:set_default_attr_ids({
@@ -1503,7 +1503,7 @@ describe('API', function()
|
]],
}
- meths.nvim_set_vvar('hlsearch', 0)
+ api.nvim_set_vvar('hlsearch', 0)
eq(0, eval('v:hlsearch'))
screen:expect {
grid = [[
@@ -1512,7 +1512,7 @@ describe('API', function()
|
]],
}
- meths.nvim_set_vvar('hlsearch', 1)
+ api.nvim_set_vvar('hlsearch', 1)
eq(1, eval('v:hlsearch'))
screen:expect {
grid = [[
@@ -1539,182 +1539,182 @@ describe('API', function()
end)
it('truncates values with NULs in them', function()
- meths.nvim_set_var('xxx', 'ab\0cd')
- eq('ab', meths.nvim_get_var('xxx'))
+ api.nvim_set_var('xxx', 'ab\0cd')
+ eq('ab', api.nvim_get_var('xxx'))
end)
end)
describe('nvim_get_option_value, nvim_set_option_value', function()
it('works', function()
- ok(meths.nvim_get_option_value('equalalways', {}))
- meths.nvim_set_option_value('equalalways', false, {})
- ok(not meths.nvim_get_option_value('equalalways', {}))
+ ok(api.nvim_get_option_value('equalalways', {}))
+ api.nvim_set_option_value('equalalways', false, {})
+ ok(not api.nvim_get_option_value('equalalways', {}))
end)
it('works to get global value of local options', function()
- eq(false, meths.nvim_get_option_value('lisp', {}))
- eq(8, meths.nvim_get_option_value('shiftwidth', {}))
+ eq(false, api.nvim_get_option_value('lisp', {}))
+ eq(8, api.nvim_get_option_value('shiftwidth', {}))
end)
it('works to set global value of local options', function()
- meths.nvim_set_option_value('lisp', true, { scope = 'global' })
- eq(true, meths.nvim_get_option_value('lisp', { scope = 'global' }))
- eq(false, meths.nvim_get_option_value('lisp', {}))
+ api.nvim_set_option_value('lisp', true, { scope = 'global' })
+ eq(true, api.nvim_get_option_value('lisp', { scope = 'global' }))
+ eq(false, api.nvim_get_option_value('lisp', {}))
eq(nil, command_output('setglobal lisp?'):match('nolisp'))
eq('nolisp', command_output('setlocal lisp?'):match('nolisp'))
- meths.nvim_set_option_value('shiftwidth', 20, { scope = 'global' })
+ api.nvim_set_option_value('shiftwidth', 20, { scope = 'global' })
eq('20', command_output('setglobal shiftwidth?'):match('%d+'))
eq('8', command_output('setlocal shiftwidth?'):match('%d+'))
end)
it('updates where the option was last set from', function()
- meths.nvim_set_option_value('equalalways', false, {})
+ api.nvim_set_option_value('equalalways', false, {})
local status, rv = pcall(command_output, 'verbose set equalalways?')
eq(true, status)
ok(
nil ~= string.find(rv, 'noequalalways\n' .. '\tLast set from API client %(channel id %d+%)')
)
- meths.nvim_exec_lua('vim.api.nvim_set_option_value("equalalways", true, {})', {})
+ api.nvim_exec_lua('vim.api.nvim_set_option_value("equalalways", true, {})', {})
status, rv = pcall(command_output, 'verbose set equalalways?')
eq(true, status)
eq(' equalalways\n\tLast set from Lua', rv)
end)
it('updates whether the option has ever been set #25025', function()
- eq(false, meths.nvim_get_option_info2('autochdir', {}).was_set)
- meths.nvim_set_option_value('autochdir', true, {})
- eq(true, meths.nvim_get_option_info2('autochdir', {}).was_set)
+ eq(false, api.nvim_get_option_info2('autochdir', {}).was_set)
+ api.nvim_set_option_value('autochdir', true, {})
+ eq(true, api.nvim_get_option_info2('autochdir', {}).was_set)
- eq(false, meths.nvim_get_option_info2('cmdwinheight', {}).was_set)
- meths.nvim_set_option_value('cmdwinheight', 10, {})
- eq(true, meths.nvim_get_option_info2('cmdwinheight', {}).was_set)
+ eq(false, api.nvim_get_option_info2('cmdwinheight', {}).was_set)
+ api.nvim_set_option_value('cmdwinheight', 10, {})
+ eq(true, api.nvim_get_option_info2('cmdwinheight', {}).was_set)
- eq(false, meths.nvim_get_option_info2('debug', {}).was_set)
- meths.nvim_set_option_value('debug', 'beep', {})
- eq(true, meths.nvim_get_option_info2('debug', {}).was_set)
+ eq(false, api.nvim_get_option_info2('debug', {}).was_set)
+ api.nvim_set_option_value('debug', 'beep', {})
+ eq(true, api.nvim_get_option_info2('debug', {}).was_set)
end)
it('validation', function()
eq(
"Invalid 'scope': expected 'local' or 'global'",
- pcall_err(meths.nvim_get_option_value, 'scrolloff', { scope = 'bogus' })
+ pcall_err(api.nvim_get_option_value, 'scrolloff', { scope = 'bogus' })
)
eq(
"Invalid 'scope': expected 'local' or 'global'",
- pcall_err(meths.nvim_set_option_value, 'scrolloff', 1, { scope = 'bogus' })
+ pcall_err(api.nvim_set_option_value, 'scrolloff', 1, { scope = 'bogus' })
)
eq(
"Invalid 'scope': expected String, got Integer",
- pcall_err(meths.nvim_get_option_value, 'scrolloff', { scope = 42 })
+ pcall_err(api.nvim_get_option_value, 'scrolloff', { scope = 42 })
)
eq(
"Invalid 'value': expected valid option type, got Array",
- pcall_err(meths.nvim_set_option_value, 'scrolloff', {}, {})
+ pcall_err(api.nvim_set_option_value, 'scrolloff', {}, {})
)
eq(
"Invalid value for option 'scrolloff': expected number, got boolean true",
- pcall_err(meths.nvim_set_option_value, 'scrolloff', true, {})
+ pcall_err(api.nvim_set_option_value, 'scrolloff', true, {})
)
eq(
'Invalid value for option \'scrolloff\': expected number, got string "wrong"',
- pcall_err(meths.nvim_set_option_value, 'scrolloff', 'wrong', {})
+ pcall_err(api.nvim_set_option_value, 'scrolloff', 'wrong', {})
)
end)
it('can get local values when global value is set', function()
- eq(0, meths.nvim_get_option_value('scrolloff', {}))
- eq(-1, meths.nvim_get_option_value('scrolloff', { scope = 'local' }))
+ eq(0, api.nvim_get_option_value('scrolloff', {}))
+ eq(-1, api.nvim_get_option_value('scrolloff', { scope = 'local' }))
end)
it('can set global and local values', function()
- meths.nvim_set_option_value('makeprg', 'hello', {})
- eq('hello', meths.nvim_get_option_value('makeprg', {}))
- eq('', meths.nvim_get_option_value('makeprg', { scope = 'local' }))
- meths.nvim_set_option_value('makeprg', 'world', { scope = 'local' })
- eq('world', meths.nvim_get_option_value('makeprg', { scope = 'local' }))
- meths.nvim_set_option_value('makeprg', 'goodbye', { scope = 'global' })
- eq('goodbye', meths.nvim_get_option_value('makeprg', { scope = 'global' }))
- meths.nvim_set_option_value('makeprg', 'hello', {})
- eq('hello', meths.nvim_get_option_value('makeprg', { scope = 'global' }))
- eq('hello', meths.nvim_get_option_value('makeprg', {}))
- eq('', meths.nvim_get_option_value('makeprg', { scope = 'local' }))
+ api.nvim_set_option_value('makeprg', 'hello', {})
+ eq('hello', api.nvim_get_option_value('makeprg', {}))
+ eq('', api.nvim_get_option_value('makeprg', { scope = 'local' }))
+ api.nvim_set_option_value('makeprg', 'world', { scope = 'local' })
+ eq('world', api.nvim_get_option_value('makeprg', { scope = 'local' }))
+ api.nvim_set_option_value('makeprg', 'goodbye', { scope = 'global' })
+ eq('goodbye', api.nvim_get_option_value('makeprg', { scope = 'global' }))
+ api.nvim_set_option_value('makeprg', 'hello', {})
+ eq('hello', api.nvim_get_option_value('makeprg', { scope = 'global' }))
+ eq('hello', api.nvim_get_option_value('makeprg', {}))
+ eq('', api.nvim_get_option_value('makeprg', { scope = 'local' }))
end)
it('clears the local value of an option with nil', function()
-- Set global value
- meths.nvim_set_option_value('shiftwidth', 42, {})
- eq(42, meths.nvim_get_option_value('shiftwidth', {}))
+ api.nvim_set_option_value('shiftwidth', 42, {})
+ eq(42, api.nvim_get_option_value('shiftwidth', {}))
-- Set local value
- meths.nvim_set_option_value('shiftwidth', 8, { scope = 'local' })
- eq(8, meths.nvim_get_option_value('shiftwidth', {}))
- eq(8, meths.nvim_get_option_value('shiftwidth', { scope = 'local' }))
- eq(42, meths.nvim_get_option_value('shiftwidth', { scope = 'global' }))
+ api.nvim_set_option_value('shiftwidth', 8, { scope = 'local' })
+ eq(8, api.nvim_get_option_value('shiftwidth', {}))
+ eq(8, api.nvim_get_option_value('shiftwidth', { scope = 'local' }))
+ eq(42, api.nvim_get_option_value('shiftwidth', { scope = 'global' }))
-- Clear value without scope
- meths.nvim_set_option_value('shiftwidth', NIL, {})
- eq(42, meths.nvim_get_option_value('shiftwidth', {}))
- eq(42, meths.nvim_get_option_value('shiftwidth', { scope = 'local' }))
+ api.nvim_set_option_value('shiftwidth', NIL, {})
+ eq(42, api.nvim_get_option_value('shiftwidth', {}))
+ eq(42, api.nvim_get_option_value('shiftwidth', { scope = 'local' }))
-- Clear value with explicit scope
- meths.nvim_set_option_value('shiftwidth', 8, { scope = 'local' })
- meths.nvim_set_option_value('shiftwidth', NIL, { scope = 'local' })
- eq(42, meths.nvim_get_option_value('shiftwidth', {}))
- eq(42, meths.nvim_get_option_value('shiftwidth', { scope = 'local' }))
+ api.nvim_set_option_value('shiftwidth', 8, { scope = 'local' })
+ api.nvim_set_option_value('shiftwidth', NIL, { scope = 'local' })
+ eq(42, api.nvim_get_option_value('shiftwidth', {}))
+ eq(42, api.nvim_get_option_value('shiftwidth', { scope = 'local' }))
-- Now try with options with a special "local is unset" value (e.g. 'undolevels')
- meths.nvim_set_option_value('undolevels', 1000, {})
- meths.nvim_set_option_value('undolevels', 1200, { scope = 'local' })
- eq(1200, meths.nvim_get_option_value('undolevels', { scope = 'local' }))
- meths.nvim_set_option_value('undolevels', NIL, { scope = 'local' })
- eq(-123456, meths.nvim_get_option_value('undolevels', { scope = 'local' }))
- eq(1000, meths.nvim_get_option_value('undolevels', {}))
+ api.nvim_set_option_value('undolevels', 1000, {})
+ api.nvim_set_option_value('undolevels', 1200, { scope = 'local' })
+ eq(1200, api.nvim_get_option_value('undolevels', { scope = 'local' }))
+ api.nvim_set_option_value('undolevels', NIL, { scope = 'local' })
+ eq(-123456, api.nvim_get_option_value('undolevels', { scope = 'local' }))
+ eq(1000, api.nvim_get_option_value('undolevels', {}))
- meths.nvim_set_option_value('autoread', true, {})
- meths.nvim_set_option_value('autoread', false, { scope = 'local' })
- eq(false, meths.nvim_get_option_value('autoread', { scope = 'local' }))
- meths.nvim_set_option_value('autoread', NIL, { scope = 'local' })
- eq(NIL, meths.nvim_get_option_value('autoread', { scope = 'local' }))
- eq(true, meths.nvim_get_option_value('autoread', {}))
+ api.nvim_set_option_value('autoread', true, {})
+ api.nvim_set_option_value('autoread', false, { scope = 'local' })
+ eq(false, api.nvim_get_option_value('autoread', { scope = 'local' }))
+ api.nvim_set_option_value('autoread', NIL, { scope = 'local' })
+ eq(NIL, api.nvim_get_option_value('autoread', { scope = 'local' }))
+ eq(true, api.nvim_get_option_value('autoread', {}))
end)
it('set window options', function()
- meths.nvim_set_option_value('colorcolumn', '4,3', {})
- eq('4,3', meths.nvim_get_option_value('colorcolumn', { scope = 'local' }))
+ api.nvim_set_option_value('colorcolumn', '4,3', {})
+ eq('4,3', api.nvim_get_option_value('colorcolumn', { scope = 'local' }))
command('set modified hidden')
command('enew') -- edit new buffer, window option is preserved
- eq('4,3', meths.nvim_get_option_value('colorcolumn', { scope = 'local' }))
+ eq('4,3', api.nvim_get_option_value('colorcolumn', { scope = 'local' }))
end)
it('set local window options', function()
- meths.nvim_set_option_value('colorcolumn', '4,3', { win = 0, scope = 'local' })
- eq('4,3', meths.nvim_get_option_value('colorcolumn', { win = 0, scope = 'local' }))
+ api.nvim_set_option_value('colorcolumn', '4,3', { win = 0, scope = 'local' })
+ eq('4,3', api.nvim_get_option_value('colorcolumn', { win = 0, scope = 'local' }))
command('set modified hidden')
command('enew') -- edit new buffer, window option is reset
- eq('', meths.nvim_get_option_value('colorcolumn', { win = 0, scope = 'local' }))
+ eq('', api.nvim_get_option_value('colorcolumn', { win = 0, scope = 'local' }))
end)
it('get buffer or window-local options', function()
command('new')
- local buf = meths.nvim_get_current_buf().id
- meths.nvim_set_option_value('tagfunc', 'foobar', { buf = buf })
- eq('foobar', meths.nvim_get_option_value('tagfunc', { buf = buf }))
+ local buf = api.nvim_get_current_buf().id
+ api.nvim_set_option_value('tagfunc', 'foobar', { buf = buf })
+ eq('foobar', api.nvim_get_option_value('tagfunc', { buf = buf }))
- local win = meths.nvim_get_current_win().id
- meths.nvim_set_option_value('number', true, { win = win })
- eq(true, meths.nvim_get_option_value('number', { win = win }))
+ local win = api.nvim_get_current_win().id
+ api.nvim_set_option_value('number', true, { win = win })
+ eq(true, api.nvim_get_option_value('number', { win = win }))
end)
it('getting current buffer option does not adjust cursor #19381', function()
command('new')
- local buf = meths.nvim_get_current_buf().id
- local win = meths.nvim_get_current_win().id
+ local buf = api.nvim_get_current_buf().id
+ local win = api.nvim_get_current_win().id
insert('some text')
feed('0v$')
- eq({ 1, 9 }, meths.nvim_win_get_cursor(win))
- meths.nvim_get_option_value('filetype', { buf = buf })
- eq({ 1, 9 }, meths.nvim_win_get_cursor(win))
+ eq({ 1, 9 }, api.nvim_win_get_cursor(win))
+ api.nvim_get_option_value('filetype', { buf = buf })
+ eq({ 1, 9 }, api.nvim_win_get_cursor(win))
end)
it('can get default option values for filetypes', function()
@@ -1726,156 +1726,156 @@ describe('API', function()
xml = { formatexpr = 'xmlformat#Format()' },
} do
for option, value in pairs(opts) do
- eq(value, meths.nvim_get_option_value(option, { filetype = ft }))
+ eq(value, api.nvim_get_option_value(option, { filetype = ft }))
end
end
command 'au FileType lua setlocal commentstring=NEW\\ %s'
- eq('NEW %s', meths.nvim_get_option_value('commentstring', { filetype = 'lua' }))
+ eq('NEW %s', api.nvim_get_option_value('commentstring', { filetype = 'lua' }))
end)
it('errors for bad FileType autocmds', function()
command 'au FileType lua setlocal commentstring=BAD'
eq(
[[FileType Autocommands for "lua": Vim(setlocal):E537: 'commentstring' must be empty or contain %s: commentstring=BAD]],
- pcall_err(meths.nvim_get_option_value, 'commentstring', { filetype = 'lua' })
+ pcall_err(api.nvim_get_option_value, 'commentstring', { filetype = 'lua' })
)
end)
it("value of 'modified' is always false for scratch buffers", function()
- meths.nvim_set_current_buf(meths.nvim_create_buf(true, true))
+ api.nvim_set_current_buf(api.nvim_create_buf(true, true))
insert([[
foo
bar
baz
]])
- eq(false, meths.nvim_get_option_value('modified', {}))
+ eq(false, api.nvim_get_option_value('modified', {}))
end)
end)
describe('nvim_{get,set}_current_buf, nvim_list_bufs', function()
it('works', function()
- eq(1, #meths.nvim_list_bufs())
- eq(meths.nvim_list_bufs()[1], meths.nvim_get_current_buf())
+ eq(1, #api.nvim_list_bufs())
+ eq(api.nvim_list_bufs()[1], api.nvim_get_current_buf())
command('new')
- eq(2, #meths.nvim_list_bufs())
- eq(meths.nvim_list_bufs()[2], meths.nvim_get_current_buf())
- meths.nvim_set_current_buf(meths.nvim_list_bufs()[1])
- eq(meths.nvim_list_bufs()[1], meths.nvim_get_current_buf())
+ eq(2, #api.nvim_list_bufs())
+ eq(api.nvim_list_bufs()[2], api.nvim_get_current_buf())
+ api.nvim_set_current_buf(api.nvim_list_bufs()[1])
+ eq(api.nvim_list_bufs()[1], api.nvim_get_current_buf())
end)
end)
describe('nvim_{get,set}_current_win, nvim_list_wins', function()
it('works', function()
- eq(1, #meths.nvim_list_wins())
- eq(meths.nvim_list_wins()[1], meths.nvim_get_current_win())
+ eq(1, #api.nvim_list_wins())
+ eq(api.nvim_list_wins()[1], api.nvim_get_current_win())
command('vsplit')
command('split')
- eq(3, #meths.nvim_list_wins())
- eq(meths.nvim_list_wins()[1], meths.nvim_get_current_win())
- meths.nvim_set_current_win(meths.nvim_list_wins()[2])
- eq(meths.nvim_list_wins()[2], meths.nvim_get_current_win())
+ eq(3, #api.nvim_list_wins())
+ eq(api.nvim_list_wins()[1], api.nvim_get_current_win())
+ api.nvim_set_current_win(api.nvim_list_wins()[2])
+ eq(api.nvim_list_wins()[2], api.nvim_get_current_win())
end)
end)
describe('nvim_{get,set}_current_tabpage, nvim_list_tabpages', function()
it('works', function()
- eq(1, #meths.nvim_list_tabpages())
- eq(meths.nvim_list_tabpages()[1], meths.nvim_get_current_tabpage())
+ eq(1, #api.nvim_list_tabpages())
+ eq(api.nvim_list_tabpages()[1], api.nvim_get_current_tabpage())
command('tabnew')
- eq(2, #meths.nvim_list_tabpages())
- eq(2, #meths.nvim_list_wins())
- eq(meths.nvim_list_wins()[2], meths.nvim_get_current_win())
- eq(meths.nvim_list_tabpages()[2], meths.nvim_get_current_tabpage())
- meths.nvim_set_current_win(meths.nvim_list_wins()[1])
+ eq(2, #api.nvim_list_tabpages())
+ eq(2, #api.nvim_list_wins())
+ eq(api.nvim_list_wins()[2], api.nvim_get_current_win())
+ eq(api.nvim_list_tabpages()[2], api.nvim_get_current_tabpage())
+ api.nvim_set_current_win(api.nvim_list_wins()[1])
-- Switching window also switches tabpages if necessary
- eq(meths.nvim_list_tabpages()[1], meths.nvim_get_current_tabpage())
- eq(meths.nvim_list_wins()[1], meths.nvim_get_current_win())
- meths.nvim_set_current_tabpage(meths.nvim_list_tabpages()[2])
- eq(meths.nvim_list_tabpages()[2], meths.nvim_get_current_tabpage())
- eq(meths.nvim_list_wins()[2], meths.nvim_get_current_win())
+ eq(api.nvim_list_tabpages()[1], api.nvim_get_current_tabpage())
+ eq(api.nvim_list_wins()[1], api.nvim_get_current_win())
+ api.nvim_set_current_tabpage(api.nvim_list_tabpages()[2])
+ eq(api.nvim_list_tabpages()[2], api.nvim_get_current_tabpage())
+ eq(api.nvim_list_wins()[2], api.nvim_get_current_win())
end)
end)
describe('nvim_get_mode', function()
it('during normal-mode `g` returns blocking=true', function()
- meths.nvim_input('o') -- add a line
- eq({ mode = 'i', blocking = false }, meths.nvim_get_mode())
- meths.nvim_input([[<C-\><C-N>]])
- eq(2, meths.nvim_eval("line('.')"))
- eq({ mode = 'n', blocking = false }, meths.nvim_get_mode())
+ api.nvim_input('o') -- add a line
+ eq({ mode = 'i', blocking = false }, api.nvim_get_mode())
+ api.nvim_input([[<C-\><C-N>]])
+ eq(2, api.nvim_eval("line('.')"))
+ eq({ mode = 'n', blocking = false }, api.nvim_get_mode())
- meths.nvim_input('g')
- eq({ mode = 'n', blocking = true }, meths.nvim_get_mode())
+ api.nvim_input('g')
+ eq({ mode = 'n', blocking = true }, api.nvim_get_mode())
- meths.nvim_input('k') -- complete the operator
- eq(1, meths.nvim_eval("line('.')")) -- verify the completed operator
- eq({ mode = 'n', blocking = false }, meths.nvim_get_mode())
+ api.nvim_input('k') -- complete the operator
+ eq(1, api.nvim_eval("line('.')")) -- verify the completed operator
+ eq({ mode = 'n', blocking = false }, api.nvim_get_mode())
end)
it('returns the correct result multiple consecutive times', function()
for _ = 1, 5 do
- eq({ mode = 'n', blocking = false }, meths.nvim_get_mode())
+ eq({ mode = 'n', blocking = false }, api.nvim_get_mode())
end
- meths.nvim_input('g')
+ api.nvim_input('g')
for _ = 1, 4 do
- eq({ mode = 'n', blocking = true }, meths.nvim_get_mode())
+ eq({ mode = 'n', blocking = true }, api.nvim_get_mode())
end
- meths.nvim_input('g')
+ api.nvim_input('g')
for _ = 1, 7 do
- eq({ mode = 'n', blocking = false }, meths.nvim_get_mode())
+ eq({ mode = 'n', blocking = false }, api.nvim_get_mode())
end
end)
it('during normal-mode CTRL-W, returns blocking=true', function()
- meths.nvim_input('<C-W>')
- eq({ mode = 'n', blocking = true }, meths.nvim_get_mode())
+ api.nvim_input('<C-W>')
+ eq({ mode = 'n', blocking = true }, api.nvim_get_mode())
- meths.nvim_input('s') -- complete the operator
- eq(2, meths.nvim_eval("winnr('$')")) -- verify the completed operator
- eq({ mode = 'n', blocking = false }, meths.nvim_get_mode())
+ api.nvim_input('s') -- complete the operator
+ eq(2, api.nvim_eval("winnr('$')")) -- verify the completed operator
+ eq({ mode = 'n', blocking = false }, api.nvim_get_mode())
end)
it('during press-enter prompt without UI returns blocking=false', function()
- eq({ mode = 'n', blocking = false }, meths.nvim_get_mode())
+ eq({ mode = 'n', blocking = false }, api.nvim_get_mode())
command("echom 'msg1'")
command("echom 'msg2'")
command("echom 'msg3'")
command("echom 'msg4'")
command("echom 'msg5'")
- eq({ mode = 'n', blocking = false }, meths.nvim_get_mode())
- meths.nvim_input(':messages<CR>')
- eq({ mode = 'n', blocking = false }, meths.nvim_get_mode())
+ eq({ mode = 'n', blocking = false }, api.nvim_get_mode())
+ api.nvim_input(':messages<CR>')
+ eq({ mode = 'n', blocking = false }, api.nvim_get_mode())
end)
it('during press-enter prompt returns blocking=true', function()
- meths.nvim_ui_attach(80, 20, {})
- eq({ mode = 'n', blocking = false }, meths.nvim_get_mode())
+ api.nvim_ui_attach(80, 20, {})
+ eq({ mode = 'n', blocking = false }, api.nvim_get_mode())
command("echom 'msg1'")
command("echom 'msg2'")
command("echom 'msg3'")
command("echom 'msg4'")
command("echom 'msg5'")
- eq({ mode = 'n', blocking = false }, meths.nvim_get_mode())
- meths.nvim_input(':messages<CR>')
- eq({ mode = 'r', blocking = true }, meths.nvim_get_mode())
+ eq({ mode = 'n', blocking = false }, api.nvim_get_mode())
+ api.nvim_input(':messages<CR>')
+ eq({ mode = 'r', blocking = true }, api.nvim_get_mode())
end)
it('during getchar() returns blocking=false', function()
- meths.nvim_input(':let g:test_input = nr2char(getchar())<CR>')
+ api.nvim_input(':let g:test_input = nr2char(getchar())<CR>')
-- Events are enabled during getchar(), RPC calls are *not* blocked. #5384
- eq({ mode = 'n', blocking = false }, meths.nvim_get_mode())
- eq(0, meths.nvim_eval("exists('g:test_input')"))
- meths.nvim_input('J')
- eq('J', meths.nvim_eval('g:test_input'))
- eq({ mode = 'n', blocking = false }, meths.nvim_get_mode())
+ eq({ mode = 'n', blocking = false }, api.nvim_get_mode())
+ eq(0, api.nvim_eval("exists('g:test_input')"))
+ api.nvim_input('J')
+ eq('J', api.nvim_eval('g:test_input'))
+ eq({ mode = 'n', blocking = false }, api.nvim_get_mode())
end)
-- TODO: bug #6247#issuecomment-286403810
it('batched with input', function()
- meths.nvim_ui_attach(80, 20, {})
- eq({ mode = 'n', blocking = false }, meths.nvim_get_mode())
+ api.nvim_ui_attach(80, 20, {})
+ eq({ mode = 'n', blocking = false }, api.nvim_get_mode())
command("echom 'msg1'")
command("echom 'msg2'")
command("echom 'msg3'")
@@ -1896,35 +1896,35 @@ describe('API', function()
1,
},
NIL,
- }, meths.nvim_call_atomic(req))
- eq({ mode = 'r', blocking = true }, meths.nvim_get_mode())
+ }, api.nvim_call_atomic(req))
+ eq({ mode = 'r', blocking = true }, api.nvim_get_mode())
end)
it('during insert-mode map-pending, returns blocking=true #6166', function()
command('inoremap xx foo')
- meths.nvim_input('ix')
- eq({ mode = 'i', blocking = true }, meths.nvim_get_mode())
+ api.nvim_input('ix')
+ eq({ mode = 'i', blocking = true }, api.nvim_get_mode())
end)
it('during normal-mode gU, returns blocking=false #6166', function()
- meths.nvim_input('gu')
- eq({ mode = 'no', blocking = false }, meths.nvim_get_mode())
+ api.nvim_input('gu')
+ eq({ mode = 'no', blocking = false }, api.nvim_get_mode())
end)
it("at '-- More --' prompt returns blocking=true #11899", function()
command('set more')
feed(':digraphs<cr>')
- eq({ mode = 'rm', blocking = true }, meths.nvim_get_mode())
+ eq({ mode = 'rm', blocking = true }, api.nvim_get_mode())
end)
it('after <Nop> mapping returns blocking=false #17257', function()
command('nnoremap <F2> <Nop>')
feed('<F2>')
- eq({ mode = 'n', blocking = false }, meths.nvim_get_mode())
+ eq({ mode = 'n', blocking = false }, api.nvim_get_mode())
end)
it('after empty string <expr> mapping returns blocking=false #17257', function()
command('nnoremap <expr> <F2> ""')
feed('<F2>')
- eq({ mode = 'n', blocking = false }, meths.nvim_get_mode())
+ eq({ mode = 'n', blocking = false }, api.nvim_get_mode())
end)
end)
@@ -1933,16 +1933,16 @@ describe('API', function()
helpers.insert([[
FIRST LINE
SECOND LINE]])
- meths.nvim_input('gg')
- meths.nvim_input('gu')
+ api.nvim_input('gg')
+ api.nvim_input('gu')
-- Make any RPC request (can be non-async: op-pending does not block).
- meths.nvim_get_current_buf()
+ api.nvim_get_current_buf()
-- Buffer should not change.
expect([[
FIRST LINE
SECOND LINE]])
-- Now send input to complete the operator.
- meths.nvim_input('j')
+ api.nvim_input('j')
expect([[
first line
second line]])
@@ -1956,7 +1956,7 @@ describe('API', function()
feed('ia<cr>b<cr>c<cr><Esc>kkk')
feed('d')
-- Make any RPC request (can be non-async: op-pending does not block).
- meths.nvim_get_current_buf()
+ api.nvim_get_current_buf()
screen:expect([[
^a$ |
b$ |
@@ -1970,12 +1970,12 @@ describe('API', function()
helpers.insert([[
FIRST LINE
SECOND LINE]])
- meths.nvim_input('gg')
- meths.nvim_input('d')
+ api.nvim_input('gg')
+ api.nvim_input('d')
-- Make any RPC request (must be async, because map-pending blocks).
- meths.nvim_get_api_info()
+ api.nvim_get_api_info()
-- Send input to complete the mapping.
- meths.nvim_input('d')
+ api.nvim_input('d')
expect([[
FIRST LINE
SECOND LINE]])
@@ -1988,11 +1988,11 @@ describe('API', function()
helpers.insert([[
FIRST LINE
SECOND LINE]])
- meths.nvim_input('ix')
+ api.nvim_input('ix')
-- Make any RPC request (must be async, because map-pending blocks).
- meths.nvim_get_api_info()
+ api.nvim_get_api_info()
-- Send input to complete the mapping.
- meths.nvim_input('x')
+ api.nvim_input('x')
expect([[
FIRST LINE
SECOND LINfooE]])
@@ -2000,24 +2000,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.nvim_get_mode()) -- fast event
+ eq({ mode = 'niI', blocking = false }, api.nvim_get_mode()) -- fast event
eq(2, eval('1+1')) -- causes K_EVENT key
- eq({ mode = 'niI', blocking = false }, meths.nvim_get_mode()) -- still in ctrl-o mode
+ eq({ mode = 'niI', blocking = false }, api.nvim_get_mode()) -- still in ctrl-o mode
feed('dd')
- eq({ mode = 'i', blocking = false }, meths.nvim_get_mode()) -- left ctrl-o mode
+ eq({ mode = 'i', blocking = false }, api.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.nvim_get_mode()) -- fast event
- eq({ mode = 'vs', blocking = false }, meths.nvim_get_mode()) -- again #15288
+ eq({ mode = 'vs', blocking = false }, api.nvim_get_mode()) -- fast event
+ eq({ mode = 'vs', blocking = false }, api.nvim_get_mode()) -- again #15288
eq(2, eval('1+1')) -- causes K_EVENT key
- eq({ mode = 'vs', blocking = false }, meths.nvim_get_mode()) -- still in ctrl-o mode
+ eq({ mode = 'vs', blocking = false }, api.nvim_get_mode()) -- still in ctrl-o mode
feed('^')
- eq({ mode = 's', blocking = false }, meths.nvim_get_mode()) -- left ctrl-o mode
+ eq({ mode = 's', blocking = false }, api.nvim_get_mode()) -- left ctrl-o mode
feed('h')
- eq({ mode = 'i', blocking = false }, meths.nvim_get_mode()) -- entered insert mode
+ eq({ mode = 'i', blocking = false }, api.nvim_get_mode()) -- entered insert mode
expect('h') -- selection is the whole line and is replaced
end)
@@ -2043,34 +2043,34 @@ describe('API', function()
feed('<BS>')
eq(2, eval('1+1')) -- causes K_EVENT key
feed('.')
- eq('…', funcs.getcmdline()) -- digraph ",." worked
+ eq('…', fn.getcmdline()) -- digraph ",." worked
end)
end)
describe('nvim_get_context', function()
it('validation', function()
- eq("Invalid key: 'blah'", pcall_err(meths.nvim_get_context, { blah = {} }))
+ eq("Invalid key: 'blah'", pcall_err(api.nvim_get_context, { blah = {} }))
eq(
"Invalid 'types': expected Array, got Integer",
- pcall_err(meths.nvim_get_context, { types = 42 })
+ pcall_err(api.nvim_get_context, { types = 42 })
)
eq(
"Invalid 'type': 'zub'",
- pcall_err(meths.nvim_get_context, { types = { 'jumps', 'zub', 'zam' } })
+ pcall_err(api.nvim_get_context, { types = { 'jumps', 'zub', 'zam' } })
)
end)
it('returns map of current editor state', function()
local opts = { types = { 'regs', 'jumps', 'bufs', 'gvars' } }
- eq({}, parse_context(meths.nvim_get_context({})))
+ eq({}, parse_context(api.nvim_get_context({})))
feed('i1<cr>2<cr>3<c-[>ddddddqahjklquuu')
feed('gg')
feed('G')
command('edit! BUF1')
command('edit BUF2')
- meths.nvim_set_var('one', 1)
- meths.nvim_set_var('Two', 2)
- meths.nvim_set_var('THREE', 3)
+ api.nvim_set_var('one', 1)
+ api.nvim_set_var('Two', 2)
+ api.nvim_set_var('THREE', 3)
local expected_ctx = {
['regs'] = {
@@ -2095,72 +2095,72 @@ describe('API', function()
['gvars'] = { { 'one', 1 }, { 'Two', 2 }, { 'THREE', 3 } },
}
- eq(expected_ctx, parse_context(meths.nvim_get_context(opts)))
- eq(expected_ctx, parse_context(meths.nvim_get_context({})))
- eq(expected_ctx, parse_context(meths.nvim_get_context({ types = {} })))
+ eq(expected_ctx, parse_context(api.nvim_get_context(opts)))
+ eq(expected_ctx, parse_context(api.nvim_get_context({})))
+ eq(expected_ctx, parse_context(api.nvim_get_context({ types = {} })))
end)
end)
describe('nvim_load_context', function()
it('sets current editor state to given context dictionary', function()
local opts = { types = { 'regs', 'jumps', 'bufs', 'gvars' } }
- eq({}, parse_context(meths.nvim_get_context(opts)))
-
- meths.nvim_set_var('one', 1)
- meths.nvim_set_var('Two', 2)
- meths.nvim_set_var('THREE', 3)
- local ctx = meths.nvim_get_context(opts)
- meths.nvim_set_var('one', 'a')
- meths.nvim_set_var('Two', 'b')
- meths.nvim_set_var('THREE', 'c')
+ eq({}, parse_context(api.nvim_get_context(opts)))
+
+ api.nvim_set_var('one', 1)
+ api.nvim_set_var('Two', 2)
+ api.nvim_set_var('THREE', 3)
+ local ctx = api.nvim_get_context(opts)
+ api.nvim_set_var('one', 'a')
+ api.nvim_set_var('Two', 'b')
+ api.nvim_set_var('THREE', 'c')
eq({ 'a', 'b', 'c' }, eval('[g:one, g:Two, g:THREE]'))
- meths.nvim_load_context(ctx)
+ api.nvim_load_context(ctx)
eq({ 1, 2, 3 }, eval('[g:one, g:Two, g:THREE]'))
end)
it('errors when context dictionary is invalid', function()
eq(
'E474: Failed to convert list to msgpack string buffer',
- pcall_err(meths.nvim_load_context, { regs = { {} }, jumps = { {} } })
+ pcall_err(api.nvim_load_context, { regs = { {} }, jumps = { {} } })
)
eq(
'E474: Failed to convert list to msgpack string buffer',
- pcall_err(meths.nvim_load_context, { regs = { { [''] = '' } } })
+ pcall_err(api.nvim_load_context, { regs = { { [''] = '' } } })
)
end)
end)
describe('nvim_replace_termcodes', function()
it('escapes K_SPECIAL as K_SPECIAL KS_SPECIAL KE_FILLER', function()
- eq('\128\254X', helpers.meths.nvim_replace_termcodes('\128', true, true, true))
+ eq('\128\254X', helpers.api.nvim_replace_termcodes('\128', true, true, true))
end)
it('leaves non-K_SPECIAL string unchanged', function()
- eq('abc', helpers.meths.nvim_replace_termcodes('abc', true, true, true))
+ eq('abc', helpers.api.nvim_replace_termcodes('abc', true, true, true))
end)
it('converts <expressions>', function()
- eq('\\', helpers.meths.nvim_replace_termcodes('<Leader>', true, true, true))
+ eq('\\', helpers.api.nvim_replace_termcodes('<Leader>', true, true, true))
end)
it('converts <LeftMouse> to K_SPECIAL KS_EXTRA KE_LEFTMOUSE', function()
-- K_SPECIAL KS_EXTRA KE_LEFTMOUSE
-- 0x80 0xfd 0x2c
-- 128 253 44
- eq('\128\253\44', helpers.meths.nvim_replace_termcodes('<LeftMouse>', true, true, true))
+ eq('\128\253\44', helpers.api.nvim_replace_termcodes('<LeftMouse>', true, true, true))
end)
it('converts keycodes', function()
eq(
'\nx\27x\rx<x',
- helpers.meths.nvim_replace_termcodes('<NL>x<Esc>x<CR>x<lt>x', true, true, true)
+ helpers.api.nvim_replace_termcodes('<NL>x<Esc>x<CR>x<lt>x', true, true, true)
)
end)
it('does not convert keycodes if special=false', function()
eq(
'<NL>x<Esc>x<CR>x<lt>x',
- helpers.meths.nvim_replace_termcodes('<NL>x<Esc>x<CR>x<lt>x', true, true, false)
+ helpers.api.nvim_replace_termcodes('<NL>x<Esc>x<CR>x<lt>x', true, true, false)
)
end)
@@ -2172,13 +2172,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.nvim_replace_termcodes('', true, true, true))
+ eq('', api.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.nvim_replace_termcodes(funcs.keytrans(s), true, true, true))
+ eq(s, api.nvim_replace_termcodes(fn.keytrans(s), true, true, true))
end)
end)
@@ -2186,15 +2186,15 @@ describe('API', function()
it('K_SPECIAL escaping', function()
local function on_setup()
-- notice the special char(…) \xe2\80\xa6
- meths.nvim_feedkeys(':let x1="…"\n', '', true)
+ api.nvim_feedkeys(':let x1="…"\n', '', true)
-- Both nvim_replace_termcodes and nvim_feedkeys escape \x80
- local inp = helpers.meths.nvim_replace_termcodes(':let x2="…"<CR>', true, true, true)
- meths.nvim_feedkeys(inp, '', true) -- escape_ks=true
+ local inp = helpers.api.nvim_replace_termcodes(':let x2="…"<CR>', true, true, true)
+ api.nvim_feedkeys(inp, '', true) -- escape_ks=true
-- nvim_feedkeys with K_SPECIAL escaping disabled
- inp = helpers.meths.nvim_replace_termcodes(':let x3="…"<CR>', true, true, true)
- meths.nvim_feedkeys(inp, '', false) -- escape_ks=false
+ inp = helpers.api.nvim_replace_termcodes(':let x3="…"<CR>', true, true, true)
+ api.nvim_feedkeys(inp, '', false) -- escape_ks=false
helpers.stop()
end
@@ -2202,10 +2202,10 @@ describe('API', function()
-- spin the loop a bit
helpers.run(nil, nil, on_setup)
- eq('…', meths.nvim_get_var('x1'))
+ eq('…', api.nvim_get_var('x1'))
-- Because of the double escaping this is neq
- neq('…', meths.nvim_get_var('x2'))
- eq('…', meths.nvim_get_var('x3'))
+ neq('…', api.nvim_get_var('x2'))
+ eq('…', api.nvim_get_var('x3'))
end)
end)
@@ -2240,7 +2240,7 @@ describe('API', function()
silent! call nvim_out_write("\n")
redir END
]])
- eq('\naaa\n' .. ('a'):rep(5002) .. '\naaa', meths.nvim_get_var('out'))
+ eq('\naaa\n' .. ('a'):rep(5002) .. '\naaa', api.nvim_get_var('out'))
end)
it('blank line in message', function()
@@ -2426,18 +2426,18 @@ describe('API', function()
}
it('returns {} for invalid channel', function()
- eq({}, meths.nvim_get_chan_info(0))
- eq({}, meths.nvim_get_chan_info(-1))
+ eq({}, api.nvim_get_chan_info(0))
+ eq({}, api.nvim_get_chan_info(-1))
-- more preallocated numbers might be added, try something high
- eq({}, meths.nvim_get_chan_info(10))
+ eq({}, api.nvim_get_chan_info(10))
end)
it('stream=stdio channel', function()
- 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))
+ eq({ [1] = testinfo, [2] = stderr }, api.nvim_list_chans())
+ eq(testinfo, api.nvim_get_chan_info(1))
+ eq(stderr, api.nvim_get_chan_info(2))
- meths.nvim_set_client_info(
+ api.nvim_set_client_info(
'functionaltests',
{ major = 0, minor = 3, patch = 17 },
'ui',
@@ -2456,9 +2456,9 @@ describe('API', function()
attributes = { license = 'Apache2' },
},
}
- 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))
+ eq({ info = info }, api.nvim_get_var('info_event'))
+ eq({ [1] = info, [2] = stderr }, api.nvim_list_chans())
+ eq(info, api.nvim_get_chan_info(1))
end)
it('stream=job channel', function()
@@ -2471,9 +2471,9 @@ describe('API', function()
mode = 'rpc',
client = {},
}
- 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))
+ eq({ info = info }, api.nvim_get_var('opened_event'))
+ eq({ [1] = testinfo, [2] = stderr, [3] = info }, api.nvim_list_chans())
+ eq(info, api.nvim_get_chan_info(3))
eval(
'rpcrequest(3, "nvim_set_client_info", "amazing-cat", {}, "remote",'
.. '{"nvim_command":{"n_args":1}},' -- and so on
@@ -2492,8 +2492,8 @@ describe('API', function()
attributes = { description = 'The Amazing Cat' },
},
}
- eq({ info = info }, meths.nvim_get_var('info_event'))
- eq({ [1] = testinfo, [2] = stderr, [3] = info }, meths.nvim_list_chans())
+ eq({ info = info }, api.nvim_get_var('info_event'))
+ eq({ [1] = testinfo, [2] = stderr, [3] = info }, api.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",
@@ -2503,8 +2503,8 @@ describe('API', function()
it('stream=job :terminal channel', function()
command(':terminal')
- eq({ id = 1 }, meths.nvim_get_current_buf())
- eq(3, meths.nvim_get_option_value('channel', { buf = 1 }))
+ eq({ id = 1 }, api.nvim_get_current_buf())
+ eq(3, api.nvim_get_option_value('channel', { buf = 1 }))
local info = {
stream = 'job',
@@ -2514,20 +2514,20 @@ describe('API', function()
buffer = 1,
pty = '?',
}
- local event = meths.nvim_get_var('opened_event')
+ local event = api.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.nvim_list_chans())
- eq(info, meths.nvim_get_chan_info(3))
+ eq({ [1] = testinfo, [2] = stderr, [3] = info }, api.nvim_list_chans())
+ eq(info, api.nvim_get_chan_info(3))
-- :terminal with args + running process.
command('enew')
local progpath_esc = eval('shellescape(v:progpath)')
- funcs.termopen(('%s -u NONE -i NONE'):format(progpath_esc), {
+ fn.termopen(('%s -u NONE -i NONE'):format(progpath_esc), {
env = { VIMRUNTIME = os.getenv('VIMRUNTIME') },
})
eq(-1, eval('jobwait([&channel], 0)[0]')) -- Running?
@@ -2562,13 +2562,13 @@ describe('API', function()
describe('nvim_call_atomic', function()
it('works', function()
- meths.nvim_buf_set_lines(0, 0, -1, true, { 'first' })
+ api.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.nvim_call_atomic(req))
- eq({ 'second' }, meths.nvim_buf_get_lines(0, 0, -1, true))
+ eq({ { 'first', NIL }, NIL }, api.nvim_call_atomic(req))
+ eq({ 'second' }, api.nvim_buf_get_lines(0, 0, -1, true))
end)
it('allows multiple return values', function()
@@ -2578,11 +2578,11 @@ describe('API', function()
{ 'nvim_get_var', { 'avar' } },
{ 'nvim_get_var', { 'bvar' } },
}
- eq({ { NIL, NIL, true, 'string' }, NIL }, meths.nvim_call_atomic(req))
+ eq({ { NIL, NIL, true, 'string' }, NIL }, api.nvim_call_atomic(req))
end)
it('is aborted by errors in call', function()
- local error_types = meths.nvim_get_api_info()[2].error_types
+ local error_types = api.nvim_get_api_info()[2].error_types
local req = {
{ 'nvim_set_var', { 'one', 1 } },
{ 'nvim_buf_set_lines', {} },
@@ -2595,9 +2595,9 @@ describe('API', function()
error_types.Exception.id,
'Wrong number of arguments: expecting 5 but got 0',
},
- }, meths.nvim_call_atomic(req))
- eq(1, meths.nvim_get_var('one'))
- eq(false, pcall(meths.nvim_get_var, 'two'))
+ }, api.nvim_call_atomic(req))
+ eq(1, api.nvim_get_var('one'))
+ eq(false, pcall(api.nvim_get_var, 'two'))
-- still returns all previous successful calls
req = {
@@ -2609,7 +2609,7 @@ describe('API', function()
}
eq(
{ { NIL, NIL, 5 }, { 3, error_types.Validation.id, 'Index out of bounds' } },
- meths.nvim_call_atomic(req)
+ api.nvim_call_atomic(req)
)
req = {
@@ -2618,9 +2618,9 @@ describe('API', function()
}
eq(
{ {}, { 0, error_types.Exception.id, 'Invalid method: i_am_not_a_method' } },
- meths.nvim_call_atomic(req)
+ api.nvim_call_atomic(req)
)
- eq(5, meths.nvim_get_var('avar'))
+ eq(5, api.nvim_get_var('avar'))
end)
it('validation', function()
@@ -2629,28 +2629,25 @@ describe('API', function()
{ 'nvim_set_var' },
{ 'nvim_set_var', { 'avar', 2 } },
}
- eq("Invalid 'calls' item: expected 2-item Array", pcall_err(meths.nvim_call_atomic, req))
+ eq("Invalid 'calls' item: expected 2-item Array", pcall_err(api.nvim_call_atomic, req))
-- call before was done, but not after
- eq(1, meths.nvim_get_var('avar'))
+ eq(1, api.nvim_get_var('avar'))
req = {
{ 'nvim_set_var', { 'bvar', { 2, 3 } } },
12,
}
- eq(
- "Invalid 'calls' item: expected Array, got Integer",
- pcall_err(meths.nvim_call_atomic, req)
- )
- eq({ 2, 3 }, meths.nvim_get_var('bvar'))
+ eq("Invalid 'calls' item: expected Array, got Integer", pcall_err(api.nvim_call_atomic, req))
+ eq({ 2, 3 }, api.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.nvim_call_atomic, req))
+ eq('Invalid call args: expected Array, got String', pcall_err(api.nvim_call_atomic, req))
-- call before was done, but not after
- eq(1, meths.nvim_get_var('avar'))
- eq({ '' }, meths.nvim_buf_get_lines(0, 0, -1, true))
+ eq(1, api.nvim_get_var('avar'))
+ eq({ '' }, api.nvim_buf_get_lines(0, 0, -1, true))
end)
end)
@@ -2664,55 +2661,55 @@ describe('API', function()
rmdir 'Xtest'
end)
before_each(function()
- meths.nvim_set_current_dir 'Xtest'
+ api.nvim_set_current_dir 'Xtest'
end)
it('returns nothing with empty &runtimepath', function()
- meths.nvim_set_option_value('runtimepath', '', {})
- eq({}, meths.nvim_list_runtime_paths())
+ api.nvim_set_option_value('runtimepath', '', {})
+ eq({}, api.nvim_list_runtime_paths())
end)
it('returns single runtimepath', function()
- meths.nvim_set_option_value('runtimepath', 'a', {})
- eq({ 'a' }, meths.nvim_list_runtime_paths())
+ api.nvim_set_option_value('runtimepath', 'a', {})
+ eq({ 'a' }, api.nvim_list_runtime_paths())
end)
it('returns two runtimepaths', function()
- meths.nvim_set_option_value('runtimepath', 'a,b', {})
- eq({ 'a', 'b' }, meths.nvim_list_runtime_paths())
+ api.nvim_set_option_value('runtimepath', 'a,b', {})
+ eq({ 'a', 'b' }, api.nvim_list_runtime_paths())
end)
it('returns empty strings when appropriate', function()
- 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())
+ api.nvim_set_option_value('runtimepath', 'a,,b', {})
+ eq({ 'a', '', 'b' }, api.nvim_list_runtime_paths())
+ api.nvim_set_option_value('runtimepath', ',a,b', {})
+ eq({ '', 'a', 'b' }, api.nvim_list_runtime_paths())
-- Trailing "," is ignored. Use ",," if you really really want CWD.
- 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())
+ api.nvim_set_option_value('runtimepath', 'a,b,', {})
+ eq({ 'a', 'b' }, api.nvim_list_runtime_paths())
+ api.nvim_set_option_value('runtimepath', 'a,b,,', {})
+ eq({ 'a', 'b', '' }, api.nvim_list_runtime_paths())
end)
it('truncates too long paths', function()
local long_path = ('/a'):rep(8192)
- meths.nvim_set_option_value('runtimepath', long_path, {})
- local paths_list = meths.nvim_list_runtime_paths()
+ api.nvim_set_option_value('runtimepath', long_path, {})
+ local paths_list = api.nvim_list_runtime_paths()
eq({}, paths_list)
end)
end)
it('can throw exceptions', function()
- local status, err = pcall(meths.nvim_get_option_value, 'invalid-option', {})
+ local status, err = pcall(api.nvim_get_option_value, 'invalid-option', {})
eq(false, status)
ok(err:match("Unknown option 'invalid%-option'") ~= nil)
end)
it('does not truncate error message <1 MB #5984', function()
local very_long_name = 'A' .. ('x'):rep(10000) .. 'Z'
- local status, err = pcall(meths.nvim_get_option_value, very_long_name, {})
+ local status, err = pcall(api.nvim_get_option_value, very_long_name, {})
eq(false, status)
eq(very_long_name, err:match('Ax+Z?'))
end)
it('does not leak memory on incorrect argument types', function()
- local status, err = pcall(meths.nvim_set_current_dir, { 'not', 'a', 'dir' })
+ local status, err = pcall(api.nvim_set_current_dir, { 'not', 'a', 'dir' })
eq(false, status)
ok(
err:match(': Wrong type for argument 1 when calling nvim_set_current_dir, expecting String')
@@ -2722,7 +2719,7 @@ describe('API', function()
describe('nvim_parse_expression', function()
before_each(function()
- meths.nvim_set_option_value('isident', '', {})
+ api.nvim_set_option_value('isident', '', {})
end)
local function simplify_east_api_node(line, east_api_node)
@@ -2855,7 +2852,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.nvim_parse_expression(str, FLAGS_TO_STR[flags], true)
+ local east_api = api.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)
@@ -2935,7 +2932,7 @@ describe('API', function()
describe('nvim_list_uis', function()
it('returns empty if --headless', function()
-- Test runner defaults to --headless.
- eq({}, meths.nvim_list_uis())
+ eq({}, api.nvim_list_uis())
end)
it('returns attached UIs', function()
local screen = Screen.new(20, 4)
@@ -2964,7 +2961,7 @@ describe('API', function()
},
}
- eq(expected, meths.nvim_list_uis())
+ eq(expected, api.nvim_list_uis())
screen:detach()
screen = Screen.new(44, 99)
@@ -2973,39 +2970,39 @@ describe('API', function()
expected[1].override = false
expected[1].width = 44
expected[1].height = 99
- eq(expected, meths.nvim_list_uis())
+ eq(expected, api.nvim_list_uis())
end)
end)
describe('nvim_create_namespace', function()
it('works', function()
- 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())
+ eq({}, api.nvim_get_namespaces())
+ eq(1, api.nvim_create_namespace('ns-1'))
+ eq(2, api.nvim_create_namespace('ns-2'))
+ eq(1, api.nvim_create_namespace('ns-1'))
+ eq({ ['ns-1'] = 1, ['ns-2'] = 2 }, api.nvim_get_namespaces())
+ eq(3, api.nvim_create_namespace(''))
+ eq(4, api.nvim_create_namespace(''))
+ eq({ ['ns-1'] = 1, ['ns-2'] = 2 }, api.nvim_get_namespaces())
end)
end)
describe('nvim_create_buf', function()
it('works', function()
- eq({ id = 2 }, meths.nvim_create_buf(true, false))
- eq({ id = 3 }, meths.nvim_create_buf(false, false))
+ eq({ id = 2 }, api.nvim_create_buf(true, false))
+ eq({ id = 3 }, api.nvim_create_buf(false, false))
eq(
' 1 %a "[No Name]" line 1\n'
.. ' 2 h "[No Name]" line 0',
command_output('ls')
)
-- current buffer didn't change
- eq({ id = 1 }, meths.nvim_get_current_buf())
+ eq({ id = 1 }, api.nvim_get_current_buf())
local screen = Screen.new(20, 4)
screen:attach()
- meths.nvim_buf_set_lines(2, 0, -1, true, { 'some text' })
- meths.nvim_set_current_buf(2)
+ api.nvim_buf_set_lines(2, 0, -1, true, { 'some text' })
+ api.nvim_set_current_buf(2)
screen:expect(
[[
^some text |
@@ -3019,43 +3016,43 @@ describe('API', function()
end)
it('can change buftype before visiting', function()
- 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' })
+ api.nvim_set_option_value('hidden', false, {})
+ eq({ id = 2 }, api.nvim_create_buf(true, false))
+ api.nvim_set_option_value('buftype', 'nofile', { buf = 2 })
+ api.nvim_buf_set_lines(2, 0, -1, true, { 'test text' })
command('split | buffer 2')
- eq({ id = 2 }, meths.nvim_get_current_buf())
+ eq({ id = 2 }, api.nvim_get_current_buf())
-- if the buf_set_option("buftype") didn't work, this would error out.
command('close')
- eq({ id = 1 }, meths.nvim_get_current_buf())
+ eq({ id = 1 }, api.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.nvim_create_buf(true, false))
- meths.nvim_buf_set_lines(2, 0, -1, true, { 'test', 'text' })
+ eq({ id = 2 }, api.nvim_create_buf(true, false))
+ api.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.nvim_create_buf(true, false)
+ local buf = api.nvim_create_buf(true, false)
command([[let g:changed = '']])
- meths.nvim_create_autocmd({ 'TextChanged', 'TextChangedI' }, {
+ api.nvim_create_autocmd({ 'TextChanged', 'TextChangedI' }, {
buffer = buf,
command = 'let g:changed ..= mode()',
})
- meths.nvim_set_current_buf(buf)
+ api.nvim_set_current_buf(buf)
feed('i')
- eq('', meths.nvim_get_var('changed'))
+ eq('', api.nvim_get_var('changed'))
end)
it('scratch-buffer', function()
- 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))
+ eq({ id = 2 }, api.nvim_create_buf(false, true))
+ eq({ id = 3 }, api.nvim_create_buf(true, true))
+ eq({ id = 4 }, api.nvim_create_buf(true, true))
local scratch_bufs = { 2, 3, 4 }
eq(
' 1 %a "[No Name]" line 1\n'
@@ -3064,7 +3061,7 @@ describe('API', function()
exec_capture('ls')
)
-- current buffer didn't change
- eq({ id = 1 }, meths.nvim_get_current_buf())
+ eq({ id = 1 }, api.nvim_get_current_buf())
local screen = Screen.new(20, 4)
screen:set_default_attr_ids({
@@ -3076,27 +3073,27 @@ describe('API', function()
-- Editing a scratch-buffer does NOT change its properties.
--
local edited_buf = 2
- meths.nvim_buf_set_lines(edited_buf, 0, -1, true, { 'some text' })
+ api.nvim_buf_set_lines(edited_buf, 0, -1, true, { 'some text' })
for _, b in ipairs(scratch_bufs) do
- 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 }))
+ eq('nofile', api.nvim_get_option_value('buftype', { buf = b }))
+ eq('hide', api.nvim_get_option_value('bufhidden', { buf = b }))
+ eq(false, api.nvim_get_option_value('swapfile', { buf = b }))
+ eq(false, api.nvim_get_option_value('modeline', { buf = b }))
end
--
-- Visiting a scratch-buffer DOES NOT change its properties.
--
- meths.nvim_set_current_buf(edited_buf)
+ api.nvim_set_current_buf(edited_buf)
screen:expect([[
^some text |
{1:~ }|*2
|
]])
- 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 }))
+ eq('nofile', api.nvim_get_option_value('buftype', { buf = edited_buf }))
+ eq('hide', api.nvim_get_option_value('bufhidden', { buf = edited_buf }))
+ eq(false, api.nvim_get_option_value('swapfile', { buf = edited_buf }))
+ eq(false, api.nvim_get_option_value('modeline', { buf = edited_buf }))
-- Scratch buffer can be wiped without error.
command('bwipe')
@@ -3118,11 +3115,11 @@ describe('API', function()
describe('nvim_get_runtime_file', function()
local p = helpers.alter_slashes
it('can find files', function()
- 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({}, api.nvim_get_runtime_file('bork.borkbork', false))
+ eq({}, api.nvim_get_runtime_file('bork.borkbork', true))
+ eq(1, #api.nvim_get_runtime_file('autoload/msgpack.vim', false))
+ eq(1, #api.nvim_get_runtime_file('autoload/msgpack.vim', true))
+ local val = api.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'))
@@ -3131,37 +3128,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.nvim_get_runtime_file('autoload/remote/*.vim', false)
+ val = api.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.nvim_get_runtime_file('lua', true)
+ val = api.nvim_get_runtime_file('lua', true)
eq(1, #val)
ok(endswith(val[1], p 'lua'))
- val = meths.nvim_get_runtime_file('lua/vim', true)
+ val = api.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.nvim_get_runtime_file('lua/', true)
+ local val = api.nvim_get_runtime_file('lua/', true)
eq(1, #val)
ok(endswith(val[1], p 'lua/'))
- val = meths.nvim_get_runtime_file('lua/vim/', true)
+ val = api.nvim_get_runtime_file('lua/vim/', true)
eq(1, #val)
ok(endswith(val[1], p 'lua/vim/'))
- eq({}, meths.nvim_get_runtime_file('foobarlang/', true))
+ eq({}, api.nvim_get_runtime_file('foobarlang/', true))
end)
it('can handle bad patterns', function()
skip(is_os('win'))
- eq('Vim:E220: Missing }.', pcall_err(meths.nvim_get_runtime_file, '{', false))
+ eq('Vim:E220: Missing }.', pcall_err(api.nvim_get_runtime_file, '{', false))
eq(
'Vim(echo):E5555: API call: Vim:E220: Missing }.',
@@ -3172,25 +3169,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.nvim_get_all_options_info()
+ local options_info = api.nvim_get_all_options_info()
neq(nil, options_info.listchars)
neq(nil, options_info.tabstop)
- eq(meths.nvim_get_option_info 'winhighlight', options_info.winhighlight)
+ eq(api.nvim_get_option_info 'winhighlight', options_info.winhighlight)
end)
it('should not crash when echoed', function()
- meths.nvim_exec2('echo nvim_get_all_options_info()', { output = true })
+ api.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.nvim_get_option_info, 'bogus'))
+ eq("Invalid option (not found): 'bogus'", pcall_err(api.nvim_get_option_info, 'bogus'))
end)
it('should return the same options for short and long name', function()
- eq(meths.nvim_get_option_info 'winhl', meths.nvim_get_option_info 'winhighlight')
+ eq(api.nvim_get_option_info 'winhl', api.nvim_get_option_info 'winhighlight')
end)
it('should have information about window options', function()
@@ -3208,7 +3205,7 @@ describe('API', function()
shortname = 'winhl',
type = 'string',
was_set = false,
- }, meths.nvim_get_option_info 'winhl')
+ }, api.nvim_get_option_info 'winhl')
end)
it('should have information about buffer options', function()
@@ -3226,13 +3223,13 @@ describe('API', function()
shortname = 'ft',
type = 'string',
was_set = false,
- }, meths.nvim_get_option_info 'filetype')
+ }, api.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.nvim_get_option_value('showcmd', {}))
+ eq(false, api.nvim_get_option_value('showcmd', {}))
eq({
allows_duplicates = true,
@@ -3248,9 +3245,9 @@ describe('API', function()
shortname = 'sc',
type = 'boolean',
was_set = true,
- }, meths.nvim_get_option_info 'showcmd')
+ }, api.nvim_get_option_info 'showcmd')
- meths.nvim_set_option_value('showcmd', true, {})
+ api.nvim_set_option_value('showcmd', true, {})
eq({
allows_duplicates = true,
@@ -3266,7 +3263,7 @@ describe('API', function()
shortname = 'sc',
type = 'boolean',
was_set = true,
- }, meths.nvim_get_option_info 'showcmd')
+ }, api.nvim_get_option_info 'showcmd')
end)
end)
@@ -3293,18 +3290,18 @@ describe('API', function()
)
exec_lua 'vim.cmd.vsplit()'
- meths.nvim_create_buf(false, false)
+ api.nvim_create_buf(false, false)
- bufs = meths.nvim_list_bufs()
- wins = meths.nvim_list_wins()
+ bufs = api.nvim_list_bufs()
+ wins = api.nvim_list_wins()
- meths.nvim_win_set_buf(wins[1].id, bufs[1].id)
- meths.nvim_win_set_buf(wins[2].id, bufs[2].id)
+ api.nvim_win_set_buf(wins[1].id, bufs[1].id)
+ api.nvim_win_set_buf(wins[2].id, bufs[2].id)
- meths.nvim_set_current_win(wins[2].id)
- meths.nvim_exec('source ' .. fname, false)
+ api.nvim_set_current_win(wins[2].id)
+ api.nvim_exec('source ' .. fname, false)
- meths.nvim_set_current_win(wins[1].id)
+ api.nvim_set_current_win(wins[1].id)
end)
after_each(function()
@@ -3312,9 +3309,9 @@ describe('API', function()
end)
it('should return option information', function()
- 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
+ eq(api.nvim_get_option_info('dictionary'), api.nvim_get_option_info2('dictionary', {})) -- buffer
+ eq(api.nvim_get_option_info('fillchars'), api.nvim_get_option_info2('fillchars', {})) -- window
+ eq(api.nvim_get_option_info('completeopt'), api.nvim_get_option_info2('completeopt', {})) -- global
end)
describe('last set', function()
@@ -3346,21 +3343,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.nvim_set_current_win(wins[2].id)
- local info = meths.nvim_get_option_info2(unpack(t.args))
+ api.nvim_set_current_win(wins[2].id)
+ local info = api.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.nvim_get_option_info2('formatprg', { buf = bufs[2].id })
+ local info = api.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.nvim_get_option_info2('listchars', { win = wins[2].id })
+ local info = api.nvim_get_option_info2('listchars', { win = wins[2].id })
eq(6, info.last_set_linenr)
eq(1, info.last_set_sid)
end)
@@ -3427,7 +3424,7 @@ describe('API', function()
it('can save message history', function()
command('set cmdheight=2') -- suppress Press ENTER
- meths.nvim_echo({ { 'msg\nmsg' }, { 'msg' } }, true, {})
+ api.nvim_echo({ { 'msg\nmsg' }, { 'msg' } }, true, {})
eq('msg\nmsgmsg', exec_capture('messages'))
end)
@@ -3465,15 +3462,15 @@ describe('API', function()
end)
it('can batch process sequences', function()
- local b = meths.nvim_create_buf(true, true)
- meths.nvim_open_win(
+ local b = api.nvim_create_buf(true, true)
+ api.nvim_open_win(
b,
false,
{ width = 79, height = 31, row = 1, col = 1, relative = 'editor' }
)
- local t = meths.nvim_open_term(b, {})
+ local t = api.nvim_open_term(b, {})
- meths.nvim_chan_send(t, io.open('test/functional/fixtures/smile2.cat', 'r'):read('*a'))
+ api.nvim_chan_send(t, io.open('test/functional/fixtures/smile2.cat', 'r'):read('*a'))
screen:expect {
grid = [[
^ |
@@ -3579,56 +3576,53 @@ describe('API', function()
describe('nvim_del_mark', function()
it('works', function()
- 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'))
+ local buf = api.nvim_create_buf(false, true)
+ api.nvim_buf_set_lines(buf, -1, -1, true, { 'a', 'bit of', 'text' })
+ eq(true, api.nvim_buf_set_mark(buf, 'F', 2, 2, {}))
+ eq(true, api.nvim_del_mark('F'))
+ eq({ 0, 0 }, api.nvim_buf_get_mark(buf, 'F'))
end)
it('validation', function()
- 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')
- )
+ eq("Invalid mark name (must be file/uppercase): 'f'", pcall_err(api.nvim_del_mark, 'f'))
+ eq("Invalid mark name (must be file/uppercase): '!'", pcall_err(api.nvim_del_mark, '!'))
+ eq("Invalid mark name (must be a single char): 'fail'", pcall_err(api.nvim_del_mark, 'fail'))
end)
end)
describe('nvim_get_mark', function()
it('works', function()
- 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', {})
+ local buf = api.nvim_create_buf(false, true)
+ api.nvim_buf_set_lines(buf, -1, -1, true, { 'a', 'bit of', 'text' })
+ api.nvim_buf_set_mark(buf, 'F', 2, 2, {})
+ api.nvim_buf_set_name(buf, 'mybuf')
+ local mark = api.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.nvim_get_mark, 'f', {}))
- eq("Invalid mark name (must be file/uppercase): '!'", pcall_err(meths.nvim_get_mark, '!', {}))
+ eq("Invalid mark name (must be file/uppercase): 'f'", pcall_err(api.nvim_get_mark, 'f', {}))
+ eq("Invalid mark name (must be file/uppercase): '!'", pcall_err(api.nvim_get_mark, '!', {}))
eq(
"Invalid mark name (must be a single char): 'fail'",
- pcall_err(meths.nvim_get_mark, 'fail', {})
+ pcall_err(api.nvim_get_mark, 'fail', {})
)
end)
it('returns the expected when mark is not set', function()
- eq(true, meths.nvim_del_mark('A'))
- eq({ 0, 0, 0, '' }, meths.nvim_get_mark('A', {}))
+ eq(true, api.nvim_del_mark('A'))
+ eq({ 0, 0, 0, '' }, api.nvim_get_mark('A', {}))
end)
it('works with deleted buffers', function()
local fname = tmpname()
write_file(fname, 'a\nbit of\text')
command('edit ' .. fname)
- local buf = meths.nvim_get_current_buf()
+ local buf = api.nvim_get_current_buf()
- meths.nvim_buf_set_mark(buf, 'F', 2, 2, {})
+ api.nvim_buf_set_mark(buf, 'F', 2, 2, {})
command('new') -- Create new buf to avoid :bd failing
command('bd! ' .. buf.id)
os.remove(fname)
- local mark = meths.nvim_get_mark('F', {})
+ local mark = api.nvim_get_mark('F', {})
-- To avoid comparing relative vs absolute path
local mfname = mark[4]
local tail_patt = [[[\/][^\/]*$]]
@@ -3642,72 +3636,72 @@ describe('API', function()
eq({
str = '%StatusLineStringWithHighlights',
width = 31,
- }, meths.nvim_eval_statusline('%%StatusLineString%#WarningMsg#WithHighlights', {}))
+ }, api.nvim_eval_statusline('%%StatusLineString%#WarningMsg#WithHighlights', {}))
end)
it("doesn't exceed maxwidth", function()
eq({
str = 'Should be trun>',
width = 15,
- }, meths.nvim_eval_statusline('Should be truncated%<', { maxwidth = 15 }))
+ }, api.nvim_eval_statusline('Should be truncated%<', { maxwidth = 15 }))
end)
it('supports ASCII fillchar', function()
eq(
{ str = 'a~~~b', width = 5 },
- meths.nvim_eval_statusline('a%=b', { fillchar = '~', maxwidth = 5 })
+ api.nvim_eval_statusline('a%=b', { fillchar = '~', maxwidth = 5 })
)
end)
it('supports single-width multibyte fillchar', function()
eq(
{ str = 'a━━━b', width = 5 },
- meths.nvim_eval_statusline('a%=b', { fillchar = '━', maxwidth = 5 })
+ api.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.nvim_eval_statusline('a%=b', { fillchar = '哦', maxwidth = 5 })
+ api.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.nvim_eval_statusline('a%=b', { fillchar = '\031', maxwidth = 5 })
+ api.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.nvim_eval_statusline, '', { fillchar = 'aa' })
+ pcall_err(api.nvim_eval_statusline, '', { fillchar = 'aa' })
)
end)
it('rejects empty string fillchar', function()
eq(
"Invalid 'fillchar': expected single character",
- pcall_err(meths.nvim_eval_statusline, '', { fillchar = '' })
+ pcall_err(api.nvim_eval_statusline, '', { fillchar = '' })
)
end)
it('rejects non-string fillchar', function()
eq(
"Invalid 'fillchar': expected String, got Integer",
- pcall_err(meths.nvim_eval_statusline, '', { fillchar = 1 })
+ pcall_err(api.nvim_eval_statusline, '', { fillchar = 1 })
)
end)
it('rejects invalid string', function()
- eq('E539: Illegal character <}>', pcall_err(meths.nvim_eval_statusline, '%{%}', {}))
+ eq('E539: Illegal character <}>', pcall_err(api.nvim_eval_statusline, '%{%}', {}))
end)
it('supports various items', function()
- eq({ str = '0', width = 1 }, meths.nvim_eval_statusline('%l', { maxwidth = 5 }))
+ eq({ str = '0', width = 1 }, api.nvim_eval_statusline('%l', { maxwidth = 5 }))
command('set readonly')
- eq({ str = '[RO]', width = 4 }, meths.nvim_eval_statusline('%r', { maxwidth = 5 }))
+ eq({ str = '[RO]', width = 4 }, api.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.nvim_eval_statusline('%S', { maxwidth = 5 }))
+ eq({ str = '1234', width = 4 }, api.nvim_eval_statusline('%S', { maxwidth = 5 }))
feed('56')
screen:expect({ any = '123456' })
- eq({ str = '<3456', width = 5 }, meths.nvim_eval_statusline('%S', { maxwidth = 5 }))
+ eq({ str = '<3456', width = 5 }, api.nvim_eval_statusline('%S', { maxwidth = 5 }))
end)
describe('highlight parsing', function()
it('works', function()
@@ -3720,7 +3714,7 @@ describe('API', function()
{ start = 24, group = 'User1' },
},
},
- meths.nvim_eval_statusline(
+ api.nvim_eval_statusline(
'%#WarningMsg#TextWithWarningHighlight%1*TextWithUserHighlight',
{ highlights = true }
)
@@ -3733,7 +3727,7 @@ describe('API', function()
highlights = {
{ start = 0, group = 'StatusLine' },
},
- }, meths.nvim_eval_statusline('TextWithNoHighlight', { highlights = true }))
+ }, api.nvim_eval_statusline('TextWithNoHighlight', { highlights = true }))
end)
it('works with inactive statusline', function()
command('split')
@@ -3747,9 +3741,9 @@ describe('API', function()
{ start = 19, group = 'WarningMsg' },
},
},
- meths.nvim_eval_statusline(
+ api.nvim_eval_statusline(
'TextWithNoHighlight%#WarningMsg#TextWithWarningHighlight',
- { winid = meths.nvim_list_wins()[2].id, highlights = true }
+ { winid = api.nvim_list_wins()[2].id, highlights = true }
)
)
end)
@@ -3763,7 +3757,7 @@ describe('API', function()
{ start = 19, group = 'WarningMsg' },
},
},
- meths.nvim_eval_statusline(
+ api.nvim_eval_statusline(
'TextWithNoHighlight%#WarningMsg#TextWithWarningHighlight',
{ use_tabline = true, highlights = true }
)
@@ -3779,7 +3773,7 @@ describe('API', function()
{ start = 19, group = 'WarningMsg' },
},
},
- meths.nvim_eval_statusline(
+ api.nvim_eval_statusline(
'TextWithNoHighlight%#WarningMsg#TextWithWarningHighlight',
{ use_winbar = true, highlights = true }
)
@@ -3807,7 +3801,7 @@ describe('API', function()
{ group = 'ErrorMsg', start = 8 },
{ group = 'Normal', start = 10 },
},
- }, meths.nvim_eval_statusline(
+ }, api.nvim_eval_statusline(
'%C%s%=%l ',
{ use_statuscol_lnum = 4, highlights = true }
))
@@ -3820,18 +3814,15 @@ describe('API', function()
{ group = 'ErrorMsg', start = 1 },
},
},
- meths.nvim_eval_statusline(
- '%l%#ErrorMsg# ',
- { use_statuscol_lnum = 3, highlights = true }
- )
+ api.nvim_eval_statusline('%l%#ErrorMsg# ', { use_statuscol_lnum = 3, highlights = true })
)
end)
it('no memory leak with click functions', function()
- meths.nvim_eval_statusline('%@ClickFunc@StatusLineStringWithClickFunc%T', {})
+ api.nvim_eval_statusline('%@ClickFunc@StatusLineStringWithClickFunc%T', {})
eq({
str = 'StatusLineStringWithClickFunc',
width = 29,
- }, meths.nvim_eval_statusline('%@ClickFunc@StatusLineStringWithClickFunc%T', {}))
+ }, api.nvim_eval_statusline('%@ClickFunc@StatusLineStringWithClickFunc%T', {}))
end)
end)
end)
@@ -3874,7 +3865,7 @@ describe('API', function()
verbose = -1,
vertical = false,
},
- }, meths.nvim_parse_cmd('echo foo', {}))
+ }, api.nvim_parse_cmd('echo foo', {}))
end)
it('works with ranges', function()
eq({
@@ -3914,7 +3905,7 @@ describe('API', function()
verbose = -1,
vertical = false,
},
- }, meths.nvim_parse_cmd('4,6s/math.random/math.max/', {}))
+ }, api.nvim_parse_cmd('4,6s/math.random/math.max/', {}))
end)
it('works with count', function()
eq({
@@ -3955,7 +3946,7 @@ describe('API', function()
verbose = -1,
vertical = false,
},
- }, meths.nvim_parse_cmd('buffer 1', {}))
+ }, api.nvim_parse_cmd('buffer 1', {}))
end)
it('works with register', function()
eq({
@@ -3996,7 +3987,7 @@ describe('API', function()
verbose = -1,
vertical = false,
},
- }, meths.nvim_parse_cmd('put +', {}))
+ }, api.nvim_parse_cmd('put +', {}))
eq({
cmd = 'put',
args = {},
@@ -4035,7 +4026,7 @@ describe('API', function()
verbose = -1,
vertical = false,
},
- }, meths.nvim_parse_cmd('put', {}))
+ }, api.nvim_parse_cmd('put', {}))
end)
it('works with range, count and register', function()
eq({
@@ -4077,7 +4068,7 @@ describe('API', function()
verbose = -1,
vertical = false,
},
- }, meths.nvim_parse_cmd('1,3delete * 5', {}))
+ }, api.nvim_parse_cmd('1,3delete * 5', {}))
end)
it('works with bang', function()
eq({
@@ -4117,7 +4108,7 @@ describe('API', function()
verbose = -1,
vertical = false,
},
- }, meths.nvim_parse_cmd('w!', {}))
+ }, api.nvim_parse_cmd('w!', {}))
end)
it('works with modifiers', function()
eq(
@@ -4159,7 +4150,7 @@ describe('API', function()
vertical = false,
},
},
- meths.nvim_parse_cmd(
+ api.nvim_parse_cmd(
'15verbose silent! horizontal topleft tab filter /foo/ split foo.txt',
{}
)
@@ -4203,7 +4194,7 @@ describe('API', function()
vertical = false,
},
},
- meths.nvim_parse_cmd(
+ api.nvim_parse_cmd(
'0verbose unsilent botright 0tab confirm filter! /foo/ split foo.txt',
{}
)
@@ -4248,7 +4239,7 @@ describe('API', function()
verbose = -1,
vertical = false,
},
- }, meths.nvim_parse_cmd('4,6MyCommand! test it', {}))
+ }, api.nvim_parse_cmd('4,6MyCommand! test it', {}))
end)
it('works for commands separated by bar', function()
eq({
@@ -4288,7 +4279,7 @@ describe('API', function()
verbose = -1,
vertical = false,
},
- }, meths.nvim_parse_cmd('argadd a.txt | argadd b.txt', {}))
+ }, api.nvim_parse_cmd('argadd a.txt | argadd b.txt', {}))
end)
it('works for nargs=1', function()
command('command -nargs=1 MyCommand echo <q-args>')
@@ -4328,28 +4319,28 @@ describe('API', function()
verbose = -1,
vertical = false,
},
- }, meths.nvim_parse_cmd('MyCommand test it', {}))
+ }, api.nvim_parse_cmd('MyCommand test it', {}))
end)
it('validates command', function()
- 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', pcall_err(api.nvim_parse_cmd, '', {}))
+ eq('Error while parsing command line', pcall_err(api.nvim_parse_cmd, '" foo', {}))
eq(
'Error while parsing command line: E492: Not an editor command: Fubar',
- pcall_err(meths.nvim_parse_cmd, 'Fubar', {})
+ pcall_err(api.nvim_parse_cmd, 'Fubar', {})
)
command('command! Fubar echo foo')
eq(
'Error while parsing command line: E477: No ! allowed',
- pcall_err(meths.nvim_parse_cmd, 'Fubar!', {})
+ pcall_err(api.nvim_parse_cmd, 'Fubar!', {})
)
eq(
'Error while parsing command line: E481: No range allowed',
- pcall_err(meths.nvim_parse_cmd, '4,6Fubar', {})
+ pcall_err(api.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.nvim_parse_cmd, 'F', {})
+ pcall_err(api.nvim_parse_cmd, 'F', {})
)
end)
it('does not interfere with printing line in Ex mode #19400', function()
@@ -4371,7 +4362,7 @@ describe('API', function()
Entering Ex mode. Type "visual" to go to Normal mode. |
:1^ |
]])
- eq('Error while parsing command line', pcall_err(meths.nvim_parse_cmd, '', {}))
+ eq('Error while parsing command line', pcall_err(api.nvim_parse_cmd, '', {}))
feed('<CR>')
screen:expect([[
foo |
@@ -4384,10 +4375,10 @@ describe('API', function()
]])
end)
it('does not move cursor or change search history/pattern #19878 #19890', function()
- 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'))
+ api.nvim_buf_set_lines(0, 0, -1, true, { 'foo', 'bar', 'foo', 'bar' })
+ eq({ 1, 0 }, api.nvim_win_get_cursor(0))
+ eq('', fn.getreg('/'))
+ eq('', fn.histget('search'))
feed(':') -- call the API in cmdline mode to test whether it changes search history
eq({
cmd = 'normal',
@@ -4426,15 +4417,15 @@ describe('API', function()
verbose = -1,
vertical = false,
},
- }, meths.nvim_parse_cmd('+2;/bar/normal! x', {}))
- eq({ 1, 0 }, meths.nvim_win_get_cursor(0))
- eq('', funcs.getreg('/'))
- eq('', funcs.histget('search'))
+ }, api.nvim_parse_cmd('+2;/bar/normal! x', {}))
+ eq({ 1, 0 }, api.nvim_win_get_cursor(0))
+ eq('', fn.getreg('/'))
+ eq('', fn.histget('search'))
end)
it('result can be used directly by nvim_cmd #20051', function()
- 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', {}))
+ eq('foo', api.nvim_cmd(api.nvim_parse_cmd('echo "foo"', {}), { output = true }))
+ api.nvim_cmd(api.nvim_parse_cmd('set cursorline', {}), {})
+ eq(true, api.nvim_get_option_value('cursorline', {}))
end)
it('no side-effects (error messages) in pcall() #20339', function()
eq(
@@ -4447,86 +4438,83 @@ describe('API', function()
describe('nvim_cmd', function()
it('works', function()
- meths.nvim_cmd({ cmd = 'set', args = { 'cursorline' } }, {})
- eq(true, meths.nvim_get_option_value('cursorline', {}))
+ api.nvim_cmd({ cmd = 'set', args = { 'cursorline' } }, {})
+ eq(true, api.nvim_get_option_value('cursorline', {}))
end)
it('validation', function()
- 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 'cmd': expected non-empty String", pcall_err(api.nvim_cmd, { cmd = '' }, {}))
+ eq("Invalid 'cmd': expected String, got Array", pcall_err(api.nvim_cmd, { cmd = {} }, {}))
eq(
"Invalid 'args': expected Array, got Boolean",
- pcall_err(meths.nvim_cmd, { cmd = 'set', args = true }, {})
+ pcall_err(api.nvim_cmd, { cmd = 'set', args = true }, {})
)
eq(
'Invalid command arg: expected non-whitespace',
- pcall_err(meths.nvim_cmd, { cmd = 'set', args = { ' ' } }, {})
+ pcall_err(api.nvim_cmd, { cmd = 'set', args = { ' ' } }, {})
)
eq(
'Invalid command arg: expected valid type, got Array',
- pcall_err(meths.nvim_cmd, { cmd = 'set', args = { {} } }, {})
- )
- eq(
- 'Wrong number of arguments',
- pcall_err(meths.nvim_cmd, { cmd = 'aboveleft', args = {} }, {})
+ pcall_err(api.nvim_cmd, { cmd = 'set', args = { {} } }, {})
)
+ eq('Wrong number of arguments', pcall_err(api.nvim_cmd, { cmd = 'aboveleft', args = {} }, {}))
eq(
'Command cannot accept bang: print',
- pcall_err(meths.nvim_cmd, { cmd = 'print', args = {}, bang = true }, {})
+ pcall_err(api.nvim_cmd, { cmd = 'print', args = {}, bang = true }, {})
)
eq(
'Command cannot accept range: set',
- pcall_err(meths.nvim_cmd, { cmd = 'set', args = {}, range = { 1 } }, {})
+ pcall_err(api.nvim_cmd, { cmd = 'set', args = {}, range = { 1 } }, {})
)
eq(
"Invalid 'range': expected Array, got Boolean",
- pcall_err(meths.nvim_cmd, { cmd = 'print', args = {}, range = true }, {})
+ pcall_err(api.nvim_cmd, { cmd = 'print', args = {}, range = true }, {})
)
eq(
"Invalid 'range': expected <=2 elements",
- pcall_err(meths.nvim_cmd, { cmd = 'print', args = {}, range = { 1, 2, 3, 4 } }, {})
+ pcall_err(api.nvim_cmd, { cmd = 'print', args = {}, range = { 1, 2, 3, 4 } }, {})
)
eq(
'Invalid range element: expected non-negative Integer',
- pcall_err(meths.nvim_cmd, { cmd = 'print', args = {}, range = { -1 } }, {})
+ pcall_err(api.nvim_cmd, { cmd = 'print', args = {}, range = { -1 } }, {})
)
eq(
'Command cannot accept count: set',
- pcall_err(meths.nvim_cmd, { cmd = 'set', args = {}, count = 1 }, {})
+ pcall_err(api.nvim_cmd, { cmd = 'set', args = {}, count = 1 }, {})
)
eq(
"Invalid 'count': expected Integer, got Boolean",
- pcall_err(meths.nvim_cmd, { cmd = 'print', args = {}, count = true }, {})
+ pcall_err(api.nvim_cmd, { cmd = 'print', args = {}, count = true }, {})
)
eq(
"Invalid 'count': expected non-negative Integer",
- pcall_err(meths.nvim_cmd, { cmd = 'print', args = {}, count = -1 }, {})
+ pcall_err(api.nvim_cmd, { cmd = 'print', args = {}, count = -1 }, {})
)
eq(
'Command cannot accept register: set',
- pcall_err(meths.nvim_cmd, { cmd = 'set', args = {}, reg = 'x' }, {})
+ pcall_err(api.nvim_cmd, { cmd = 'set', args = {}, reg = 'x' }, {})
)
eq(
'Cannot use register "=',
- pcall_err(meths.nvim_cmd, { cmd = 'put', args = {}, reg = '=' }, {})
+ pcall_err(api.nvim_cmd, { cmd = 'put', args = {}, reg = '=' }, {})
)
eq(
"Invalid 'reg': expected single character, got xx",
- pcall_err(meths.nvim_cmd, { cmd = 'put', args = {}, reg = 'xx' }, {})
+ pcall_err(api.nvim_cmd, { cmd = 'put', args = {}, reg = 'xx' }, {})
)
-- #20681
- 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(api.nvim_cmd, { cmd = 'win_getid' }, {}))
+ eq('Invalid command: "echo "hi""', pcall_err(api.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.nvim_cmd({ cmd = 'set', args = {}, magic = {} }, {}))
+ eq('', api.nvim_cmd({ cmd = 'set', args = {}, magic = {} }, {}))
-- Lua call does not allow non-empty list-like {} for dict item.
eq(
@@ -4544,11 +4532,11 @@ describe('API', function()
end)
it('captures output', function()
- eq('foo', meths.nvim_cmd({ cmd = 'echo', args = { '"foo"' } }, { output = true }))
+ eq('foo', api.nvim_cmd({ cmd = 'echo', args = { '"foo"' } }, { output = true }))
end)
it('sets correct script context', function()
- meths.nvim_cmd({ cmd = 'set', args = { 'cursorline' } }, {})
+ api.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)
@@ -4563,7 +4551,7 @@ describe('API', function()
line5
line6
]]
- meths.nvim_cmd({ cmd = 'del', range = { 2, 4 } }, {})
+ api.nvim_cmd({ cmd = 'del', range = { 2, 4 } }, {})
expect [[
line1
you didn't expect this
@@ -4581,7 +4569,7 @@ describe('API', function()
line5
line6
]]
- meths.nvim_cmd({ cmd = 'del', range = { 2 }, count = 4 }, {})
+ api.nvim_cmd({ cmd = 'del', range = { 2 }, count = 4 }, {})
expect [[
line1
line5
@@ -4598,7 +4586,7 @@ describe('API', function()
line5
line6
]]
- meths.nvim_cmd({ cmd = 'del', range = { 2, 4 }, reg = 'a' }, {})
+ api.nvim_cmd({ cmd = 'del', range = { 2, 4 }, reg = 'a' }, {})
command('1put a')
expect [[
line1
@@ -4611,29 +4599,29 @@ describe('API', function()
]]
end)
it('works with bang', function()
- 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 }))
+ api.nvim_create_user_command('Foo', 'echo "<bang>"', { bang = true })
+ eq('!', api.nvim_cmd({ cmd = 'Foo', bang = true }, { output = true }))
+ eq('', api.nvim_cmd({ cmd = 'Foo', bang = false }, { output = true }))
end)
it('works with modifiers', function()
-- with silent = true output is still captured
eq(
'1',
- meths.nvim_cmd(
+ api.nvim_cmd(
{ cmd = 'echomsg', args = { '1' }, mods = { silent = true } },
{ output = true }
)
)
-- but message isn't added to message history
- eq('', meths.nvim_cmd({ cmd = 'messages' }, { output = true }))
+ eq('', api.nvim_cmd({ cmd = 'messages' }, { output = true }))
- meths.nvim_create_user_command('Foo', 'set verbose', {})
- eq(' verbose=1', meths.nvim_cmd({ cmd = 'Foo', mods = { verbose = 1 } }, { output = true }))
+ api.nvim_create_user_command('Foo', 'set verbose', {})
+ eq(' verbose=1', api.nvim_cmd({ cmd = 'Foo', mods = { verbose = 1 } }, { output = true }))
- meths.nvim_create_user_command('Mods', "echo '<mods>'", {})
+ api.nvim_create_user_command('Mods', "echo '<mods>'", {})
eq(
'keepmarks keeppatterns silent 3verbose aboveleft horizontal',
- meths.nvim_cmd({
+ api.nvim_cmd({
cmd = 'Mods',
mods = {
horizontal = true,
@@ -4645,19 +4633,19 @@ describe('API', function()
},
}, { output = true })
)
- eq(0, meths.nvim_get_option_value('verbose', {}))
+ eq(0, api.nvim_get_option_value('verbose', {}))
command('edit foo.txt | edit bar.txt')
eq(
' 1 #h "foo.txt" line 1',
- meths.nvim_cmd(
+ api.nvim_cmd(
{ cmd = 'buffers', mods = { filter = { pattern = 'foo', force = false } } },
{ output = true }
)
)
eq(
' 2 %a "bar.txt" line 1',
- meths.nvim_cmd(
+ api.nvim_cmd(
{ cmd = 'buffers', mods = { filter = { pattern = 'foo', force = true } } },
{ output = true }
)
@@ -4665,10 +4653,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.nvim_cmd({ cmd = 'messages' }, { output = true }))
+ eq('', api.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.nvim_cmd({ cmd = 'messages' }, { output = true }))
+ eq('E471: Argument required', api.nvim_cmd({ cmd = 'messages' }, { output = true }))
end)
it('works with magic.file', function()
exec_lua([[
@@ -4678,7 +4666,7 @@ describe('API', function()
]])
eq(
uv.cwd(),
- meths.nvim_cmd(
+ api.nvim_cmd(
{ cmd = 'Foo', args = { '%:p:h' }, magic = { file = true } },
{ output = true }
)
@@ -4690,24 +4678,24 @@ describe('API', function()
echo a:000
endfunction
]])
- meths.nvim_create_user_command('Foo', 'call FooFunc(<f-args>)', { nargs = '+' })
+ api.nvim_create_user_command('Foo', 'call FooFunc(<f-args>)', { nargs = '+' })
eq(
[=[['a quick', 'brown fox', 'jumps over the', 'lazy dog']]=],
- meths.nvim_cmd(
+ api.nvim_cmd(
{ cmd = 'Foo', args = { 'a quick', 'brown fox', 'jumps over the', 'lazy dog' } },
{ output = true }
)
)
eq(
[=[['test \ \\ \"""\', 'more\ tests\" ']]=],
- meths.nvim_cmd(
+ api.nvim_cmd(
{ cmd = 'Foo', args = { [[test \ \\ \"""\]], [[more\ tests\" ]] } },
{ output = true }
)
)
end)
it('splits arguments correctly for Lua callback', function()
- meths.nvim_exec_lua(
+ api.nvim_exec_lua(
[[
local function FooFunc(opts)
vim.print(opts.fargs)
@@ -4719,14 +4707,14 @@ describe('API', function()
)
eq(
[[{ "a quick", "brown fox", "jumps over the", "lazy dog" }]],
- meths.nvim_cmd(
+ api.nvim_cmd(
{ cmd = 'Foo', args = { 'a quick', 'brown fox', 'jumps over the', 'lazy dog' } },
{ output = true }
)
)
eq(
[[{ 'test \\ \\\\ \\"""\\', 'more\\ tests\\" ' }]],
- meths.nvim_cmd(
+ api.nvim_cmd(
{ cmd = 'Foo', args = { [[test \ \\ \"""\]], [[more\ tests\" ]] } },
{ output = true }
)
@@ -4734,13 +4722,13 @@ describe('API', function()
end)
it('works with buffer names', function()
command('edit foo.txt | edit bar.txt')
- 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'))
+ api.nvim_cmd({ cmd = 'buffer', args = { 'foo.txt' } }, {})
+ eq('foo.txt', fn.fnamemodify(api.nvim_buf_get_name(0), ':t'))
+ api.nvim_cmd({ cmd = 'buffer', args = { 'bar.txt' } }, {})
+ eq('bar.txt', fn.fnamemodify(api.nvim_buf_get_name(0), ':t'))
end)
it('triggers CmdUndefined event if command is not found', function()
- meths.nvim_exec_lua(
+ api.nvim_exec_lua(
[[
vim.api.nvim_create_autocmd("CmdUndefined",
{ pattern = "Foo",
@@ -4751,17 +4739,17 @@ describe('API', function()
]],
{}
)
- eq('foo', meths.nvim_cmd({ cmd = 'Foo' }, { output = true }))
+ eq('foo', api.nvim_cmd({ cmd = 'Foo' }, { output = true }))
end)
it('errors if command is not implemented', function()
- eq('Command not implemented: winpos', pcall_err(meths.nvim_cmd, { cmd = 'winpos' }, {}))
+ eq('Command not implemented: winpos', pcall_err(api.nvim_cmd, { cmd = 'winpos' }, {}))
end)
it('works with empty arguments list', function()
- meths.nvim_cmd({ cmd = 'update' }, {})
- meths.nvim_cmd({ cmd = 'buffer', count = 0 }, {})
+ api.nvim_cmd({ cmd = 'update' }, {})
+ api.nvim_cmd({ cmd = 'buffer', count = 0 }, {})
end)
it("doesn't suppress errors when used in keymapping", function()
- meths.nvim_exec_lua(
+ api.nvim_exec_lua(
[[
vim.keymap.set("n", "[l",
function() vim.api.nvim_cmd({ cmd = "echo", args = {"foo"} }, {}) end)
@@ -4772,31 +4760,31 @@ describe('API', function()
neq(nil, string.find(eval('v:errmsg'), 'E5108:'))
end)
it('handles 0 range #19608', function()
- meths.nvim_buf_set_lines(0, 0, -1, false, { 'aa' })
- meths.nvim_cmd({ cmd = 'delete', range = { 0 } }, {})
+ api.nvim_buf_set_lines(0, 0, -1, false, { 'aa' })
+ api.nvim_cmd({ cmd = 'delete', range = { 0 } }, {})
command('undo')
- eq({ 'aa' }, meths.nvim_buf_get_lines(0, 0, 1, false))
+ eq({ 'aa' }, api.nvim_buf_get_lines(0, 0, 1, false))
assert_alive()
end)
it('supports filename expansion', function()
- meths.nvim_cmd({ cmd = 'argadd', args = { '%:p:h:t', '%:p:h:t' } }, {})
- local arg = funcs.expand('%:p:h:t')
- eq({ arg, arg }, funcs.argv())
+ api.nvim_cmd({ cmd = 'argadd', args = { '%:p:h:t', '%:p:h:t' } }, {})
+ local arg = fn.expand('%:p:h:t')
+ eq({ arg, arg }, fn.argv())
end)
it("'make' command works when argument count isn't 1 #19696", function()
command('set makeprg=echo')
command('set shellquote=')
- matches('^:!echo ', meths.nvim_cmd({ cmd = 'make' }, { output = true }))
+ matches('^:!echo ', api.nvim_cmd({ cmd = 'make' }, { output = true }))
assert_alive()
matches(
'^:!echo foo bar',
- meths.nvim_cmd({ cmd = 'make', args = { 'foo', 'bar' } }, { output = true })
+ api.nvim_cmd({ cmd = 'make', args = { 'foo', 'bar' } }, { output = true })
)
assert_alive()
- local arg_pesc = pesc(funcs.expand('%:p:h:t'))
+ local arg_pesc = pesc(fn.expand('%:p:h:t'))
matches(
('^:!echo %s %s'):format(arg_pesc, arg_pesc),
- meths.nvim_cmd({ cmd = 'make', args = { '%:p:h:t', '%:p:h:t' } }, { output = true })
+ api.nvim_cmd({ cmd = 'make', args = { '%:p:h:t', '%:p:h:t' } }, { output = true })
)
assert_alive()
end)
@@ -4806,7 +4794,7 @@ describe('API', function()
screen:set_default_attr_ids({
[0] = { bold = true, foreground = Screen.colors.Blue },
})
- meths.nvim_cmd({ cmd = 'echo', args = { [['hello']] } }, { output = true })
+ api.nvim_cmd({ cmd = 'echo', args = { [['hello']] } }, { output = true })
screen:expect {
grid = [[
^ |
@@ -4829,29 +4817,29 @@ describe('API', function()
}
end)
it('works with non-String args', function()
- eq('2', meths.nvim_cmd({ cmd = 'echo', args = { 2 } }, { output = true }))
- eq('1', meths.nvim_cmd({ cmd = 'echo', args = { true } }, { output = true }))
+ eq('2', api.nvim_cmd({ cmd = 'echo', args = { 2 } }, { output = true }))
+ eq('1', api.nvim_cmd({ cmd = 'echo', args = { true } }, { output = true }))
end)
describe('first argument as count', function()
it('works', function()
command('vsplit | enew')
- meths.nvim_cmd({ cmd = 'bdelete', args = { meths.nvim_get_current_buf() } }, {})
- eq(1, meths.nvim_get_current_buf().id)
+ api.nvim_cmd({ cmd = 'bdelete', args = { api.nvim_get_current_buf() } }, {})
+ eq(1, api.nvim_get_current_buf().id)
end)
it('works with :sleep using milliseconds', function()
local start = uv.now()
- meths.nvim_cmd({ cmd = 'sleep', args = { '100m' } }, {})
+ api.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.nvim_cmd, { cmd = 'call', args = { 'UnknownFunc()' } }, {})
+ pcall_err(api.nvim_cmd, { cmd = 'call', args = { 'UnknownFunc()' } }, {})
)
end)
it(':throw does not crash #24556', function()
- eq('42', pcall_err(meths.nvim_cmd, { cmd = 'throw', args = { '42' } }, {}))
+ eq('42', pcall_err(api.nvim_cmd, { cmd = 'throw', args = { '42' } }, {}))
end)
it('can use :return #24556', function()
exec([[
@@ -4862,8 +4850,8 @@ describe('API', function()
endfunc
let g:result = Foo()
]])
- eq('before', meths.nvim_get_var('pos'))
- eq({ 1, 2, 3 }, meths.nvim_get_var('result'))
+ eq('before', api.nvim_get_var('pos'))
+ eq({ 1, 2, 3 }, api.nvim_get_var('result'))
end)
end)
end)
diff --git a/test/functional/api/window_spec.lua b/test/functional/api/window_spec.lua
index 87aa0ca2a8..d30a6460a6 100644
--- a/test/functional/api/window_spec.lua
+++ b/test/functional/api/window_spec.lua
@@ -2,9 +2,9 @@ local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local clear, curbuf, curbuf_contents, curwin, eq, neq, ok, feed, insert, eval =
helpers.clear,
- helpers.meths.nvim_get_current_buf,
+ helpers.api.nvim_get_current_buf,
helpers.curbuf_contents,
- helpers.meths.nvim_get_current_win,
+ helpers.api.nvim_get_current_win,
helpers.eq,
helpers.neq,
helpers.ok,
@@ -13,10 +13,10 @@ local clear, curbuf, curbuf_contents, curwin, eq, neq, ok, feed, insert, eval =
helpers.eval
local poke_eventloop = helpers.poke_eventloop
local exec = helpers.exec
-local funcs = helpers.funcs
+local fn = helpers.fn
local request = helpers.request
local NIL = vim.NIL
-local meths = helpers.meths
+local api = helpers.api
local command = helpers.command
local pcall_err = helpers.pcall_err
local assert_alive = helpers.assert_alive
@@ -26,13 +26,13 @@ describe('API/win', function()
describe('get_buf', function()
it('works', function()
- eq(curbuf(), meths.nvim_win_get_buf(meths.nvim_list_wins()[1]))
+ eq(curbuf(), api.nvim_win_get_buf(api.nvim_list_wins()[1]))
command('new')
- meths.nvim_set_current_win(meths.nvim_list_wins()[2])
- eq(curbuf(), meths.nvim_win_get_buf(meths.nvim_list_wins()[2]))
+ api.nvim_set_current_win(api.nvim_list_wins()[2])
+ eq(curbuf(), api.nvim_win_get_buf(api.nvim_list_wins()[2]))
neq(
- meths.nvim_win_get_buf(meths.nvim_list_wins()[1]),
- meths.nvim_win_get_buf(meths.nvim_list_wins()[2])
+ api.nvim_win_get_buf(api.nvim_list_wins()[1]),
+ api.nvim_win_get_buf(api.nvim_list_wins()[2])
)
end)
end)
@@ -40,27 +40,21 @@ describe('API/win', function()
describe('set_buf', function()
it('works', function()
command('new')
- local windows = meths.nvim_list_wins()
- neq(meths.nvim_win_get_buf(windows[2]), meths.nvim_win_get_buf(windows[1]))
- meths.nvim_win_set_buf(windows[2], meths.nvim_win_get_buf(windows[1]))
- eq(meths.nvim_win_get_buf(windows[2]), meths.nvim_win_get_buf(windows[1]))
+ local windows = api.nvim_list_wins()
+ neq(api.nvim_win_get_buf(windows[2]), api.nvim_win_get_buf(windows[1]))
+ api.nvim_win_set_buf(windows[2], api.nvim_win_get_buf(windows[1]))
+ eq(api.nvim_win_get_buf(windows[2]), api.nvim_win_get_buf(windows[1]))
end)
it('validates args', function()
- eq(
- 'Invalid buffer id: 23',
- pcall_err(meths.nvim_win_set_buf, meths.nvim_get_current_win(), 23)
- )
- eq(
- 'Invalid window id: 23',
- pcall_err(meths.nvim_win_set_buf, 23, meths.nvim_get_current_buf())
- )
+ eq('Invalid buffer id: 23', pcall_err(api.nvim_win_set_buf, api.nvim_get_current_win(), 23))
+ eq('Invalid window id: 23', pcall_err(api.nvim_win_set_buf, 23, api.nvim_get_current_buf()))
end)
it('disallowed in cmdwin if win={old_}curwin or buf=curbuf', function()
- 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, {
+ local new_buf = api.nvim_create_buf(true, true)
+ local old_win = api.nvim_get_current_win()
+ local new_win = api.nvim_open_win(new_buf, false, {
relative = 'editor',
row = 10,
col = 10,
@@ -70,36 +64,36 @@ describe('API/win', function()
feed('q:')
eq(
'E11: Invalid in command-line window; <CR> executes, CTRL-C quits',
- pcall_err(meths.nvim_win_set_buf, 0, new_buf)
+ pcall_err(api.nvim_win_set_buf, 0, new_buf)
)
eq(
'E11: Invalid in command-line window; <CR> executes, CTRL-C quits',
- pcall_err(meths.nvim_win_set_buf, old_win, new_buf)
+ pcall_err(api.nvim_win_set_buf, old_win, new_buf)
)
eq(
'E11: Invalid in command-line window; <CR> executes, CTRL-C quits',
- pcall_err(meths.nvim_win_set_buf, new_win, 0)
+ pcall_err(api.nvim_win_set_buf, new_win, 0)
)
- 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))
+ local next_buf = api.nvim_create_buf(true, true)
+ api.nvim_win_set_buf(new_win, next_buf)
+ eq(next_buf, api.nvim_win_get_buf(new_win))
end)
end)
describe('{get,set}_cursor', function()
it('works', function()
- eq({ 1, 0 }, meths.nvim_win_get_cursor(0))
+ eq({ 1, 0 }, api.nvim_win_get_cursor(0))
command('normal ityping\027o some text')
eq('typing\n some text', curbuf_contents())
- eq({ 2, 10 }, meths.nvim_win_get_cursor(0))
- meths.nvim_win_set_cursor(0, { 2, 6 })
+ eq({ 2, 10 }, api.nvim_win_get_cursor(0))
+ api.nvim_win_set_cursor(0, { 2, 6 })
command('normal i dumb')
eq('typing\n some dumb text', curbuf_contents())
end)
it('does not leak memory when using invalid window ID with invalid pos', function()
- eq('Invalid window id: 1', pcall_err(meths.nvim_win_set_cursor, 1, { 'b\na' }))
+ eq('Invalid window id: 1', pcall_err(api.nvim_win_set_cursor, 1, { 'b\na' }))
end)
it('updates the screen, and also when the window is unfocused', function()
@@ -124,10 +118,10 @@ describe('API/win', function()
]],
}
-- cursor position is at beginning
- eq({ 1, 0 }, meths.nvim_win_get_cursor(win))
+ eq({ 1, 0 }, api.nvim_win_get_cursor(win))
-- move cursor to end
- meths.nvim_win_set_cursor(win, { 101, 0 })
+ api.nvim_win_set_cursor(win, { 101, 0 })
screen:expect {
grid = [[
|*7
@@ -137,7 +131,7 @@ describe('API/win', function()
}
-- move cursor to the beginning again
- meths.nvim_win_set_cursor(win, { 1, 0 })
+ api.nvim_win_set_cursor(win, { 1, 0 })
screen:expect {
grid = [[
^prologue |
@@ -150,7 +144,7 @@ describe('API/win', function()
neq(win, curwin())
-- sanity check, cursor position is kept
- eq({ 1, 0 }, meths.nvim_win_get_cursor(win))
+ eq({ 1, 0 }, api.nvim_win_get_cursor(win))
screen:expect {
grid = [[
^ |
@@ -164,7 +158,7 @@ describe('API/win', function()
}
-- move cursor to end
- meths.nvim_win_set_cursor(win, { 101, 0 })
+ api.nvim_win_set_cursor(win, { 101, 0 })
screen:expect {
grid = [[
^ |
@@ -178,7 +172,7 @@ describe('API/win', function()
}
-- move cursor to the beginning again
- meths.nvim_win_set_cursor(win, { 1, 0 })
+ api.nvim_win_set_cursor(win, { 1, 0 })
screen:expect {
grid = [[
^ |
@@ -205,17 +199,17 @@ describe('API/win', function()
-- cursor position is at beginning
local win = curwin()
- eq({ 1, 0 }, meths.nvim_win_get_cursor(win))
+ eq({ 1, 0 }, api.nvim_win_get_cursor(win))
-- move cursor to column 5
- meths.nvim_win_set_cursor(win, { 1, 5 })
+ api.nvim_win_set_cursor(win, { 1, 5 })
-- move down a line
feed('j')
poke_eventloop() -- let nvim process the 'j' command
-- cursor is still in column 5
- eq({ 2, 5 }, meths.nvim_win_get_cursor(win))
+ eq({ 2, 5 }, api.nvim_win_get_cursor(win))
end)
it('updates cursorline and statusline ruler in non-current window', function()
@@ -245,7 +239,7 @@ describe('API/win', function()
{3:[No Name] [+] 4,3 All }{4:[No Name] [+] 4,3 All}|
|
]])
- meths.nvim_win_set_cursor(oldwin, { 1, 0 })
+ api.nvim_win_set_cursor(oldwin, { 1, 0 })
screen:expect([[
aaa │{2:aaa }|
bbb │bbb |
@@ -283,7 +277,7 @@ describe('API/win', function()
{3:[No Name] [+] }{4:[No Name] [+] }|
|
]])
- meths.nvim_win_set_cursor(oldwin, { 2, 0 })
+ api.nvim_win_set_cursor(oldwin, { 2, 0 })
screen:expect([[
aa{2:a} │{2:a}aa |
bb{2:b} │bbb |
@@ -300,33 +294,33 @@ describe('API/win', function()
it('works', function()
command('vsplit')
eq(
- meths.nvim_win_get_height(meths.nvim_list_wins()[2]),
- meths.nvim_win_get_height(meths.nvim_list_wins()[1])
+ api.nvim_win_get_height(api.nvim_list_wins()[2]),
+ api.nvim_win_get_height(api.nvim_list_wins()[1])
)
- meths.nvim_set_current_win(meths.nvim_list_wins()[2])
+ api.nvim_set_current_win(api.nvim_list_wins()[2])
command('split')
eq(
- meths.nvim_win_get_height(meths.nvim_list_wins()[2]),
- math.floor(meths.nvim_win_get_height(meths.nvim_list_wins()[1]) / 2)
+ api.nvim_win_get_height(api.nvim_list_wins()[2]),
+ math.floor(api.nvim_win_get_height(api.nvim_list_wins()[1]) / 2)
)
- meths.nvim_win_set_height(meths.nvim_list_wins()[2], 2)
- eq(2, meths.nvim_win_get_height(meths.nvim_list_wins()[2]))
+ api.nvim_win_set_height(api.nvim_list_wins()[2], 2)
+ eq(2, api.nvim_win_get_height(api.nvim_list_wins()[2]))
end)
it('correctly handles height=1', function()
command('split')
- meths.nvim_set_current_win(meths.nvim_list_wins()[1])
- meths.nvim_win_set_height(meths.nvim_list_wins()[2], 1)
- eq(1, meths.nvim_win_get_height(meths.nvim_list_wins()[2]))
+ api.nvim_set_current_win(api.nvim_list_wins()[1])
+ api.nvim_win_set_height(api.nvim_list_wins()[2], 1)
+ eq(1, api.nvim_win_get_height(api.nvim_list_wins()[2]))
end)
it('correctly handles height=1 with a winbar', function()
command('set winbar=foobar')
command('set winminheight=0')
command('split')
- meths.nvim_set_current_win(meths.nvim_list_wins()[1])
- meths.nvim_win_set_height(meths.nvim_list_wins()[2], 1)
- eq(1, meths.nvim_win_get_height(meths.nvim_list_wins()[2]))
+ api.nvim_set_current_win(api.nvim_list_wins()[1])
+ api.nvim_win_set_height(api.nvim_list_wins()[2], 1)
+ eq(1, api.nvim_win_get_height(api.nvim_list_wins()[2]))
end)
it('do not cause ml_get errors with foldmethod=expr #19989', function()
@@ -342,7 +336,7 @@ describe('API/win', function()
call nvim_win_set_height(w, 5)
]])
feed('l')
- eq('', meths.nvim_get_vvar('errmsg'))
+ eq('', api.nvim_get_vvar('errmsg'))
end)
end)
@@ -350,17 +344,17 @@ describe('API/win', function()
it('works', function()
command('split')
eq(
- meths.nvim_win_get_width(meths.nvim_list_wins()[2]),
- meths.nvim_win_get_width(meths.nvim_list_wins()[1])
+ api.nvim_win_get_width(api.nvim_list_wins()[2]),
+ api.nvim_win_get_width(api.nvim_list_wins()[1])
)
- meths.nvim_set_current_win(meths.nvim_list_wins()[2])
+ api.nvim_set_current_win(api.nvim_list_wins()[2])
command('vsplit')
eq(
- meths.nvim_win_get_width(meths.nvim_list_wins()[2]),
- math.floor(meths.nvim_win_get_width(meths.nvim_list_wins()[1]) / 2)
+ api.nvim_win_get_width(api.nvim_list_wins()[2]),
+ math.floor(api.nvim_win_get_width(api.nvim_list_wins()[1]) / 2)
)
- meths.nvim_win_set_width(meths.nvim_list_wins()[2], 2)
- eq(2, meths.nvim_win_get_width(meths.nvim_list_wins()[2]))
+ api.nvim_win_set_width(api.nvim_list_wins()[2], 2)
+ eq(2, api.nvim_win_get_width(api.nvim_list_wins()[2]))
end)
it('do not cause ml_get errors with foldmethod=expr #19989', function()
@@ -376,23 +370,23 @@ describe('API/win', function()
call nvim_win_set_width(w, 5)
]])
feed('l')
- eq('', meths.nvim_get_vvar('errmsg'))
+ eq('', api.nvim_get_vvar('errmsg'))
end)
end)
describe('{get,set,del}_var', function()
it('works', function()
- meths.nvim_win_set_var(0, 'lua', { 1, 2, { ['3'] = 1 } })
- eq({ 1, 2, { ['3'] = 1 } }, meths.nvim_win_get_var(0, 'lua'))
- eq({ 1, 2, { ['3'] = 1 } }, meths.nvim_eval('w:lua'))
- eq(1, funcs.exists('w:lua'))
- meths.nvim_win_del_var(0, 'lua')
- eq(0, funcs.exists('w:lua'))
- eq('Key not found: lua', pcall_err(meths.nvim_win_del_var, 0, 'lua'))
- meths.nvim_win_set_var(0, 'lua', 1)
+ api.nvim_win_set_var(0, 'lua', { 1, 2, { ['3'] = 1 } })
+ eq({ 1, 2, { ['3'] = 1 } }, api.nvim_win_get_var(0, 'lua'))
+ eq({ 1, 2, { ['3'] = 1 } }, api.nvim_eval('w:lua'))
+ eq(1, fn.exists('w:lua'))
+ api.nvim_win_del_var(0, 'lua')
+ eq(0, fn.exists('w:lua'))
+ eq('Key not found: lua', pcall_err(api.nvim_win_del_var, 0, 'lua'))
+ api.nvim_win_set_var(0, 'lua', 1)
command('lockvar w:lua')
- eq('Key is locked: lua', pcall_err(meths.nvim_win_del_var, 0, 'lua'))
- eq('Key is locked: lua', pcall_err(meths.nvim_win_set_var, 0, 'lua', 1))
+ eq('Key is locked: lua', pcall_err(api.nvim_win_del_var, 0, 'lua'))
+ eq('Key is locked: lua', pcall_err(api.nvim_win_set_var, 0, 'lua', 1))
end)
it('window_set_var returns the old value', function()
@@ -413,51 +407,51 @@ describe('API/win', function()
describe('nvim_get_option_value, nvim_set_option_value', function()
it('works', function()
- meths.nvim_set_option_value('colorcolumn', '4,3', {})
- eq('4,3', meths.nvim_get_option_value('colorcolumn', {}))
+ api.nvim_set_option_value('colorcolumn', '4,3', {})
+ eq('4,3', api.nvim_get_option_value('colorcolumn', {}))
command('set modified hidden')
command('enew') -- edit new buffer, window option is preserved
- eq('4,3', meths.nvim_get_option_value('colorcolumn', {}))
+ eq('4,3', api.nvim_get_option_value('colorcolumn', {}))
-- global-local option
- meths.nvim_set_option_value('statusline', 'window-status', { win = 0 })
- eq('window-status', meths.nvim_get_option_value('statusline', { win = 0 }))
- eq('', meths.nvim_get_option_value('statusline', { scope = 'global' }))
+ api.nvim_set_option_value('statusline', 'window-status', { win = 0 })
+ eq('window-status', api.nvim_get_option_value('statusline', { win = 0 }))
+ eq('', api.nvim_get_option_value('statusline', { scope = 'global' }))
command('set modified')
command('enew') -- global-local: not preserved in new buffer
-- confirm local value was not copied
- eq('', meths.nvim_get_option_value('statusline', { win = 0 }))
+ eq('', api.nvim_get_option_value('statusline', { win = 0 }))
eq('', eval('&l:statusline'))
end)
it('after switching windows #15390', function()
command('tabnew')
- local tab1 = unpack(meths.nvim_list_tabpages())
- local win1 = unpack(meths.nvim_tabpage_list_wins(tab1))
- meths.nvim_set_option_value('statusline', 'window-status', { win = win1.id })
+ local tab1 = unpack(api.nvim_list_tabpages())
+ local win1 = unpack(api.nvim_tabpage_list_wins(tab1))
+ api.nvim_set_option_value('statusline', 'window-status', { win = win1.id })
command('split')
command('wincmd J')
command('wincmd j')
- eq('window-status', meths.nvim_get_option_value('statusline', { win = win1.id }))
+ eq('window-status', api.nvim_get_option_value('statusline', { win = win1.id }))
assert_alive()
end)
it('returns values for unset local options', function()
- eq(-1, meths.nvim_get_option_value('scrolloff', { win = 0, scope = 'local' }))
+ eq(-1, api.nvim_get_option_value('scrolloff', { win = 0, scope = 'local' }))
end)
end)
describe('get_position', function()
it('works', function()
- local height = meths.nvim_win_get_height(meths.nvim_list_wins()[1])
- local width = meths.nvim_win_get_width(meths.nvim_list_wins()[1])
+ local height = api.nvim_win_get_height(api.nvim_list_wins()[1])
+ local width = api.nvim_win_get_width(api.nvim_list_wins()[1])
command('split')
command('vsplit')
- eq({ 0, 0 }, meths.nvim_win_get_position(meths.nvim_list_wins()[1]))
+ eq({ 0, 0 }, api.nvim_win_get_position(api.nvim_list_wins()[1]))
local vsplit_pos = math.floor(width / 2)
local split_pos = math.floor(height / 2)
- local win2row, win2col = unpack(meths.nvim_win_get_position(meths.nvim_list_wins()[2]))
- local win3row, win3col = unpack(meths.nvim_win_get_position(meths.nvim_list_wins()[3]))
+ local win2row, win2col = unpack(api.nvim_win_get_position(api.nvim_list_wins()[2]))
+ local win3row, win3col = unpack(api.nvim_win_get_position(api.nvim_list_wins()[3]))
eq(0, win2row)
eq(0, win3col)
ok(vsplit_pos - 1 <= win2col and win2col <= vsplit_pos + 1)
@@ -469,91 +463,91 @@ describe('API/win', function()
it('works', function()
command('tabnew')
command('vsplit')
- eq(meths.nvim_win_get_tabpage(meths.nvim_list_wins()[1]), meths.nvim_list_tabpages()[1])
- eq(meths.nvim_win_get_tabpage(meths.nvim_list_wins()[2]), meths.nvim_list_tabpages()[2])
- eq(meths.nvim_win_get_tabpage(meths.nvim_list_wins()[3]), meths.nvim_list_tabpages()[2])
+ eq(api.nvim_win_get_tabpage(api.nvim_list_wins()[1]), api.nvim_list_tabpages()[1])
+ eq(api.nvim_win_get_tabpage(api.nvim_list_wins()[2]), api.nvim_list_tabpages()[2])
+ eq(api.nvim_win_get_tabpage(api.nvim_list_wins()[3]), api.nvim_list_tabpages()[2])
end)
end)
describe('get_number', function()
it('works', function()
- local wins = meths.nvim_list_wins()
- eq(1, meths.nvim_win_get_number(wins[1]))
+ local wins = api.nvim_list_wins()
+ eq(1, api.nvim_win_get_number(wins[1]))
command('split')
- local win1, win2 = unpack(meths.nvim_list_wins())
- eq(1, meths.nvim_win_get_number(win1))
- eq(2, meths.nvim_win_get_number(win2))
+ local win1, win2 = unpack(api.nvim_list_wins())
+ eq(1, api.nvim_win_get_number(win1))
+ eq(2, api.nvim_win_get_number(win2))
command('wincmd J')
- eq(2, meths.nvim_win_get_number(win1))
- eq(1, meths.nvim_win_get_number(win2))
+ eq(2, api.nvim_win_get_number(win1))
+ eq(1, api.nvim_win_get_number(win2))
command('tabnew')
- local win3 = meths.nvim_list_wins()[3]
+ local win3 = api.nvim_list_wins()[3]
-- First tab page
- eq(2, meths.nvim_win_get_number(win1))
- eq(1, meths.nvim_win_get_number(win2))
+ eq(2, api.nvim_win_get_number(win1))
+ eq(1, api.nvim_win_get_number(win2))
-- Second tab page
- eq(1, meths.nvim_win_get_number(win3))
+ eq(1, api.nvim_win_get_number(win3))
end)
end)
describe('is_valid', function()
it('works', function()
command('split')
- local win = meths.nvim_list_wins()[2]
- meths.nvim_set_current_win(win)
- ok(meths.nvim_win_is_valid(win))
+ local win = api.nvim_list_wins()[2]
+ api.nvim_set_current_win(win)
+ ok(api.nvim_win_is_valid(win))
command('close')
- ok(not meths.nvim_win_is_valid(win))
+ ok(not api.nvim_win_is_valid(win))
end)
end)
describe('close', function()
it('can close current window', function()
- local oldwin = meths.nvim_get_current_win()
+ local oldwin = api.nvim_get_current_win()
command('split')
- local newwin = meths.nvim_get_current_win()
- meths.nvim_win_close(newwin, false)
- eq({ oldwin }, meths.nvim_list_wins())
+ local newwin = api.nvim_get_current_win()
+ api.nvim_win_close(newwin, false)
+ eq({ oldwin }, api.nvim_list_wins())
end)
it('can close noncurrent window', function()
- local oldwin = meths.nvim_get_current_win()
+ local oldwin = api.nvim_get_current_win()
command('split')
- local newwin = meths.nvim_get_current_win()
- meths.nvim_win_close(oldwin, false)
- eq({ newwin }, meths.nvim_list_wins())
+ local newwin = api.nvim_get_current_win()
+ api.nvim_win_close(oldwin, false)
+ eq({ newwin }, api.nvim_list_wins())
end)
it("handles changed buffer when 'hidden' is unset", function()
command('set nohidden')
- local oldwin = meths.nvim_get_current_win()
+ local oldwin = api.nvim_get_current_win()
insert('text')
command('new')
- local newwin = meths.nvim_get_current_win()
+ local newwin = api.nvim_get_current_win()
eq(
'Vim:E37: No write since last change (add ! to override)',
- pcall_err(meths.nvim_win_close, oldwin, false)
+ pcall_err(api.nvim_win_close, oldwin, false)
)
- eq({ newwin, oldwin }, meths.nvim_list_wins())
+ eq({ newwin, oldwin }, api.nvim_list_wins())
end)
it('handles changed buffer with force', function()
- local oldwin = meths.nvim_get_current_win()
+ local oldwin = api.nvim_get_current_win()
insert('text')
command('new')
- local newwin = meths.nvim_get_current_win()
- meths.nvim_win_close(oldwin, true)
- eq({ newwin }, meths.nvim_list_wins())
+ local newwin = api.nvim_get_current_win()
+ api.nvim_win_close(oldwin, true)
+ eq({ newwin }, api.nvim_list_wins())
end)
it('in cmdline-window #9767', function()
command('split')
- eq(2, #meths.nvim_list_wins())
- local oldwin = meths.nvim_get_current_win()
- local otherwin = meths.nvim_open_win(0, false, {
+ eq(2, #api.nvim_list_wins())
+ local oldwin = api.nvim_get_current_win()
+ local otherwin = api.nvim_open_win(0, false, {
relative = 'editor',
row = 10,
col = 10,
@@ -562,20 +556,20 @@ describe('API/win', function()
})
-- Open cmdline-window.
feed('q:')
- eq(4, #meths.nvim_list_wins())
- eq(':', funcs.getcmdwintype())
+ eq(4, #api.nvim_list_wins())
+ eq(':', fn.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.nvim_win_close, oldwin, true)
+ pcall_err(api.nvim_win_close, oldwin, true)
)
-- Closing other windows is fine.
- meths.nvim_win_close(otherwin, true)
- eq(false, meths.nvim_win_is_valid(otherwin))
+ api.nvim_win_close(otherwin, true)
+ eq(false, api.nvim_win_is_valid(otherwin))
-- Close cmdline-window.
- meths.nvim_win_close(0, true)
- eq(2, #meths.nvim_list_wins())
- eq('', funcs.getcmdwintype())
+ api.nvim_win_close(0, true)
+ eq(2, #api.nvim_list_wins())
+ eq('', fn.getcmdwintype())
end)
it('closing current (float) window of another tabpage #15313', function()
@@ -583,7 +577,7 @@ describe('API/win', function()
command('botright split')
local prevwin = curwin().id
eq(2, eval('tabpagenr()'))
- local win = meths.nvim_open_win(0, true, {
+ local win = api.nvim_open_win(0, true, {
relative = 'editor',
row = 10,
col = 10,
@@ -593,67 +587,67 @@ describe('API/win', function()
local tab = eval('tabpagenr()')
command('tabprevious')
eq(1, eval('tabpagenr()'))
- meths.nvim_win_close(win, false)
+ api.nvim_win_close(win, false)
- eq(prevwin, meths.nvim_tabpage_get_win(tab).id)
+ eq(prevwin, api.nvim_tabpage_get_win(tab).id)
assert_alive()
end)
end)
describe('hide', function()
it('can hide current window', function()
- local oldwin = meths.nvim_get_current_win()
+ local oldwin = api.nvim_get_current_win()
command('split')
- local newwin = meths.nvim_get_current_win()
- meths.nvim_win_hide(newwin)
- eq({ oldwin }, meths.nvim_list_wins())
+ local newwin = api.nvim_get_current_win()
+ api.nvim_win_hide(newwin)
+ eq({ oldwin }, api.nvim_list_wins())
end)
it('can hide noncurrent window', function()
- local oldwin = meths.nvim_get_current_win()
+ local oldwin = api.nvim_get_current_win()
command('split')
- local newwin = meths.nvim_get_current_win()
- meths.nvim_win_hide(oldwin)
- eq({ newwin }, meths.nvim_list_wins())
+ local newwin = api.nvim_get_current_win()
+ api.nvim_win_hide(oldwin)
+ eq({ newwin }, api.nvim_list_wins())
end)
it('does not close the buffer', function()
- 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, {
+ local oldwin = api.nvim_get_current_win()
+ local oldbuf = api.nvim_get_current_buf()
+ local buf = api.nvim_create_buf(true, false)
+ local newwin = api.nvim_open_win(buf, true, {
relative = 'win',
row = 3,
col = 3,
width = 12,
height = 3,
})
- meths.nvim_win_hide(newwin)
- eq({ oldwin }, meths.nvim_list_wins())
- eq({ oldbuf, buf }, meths.nvim_list_bufs())
+ api.nvim_win_hide(newwin)
+ eq({ oldwin }, api.nvim_list_wins())
+ eq({ oldbuf, buf }, api.nvim_list_bufs())
end)
it('deletes the buffer when bufhidden=wipe', function()
- 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, {
+ local oldwin = api.nvim_get_current_win()
+ local oldbuf = api.nvim_get_current_buf()
+ local buf = api.nvim_create_buf(true, false).id
+ local newwin = api.nvim_open_win(buf, true, {
relative = 'win',
row = 3,
col = 3,
width = 12,
height = 3,
})
- 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())
+ api.nvim_set_option_value('bufhidden', 'wipe', { buf = buf })
+ api.nvim_win_hide(newwin)
+ eq({ oldwin }, api.nvim_list_wins())
+ eq({ oldbuf }, api.nvim_list_bufs())
end)
it('in the cmdwin', function()
feed('q:')
-- Can close the cmdwin.
- meths.nvim_win_hide(0)
- eq('', funcs.getcmdwintype())
+ api.nvim_win_hide(0)
+ eq('', fn.getcmdwintype())
- local old_win = meths.nvim_get_current_win()
- local other_win = meths.nvim_open_win(0, false, {
+ local old_win = api.nvim_get_current_win()
+ local other_win = api.nvim_open_win(0, false, {
relative = 'win',
row = 3,
col = 3,
@@ -664,60 +658,60 @@ describe('API/win', function()
-- Cannot close the previous window.
eq(
'E11: Invalid in command-line window; <CR> executes, CTRL-C quits',
- pcall_err(meths.nvim_win_hide, old_win)
+ pcall_err(api.nvim_win_hide, old_win)
)
-- Can close other windows.
- meths.nvim_win_hide(other_win)
- eq(false, meths.nvim_win_is_valid(other_win))
+ api.nvim_win_hide(other_win)
+ eq(false, api.nvim_win_is_valid(other_win))
end)
end)
describe('text_height', function()
it('validation', function()
- local X = meths.nvim_get_vvar('maxcol')
+ local X = api.nvim_get_vvar('maxcol')
insert([[
aaa
bbb
ccc
ddd
eee]])
- eq('Invalid window id: 23', pcall_err(meths.nvim_win_text_height, 23, {}))
- eq('Line index out of bounds', pcall_err(meths.nvim_win_text_height, 0, { start_row = 5 }))
- eq('Line index out of bounds', pcall_err(meths.nvim_win_text_height, 0, { start_row = -6 }))
- eq('Line index out of bounds', pcall_err(meths.nvim_win_text_height, 0, { end_row = 5 }))
- eq('Line index out of bounds', pcall_err(meths.nvim_win_text_height, 0, { end_row = -6 }))
+ eq('Invalid window id: 23', pcall_err(api.nvim_win_text_height, 23, {}))
+ eq('Line index out of bounds', pcall_err(api.nvim_win_text_height, 0, { start_row = 5 }))
+ eq('Line index out of bounds', pcall_err(api.nvim_win_text_height, 0, { start_row = -6 }))
+ eq('Line index out of bounds', pcall_err(api.nvim_win_text_height, 0, { end_row = 5 }))
+ eq('Line index out of bounds', pcall_err(api.nvim_win_text_height, 0, { end_row = -6 }))
eq(
"'start_row' is higher than 'end_row'",
- pcall_err(meths.nvim_win_text_height, 0, { start_row = 3, end_row = 1 })
+ pcall_err(api.nvim_win_text_height, 0, { start_row = 3, end_row = 1 })
)
eq(
"'start_vcol' specified without 'start_row'",
- pcall_err(meths.nvim_win_text_height, 0, { end_row = 2, start_vcol = 0 })
+ pcall_err(api.nvim_win_text_height, 0, { end_row = 2, start_vcol = 0 })
)
eq(
"'end_vcol' specified without 'end_row'",
- pcall_err(meths.nvim_win_text_height, 0, { start_row = 2, end_vcol = 0 })
+ pcall_err(api.nvim_win_text_height, 0, { start_row = 2, end_vcol = 0 })
)
eq(
"Invalid 'start_vcol': out of range",
- pcall_err(meths.nvim_win_text_height, 0, { start_row = 2, start_vcol = -1 })
+ pcall_err(api.nvim_win_text_height, 0, { start_row = 2, start_vcol = -1 })
)
eq(
"Invalid 'start_vcol': out of range",
- pcall_err(meths.nvim_win_text_height, 0, { start_row = 2, start_vcol = X + 1 })
+ pcall_err(api.nvim_win_text_height, 0, { start_row = 2, start_vcol = X + 1 })
)
eq(
"Invalid 'end_vcol': out of range",
- pcall_err(meths.nvim_win_text_height, 0, { end_row = 2, end_vcol = -1 })
+ pcall_err(api.nvim_win_text_height, 0, { end_row = 2, end_vcol = -1 })
)
eq(
"Invalid 'end_vcol': out of range",
- pcall_err(meths.nvim_win_text_height, 0, { end_row = 2, end_vcol = X + 1 })
+ pcall_err(api.nvim_win_text_height, 0, { end_row = 2, end_vcol = X + 1 })
)
eq(
"'start_vcol' is higher than 'end_vcol'",
pcall_err(
- meths.nvim_win_text_height,
+ api.nvim_win_text_height,
0,
{ start_row = 2, end_row = 2, start_vcol = 10, end_vcol = 5 }
)
@@ -725,7 +719,7 @@ describe('API/win', function()
end)
it('with two diff windows', function()
- local X = meths.nvim_get_vvar('maxcol')
+ local X = api.nvim_get_vvar('maxcol')
local screen = Screen.new(45, 22)
screen:set_default_attr_ids({
[0] = { foreground = Screen.colors.Blue1, bold = true },
@@ -787,80 +781,71 @@ describe('API/win', function()
|
]],
}
- 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 = 20, fill = 5 }, api.nvim_win_text_height(1000, {}))
+ eq({ all = 20, fill = 5 }, api.nvim_win_text_height(1001, {}))
+ eq({ all = 20, fill = 5 }, api.nvim_win_text_height(1000, { start_row = 0 }))
+ eq({ all = 20, fill = 5 }, api.nvim_win_text_height(1001, { start_row = 0 }))
+ eq({ all = 15, fill = 0 }, api.nvim_win_text_height(1000, { end_row = -1 }))
+ eq({ all = 15, fill = 0 }, api.nvim_win_text_height(1000, { end_row = 40 }))
+ eq({ all = 20, fill = 5 }, api.nvim_win_text_height(1001, { end_row = -1 }))
+ eq({ all = 20, fill = 5 }, api.nvim_win_text_height(1001, { end_row = 40 }))
+ eq({ all = 10, fill = 5 }, api.nvim_win_text_height(1000, { start_row = 23 }))
+ eq({ all = 13, fill = 3 }, api.nvim_win_text_height(1001, { start_row = 18 }))
+ eq({ all = 11, fill = 0 }, api.nvim_win_text_height(1000, { end_row = 23 }))
+ eq({ all = 11, fill = 5 }, api.nvim_win_text_height(1001, { end_row = 18 }))
+ eq({ all = 11, fill = 0 }, api.nvim_win_text_height(1000, { start_row = 3, end_row = 39 }))
+ eq({ all = 11, fill = 3 }, api.nvim_win_text_height(1001, { start_row = 1, end_row = 34 }))
+ eq({ all = 9, fill = 0 }, api.nvim_win_text_height(1000, { start_row = 4, end_row = 38 }))
+ eq({ all = 9, fill = 3 }, api.nvim_win_text_height(1001, { start_row = 2, end_row = 33 }))
+ eq({ all = 9, fill = 0 }, api.nvim_win_text_height(1000, { start_row = 5, end_row = 37 }))
+ eq({ all = 9, fill = 3 }, api.nvim_win_text_height(1001, { start_row = 3, end_row = 32 }))
+ eq({ all = 9, fill = 0 }, api.nvim_win_text_height(1000, { start_row = 17, end_row = 25 }))
+ eq({ all = 9, fill = 3 }, api.nvim_win_text_height(1001, { start_row = 15, end_row = 20 }))
+ eq({ all = 7, fill = 0 }, api.nvim_win_text_height(1000, { start_row = 18, end_row = 24 }))
+ eq({ all = 7, fill = 3 }, api.nvim_win_text_height(1001, { start_row = 16, end_row = 19 }))
+ eq({ all = 6, fill = 5 }, api.nvim_win_text_height(1000, { start_row = -1 }))
+ eq({ all = 5, fill = 5 }, api.nvim_win_text_height(1000, { start_row = -1, start_vcol = X }))
eq(
{ all = 0, fill = 0 },
- meths.nvim_win_text_height(1000, { start_row = -1, start_vcol = X, end_row = -1 })
+ api.nvim_win_text_height(1000, { start_row = -1, start_vcol = X, end_row = -1 })
)
eq(
{ all = 0, fill = 0 },
- meths.nvim_win_text_height(
+ api.nvim_win_text_height(
1000,
{ start_row = -1, start_vcol = X, end_row = -1, end_vcol = X }
)
)
eq(
{ all = 1, fill = 0 },
- meths.nvim_win_text_height(
+ api.nvim_win_text_height(
1000,
{ start_row = -1, start_vcol = 0, end_row = -1, end_vcol = X }
)
)
- 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 = 3, fill = 2 }, api.nvim_win_text_height(1001, { end_row = 0 }))
+ eq({ all = 2, fill = 2 }, api.nvim_win_text_height(1001, { end_row = 0, end_vcol = 0 }))
eq(
{ all = 2, fill = 2 },
- meths.nvim_win_text_height(1001, { start_row = 0, end_row = 0, end_vcol = 0 })
+ api.nvim_win_text_height(1001, { start_row = 0, end_row = 0, end_vcol = 0 })
)
eq(
{ all = 0, fill = 0 },
- meths.nvim_win_text_height(
- 1001,
- { start_row = 0, start_vcol = 0, end_row = 0, end_vcol = 0 }
- )
+ api.nvim_win_text_height(1001, { start_row = 0, start_vcol = 0, end_row = 0, end_vcol = 0 })
)
eq(
{ all = 1, fill = 0 },
- meths.nvim_win_text_height(
- 1001,
- { start_row = 0, start_vcol = 0, end_row = 0, end_vcol = X }
- )
+ api.nvim_win_text_height(1001, { start_row = 0, start_vcol = 0, end_row = 0, end_vcol = X })
)
- eq({ all = 11, fill = 5 }, meths.nvim_win_text_height(1001, { end_row = 18 }))
+ eq({ all = 11, fill = 5 }, api.nvim_win_text_height(1001, { end_row = 18 }))
eq(
{ all = 9, fill = 3 },
- meths.nvim_win_text_height(1001, { start_row = 0, start_vcol = 0, end_row = 18 })
+ api.nvim_win_text_height(1001, { start_row = 0, start_vcol = 0, end_row = 18 })
)
- eq({ all = 10, fill = 5 }, meths.nvim_win_text_height(1001, { end_row = 18, end_vcol = 0 }))
+ eq({ all = 10, fill = 5 }, api.nvim_win_text_height(1001, { end_row = 18, end_vcol = 0 }))
eq(
{ all = 8, fill = 3 },
- meths.nvim_win_text_height(
+ api.nvim_win_text_height(
1001,
{ start_row = 0, start_vcol = 0, end_row = 18, end_vcol = 0 }
)
@@ -868,7 +853,7 @@ describe('API/win', function()
end)
it('with wrapped lines', function()
- local X = meths.nvim_get_vvar('maxcol')
+ local X = api.nvim_get_vvar('maxcol')
local screen = Screen.new(45, 22)
screen:set_default_attr_ids({
[0] = { foreground = Screen.colors.Blue1, bold = true },
@@ -880,15 +865,15 @@ describe('API/win', function()
set number cpoptions+=n
call setline(1, repeat([repeat('foobar-', 36)], 3))
]])
- local ns = meths.nvim_create_namespace('')
- meths.nvim_buf_set_extmark(
+ local ns = api.nvim_create_namespace('')
+ api.nvim_buf_set_extmark(
0,
ns,
1,
100,
{ virt_text = { { ('?'):rep(15), 'Search' } }, virt_text_pos = 'inline' }
)
- meths.nvim_buf_set_extmark(
+ api.nvim_buf_set_extmark(
0,
ns,
2,
@@ -928,155 +913,122 @@ describe('API/win', function()
|
]],
}
- 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 = 21, fill = 0 }, api.nvim_win_text_height(0, {}))
+ eq({ all = 6, fill = 0 }, api.nvim_win_text_height(0, { start_row = 0, end_row = 0 }))
+ eq({ all = 7, fill = 0 }, api.nvim_win_text_height(0, { start_row = 1, end_row = 1 }))
+ eq({ all = 8, fill = 0 }, api.nvim_win_text_height(0, { start_row = 2, end_row = 2 }))
eq(
{ all = 0, fill = 0 },
- meths.nvim_win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 0 })
+ api.nvim_win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 0 })
)
eq(
{ all = 1, fill = 0 },
- meths.nvim_win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 41 })
+ api.nvim_win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 41 })
)
eq(
{ all = 2, fill = 0 },
- meths.nvim_win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 42 })
+ api.nvim_win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 42 })
)
eq(
{ all = 2, fill = 0 },
- meths.nvim_win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 86 })
+ api.nvim_win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 86 })
)
eq(
{ all = 3, fill = 0 },
- meths.nvim_win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 87 })
+ api.nvim_win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 87 })
)
eq(
{ all = 6, fill = 0 },
- meths.nvim_win_text_height(
- 0,
- { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 266 }
- )
+ api.nvim_win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 266 })
)
eq(
{ all = 7, fill = 0 },
- meths.nvim_win_text_height(
- 0,
- { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 267 }
- )
+ api.nvim_win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 267 })
)
eq(
{ all = 7, fill = 0 },
- meths.nvim_win_text_height(
- 0,
- { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 311 }
- )
+ api.nvim_win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 311 })
)
eq(
{ all = 7, fill = 0 },
- meths.nvim_win_text_height(
- 0,
- { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 312 }
- )
+ api.nvim_win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 312 })
)
eq(
{ all = 7, fill = 0 },
- meths.nvim_win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = X })
+ api.nvim_win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = X })
)
eq(
{ all = 7, fill = 0 },
- meths.nvim_win_text_height(0, { start_row = 1, start_vcol = 40, end_row = 1, end_vcol = X })
+ api.nvim_win_text_height(0, { start_row = 1, start_vcol = 40, end_row = 1, end_vcol = X })
)
eq(
{ all = 6, fill = 0 },
- meths.nvim_win_text_height(0, { start_row = 1, start_vcol = 41, end_row = 1, end_vcol = X })
+ api.nvim_win_text_height(0, { start_row = 1, start_vcol = 41, end_row = 1, end_vcol = X })
)
eq(
{ all = 6, fill = 0 },
- meths.nvim_win_text_height(0, { start_row = 1, start_vcol = 85, end_row = 1, end_vcol = X })
+ api.nvim_win_text_height(0, { start_row = 1, start_vcol = 85, end_row = 1, end_vcol = X })
)
eq(
{ all = 5, fill = 0 },
- meths.nvim_win_text_height(0, { start_row = 1, start_vcol = 86, end_row = 1, end_vcol = X })
+ api.nvim_win_text_height(0, { start_row = 1, start_vcol = 86, end_row = 1, end_vcol = X })
)
eq(
{ all = 2, fill = 0 },
- meths.nvim_win_text_height(
- 0,
- { start_row = 1, start_vcol = 265, end_row = 1, end_vcol = X }
- )
+ api.nvim_win_text_height(0, { start_row = 1, start_vcol = 265, end_row = 1, end_vcol = X })
)
eq(
{ all = 1, fill = 0 },
- meths.nvim_win_text_height(
- 0,
- { start_row = 1, start_vcol = 266, end_row = 1, end_vcol = X }
- )
+ api.nvim_win_text_height(0, { start_row = 1, start_vcol = 266, end_row = 1, end_vcol = X })
)
eq(
{ all = 1, fill = 0 },
- meths.nvim_win_text_height(
- 0,
- { start_row = 1, start_vcol = 310, end_row = 1, end_vcol = X }
- )
+ api.nvim_win_text_height(0, { start_row = 1, start_vcol = 310, end_row = 1, end_vcol = X })
)
eq(
{ all = 0, fill = 0 },
- meths.nvim_win_text_height(
- 0,
- { start_row = 1, start_vcol = 311, end_row = 1, end_vcol = X }
- )
+ api.nvim_win_text_height(0, { start_row = 1, start_vcol = 311, end_row = 1, end_vcol = X })
)
eq(
{ all = 1, fill = 0 },
- meths.nvim_win_text_height(
- 0,
- { start_row = 1, start_vcol = 86, end_row = 1, end_vcol = 131 }
- )
+ api.nvim_win_text_height(0, { start_row = 1, start_vcol = 86, end_row = 1, end_vcol = 131 })
)
eq(
{ all = 1, fill = 0 },
- meths.nvim_win_text_height(
+ api.nvim_win_text_height(
0,
{ start_row = 1, start_vcol = 221, end_row = 1, end_vcol = 266 }
)
)
- 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 = 18, fill = 0 }, api.nvim_win_text_height(0, { start_row = 0, start_vcol = 131 }))
+ eq({ all = 19, fill = 0 }, api.nvim_win_text_height(0, { start_row = 0, start_vcol = 130 }))
+ eq({ all = 20, fill = 0 }, api.nvim_win_text_height(0, { end_row = 2, end_vcol = 311 }))
+ eq({ all = 21, fill = 0 }, api.nvim_win_text_height(0, { end_row = 2, end_vcol = 312 }))
eq(
{ all = 17, fill = 0 },
- meths.nvim_win_text_height(
+ api.nvim_win_text_height(
0,
{ start_row = 0, start_vcol = 131, end_row = 2, end_vcol = 311 }
)
)
eq(
{ all = 19, fill = 0 },
- meths.nvim_win_text_height(
+ api.nvim_win_text_height(
0,
{ start_row = 0, start_vcol = 130, end_row = 2, end_vcol = 312 }
)
)
- 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 = 16, fill = 0 }, api.nvim_win_text_height(0, { start_row = 0, start_vcol = 221 }))
+ eq({ all = 17, fill = 0 }, api.nvim_win_text_height(0, { start_row = 0, start_vcol = 220 }))
+ eq({ all = 14, fill = 0 }, api.nvim_win_text_height(0, { end_row = 2, end_vcol = 41 }))
+ eq({ all = 15, fill = 0 }, api.nvim_win_text_height(0, { end_row = 2, end_vcol = 42 }))
eq(
{ all = 9, fill = 0 },
- meths.nvim_win_text_height(
- 0,
- { start_row = 0, start_vcol = 221, end_row = 2, end_vcol = 41 }
- )
+ api.nvim_win_text_height(0, { start_row = 0, start_vcol = 221, end_row = 2, end_vcol = 41 })
)
eq(
{ all = 11, fill = 0 },
- meths.nvim_win_text_height(
- 0,
- { start_row = 0, start_vcol = 220, end_row = 2, end_vcol = 42 }
- )
+ api.nvim_win_text_height(0, { start_row = 0, start_vcol = 220, end_row = 2, end_vcol = 42 })
)
end)
end)
@@ -1084,7 +1036,7 @@ describe('API/win', function()
describe('open_win', function()
it('noautocmd option works', function()
command('autocmd BufEnter,BufLeave,BufWinEnter * let g:fired = 1')
- meths.nvim_open_win(meths.nvim_create_buf(true, true), true, {
+ api.nvim_open_win(api.nvim_create_buf(true, true), true, {
relative = 'win',
row = 3,
col = 3,
@@ -1092,23 +1044,23 @@ describe('API/win', function()
height = 3,
noautocmd = true,
})
- eq(0, funcs.exists('g:fired'))
- meths.nvim_open_win(meths.nvim_create_buf(true, true), true, {
+ eq(0, fn.exists('g:fired'))
+ api.nvim_open_win(api.nvim_create_buf(true, true), true, {
relative = 'win',
row = 3,
col = 3,
width = 12,
height = 3,
})
- eq(1, funcs.exists('g:fired'))
+ eq(1, fn.exists('g:fired'))
end)
it('disallowed in cmdwin if enter=true or buf=curbuf', function()
- local new_buf = meths.nvim_create_buf(true, true)
+ local new_buf = api.nvim_create_buf(true, true)
feed('q:')
eq(
'E11: Invalid in command-line window; <CR> executes, CTRL-C quits',
- pcall_err(meths.nvim_open_win, new_buf, true, {
+ pcall_err(api.nvim_open_win, new_buf, true, {
relative = 'editor',
row = 5,
col = 5,
@@ -1118,7 +1070,7 @@ describe('API/win', function()
)
eq(
'E11: Invalid in command-line window; <CR> executes, CTRL-C quits',
- pcall_err(meths.nvim_open_win, 0, false, {
+ pcall_err(api.nvim_open_win, 0, false, {
relative = 'editor',
row = 5,
col = 5,
@@ -1129,7 +1081,7 @@ describe('API/win', function()
eq(
new_buf,
- meths.nvim_win_get_buf(meths.nvim_open_win(new_buf, false, {
+ api.nvim_win_get_buf(api.nvim_open_win(new_buf, false, {
relative = 'editor',
row = 5,
col = 5,
@@ -1140,10 +1092,10 @@ describe('API/win', function()
end)
it('aborts if buffer is invalid', function()
- local wins_before = meths.nvim_list_wins()
+ local wins_before = api.nvim_list_wins()
eq(
'Invalid buffer id: 1337',
- pcall_err(meths.nvim_open_win, 1337, false, {
+ pcall_err(api.nvim_open_win, 1337, false, {
relative = 'editor',
row = 5,
col = 5,
@@ -1151,14 +1103,14 @@ describe('API/win', function()
height = 5,
})
)
- eq(wins_before, meths.nvim_list_wins())
+ eq(wins_before, api.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.nvim_open_win(0, true, {
+ local win = api.nvim_open_win(0, true, {
relative = 'win',
row = 3,
col = 3,
@@ -1167,7 +1119,7 @@ describe('API/win', function()
border = b,
})
- local cfg = meths.nvim_win_get_config(win)
+ local cfg = api.nvim_win_get_config(win)
eq(b, cfg.border)
end)
@@ -1182,7 +1134,7 @@ describe('API/win', function()
{ 'g', 'Constant' },
{ 'h', 'PreProc' },
}
- local win = meths.nvim_open_win(0, true, {
+ local win = api.nvim_open_win(0, true, {
relative = 'win',
row = 3,
col = 3,
@@ -1191,14 +1143,14 @@ describe('API/win', function()
border = b,
})
- local cfg = meths.nvim_win_get_config(win)
+ local cfg = api.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.nvim_open_win(0, true, {
+ local win = api.nvim_open_win(0, true, {
relative = 'win',
row = 3,
col = 3,
@@ -1209,7 +1161,7 @@ describe('API/win', function()
footer = footer,
})
- local cfg = meths.nvim_win_get_config(win)
+ local cfg = api.nvim_win_get_config(win)
eq(title, cfg.title)
eq(footer, cfg.footer)
end)
@@ -1217,7 +1169,7 @@ describe('API/win', function()
describe('set_config', function()
it('no crash with invalid title', function()
- local win = meths.nvim_open_win(0, true, {
+ local win = api.nvim_open_win(0, true, {
width = 10,
height = 10,
relative = 'editor',
@@ -1228,14 +1180,14 @@ describe('API/win', function()
})
eq(
'title/footer cannot be an empty array',
- pcall_err(meths.nvim_win_set_config, win, { title = {} })
+ pcall_err(api.nvim_win_set_config, win, { title = {} })
)
command('redraw!')
assert_alive()
end)
it('no crash with invalid footer', function()
- local win = meths.nvim_open_win(0, true, {
+ local win = api.nvim_open_win(0, true, {
width = 10,
height = 10,
relative = 'editor',
@@ -1246,7 +1198,7 @@ describe('API/win', function()
})
eq(
'title/footer cannot be an empty array',
- pcall_err(meths.nvim_win_set_config, win, { footer = {} })
+ pcall_err(api.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 fb566e27c3..0243674f2d 100644
--- a/test/functional/autocmd/autocmd_oldtest_spec.lua
+++ b/test/functional/autocmd/autocmd_oldtest_spec.lua
@@ -3,8 +3,8 @@ local Screen = require('test.functional.ui.screen')
local clear = helpers.clear
local eq = helpers.eq
-local meths = helpers.meths
-local funcs = helpers.funcs
+local api = helpers.api
+local fn = helpers.fn
local exec = helpers.exec
local feed = helpers.feed
@@ -12,7 +12,7 @@ describe('oldtests', function()
before_each(clear)
local exec_lines = function(str)
- return funcs.split(funcs.execute(str), '\n')
+ return fn.split(fn.execute(str), '\n')
end
local add_an_autocmd = function()
@@ -23,7 +23,7 @@ describe('oldtests', function()
]]
eq(3, #exec_lines('au vimBarTest'))
- eq(1, #meths.nvim_get_autocmds({ group = 'vimBarTest' }))
+ eq(1, #api.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.nvim_get_autocmds({ group = 'vimBarTest' }))
+ eq({}, api.nvim_get_autocmds({ group = 'vimBarTest' }))
-- Sad spacing
add_an_autocmd()
@@ -49,8 +49,8 @@ describe('oldtests', function()
end)
it('should fire on unload buf', function()
- funcs.writefile({ 'Test file Xxx1' }, 'Xxx1')
- funcs.writefile({ 'Test file Xxx2' }, 'Xxx2')
+ fn.writefile({ 'Test file Xxx1' }, 'Xxx1')
+ fn.writefile({ 'Test file Xxx2' }, 'Xxx2')
local fname = 'Xtest_functional_autocmd_unload'
local content = [[
@@ -71,16 +71,16 @@ describe('oldtests', function()
q
]]
- funcs.writefile(funcs.split(content, '\n'), fname)
+ fn.writefile(fn.split(content, '\n'), fname)
- funcs.delete('Xout')
- funcs.system(string.format('%s --clean -N -S %s', meths.nvim_get_vvar('progpath'), fname))
- eq(1, funcs.filereadable('Xout'))
+ fn.delete('Xout')
+ fn.system(string.format('%s --clean -N -S %s', api.nvim_get_vvar('progpath'), fname))
+ eq(1, fn.filereadable('Xout'))
- funcs.delete('Xxx1')
- funcs.delete('Xxx2')
- funcs.delete(fname)
- funcs.delete('Xout')
+ fn.delete('Xxx1')
+ fn.delete('Xxx2')
+ fn.delete(fname)
+ fn.delete('Xout')
end)
-- oldtest: Test_delete_ml_get_errors()
diff --git a/test/functional/autocmd/autocmd_spec.lua b/test/functional/autocmd/autocmd_spec.lua
index 9ed3c5fbad..5fffb70095 100644
--- a/test/functional/autocmd/autocmd_spec.lua
+++ b/test/functional/autocmd/autocmd_spec.lua
@@ -10,9 +10,9 @@ local eval = helpers.eval
local feed = helpers.feed
local clear = helpers.clear
local matches = helpers.matches
-local meths = helpers.meths
+local api = helpers.api
local pcall_err = helpers.pcall_err
-local funcs = helpers.funcs
+local fn = helpers.fn
local expect = helpers.expect
local command = helpers.command
local exc_exec = helpers.exc_exec
@@ -142,8 +142,8 @@ describe('autocmd', function()
describe('BufLeave autocommand', function()
it('can wipe out the buffer created by :edit which triggered autocmd', function()
- meths.nvim_set_option_value('hidden', true, {})
- meths.nvim_buf_set_lines(0, 0, 1, false, {
+ api.nvim_set_option_value('hidden', true, {})
+ api.nvim_buf_set_lines(0, 0, 1, false, {
'start of test file xx',
'end of test file xx',
})
@@ -188,7 +188,7 @@ describe('autocmd', function()
:call add(g:foo, "Once2")
:call add(g:foo, "Many2")
:call add(g:foo, "Once3")]]),
- funcs.execute('autocmd Tabnew')
+ fn.execute('autocmd Tabnew')
)
command('tabnew')
command('tabnew')
@@ -201,7 +201,7 @@ describe('autocmd', function()
TabNew
* :call add(g:foo, "Many1")
:call add(g:foo, "Many2")]]),
- funcs.execute('autocmd Tabnew')
+ fn.execute('autocmd Tabnew')
)
--
@@ -247,7 +247,7 @@ describe('autocmd', function()
dedent([[
--- Autocommands ---]]),
- funcs.execute('autocmd Tabnew')
+ fn.execute('autocmd Tabnew')
)
end)
@@ -415,7 +415,7 @@ describe('autocmd', function()
end)
it('gives E814 when there are other floating windows', function()
- meths.nvim_open_win(
+ api.nvim_open_win(
0,
true,
{ width = 10, height = 10, relative = 'editor', row = 10, col = 10 }
@@ -513,17 +513,17 @@ describe('autocmd', function()
describe('v:event is readonly #18063', function()
it('during ChanOpen event', function()
command('autocmd ChanOpen * let v:event.info.id = 0')
- funcs.jobstart({ 'cat' })
+ fn.jobstart({ 'cat' })
retry(nil, nil, function()
- eq('E46: Cannot change read-only variable "v:event.info"', meths.nvim_get_vvar('errmsg'))
+ eq('E46: Cannot change read-only variable "v:event.info"', api.nvim_get_vvar('errmsg'))
end)
end)
it('during ChanOpen event', function()
command('autocmd ChanInfo * let v:event.info.id = 0')
- meths.nvim_set_client_info('foo', {}, 'remote', {}, {})
+ api.nvim_set_client_info('foo', {}, 'remote', {}, {})
retry(nil, nil, function()
- eq('E46: Cannot change read-only variable "v:event.info"', meths.nvim_get_vvar('errmsg'))
+ eq('E46: Cannot change read-only variable "v:event.info"', api.nvim_get_vvar('errmsg'))
end)
end)
@@ -577,7 +577,7 @@ describe('autocmd', function()
call assert_fails('au WinNew * ++once ++once echo bad', 'E983:')
]]
- meths.nvim_set_var('did_split', 0)
+ api.nvim_set_var('did_split', 0)
source [[
augroup Testing
@@ -589,11 +589,11 @@ describe('autocmd', function()
split
]]
- eq(2, meths.nvim_get_var('did_split'))
- eq(1, funcs.exists('#WinNew'))
+ eq(2, api.nvim_get_var('did_split'))
+ eq(1, fn.exists('#WinNew'))
-- Now with once
- meths.nvim_set_var('did_split', 0)
+ api.nvim_set_var('did_split', 0)
source [[
augroup Testing
@@ -605,8 +605,8 @@ describe('autocmd', function()
split
]]
- eq(1, meths.nvim_get_var('did_split'))
- eq(0, funcs.exists('#WinNew'))
+ eq(1, api.nvim_get_var('did_split'))
+ eq(0, fn.exists('#WinNew'))
-- call assert_fails('au WinNew * ++once ++once echo bad', 'E983:')
local ok, msg = pcall(
@@ -622,7 +622,7 @@ describe('autocmd', function()
it('should have autocmds in filetypedetect group', function()
source [[filetype on]]
- neq({}, meths.nvim_get_autocmds { group = 'filetypedetect' })
+ neq({}, api.nvim_get_autocmds { group = 'filetypedetect' })
end)
it('should allow comma-separated patterns', function()
@@ -634,7 +634,7 @@ describe('autocmd', function()
augroup END
]]
- eq(4, #meths.nvim_get_autocmds { event = 'BufReadCmd', group = 'TestingPatterns' })
+ eq(4, #api.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 11a320910c..5a5b16b438 100644
--- a/test/functional/autocmd/cmdline_spec.lua
+++ b/test/functional/autocmd/cmdline_spec.lua
@@ -8,14 +8,14 @@ local expect = helpers.expect
local eval = helpers.eval
local next_msg = helpers.next_msg
local feed = helpers.feed
-local meths = helpers.meths
+local api = helpers.api
describe('cmdline autocommands', function()
local channel
before_each(function()
clear()
- channel = meths.nvim_get_api_info()[1]
- meths.nvim_set_var('channel', channel)
+ channel = api.nvim_get_api_info()[1]
+ api.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 58c50c9922..fc2b65f53a 100644
--- a/test/functional/autocmd/cursorhold_spec.lua
+++ b/test/functional/autocmd/cursorhold_spec.lua
@@ -6,7 +6,7 @@ local feed = helpers.feed
local retry = helpers.retry
local exec = helpers.source
local sleep = vim.uv.sleep
-local meths = helpers.meths
+local api = helpers.api
before_each(clear)
@@ -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.nvim_set_option_value('updatetime', ut, {})
+ api.nvim_set_option_value('updatetime', ut, {})
feed('0') -- reset did_cursorhold
- meths.nvim_set_var('cursorhold', 0)
+ api.nvim_set_var('cursorhold', 0)
sleep(ut / 4)
fn()
- eq(0, meths.nvim_get_var('cursorhold'))
+ eq(0, api.nvim_get_var('cursorhold'))
sleep(ut / 2)
fn()
- eq(0, meths.nvim_get_var('cursorhold'))
+ eq(0, api.nvim_get_var('cursorhold'))
sleep(ut / 2)
- eq(early, meths.nvim_get_var('cursorhold'))
+ eq(early, api.nvim_get_var('cursorhold'))
sleep(ut / 4 * 3)
- eq(1, meths.nvim_get_var('cursorhold'))
+ eq(1, api.nvim_get_var('cursorhold'))
end)
end
- local ignore_key = meths.nvim_replace_termcodes('<Ignore>', true, true, true)
+ local ignore_key = api.nvim_replace_termcodes('<Ignore>', true, true, true)
test_cursorhold(function() end, 1)
test_cursorhold(function()
feed('')
end, 1)
test_cursorhold(function()
- meths.nvim_feedkeys('', 'n', true)
+ api.nvim_feedkeys('', 'n', true)
end, 1)
test_cursorhold(function()
feed('<Ignore>')
end, 0)
test_cursorhold(function()
- meths.nvim_feedkeys(ignore_key, 'n', true)
+ api.nvim_feedkeys(ignore_key, 'n', true)
end, 0)
end)
it("reducing 'updatetime' while waiting for CursorHold #20241", function()
- meths.nvim_set_option_value('updatetime', 10000, {})
+ api.nvim_set_option_value('updatetime', 10000, {})
feed('0') -- reset did_cursorhold
- meths.nvim_set_var('cursorhold', 0)
+ api.nvim_set_var('cursorhold', 0)
sleep(50)
- eq(0, meths.nvim_get_var('cursorhold'))
- meths.nvim_set_option_value('updatetime', 20, {})
+ eq(0, api.nvim_get_var('cursorhold'))
+ api.nvim_set_option_value('updatetime', 20, {})
sleep(10)
- eq(1, meths.nvim_get_var('cursorhold'))
+ eq(1, api.nvim_get_var('cursorhold'))
end)
end)
@@ -85,7 +85,7 @@ describe('CursorHoldI', function()
feed('ifoo')
retry(5, nil, function()
sleep(1)
- eq(1, meths.nvim_get_var('cursorhold'))
+ eq(1, api.nvim_get_var('cursorhold'))
end)
end)
end)
diff --git a/test/functional/autocmd/cursormoved_spec.lua b/test/functional/autocmd/cursormoved_spec.lua
index 0fa5ab296c..302afe87b8 100644
--- a/test/functional/autocmd/cursormoved_spec.lua
+++ b/test/functional/autocmd/cursormoved_spec.lua
@@ -3,7 +3,7 @@ local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
local eq = helpers.eq
local eval = helpers.eval
-local meths = helpers.meths
+local api = helpers.api
local source = helpers.source
local command = helpers.command
@@ -41,9 +41,9 @@ describe('CursorMoved', function()
vsplit foo
autocmd CursorMoved * let g:cursormoved += 1
]])
- meths.nvim_buf_set_lines(eval('g:buf'), 0, -1, true, { 'aaa' })
+ api.nvim_buf_set_lines(eval('g:buf'), 0, -1, true, { 'aaa' })
eq(0, eval('g:cursormoved'))
- eq({ 'aaa' }, meths.nvim_buf_get_lines(eval('g:buf'), 0, -1, true))
+ eq({ 'aaa' }, api.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 867f845e48..b5b7ab2f95 100644
--- a/test/functional/autocmd/safestate_spec.lua
+++ b/test/functional/autocmd/safestate_spec.lua
@@ -3,7 +3,7 @@ local clear = helpers.clear
local eq = helpers.eq
local exec = helpers.exec
local feed = helpers.feed
-local meths = helpers.meths
+local api = helpers.api
before_each(clear)
@@ -18,40 +18,40 @@ describe('SafeState autocommand', function()
it('with pending operator', function()
feed('d')
create_autocmd()
- eq(0, meths.nvim_get_var('safe'))
+ eq(0, api.nvim_get_var('safe'))
feed('d')
- eq(1, meths.nvim_get_var('safe'))
+ eq(1, api.nvim_get_var('safe'))
end)
it('with specified register', function()
feed('"r')
create_autocmd()
- eq(0, meths.nvim_get_var('safe'))
+ eq(0, api.nvim_get_var('safe'))
feed('x')
- eq(1, meths.nvim_get_var('safe'))
+ eq(1, api.nvim_get_var('safe'))
end)
it('with i_CTRL-O', function()
feed('i<C-O>')
create_autocmd()
- eq(0, meths.nvim_get_var('safe'))
+ eq(0, api.nvim_get_var('safe'))
feed('x')
- eq(1, meths.nvim_get_var('safe'))
+ eq(1, api.nvim_get_var('safe'))
end)
it('with Insert mode completion', function()
feed('i<C-X><C-V>')
create_autocmd()
- eq(0, meths.nvim_get_var('safe'))
+ eq(0, api.nvim_get_var('safe'))
feed('<C-X><C-Z>')
- eq(1, meths.nvim_get_var('safe'))
+ eq(1, api.nvim_get_var('safe'))
end)
it('with Cmdline completion', function()
feed(':<Tab>')
create_autocmd()
- eq(0, meths.nvim_get_var('safe'))
+ eq(0, api.nvim_get_var('safe'))
feed('<C-E>')
- eq(1, meths.nvim_get_var('safe'))
+ eq(1, api.nvim_get_var('safe'))
end)
end)
diff --git a/test/functional/autocmd/searchwrapped_spec.lua b/test/functional/autocmd/searchwrapped_spec.lua
index 8d25106680..0705b2d5de 100644
--- a/test/functional/autocmd/searchwrapped_spec.lua
+++ b/test/functional/autocmd/searchwrapped_spec.lua
@@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
local command = helpers.command
-local meths = helpers.meths
+local api = helpers.api
local eq = helpers.eq
local eval = helpers.eval
local feed = helpers.feed
@@ -13,7 +13,7 @@ describe('autocmd SearchWrapped', function()
command('set ignorecase')
command('let g:test = 0')
command('autocmd! SearchWrapped * let g:test += 1')
- meths.nvim_buf_set_lines(0, 0, 1, false, {
+ api.nvim_buf_set_lines(0, 0, 1, false, {
'The quick brown fox',
'jumps over the lazy dog',
})
diff --git a/test/functional/autocmd/show_spec.lua b/test/functional/autocmd/show_spec.lua
index f081c918fc..1a9dc8a337 100644
--- a/test/functional/autocmd/show_spec.lua
+++ b/test/functional/autocmd/show_spec.lua
@@ -5,7 +5,7 @@ local clear = helpers.clear
local command = helpers.command
local dedent = helpers.dedent
local eq = helpers.eq
-local funcs = helpers.funcs
+local fn = helpers.fn
local eval = helpers.eval
local exec = helpers.exec
local feed = helpers.feed
@@ -36,7 +36,7 @@ describe(':autocmd', function()
TestingOne BufEnter
* :echo "Line 1"
:echo "Line 2"]]),
- funcs.execute('autocmd BufEnter')
+ fn.execute('autocmd BufEnter')
)
end)
@@ -160,7 +160,7 @@ describe(':autocmd', function()
A echo "A2"
test_3 User
A echo "A3"]]),
- funcs.execute('autocmd User A')
+ fn.execute('autocmd User A')
)
eq(
dedent([[
@@ -178,7 +178,7 @@ describe(':autocmd', function()
B echo "B2"
test_3 User
B echo "B3"]]),
- funcs.execute('autocmd * B')
+ fn.execute('autocmd * B')
)
eq(
dedent([[
@@ -188,7 +188,7 @@ describe(':autocmd', function()
B echo "B3"
test_3 User
B echo "B3"]]),
- funcs.execute('autocmd test_3 * B')
+ fn.execute('autocmd test_3 * B')
)
end)
diff --git a/test/functional/autocmd/signal_spec.lua b/test/functional/autocmd/signal_spec.lua
index 96924fb2fc..c7087254e7 100644
--- a/test/functional/autocmd/signal_spec.lua
+++ b/test/functional/autocmd/signal_spec.lua
@@ -3,7 +3,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
local next_msg = helpers.next_msg
local is_os = helpers.is_os
local skip = helpers.skip
@@ -21,25 +21,25 @@ describe('autocmd Signal', function()
it('matches *', function()
command('autocmd Signal * call rpcnotify(1, "foo")')
- posix_kill('USR1', funcs.getpid())
+ posix_kill('USR1', fn.getpid())
eq({ 'notification', 'foo', {} }, next_msg())
end)
it('matches SIGUSR1', function()
command('autocmd Signal SIGUSR1 call rpcnotify(1, "foo")')
- posix_kill('USR1', funcs.getpid())
+ posix_kill('USR1', fn.getpid())
eq({ 'notification', 'foo', {} }, next_msg())
end)
it('matches SIGWINCH', function()
command('autocmd Signal SIGWINCH call rpcnotify(1, "foo")')
- posix_kill('WINCH', funcs.getpid())
+ posix_kill('WINCH', fn.getpid())
eq({ 'notification', 'foo', {} }, next_msg())
end)
it('does not match unknown patterns', function()
command('autocmd Signal SIGUSR2 call rpcnotify(1, "foo")')
- posix_kill('USR1', funcs.getpid())
+ posix_kill('USR1', fn.getpid())
eq(nil, next_msg(500))
end)
end)
diff --git a/test/functional/autocmd/tabclose_spec.lua b/test/functional/autocmd/tabclose_spec.lua
index 34f5178158..d0b2ac6a8d 100644
--- a/test/functional/autocmd/tabclose_spec.lua
+++ b/test/functional/autocmd/tabclose_spec.lua
@@ -1,6 +1,6 @@
local helpers = require('test.functional.helpers')(after_each)
local clear, eq = helpers.clear, helpers.eq
-local meths = helpers.meths
+local api = helpers.api
local command = helpers.command
describe('TabClosed', function()
@@ -14,11 +14,11 @@ describe('TabClosed', function()
)
repeat
command('tabnew')
- until meths.nvim_eval('tabpagenr()') == 6 -- current tab is now 6
- eq('tabclosed:6:6:5', meths.nvim_exec('tabclose', true)) -- close last 6, current tab is now 5
- eq('tabclosed:5:5:4', meths.nvim_exec('close', true)) -- close last window on tab, closes tab
- eq('tabclosed:2:2:3', meths.nvim_exec('2tabclose', true)) -- close tab 2, current tab is now 3
- eq('tabclosed:1:1:2\ntabclosed:1:1:1', meths.nvim_exec('tabonly', true)) -- close tabs 1 and 2
+ until api.nvim_eval('tabpagenr()') == 6 -- current tab is now 6
+ eq('tabclosed:6:6:5', api.nvim_exec('tabclose', true)) -- close last 6, current tab is now 5
+ eq('tabclosed:5:5:4', api.nvim_exec('close', true)) -- close last window on tab, closes tab
+ eq('tabclosed:2:2:3', api.nvim_exec('2tabclose', true)) -- close tab 2, current tab is now 3
+ eq('tabclosed:1:1:2\ntabclosed:1:1:1', api.nvim_exec('tabonly', true)) -- close tabs 1 and 2
end)
it('is triggered when closing a window via bdelete from another tab', function()
@@ -28,9 +28,9 @@ describe('TabClosed', function()
command('1tabedit Xtestfile')
command('1tabedit Xtestfile')
command('normal! 1gt')
- eq({ 1, 3 }, meths.nvim_eval('[tabpagenr(), tabpagenr("$")]'))
- eq('tabclosed:2:2:1\ntabclosed:2:2:1', meths.nvim_exec('bdelete Xtestfile', true))
- eq({ 1, 1 }, meths.nvim_eval('[tabpagenr(), tabpagenr("$")]'))
+ eq({ 1, 3 }, api.nvim_eval('[tabpagenr(), tabpagenr("$")]'))
+ eq('tabclosed:2:2:1\ntabclosed:2:2:1', api.nvim_exec('bdelete Xtestfile', true))
+ eq({ 1, 1 }, api.nvim_eval('[tabpagenr(), tabpagenr("$")]'))
end)
it('is triggered when closing a window via bdelete from current tab', function()
@@ -42,9 +42,9 @@ describe('TabClosed', function()
command('1tabedit Xtestfile2')
-- Only one tab is closed, and the alternate file is used for the other.
- eq({ 2, 3 }, meths.nvim_eval('[tabpagenr(), tabpagenr("$")]'))
- eq('tabclosed:2:2:2', meths.nvim_exec('bdelete Xtestfile2', true))
- eq('Xtestfile1', meths.nvim_eval('bufname("")'))
+ eq({ 2, 3 }, api.nvim_eval('[tabpagenr(), tabpagenr("$")]'))
+ eq('tabclosed:2:2:2', api.nvim_exec('bdelete Xtestfile2', true))
+ eq('Xtestfile1', api.nvim_eval('bufname("")'))
end)
end)
@@ -56,11 +56,11 @@ describe('TabClosed', function()
command('au! TabClosed 2 echom "tabclosed:match"')
repeat
command('tabnew')
- until meths.nvim_eval('tabpagenr()') == 7 -- current tab is now 7
+ until api.nvim_eval('tabpagenr()') == 7 -- current tab is now 7
-- sanity check, we shouldn't match on tabs with numbers other than 2
- eq('tabclosed:7:7:6', meths.nvim_exec('tabclose', true))
+ eq('tabclosed:7:7:6', api.nvim_exec('tabclose', true))
-- close tab page 2, current tab is now 5
- eq('tabclosed:2:2:5\ntabclosed:match', meths.nvim_exec('2tabclose', true))
+ eq('tabclosed:2:2:5\ntabclosed:match', api.nvim_exec('2tabclose', true))
end)
end)
@@ -70,9 +70,9 @@ describe('TabClosed', function()
'au! TabClosed * echom "tabclosed:".expand("<afile>").":".expand("<amatch>").":".tabpagenr()'
)
command('tabedit Xtestfile')
- eq({ 2, 2 }, meths.nvim_eval('[tabpagenr(), tabpagenr("$")]'))
- eq('tabclosed:2:2:1', meths.nvim_exec('close', true))
- eq({ 1, 1 }, meths.nvim_eval('[tabpagenr(), tabpagenr("$")]'))
+ eq({ 2, 2 }, api.nvim_eval('[tabpagenr(), tabpagenr("$")]'))
+ eq('tabclosed:2:2:1', api.nvim_exec('close', true))
+ eq({ 1, 1 }, api.nvim_eval('[tabpagenr(), tabpagenr("$")]'))
end)
end)
end)
diff --git a/test/functional/autocmd/tabnewentered_spec.lua b/test/functional/autocmd/tabnewentered_spec.lua
index cdde9ad247..b888845e3b 100644
--- a/test/functional/autocmd/tabnewentered_spec.lua
+++ b/test/functional/autocmd/tabnewentered_spec.lua
@@ -6,7 +6,7 @@ local dedent = helpers.dedent
local eval = helpers.eval
local eq = helpers.eq
local feed = helpers.feed
-local meths = helpers.meths
+local api = helpers.api
local exec_capture = helpers.exec_capture
describe('TabNewEntered', function()
@@ -15,15 +15,15 @@ describe('TabNewEntered', function()
it('matches when entering any new tab', function()
clear()
command('au! TabNewEntered * echom "tabnewentered:".tabpagenr().":".bufnr("")')
- eq('tabnewentered:2:2', meths.nvim_exec('tabnew', true))
- eq('tabnewentered:3:3', meths.nvim_exec('tabnew test.x2', true))
+ eq('tabnewentered:2:2', api.nvim_exec('tabnew', true))
+ eq('tabnewentered:3:3', api.nvim_exec('tabnew test.x2', true))
end)
end)
describe('with FILE as <afile>', function()
it('matches when opening a new tab for FILE', function()
clear()
command('au! TabNewEntered Xtest-tabnewentered echom "tabnewentered:match"')
- eq('tabnewentered:match', meths.nvim_exec('tabnew Xtest-tabnewentered', true))
+ eq('tabnewentered:match', api.nvim_exec('tabnew Xtest-tabnewentered', true))
end)
end)
describe('with CTRL-W T', function()
@@ -32,7 +32,7 @@ describe('TabNewEntered', function()
command('au! TabNewEntered * echom "entered"')
command('tabnew test.x2')
command('split')
- eq('entered', meths.nvim_exec('execute "normal \\<C-W>T"', true))
+ eq('entered', api.nvim_exec('execute "normal \\<C-W>T"', true))
end)
end)
describe('with tab split #4334', function()
@@ -40,7 +40,7 @@ describe('TabNewEntered', function()
clear()
command('au! TabNewEntered * let b:entered = "entered"')
command('tab split')
- eq('entered', meths.nvim_exec('echo b:entered', true))
+ eq('entered', api.nvim_exec('echo b:entered', true))
end)
end)
end)
@@ -52,8 +52,8 @@ describe('TabEnter', function()
command('augroup TEMP')
command('au! TabEnter * echom "tabenter:".tabpagenr().":".tabpagenr(\'#\')')
command('augroup END')
- eq('tabenter:2:1', meths.nvim_exec('tabnew', true))
- eq('tabenter:3:2', meths.nvim_exec('tabnew test.x2', true))
+ eq('tabenter:2:1', api.nvim_exec('tabnew', true))
+ eq('tabenter:3:2', api.nvim_exec('tabnew test.x2', true))
command('augroup! TEMP')
end)
it('has correct previous tab when entering any preexisting tab', function()
@@ -62,8 +62,8 @@ describe('TabEnter', function()
command('augroup TEMP')
command('au! TabEnter * echom "tabenter:".tabpagenr().":".tabpagenr(\'#\')')
command('augroup END')
- eq('tabenter:1:3', meths.nvim_exec('tabnext', true))
- eq('tabenter:2:1', meths.nvim_exec('tabnext', true))
+ eq('tabenter:1:3', api.nvim_exec('tabnext', true))
+ eq('tabenter:2:1', api.nvim_exec('tabnext', true))
command('augroup! TEMP')
end)
end)
diff --git a/test/functional/autocmd/termxx_spec.lua b/test/functional/autocmd/termxx_spec.lua
index 0243fdf600..982edfa06a 100644
--- a/test/functional/autocmd/termxx_spec.lua
+++ b/test/functional/autocmd/termxx_spec.lua
@@ -7,7 +7,7 @@ local eval, eq, neq, retry = helpers.eval, helpers.eq, helpers.neq, helpers.retr
local matches = helpers.matches
local ok = helpers.ok
local feed = helpers.feed
-local meths = helpers.meths
+local api = helpers.api
local pcall_err = helpers.pcall_err
local assert_alive = helpers.assert_alive
local skip = helpers.skip
@@ -16,13 +16,13 @@ local is_os = helpers.is_os
describe('autocmd TermClose', function()
before_each(function()
clear()
- meths.nvim_set_option_value('shell', testprg('shell-test'), {})
+ api.nvim_set_option_value('shell', testprg('shell-test'), {})
command('set shellcmdflag=EXE shellredir= shellpipe= shellquote= shellxquote=')
end)
local function test_termclose_delete_own_buf()
-- The terminal process needs to keep running so that TermClose isn't triggered immediately.
- meths.nvim_set_option_value('shell', string.format('"%s" INTERACT', testprg('shell-test')), {})
+ api.nvim_set_option_value('shell', string.format('"%s" INTERACT', testprg('shell-test')), {})
command('autocmd TermClose * bdelete!')
command('terminal')
matches(
@@ -56,7 +56,7 @@ describe('autocmd TermClose', function()
it('triggers when long-running terminal job gets stopped', function()
skip(is_os('win'))
- meths.nvim_set_option_value('shell', is_os('win') and 'cmd.exe' or 'sh', {})
+ api.nvim_set_option_value('shell', is_os('win') and 'cmd.exe' or 'sh', {})
command('autocmd TermClose * let g:test_termclose = 23')
command('terminal')
command('call jobstop(b:terminal_job_id)')
@@ -67,8 +67,8 @@ describe('autocmd TermClose', function()
it('kills job trapping SIGTERM', function()
skip(is_os('win'))
- meths.nvim_set_option_value('shell', 'sh', {})
- meths.nvim_set_option_value('shellcmdflag', '-c', {})
+ api.nvim_set_option_value('shell', 'sh', {})
+ api.nvim_set_option_value('shellcmdflag', '-c', {})
command(
[[ let g:test_job = jobstart('trap "" TERM && echo 1 && sleep 60', { ]]
.. [[ 'on_stdout': {-> execute('let g:test_job_started = 1')}, ]]
@@ -93,8 +93,8 @@ describe('autocmd TermClose', function()
it('kills PTY job trapping SIGHUP and SIGTERM', function()
skip(is_os('win'))
- meths.nvim_set_option_value('shell', 'sh', {})
- meths.nvim_set_option_value('shellcmdflag', '-c', {})
+ api.nvim_set_option_value('shell', 'sh', {})
+ api.nvim_set_option_value('shellcmdflag', '-c', {})
command(
[[ let g:test_job = jobstart('trap "" HUP TERM && echo 1 && sleep 60', { ]]
.. [[ 'pty': 1,]]
@@ -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.nvim_get_var('called'))
+ eq(1, api.nvim_get_var('called'))
end)
end)
@@ -214,7 +214,7 @@ describe('autocmd TextChangedT', function()
screen:expect({ any = 'E937: ' })
matches(
'^E937: Attempt to delete a buffer that is in use: term://',
- meths.nvim_get_vvar('errmsg')
+ api.nvim_get_vvar('errmsg')
)
end)
end)
diff --git a/test/functional/autocmd/textyankpost_spec.lua b/test/functional/autocmd/textyankpost_spec.lua
index 964b5c0be4..29cd62f586 100644
--- a/test/functional/autocmd/textyankpost_spec.lua
+++ b/test/functional/autocmd/textyankpost_spec.lua
@@ -1,7 +1,7 @@
local helpers = require('test.functional.helpers')(after_each)
local clear, eval, eq = helpers.clear, helpers.eval, helpers.eq
local feed, command, expect = helpers.feed, helpers.command, helpers.expect
-local meths, funcs, neq = helpers.meths, helpers.funcs, helpers.neq
+local api, fn, neq = helpers.api, helpers.fn, helpers.neq
describe('TextYankPost', function()
before_each(function()
@@ -14,7 +14,7 @@ describe('TextYankPost', function()
command('autocmd TextYankPost * let g:event = copy(v:event)')
command('autocmd TextYankPost * let g:count += 1')
- meths.nvim_buf_set_lines(0, 0, -1, true, {
+ api.nvim_buf_set_lines(0, 0, -1, true, {
'foo\0bar',
'baz text',
})
@@ -100,7 +100,7 @@ describe('TextYankPost', function()
visual = false,
}, eval('g:event'))
eq(1, eval('g:count'))
- eq({ 'foo\nbar' }, funcs.getreg('+', 1, 1))
+ eq({ 'foo\nbar' }, fn.getreg('+', 1, 1))
end)
it('is executed after delete and change', function()
diff --git a/test/functional/autocmd/win_scrolled_resized_spec.lua b/test/functional/autocmd/win_scrolled_resized_spec.lua
index 67cb84de5b..26d2b68ad4 100644
--- a/test/functional/autocmd/win_scrolled_resized_spec.lua
+++ b/test/functional/autocmd/win_scrolled_resized_spec.lua
@@ -7,7 +7,7 @@ local eval = helpers.eval
local exec = helpers.exec
local command = helpers.command
local feed = helpers.feed
-local meths = helpers.meths
+local api = helpers.api
local assert_alive = helpers.assert_alive
before_each(clear)
@@ -45,7 +45,7 @@ describe('WinScrolled', function()
local win_id
before_each(function()
- win_id = meths.nvim_get_current_win().id
+ win_id = api.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.nvim_buf_set_lines(0, 0, -1, true, lines)
+ api.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.nvim_win_get_width(0)
+ local width = api.nvim_win_get_width(0)
local line = '123' .. ('*'):rep(width * 2)
local lines = { line, line }
- meths.nvim_buf_set_lines(0, 0, -1, true, lines)
+ api.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.nvim_buf_set_lines(0, 0, -1, true, lines)
- meths.nvim_win_set_cursor(0, { 3, 0 })
+ api.nvim_buf_set_lines(0, 0, -1, true, lines)
+ api.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.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 })
+ local height = api.nvim_win_get_height(0)
+ local width = api.nvim_win_get_width(0)
+ api.nvim_buf_set_lines(0, 0, -1, true, { ('foo'):rep(height * width) })
+ api.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.nvim_win_get_height(0)
+ local height = api.nvim_win_get_height(0)
local lines = {}
for i = 1, height * 2 do
lines[i] = tostring(i)
end
- meths.nvim_buf_set_lines(0, 0, -1, true, lines)
+ api.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.nvim_input_mouse('wheel', 'down', '', 0, 6, 0)
+ api.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.nvim_input_mouse('wheel', 'down', '', 0, 6, 0)
+ api.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.nvim_create_buf(true, true)
- meths.nvim_buf_set_lines(
+ local buf = api.nvim_create_buf(true, true)
+ api.nvim_buf_set_lines(
buf,
0,
-1,
false,
{ '@', 'b', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n' }
)
- local win = meths.nvim_open_win(buf, false, {
+ local win = api.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.nvim_input_mouse('wheel', 'down', '', 0, 3, 3)
+ api.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.nvim_input_mouse('wheel', 'up', '', 0, 3, 3)
+ api.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 566b8e4250..ce13c4755d 100644
--- a/test/functional/core/channels_spec.lua
+++ b/test/functional/core/channels_spec.lua
@@ -1,7 +1,7 @@
local helpers = require('test.functional.helpers')(after_each)
local clear, eq, eval, next_msg, ok, source =
helpers.clear, helpers.eq, helpers.eval, helpers.next_msg, helpers.ok, helpers.source
-local command, funcs, meths = helpers.command, helpers.funcs, helpers.meths
+local command, fn, api = helpers.command, helpers.fn, helpers.api
local sleep = vim.uv.sleep
local spawn, nvim_argv = helpers.spawn, helpers.nvim_argv
local set_session = helpers.set_session
@@ -33,12 +33,12 @@ describe('channels', function()
pending('can connect to socket', function()
local server = spawn(nvim_argv, nil, nil, true)
set_session(server)
- local address = funcs.serverlist()[1]
+ local address = fn.serverlist()[1]
local client = spawn(nvim_argv, nil, nil, true)
set_session(client)
source(init)
- meths.nvim_set_var('address', address)
+ api.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.nvim_get_var('code'))
+ eq(23, api.nvim_get_var('code'))
end)
set_session(client)
@@ -67,8 +67,8 @@ describe('channels', function()
\ 'on_exit': function('OnEvent'),
\ }
]])
- meths.nvim_set_var('nvim_prog', nvim_prog)
- meths.nvim_set_var(
+ api.nvim_set_var('nvim_prog', nvim_prog)
+ api.nvim_set_var(
'code',
[[
function! OnEvent(id, data, event) dict
@@ -117,8 +117,8 @@ describe('channels', function()
\ 'on_exit': function('OnEvent'),
\ }
]])
- meths.nvim_set_var('nvim_prog', nvim_prog)
- meths.nvim_set_var(
+ api.nvim_set_var('nvim_prog', nvim_prog)
+ api.nvim_set_var(
'code',
[[
function! OnStdin(id, data, event) dict
@@ -165,8 +165,8 @@ describe('channels', function()
\ 'pty': v:true,
\ }
]])
- meths.nvim_set_var('nvim_prog', nvim_prog)
- meths.nvim_set_var(
+ api.nvim_set_var('nvim_prog', nvim_prog)
+ api.nvim_set_var(
'code',
[[
function! OnEvent(id, data, event) dict
@@ -220,8 +220,8 @@ describe('channels', function()
\ 'rpc': v:true,
\ }
]])
- meths.nvim_set_var('nvim_prog', nvim_prog)
- meths.nvim_set_var(
+ api.nvim_set_var('nvim_prog', nvim_prog)
+ api.nvim_set_var(
'code',
[[
let id = stdioopen({'rpc':v:true})
@@ -250,7 +250,7 @@ describe('channels', function()
end)
it('can use buffered output mode', function()
- skip(funcs.executable('grep') == 0, 'missing "grep" command')
+ skip(fn.executable('grep') == 0, 'missing "grep" command')
source([[
let g:job_opts = {
\ 'on_stdout': function('OnEvent'),
@@ -285,7 +285,7 @@ describe('channels', function()
end)
it('can use buffered output mode with no stream callback', function()
- skip(funcs.executable('grep') == 0, 'missing "grep" command')
+ skip(fn.executable('grep') == 0, 'missing "grep" command')
source([[
function! OnEvent(id, data, event) dict
call rpcnotify(1, a:event, a:id, a:data, self.stdout)
diff --git a/test/functional/core/exit_spec.lua b/test/functional/core/exit_spec.lua
index 9ae2150f84..b74ebb2367 100644
--- a/test/functional/core/exit_spec.lua
+++ b/test/functional/core/exit_spec.lua
@@ -7,7 +7,7 @@ local feed = helpers.feed
local eval = helpers.eval
local eq = helpers.eq
local run = helpers.run
-local funcs = helpers.funcs
+local fn = helpers.fn
local nvim_prog = helpers.nvim_prog
local pcall_err = helpers.pcall_err
local exec_capture = helpers.exec_capture
@@ -18,7 +18,7 @@ describe('v:exiting', function()
before_each(function()
helpers.clear()
- cid = helpers.meths.nvim_get_api_info()[1]
+ cid = helpers.api.nvim_get_api_info()[1]
end)
it('defaults to v:null', function()
@@ -68,7 +68,7 @@ describe(':cquit', function()
poke_eventloop()
assert_alive()
else
- funcs.system({ nvim_prog, '-u', 'NONE', '-i', 'NONE', '--headless', '--cmd', cmdline })
+ fn.system({ nvim_prog, '-u', 'NONE', '-i', 'NONE', '--headless', '--cmd', cmdline })
eq(exit_code, eval('v:shell_error'))
end
end
diff --git a/test/functional/core/fileio_spec.lua b/test/functional/core/fileio_spec.lua
index 229d127b6d..928cab525c 100644
--- a/test/functional/core/fileio_spec.lua
+++ b/test/functional/core/fileio_spec.lua
@@ -9,18 +9,18 @@ local eq = helpers.eq
local neq = helpers.neq
local ok = helpers.ok
local feed = helpers.feed
-local funcs = helpers.funcs
+local fn = helpers.fn
local nvim_prog = helpers.nvim_prog
local request = helpers.request
local retry = helpers.retry
local rmdir = helpers.rmdir
local matches = helpers.matches
-local meths = helpers.meths
+local api = helpers.api
local mkdir = helpers.mkdir
local sleep = vim.uv.sleep
local read_file = helpers.read_file
local trim = vim.trim
-local currentdir = helpers.funcs.getcwd
+local currentdir = helpers.fn.getcwd
local assert_alive = helpers.assert_alive
local check_close = helpers.check_close
local expect_exit = helpers.expect_exit
@@ -100,8 +100,8 @@ describe('fileio', function()
eq('foozubbaz', trim(read_file('Xtest_startup_file1')))
-- 4. Exit caused by deadly signal (+ 'swapfile').
- local j = funcs.jobstart(vim.tbl_flatten({ args, '--embed' }), { rpc = true })
- funcs.rpcrequest(
+ local j = fn.jobstart(vim.tbl_flatten({ args, '--embed' }), { rpc = true })
+ fn.rpcrequest(
j,
'nvim_exec2',
[[
@@ -112,8 +112,8 @@ describe('fileio', function()
]],
{}
)
- eq('Xtest_startup_swapdir', funcs.rpcrequest(j, 'nvim_eval', '&directory'))
- funcs.jobstop(j) -- Send deadly signal.
+ eq('Xtest_startup_swapdir', fn.rpcrequest(j, 'nvim_eval', '&directory'))
+ fn.jobstop(j) -- Send deadly signal.
local screen = startup()
feed(':recover Xtest_startup_file2<cr>')
@@ -258,9 +258,9 @@ describe('fileio', function()
'',
}
local fname = 'Xtest_тест.md'
- funcs.writefile(text, fname, 's')
+ fn.writefile(text, fname, 's')
table.insert(text, '')
- eq(text, funcs.readfile(fname, 'b'))
+ eq(text, fn.readfile(fname, 'b'))
end)
it("read invalid u8 over INT_MAX doesn't segfault", function()
clear()
@@ -341,7 +341,7 @@ describe('tmpdir', function()
-- Tempfiles typically look like: "…/nvim.<user>/xxx/0".
-- - "…/nvim.<user>/xxx/" is the per-process tmpdir, not shared with other Nvims.
-- - "…/nvim.<user>/" is the tmpdir root, shared by all Nvims (normally).
- local tmproot = (funcs.tempname()):match(tmproot_pat)
+ local tmproot = (fn.tempname()):match(tmproot_pat)
ok(tmproot:len() > 4, 'tmproot like "nvim.foo"', tmproot)
return tmproot
end
@@ -360,7 +360,7 @@ describe('tmpdir', function()
rmdir(tmproot)
write_file(tmproot, '') -- Not a directory, vim_mktempdir() should skip it.
clear({ env = { NVIM_LOG_FILE = testlog, TMPDIR = os_tmpdir } })
- matches(tmproot_pat, funcs.stdpath('run')) -- Tickle vim_mktempdir().
+ matches(tmproot_pat, fn.stdpath('run')) -- Tickle vim_mktempdir().
-- Assert that broken tmpdir root was handled.
assert_log('tempdir root not a directory', testlog, 100)
@@ -369,9 +369,9 @@ describe('tmpdir', function()
os.remove(testlog)
os.remove(tmproot)
mkdir(tmproot)
- funcs.setfperm(tmproot, 'rwxr--r--') -- Invalid permissions, vim_mktempdir() should skip it.
+ fn.setfperm(tmproot, 'rwxr--r--') -- Invalid permissions, vim_mktempdir() should skip it.
clear({ env = { NVIM_LOG_FILE = testlog, TMPDIR = os_tmpdir } })
- matches(tmproot_pat, funcs.stdpath('run')) -- Tickle vim_mktempdir().
+ matches(tmproot_pat, fn.stdpath('run')) -- Tickle vim_mktempdir().
-- Assert that broken tmpdir root was handled.
assert_log('tempdir root has invalid permissions', testlog, 100)
end)
@@ -380,8 +380,8 @@ describe('tmpdir', function()
local bigname = ('%s/%s'):format(os_tmpdir, ('x'):rep(666))
mkdir(bigname)
clear({ env = { NVIM_LOG_FILE = testlog, TMPDIR = bigname } })
- matches(tmproot_pat, funcs.stdpath('run')) -- Tickle vim_mktempdir().
- local len = (funcs.tempname()):len()
+ matches(tmproot_pat, fn.stdpath('run')) -- Tickle vim_mktempdir().
+ local len = (fn.tempname()):len()
ok(len > 4 and len < 256, '4 < len < 256', tostring(len))
end)
@@ -390,33 +390,33 @@ describe('tmpdir', function()
assert_nolog('tempdir disappeared', testlog)
local function rm_tmpdir()
- local tmpname1 = funcs.tempname()
- local tmpdir1 = funcs.fnamemodify(tmpname1, ':h')
- eq(funcs.stdpath('run'), tmpdir1)
+ local tmpname1 = fn.tempname()
+ local tmpdir1 = fn.fnamemodify(tmpname1, ':h')
+ eq(fn.stdpath('run'), tmpdir1)
rmdir(tmpdir1)
retry(nil, 1000, function()
- eq(0, funcs.isdirectory(tmpdir1))
+ eq(0, fn.isdirectory(tmpdir1))
end)
- local tmpname2 = funcs.tempname()
- local tmpdir2 = funcs.fnamemodify(tmpname2, ':h')
+ local tmpname2 = fn.tempname()
+ local tmpdir2 = fn.fnamemodify(tmpname2, ':h')
neq(tmpdir1, tmpdir2)
end
-- Your antivirus hates you...
rm_tmpdir()
assert_log('tempdir disappeared', testlog, 100)
- funcs.tempname()
- funcs.tempname()
- funcs.tempname()
- eq('', meths.nvim_get_vvar('errmsg'))
+ fn.tempname()
+ fn.tempname()
+ fn.tempname()
+ eq('', api.nvim_get_vvar('errmsg'))
rm_tmpdir()
- funcs.tempname()
- funcs.tempname()
- funcs.tempname()
- eq('E5431: tempdir disappeared (2 times)', meths.nvim_get_vvar('errmsg'))
+ fn.tempname()
+ fn.tempname()
+ fn.tempname()
+ eq('E5431: tempdir disappeared (2 times)', api.nvim_get_vvar('errmsg'))
rm_tmpdir()
- eq('E5431: tempdir disappeared (3 times)', meths.nvim_get_vvar('errmsg'))
+ eq('E5431: tempdir disappeared (3 times)', api.nvim_get_vvar('errmsg'))
end)
it('$NVIM_APPNAME relative path', function()
@@ -427,6 +427,6 @@ describe('tmpdir', function()
TMPDIR = os_tmpdir,
},
})
- matches([=[.*[/\\]a%%b%.[^/\\]+]=], funcs.tempname())
+ matches([=[.*[/\\]a%%b%.[^/\\]+]=], fn.tempname())
end)
end)
diff --git a/test/functional/core/job_spec.lua b/test/functional/core/job_spec.lua
index c0a838ed92..c6885d0b7c 100644
--- a/test/functional/core/job_spec.lua
+++ b/test/functional/core/job_spec.lua
@@ -18,10 +18,10 @@ local mkdir = helpers.mkdir
local rmdir = helpers.rmdir
local assert_alive = helpers.assert_alive
local command = helpers.command
-local funcs = helpers.funcs
+local fn = helpers.fn
local os_kill = helpers.os_kill
local retry = helpers.retry
-local meths = helpers.meths
+local api = helpers.api
local NIL = vim.NIL
local poke_eventloop = helpers.poke_eventloop
local get_pathsep = helpers.get_pathsep
@@ -42,8 +42,8 @@ describe('jobs', function()
before_each(function()
clear()
- channel = meths.nvim_get_api_info()[1]
- meths.nvim_set_var('channel', channel)
+ channel = api.nvim_get_api_info()[1]
+ api.nvim_set_var('channel', channel)
source([[
function! Normalize(data) abort
" Windows: remove ^M and term escape sequences
@@ -235,7 +235,7 @@ describe('jobs', function()
local dir = 'Xtest_not_executable_dir'
mkdir(dir)
- funcs.setfperm(dir, 'rw-------')
+ fn.setfperm(dir, 'rw-------')
matches(
'^Vim%(call%):E903: Process failed to start: permission denied: .*',
pcall_err(command, "call jobstart(['pwd'], {'cwd': '" .. dir .. "'})")
@@ -402,11 +402,11 @@ describe('jobs', function()
it('can get the pid value using getpid', function()
command("let j = jobstart(['cat', '-'], g:job_opts)")
local pid = eval('jobpid(j)')
- neq(NIL, meths.nvim_get_proc(pid))
+ neq(NIL, api.nvim_get_proc(pid))
command('call jobstop(j)')
eq({ 'notification', 'stdout', { 0, { '' } } }, next_msg())
eq({ 'notification', 'exit', { 0, 143 } }, next_msg())
- eq(NIL, meths.nvim_get_proc(pid))
+ eq(NIL, api.nvim_get_proc(pid))
end)
it('disposed on Nvim exit', function()
@@ -415,9 +415,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.nvim_get_proc(pid))
+ neq(NIL, api.nvim_get_proc(pid))
clear()
- eq(NIL, meths.nvim_get_proc(pid))
+ eq(NIL, api.nvim_get_proc(pid))
end)
it('can survive the exit of nvim with "detach"', function()
@@ -426,9 +426,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.nvim_get_proc(pid))
+ neq(NIL, api.nvim_get_proc(pid))
clear()
- neq(NIL, meths.nvim_get_proc(pid))
+ neq(NIL, api.nvim_get_proc(pid))
-- clean up after ourselves
eq(0, os_kill(pid))
end)
@@ -880,7 +880,7 @@ describe('jobs', function()
r = next_msg()
eq('job ' .. i .. ' exited', r[3][1])
end
- eq(10, meths.nvim_eval('g:counter'))
+ eq(10, api.nvim_eval('g:counter'))
end)
describe('with timeout argument', function()
@@ -945,15 +945,15 @@ describe('jobs', function()
]],
}
feed('<CR>')
- funcs.jobstop(meths.nvim_get_var('id'))
+ fn.jobstop(api.nvim_get_var('id'))
end)
end)
pending('exit event follows stdout, stderr', function()
command("let g:job_opts.on_stderr = function('OnEvent')")
command("let j = jobstart(['cat', '-'], g:job_opts)")
- meths.nvim_eval('jobsend(j, "abcdef")')
- meths.nvim_eval('jobstop(j)')
+ api.nvim_eval('jobsend(j, "abcdef")')
+ api.nvim_eval('jobstop(j)')
expect_msg_seq(
{
{ 'notification', 'stdout', { 0, { 'abcdef' } } },
@@ -1059,11 +1059,11 @@ describe('jobs', function()
end
local sleep_cmd = (is_os('win') and 'ping -n 31 127.0.0.1' or 'sleep 30')
local j = eval("jobstart('" .. sleep_cmd .. ' | ' .. sleep_cmd .. ' | ' .. sleep_cmd .. "')")
- local ppid = funcs.jobpid(j)
+ local ppid = fn.jobpid(j)
local children
if is_os('win') then
local status, result = pcall(retry, nil, nil, function()
- children = meths.nvim_get_proc_children(ppid)
+ children = api.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)
@@ -1075,22 +1075,22 @@ describe('jobs', function()
end
else
retry(nil, nil, function()
- children = meths.nvim_get_proc_children(ppid)
+ children = api.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.nvim_get_proc(child_pid)
+ local info = api.nvim_get_proc(child_pid)
-- eq((is_os('win') and 'nvim.exe' or 'nvim'), info.name)
eq(ppid, info.ppid)
end
-- Kill the root of the tree.
- eq(1, funcs.jobstop(j))
+ eq(1, fn.jobstop(j))
-- Assert that the children were killed.
retry(nil, nil, function()
for _, child_pid in ipairs(children) do
- eq(NIL, meths.nvim_get_proc(child_pid))
+ eq(NIL, api.nvim_get_proc(child_pid))
end
end)
end)
@@ -1126,7 +1126,7 @@ describe('jobs', function()
local j
local function send(str)
-- check no nvim_chan_free double free with pty job (#14198)
- meths.nvim_chan_send(j, str)
+ api.nvim_chan_send(j, str)
end
before_each(function()
@@ -1241,7 +1241,7 @@ describe('pty process teardown', function()
it('does not prevent/delay exit. #4798 #4900', function()
skip(is_os('win'))
-- Use a nested nvim (in :term) to test without --headless.
- funcs.termopen({
+ fn.termopen({
helpers.nvim_prog,
'-u',
'NONE',
diff --git a/test/functional/core/main_spec.lua b/test/functional/core/main_spec.lua
index 47b96535b3..1d2261ee05 100644
--- a/test/functional/core/main_spec.lua
+++ b/test/functional/core/main_spec.lua
@@ -7,7 +7,7 @@ local matches = helpers.matches
local feed = helpers.feed
local eval = helpers.eval
local clear = helpers.clear
-local funcs = helpers.funcs
+local fn = helpers.fn
local nvim_prog_abs = helpers.nvim_prog_abs
local write_file = helpers.write_file
local is_os = helpers.is_os
@@ -33,7 +33,7 @@ describe('command-line option', function()
it('treats - as stdin', function()
eq(nil, uv.fs_stat(fname))
- funcs.system({
+ fn.system({
nvim_prog_abs(),
'-u',
'NONE',
@@ -55,7 +55,7 @@ describe('command-line option', function()
eq(nil, uv.fs_stat(fname))
eq(true, not not dollar_fname:find('%$%w+'))
write_file(dollar_fname, ':call setline(1, "100500")\n:wqall!\n')
- funcs.system({
+ fn.system({
nvim_prog_abs(),
'-u',
'NONE',
@@ -91,7 +91,7 @@ describe('command-line option', function()
-- Need to explicitly pipe to stdin so that the embedded Nvim instance doesn't try to read
-- data from the terminal #18181
- funcs.termopen(string.format([[echo "" | %s]], table.concat(args, ' ')), {
+ fn.termopen(string.format([[echo "" | %s]], table.concat(args, ' ')), {
env = { VIMRUNTIME = os.getenv('VIMRUNTIME') },
})
screen:expect(
@@ -128,7 +128,7 @@ describe('command-line option', function()
it('errors out when trying to use nonexistent file with -s', function()
eq(
'Cannot open for reading: "' .. nonexistent_fname .. '": no such file or directory\n',
- funcs.system({
+ fn.system({
nvim_prog_abs(),
'-u',
'NONE',
@@ -151,7 +151,7 @@ describe('command-line option', function()
write_file(dollar_fname, ':call setline(1, "2")\n:wqall!\n')
eq(
'Attempt to open script file again: "-s ' .. dollar_fname .. '"\n',
- funcs.system({
+ fn.system({
nvim_prog_abs(),
'-u',
'NONE',
@@ -175,9 +175,9 @@ describe('command-line option', function()
end)
it('nvim -v, :version', function()
- matches('Run ":verbose version"', funcs.execute(':version'))
- matches('Compilation: .*Run :checkhealth', funcs.execute(':verbose version'))
- matches('Run "nvim %-V1 %-v"', funcs.system({ nvim_prog_abs(), '-v' }))
- matches('Compilation: .*Run :checkhealth', funcs.system({ nvim_prog_abs(), '-V1', '-v' }))
+ matches('Run ":verbose version"', fn.execute(':version'))
+ matches('Compilation: .*Run :checkhealth', fn.execute(':verbose version'))
+ matches('Run "nvim %-V1 %-v"', fn.system({ nvim_prog_abs(), '-v' }))
+ matches('Compilation: .*Run :checkhealth', fn.system({ nvim_prog_abs(), '-V1', '-v' }))
end)
end)
diff --git a/test/functional/core/path_spec.lua b/test/functional/core/path_spec.lua
index 21364d7c03..e98bfc0d45 100644
--- a/test/functional/core/path_spec.lua
+++ b/test/functional/core/path_spec.lua
@@ -4,7 +4,7 @@ local command = helpers.command
local eq = helpers.eq
local eval = helpers.eval
local feed = helpers.feed
-local funcs = helpers.funcs
+local fn = helpers.fn
local insert = helpers.insert
local is_os = helpers.is_os
local mkdir = helpers.mkdir
@@ -167,7 +167,7 @@ describe('file search', function()
else
write_file(expected, '')
end
- eq(expected, funcs[funcname](item, d:gsub(' ', [[\ ]])))
+ eq(expected, fn[funcname](item, d:gsub(' ', [[\ ]])))
end
it('finddir()', function()
diff --git a/test/functional/core/remote_spec.lua b/test/functional/core/remote_spec.lua
index 5eb520ef4f..a48534f51b 100644
--- a/test/functional/core/remote_spec.lua
+++ b/test/functional/core/remote_spec.lua
@@ -6,7 +6,7 @@ local eq = helpers.eq
local exec_capture = helpers.exec_capture
local exec_lua = helpers.exec_lua
local expect = helpers.expect
-local funcs = helpers.funcs
+local fn = helpers.fn
local insert = helpers.insert
local nvim_prog = helpers.nvim_prog
local new_argv = helpers.new_argv
@@ -42,7 +42,7 @@ describe('Remote', function()
-- Run a `nvim --remote*` command and return { stdout, stderr } of the process
local function run_remote(...)
set_session(server)
- local addr = funcs.serverlist()[1]
+ local addr = fn.serverlist()[1]
-- Create an nvim instance just to run the remote-invoking nvim. We want
-- to wait for the remote instance to exit and calling jobwait blocks
@@ -81,20 +81,20 @@ describe('Remote', function()
it('edit a single file', function()
eq({ '', '' }, run_remote('--remote', fname))
expect(contents)
- eq(2, #funcs.getbufinfo())
+ eq(2, #fn.getbufinfo())
end)
it('tab edit a single file with a non-changed buffer', function()
eq({ '', '' }, run_remote('--remote-tab', fname))
expect(contents)
- eq(1, #funcs.gettabinfo())
+ eq(1, #fn.gettabinfo())
end)
it('tab edit a single file with a changed buffer', function()
insert('hello')
eq({ '', '' }, run_remote('--remote-tab', fname))
expect(contents)
- eq(2, #funcs.gettabinfo())
+ eq(2, #fn.gettabinfo())
end)
it('edit multiple files', function()
@@ -102,15 +102,15 @@ describe('Remote', function()
expect(contents)
command('next')
expect(other_contents)
- eq(3, #funcs.getbufinfo())
+ eq(3, #fn.getbufinfo())
end)
it('send keys', function()
eq({ '', '' }, run_remote('--remote-send', ':edit ' .. fname .. '<CR><C-W>v'))
expect(contents)
- eq(2, #funcs.getwininfo())
+ eq(2, #fn.getwininfo())
-- Only a single buffer as we're using edit and not drop like --remote does
- eq(1, #funcs.getbufinfo())
+ eq(1, #fn.getbufinfo())
end)
it('evaluate expressions', function()
@@ -127,7 +127,7 @@ describe('Remote', function()
it('creates server if not found', function()
clear('--remote', fname)
expect(contents)
- eq(1, #funcs.getbufinfo())
+ eq(1, #fn.getbufinfo())
-- Since we didn't pass silent, we should get a complaint
neq(nil, string.find(exec_capture('messages'), 'E247:'))
end)
@@ -135,8 +135,8 @@ describe('Remote', function()
it('creates server if not found with tabs', function()
clear('--remote-tab-silent', fname, other_fname)
expect(contents)
- eq(2, #funcs.gettabinfo())
- eq(2, #funcs.getbufinfo())
+ eq(2, #fn.gettabinfo())
+ eq(2, #fn.getbufinfo())
-- We passed silent, so no message should be issued about the server not being found
eq(nil, string.find(exec_capture('messages'), 'E247:'))
end)
diff --git a/test/functional/core/spellfile_spec.lua b/test/functional/core/spellfile_spec.lua
index 0e2d71ef14..7dcdfac315 100644
--- a/test/functional/core/spellfile_spec.lua
+++ b/test/functional/core/spellfile_spec.lua
@@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')(after_each)
local eq = helpers.eq
local clear = helpers.clear
-local meths = helpers.meths
+local api = helpers.api
local exc_exec = helpers.exc_exec
local rmdir = helpers.rmdir
local write_file = helpers.write_file
@@ -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.nvim_set_option_value('runtimepath', testdir, {})
+ api.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.nvim_set_option_value('spelllang', 'en', {})
+ api.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.nvim_set_option_value('runtimepath', testdir, {})
+ api.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.nvim_set_option_value('spelllang', 'en', {})
+ api.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.nvim_set_option_value('runtimepath', testdir, {})
+ api.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.nvim_set_option_value('spelllang', 'en', {})
+ api.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.nvim_set_option_value('runtimepath', testdir, {})
+ api.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.nvim_set_option_value('spelllang', 'en', {})
+ api.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.nvim_set_option_value('runtimepath', testdir, {})
+ api.nvim_set_option_value('runtimepath', testdir, {})
write_file(testdir .. '/spell/en.ascii.spl', spellheader:sub(1, -3) .. '\000\000')
- meths.nvim_set_option_value('spelllang', 'en', {})
+ api.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 39d38a47a5..fd3748a985 100644
--- a/test/functional/core/startup_spec.lua
+++ b/test/functional/core/startup_spec.lua
@@ -13,7 +13,7 @@ local exec = helpers.exec
local exec_capture = helpers.exec_capture
local exec_lua = helpers.exec_lua
local feed = helpers.feed
-local funcs = helpers.funcs
+local fn = helpers.fn
local pesc = vim.pesc
local mkdir = helpers.mkdir
local mkdir_p = helpers.mkdir_p
@@ -25,7 +25,7 @@ local rmdir = helpers.rmdir
local sleep = vim.uv.sleep
local startswith = vim.startswith
local write_file = helpers.write_file
-local meths = helpers.meths
+local api = helpers.api
local alter_slashes = helpers.alter_slashes
local is_os = helpers.is_os
local dedent = helpers.dedent
@@ -38,8 +38,8 @@ describe('startup', function()
clear()
ok(
string.find(
- alter_slashes(meths.nvim_get_option_value('runtimepath', {})),
- funcs.stdpath('config'),
+ alter_slashes(api.nvim_get_option_value('runtimepath', {})),
+ fn.stdpath('config'),
1,
true
) ~= nil
@@ -47,8 +47,8 @@ describe('startup', function()
clear('--clean')
ok(
string.find(
- alter_slashes(meths.nvim_get_option_value('runtimepath', {})),
- funcs.stdpath('config'),
+ alter_slashes(api.nvim_get_option_value('runtimepath', {})),
+ fn.stdpath('config'),
1,
true
) == nil
@@ -60,7 +60,7 @@ describe('startup', function()
local screen
screen = Screen.new(84, 3)
screen:attach()
- funcs.termopen({ nvim_prog, '-u', 'NONE', '--server', eval('v:servername'), '--remote-ui' })
+ fn.termopen({ nvim_prog, '-u', 'NONE', '--server', eval('v:servername'), '--remote-ui' })
screen:expect([[
^Cannot attach UI of :terminal child to its parent. (Unset $NVIM to skip this check) |
|*2
@@ -82,7 +82,7 @@ describe('startup', function()
local screen
screen = Screen.new(60, 7)
screen:attach()
- local id = funcs.termopen({
+ local id = fn.termopen({
nvim_prog,
'-u',
'NONE',
@@ -105,7 +105,7 @@ describe('startup', function()
> |
|
]])
- funcs.chansend(id, 'cont\n')
+ fn.chansend(id, 'cont\n')
screen:expect([[
^ |
~ |*3
@@ -124,13 +124,13 @@ describe('startup', function()
vim.list_extend(args, nvim_args or {})
vim.list_extend(args, { '-l', (script or 'test/functional/fixtures/startup.lua') })
vim.list_extend(args, lua_args or {})
- local out = funcs.system(args, input):gsub('\r\n', '\n')
+ local out = fn.system(args, input):gsub('\r\n', '\n')
return eq(dedent(expected), out)
end
it('failure modes', function()
-- nvim -l <empty>
- matches('nvim%.?e?x?e?: Argument missing after: "%-l"', funcs.system({ nvim_prog, '-l' }))
+ matches('nvim%.?e?x?e?: Argument missing after: "%-l"', fn.system({ nvim_prog, '-l' }))
eq(1, eval('v:shell_error'))
end)
@@ -161,12 +161,12 @@ describe('startup', function()
eq(0, eval('v:shell_error'))
matches(
'E5113: .* my pearls!!',
- funcs.system({ nvim_prog, '-l', 'test/functional/fixtures/startup-fail.lua' })
+ fn.system({ nvim_prog, '-l', 'test/functional/fixtures/startup-fail.lua' })
)
eq(1, eval('v:shell_error'))
matches(
'E5113: .* %[string "error%("whoa"%)"%]:1: whoa',
- funcs.system({ nvim_prog, '-l', '-' }, 'error("whoa")')
+ fn.system({ nvim_prog, '-l', '-' }, 'error("whoa")')
)
eq(1, eval('v:shell_error'))
end)
@@ -286,7 +286,7 @@ describe('startup', function()
end)
it('--cmd/-c/+ do not truncate long Lua print() message with --headless', function()
- local out = funcs.system({
+ local out = fn.system({
nvim_prog,
'-u',
'NONE',
@@ -305,7 +305,7 @@ describe('startup', function()
it('pipe at both ends: has("ttyin")==0 has("ttyout")==0', function()
-- system() puts a pipe at both ends.
- local out = funcs.system({
+ local out = fn.system({
nvim_prog,
'-u',
'NONE',
@@ -340,7 +340,7 @@ describe('startup', function()
command([[set shellcmdflag=/s\ /c shellxquote=\"]])
end
-- Running in :terminal
- funcs.termopen({
+ fn.termopen({
nvim_prog,
'-u',
'NONE',
@@ -372,7 +372,7 @@ describe('startup', function()
os.remove('Xtest_startup_ttyout')
end)
-- Running in :terminal
- funcs.termopen(
+ fn.termopen(
(
[["%s" -u NONE -i NONE --cmd "%s"]]
.. [[ -c "call writefile([has('ttyin'), has('ttyout')], 'Xtest_startup_ttyout')"]]
@@ -402,7 +402,7 @@ describe('startup', function()
os.remove('Xtest_startup_ttyout')
end)
-- Running in :terminal
- funcs.termopen(
+ fn.termopen(
(
[[echo foo | ]] -- Input from a pipe.
.. [["%s" -u NONE -i NONE --cmd "%s"]]
@@ -431,7 +431,7 @@ describe('startup', function()
command([[set shellcmdflag=/s\ /c shellxquote=\"]])
end
-- Running in :terminal
- funcs.termopen(
+ fn.termopen(
(
[[echo foo | ]]
.. [["%s" -u NONE -i NONE --cmd "%s"]]
@@ -454,7 +454,7 @@ describe('startup', function()
it('input from pipe + file args #7679', function()
eq(
'ohyeah\r\n0 0 bufs=3',
- funcs.system({
+ fn.system({
nvim_prog,
'-n',
'-u',
@@ -475,7 +475,7 @@ describe('startup', function()
it('if stdin is empty: selects buffer 2, deletes buffer 1 #8561', function()
eq(
'\r\n 2 %a "file1" line 0\r\n 3 "file2" line 0',
- funcs.system({
+ fn.system({
nvim_prog,
'-n',
'-u',
@@ -501,7 +501,7 @@ describe('startup', function()
--
eq(
'partylikeits1999\n',
- funcs.system({
+ fn.system({
nvim_prog,
'-n',
'-u',
@@ -513,16 +513,16 @@ describe('startup', function()
'test/functional/fixtures/tty-test.c',
}, { 'partylikeits1999', '' })
)
- eq(inputstr, funcs.system({ nvim_prog, '-i', 'NONE', '-Es', '+%print', '-' }, input))
+ eq(inputstr, fn.system({ nvim_prog, '-i', 'NONE', '-Es', '+%print', '-' }, input))
-- with `-u NORC`
eq(
'thepartycontinues\n',
- funcs.system({ nvim_prog, '-n', '-u', 'NORC', '-Es', '+.print' }, { 'thepartycontinues', '' })
+ fn.system({ nvim_prog, '-n', '-u', 'NORC', '-Es', '+.print' }, { 'thepartycontinues', '' })
)
-- without `-u`
eq(
'thepartycontinues\n',
- funcs.system({ nvim_prog, '-n', '-Es', '+.print' }, { 'thepartycontinues', '' })
+ fn.system({ nvim_prog, '-n', '-Es', '+.print' }, { 'thepartycontinues', '' })
)
--
@@ -530,7 +530,7 @@ describe('startup', function()
--
eq(
' encoding=utf-8\n',
- funcs.system({
+ fn.system({
nvim_prog,
'-n',
'-u',
@@ -541,19 +541,19 @@ describe('startup', function()
'test/functional/fixtures/tty-test.c',
}, { 'set encoding', '' })
)
- eq('line1\nline2\n', funcs.system({ nvim_prog, '-i', 'NONE', '-es', '-' }, input))
+ eq('line1\nline2\n', fn.system({ nvim_prog, '-i', 'NONE', '-es', '-' }, input))
-- with `-u NORC`
eq(
' encoding=utf-8\n',
- funcs.system({ nvim_prog, '-n', '-u', 'NORC', '-es' }, { 'set encoding', '' })
+ fn.system({ nvim_prog, '-n', '-u', 'NORC', '-es' }, { 'set encoding', '' })
)
-- without `-u`
- eq(' encoding=utf-8\n', funcs.system({ nvim_prog, '-n', '-es' }, { 'set encoding', '' }))
+ eq(' encoding=utf-8\n', fn.system({ nvim_prog, '-n', '-es' }, { 'set encoding', '' }))
end)
it('-es/-Es disables swapfile, user config #8540', function()
for _, arg in ipairs({ '-es', '-Es' }) do
- local out = funcs.system({
+ local out = fn.system({
nvim_prog,
arg,
'+set swapfile? updatecount? shadafile?',
@@ -572,15 +572,15 @@ describe('startup', function()
it('fails on --embed with -es/-Es/-l', function()
matches(
'nvim[.exe]*: %-%-embed conflicts with %-es/%-Es/%-l',
- funcs.system({ nvim_prog, '--embed', '-es' })
+ fn.system({ nvim_prog, '--embed', '-es' })
)
matches(
'nvim[.exe]*: %-%-embed conflicts with %-es/%-Es/%-l',
- funcs.system({ nvim_prog, '--embed', '-Es' })
+ fn.system({ nvim_prog, '--embed', '-Es' })
)
matches(
'nvim[.exe]*: %-%-embed conflicts with %-es/%-Es/%-l',
- funcs.system({ nvim_prog, '--embed', '-l', 'foo.lua' })
+ fn.system({ nvim_prog, '--embed', '-l', 'foo.lua' })
)
end)
@@ -588,7 +588,7 @@ describe('startup', function()
local screen
screen = Screen.new(60, 6)
screen:attach()
- local id = funcs.termopen({
+ local id = fn.termopen({
nvim_prog,
'-u',
'NONE',
@@ -611,7 +611,7 @@ describe('startup', function()
Press ENTER or type command to continue |
|
]])
- funcs.chansend(id, '\n')
+ fn.chansend(id, '\n')
screen:expect([[
^ |
~ |*2
@@ -651,7 +651,7 @@ describe('startup', function()
expected,
-- FIXME(codehex): We should really set a timeout for the system function.
-- If this test fails, there will be a waiting input state.
- funcs.system({
+ fn.system({
nvim_prog,
'-u',
'NONE',
@@ -663,7 +663,7 @@ describe('startup', function()
end)
it('get command line arguments from v:argv', function()
- local out = funcs.system({
+ local out = fn.system({
nvim_prog,
'-u',
'NONE',
@@ -715,7 +715,7 @@ describe('startup', function()
:put =mode(1) |
]])
- eq('cv\n', funcs.system({ nvim_prog, '-n', '-es' }, { 'put =mode(1)', 'print', '' }))
+ eq('cv\n', fn.system({ nvim_prog, '-n', '-es' }, { 'put =mode(1)', 'print', '' }))
end)
it('-d does not diff non-arglist windows #13720 #21289', function()
@@ -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.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.nvim_win_get_config(float_win).relative)
- eq(false, meths.nvim_get_option_value('diff', { win = float_win }))
+ eq(true, api.nvim_get_option_value('diff', { win = fn.win_getid(1) }))
+ eq(true, api.nvim_get_option_value('diff', { win = fn.win_getid(2) }))
+ local float_win = fn.win_getid(3)
+ eq('editor', api.nvim_win_get_config(float_win).relative)
+ eq(false, api.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.nvim_get_option_value('rtp', {})
+ local rtp = api.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.nvim_win_get_width(0))
+ eq(81, api.nvim_win_get_width(0))
command('tabnext')
- eq(81, meths.nvim_win_get_width(0))
+ eq(81, api.nvim_win_get_width(0))
end)
end)
@@ -1062,7 +1062,7 @@ describe('user config init', function()
clear { args_rm = { '-u' }, env = xenv }
eq(1, eval('g:lua_rc'))
- eq(funcs.fnamemodify(init_lua_path, ':p'), eval('$MYVIMRC'))
+ eq(fn.fnamemodify(init_lua_path, ':p'), eval('$MYVIMRC'))
end)
describe('loads existing', function()
@@ -1122,7 +1122,7 @@ describe('user config init', function()
local screen = Screen.new(50, 8)
screen:attach()
- funcs.termopen({ nvim_prog }, {
+ fn.termopen({ nvim_prog }, {
env = {
VIMRUNTIME = os.getenv('VIMRUNTIME'),
},
@@ -1245,7 +1245,7 @@ describe('runtime:', function()
-- Check if plugin_file_path is listed in getscriptinfo()
local scripts = tbl_map(function(s)
return s.name
- end, funcs.getscriptinfo())
+ end, fn.getscriptinfo())
ok(#tbl_filter(function(s)
return endswith(s, plugin_file_path)
end, scripts) > 0)
@@ -1369,13 +1369,13 @@ describe('inccommand on ex mode', function()
local screen
screen = Screen.new(60, 10)
screen:attach()
- local id = funcs.termopen(
+ local id = fn.termopen(
{ nvim_prog, '-u', 'NONE', '-c', 'set termguicolors', '-E', 'test/README.md' },
{
env = { VIMRUNTIME = os.getenv('VIMRUNTIME') },
}
)
- funcs.chansend(id, '%s/N')
+ fn.chansend(id, '%s/N')
screen:expect {
grid = [[
{1:^ }|
diff --git a/test/functional/editor/K_spec.lua b/test/functional/editor/K_spec.lua
index bb7bcb7ca6..1fbdd1c142 100644
--- a/test/functional/editor/K_spec.lua
+++ b/test/functional/editor/K_spec.lua
@@ -1,6 +1,6 @@
local helpers = require('test.functional.helpers')(after_each)
-local eq, clear, eval, feed, meths, retry =
- helpers.eq, helpers.clear, helpers.eval, helpers.feed, helpers.meths, helpers.retry
+local eq, clear, eval, feed, api, retry =
+ helpers.eq, helpers.clear, helpers.eval, helpers.feed, helpers.api, helpers.retry
describe('K', function()
local test_file = 'K_spec_out'
@@ -61,9 +61,9 @@ describe('K', function()
end)
it('empty string falls back to :help #19298', function()
- meths.nvim_set_option_value('keywordprg', '', {})
- meths.nvim_buf_set_lines(0, 0, -1, true, { 'doesnotexist' })
+ api.nvim_set_option_value('keywordprg', '', {})
+ api.nvim_buf_set_lines(0, 0, -1, true, { 'doesnotexist' })
feed('K')
- eq('E149: Sorry, no help for doesnotexist', meths.nvim_get_vvar('errmsg'))
+ eq('E149: Sorry, no help for doesnotexist', api.nvim_get_vvar('errmsg'))
end)
end)
diff --git a/test/functional/editor/completion_spec.lua b/test/functional/editor/completion_spec.lua
index f683884292..a7704fe12b 100644
--- a/test/functional/editor/completion_spec.lua
+++ b/test/functional/editor/completion_spec.lua
@@ -4,9 +4,9 @@ local assert_alive = helpers.assert_alive
local clear, feed = helpers.clear, helpers.feed
local eval, eq, neq = helpers.eval, helpers.eq, helpers.neq
local feed_command, source, expect = helpers.feed_command, helpers.source, helpers.expect
-local funcs = helpers.funcs
+local fn = helpers.fn
local command = helpers.command
-local meths = helpers.meths
+local api = helpers.api
local poke_eventloop = helpers.poke_eventloop
describe('completion', function()
@@ -820,23 +820,23 @@ describe('completion', function()
end)
it('provides completion from `getcompletion()`', function()
- eq({ 'vim' }, funcs.getcompletion('vi', 'lua'))
- eq({ 'api' }, funcs.getcompletion('vim.ap', 'lua'))
- eq({ 'tbl_filter' }, funcs.getcompletion('vim.tbl_fil', 'lua'))
- eq({ 'vim' }, funcs.getcompletion('print(vi', 'lua'))
+ eq({ 'vim' }, fn.getcompletion('vi', 'lua'))
+ eq({ 'api' }, fn.getcompletion('vim.ap', 'lua'))
+ eq({ 'tbl_filter' }, fn.getcompletion('vim.tbl_fil', 'lua'))
+ eq({ 'vim' }, fn.getcompletion('print(vi', 'lua'))
-- fuzzy completion is not supported, so the result should be the same
command('set wildoptions+=fuzzy')
- eq({ 'vim' }, funcs.getcompletion('vi', 'lua'))
+ eq({ 'vim' }, fn.getcompletion('vi', 'lua'))
end)
end)
it('cmdline completion supports various string options', function()
- eq('auto', funcs.getcompletion('set foldcolumn=', 'cmdline')[2])
- eq({ 'nosplit', 'split' }, funcs.getcompletion('set inccommand=', 'cmdline'))
- eq({ 'ver:3,hor:6', 'hor:', 'ver:' }, funcs.getcompletion('set mousescroll=', 'cmdline'))
- eq('BS', funcs.getcompletion('set termpastefilter=', 'cmdline')[2])
- eq('SpecialKey', funcs.getcompletion('set winhighlight=', 'cmdline')[1])
- eq('SpecialKey', funcs.getcompletion('set winhighlight=NonText:', 'cmdline')[1])
+ eq('auto', fn.getcompletion('set foldcolumn=', 'cmdline')[2])
+ eq({ 'nosplit', 'split' }, fn.getcompletion('set inccommand=', 'cmdline'))
+ eq({ 'ver:3,hor:6', 'hor:', 'ver:' }, fn.getcompletion('set mousescroll=', 'cmdline'))
+ eq('BS', fn.getcompletion('set termpastefilter=', 'cmdline')[2])
+ eq('SpecialKey', fn.getcompletion('set winhighlight=', 'cmdline')[1])
+ eq('SpecialKey', fn.getcompletion('set winhighlight=NonText:', 'cmdline')[1])
end)
describe('from the commandline window', function()
@@ -882,8 +882,8 @@ describe('completion', function()
return ''
endfunction
]])
- meths.nvim_set_option_value('completeopt', 'menuone,noselect', {})
- meths.nvim_set_var('_complist', {
+ api.nvim_set_option_value('completeopt', 'menuone,noselect', {})
+ api.nvim_set_var('_complist', {
{
word = 0,
abbr = 1,
@@ -927,7 +927,7 @@ describe('completion', function()
end)
it('CompleteChanged autocommand', function()
- meths.nvim_buf_set_lines(0, 0, 1, false, { 'foo', 'bar', 'foobar', '' })
+ api.nvim_buf_set_lines(0, 0, 1, false, { 'foo', 'bar', 'foobar', '' })
source([[
set complete=. completeopt=noinsert,noselect,menuone
function! OnPumChange()
diff --git a/test/functional/editor/fold_spec.lua b/test/functional/editor/fold_spec.lua
index 3889067fd4..35632bb2f8 100644
--- a/test/functional/editor/fold_spec.lua
+++ b/test/functional/editor/fold_spec.lua
@@ -5,7 +5,7 @@ local insert = helpers.insert
local feed = helpers.feed
local expect = helpers.expect
local command = helpers.command
-local funcs = helpers.funcs
+local fn = helpers.fn
local eq = helpers.eq
local neq = helpers.neq
@@ -75,8 +75,8 @@ describe('Folds', function()
local function get_folds()
local rettab = {}
- for i = 1, funcs.line('$') do
- table.insert(rettab, funcs.foldlevel(i))
+ for i = 1, fn.line('$') do
+ table.insert(rettab, fn.foldlevel(i))
end
return rettab
end
@@ -140,21 +140,21 @@ a
a
a]])
-- lines are not closed, folds are correct
- for i = 1, funcs.line('$') do
- eq(-1, funcs.foldclosed(i))
+ for i = 1, fn.line('$') do
+ eq(-1, fn.foldclosed(i))
if i == 1 or i == 7 or i == 13 then
- eq(0, funcs.foldlevel(i))
+ eq(0, fn.foldlevel(i))
elseif i == 4 then
- eq(2, funcs.foldlevel(i))
+ eq(2, fn.foldlevel(i))
else
- eq(1, funcs.foldlevel(i))
+ eq(1, fn.foldlevel(i))
end
end
-- folds are not corrupted
feed('zM')
- eq(6, funcs.foldclosedend(2))
- eq(12, funcs.foldclosedend(8))
- eq(18, funcs.foldclosedend(14))
+ eq(6, fn.foldclosedend(2))
+ eq(12, fn.foldclosedend(8))
+ eq(18, fn.foldclosedend(14))
end)
it("doesn't split a fold when the move is within it", function()
@@ -330,13 +330,13 @@ a]],
a
]])
for i = 1, 2 do
- eq(1, funcs.foldlevel(i))
+ eq(1, fn.foldlevel(i))
end
for i = 3, 5 do
- eq(0, funcs.foldlevel(i))
+ eq(0, fn.foldlevel(i))
end
for i = 6, 8 do
- eq(1, funcs.foldlevel(i))
+ eq(1, fn.foldlevel(i))
end
end)
@@ -354,7 +354,7 @@ a]],
]])
command('setlocal foldmethod=indent')
command('3,5d')
- eq(5, funcs.foldclosedend(1))
+ eq(5, fn.foldclosedend(1))
end)
it("doesn't combine folds that have a specified end", function()
@@ -371,7 +371,7 @@ a]],
command('setlocal foldmethod=marker')
command('3,5d')
command('%foldclose')
- eq(2, funcs.foldclosedend(1))
+ eq(2, fn.foldclosedend(1))
end)
it('splits folds according to >N and <N with foldexpr', function()
@@ -415,20 +415,20 @@ a]],
command('foldopen')
command('read ' .. tempfname)
command('%foldclose')
- eq(2, funcs.foldclosedend(1))
- eq(0, funcs.foldlevel(3))
- eq(0, funcs.foldlevel(4))
- eq(6, funcs.foldclosedend(5))
- eq(10, funcs.foldclosedend(7))
- eq(14, funcs.foldclosedend(11))
+ eq(2, fn.foldclosedend(1))
+ eq(0, fn.foldlevel(3))
+ eq(0, fn.foldlevel(4))
+ eq(6, fn.foldclosedend(5))
+ eq(10, fn.foldclosedend(7))
+ eq(14, fn.foldclosedend(11))
end)
it('no folds remain if :delete makes buffer empty #19671', function()
command('setlocal foldmethod=manual')
- funcs.setline(1, { 'foo', 'bar', 'baz' })
+ fn.setline(1, { 'foo', 'bar', 'baz' })
command('2,3fold')
command('%delete')
- eq(0, funcs.foldlevel(1))
+ eq(0, fn.foldlevel(1))
end)
it('multibyte fold markers work #20438', function()
@@ -442,7 +442,7 @@ a]],
bbbbb/*«*/
bbbbb
bbbbb/*»*/]])
- eq(1, funcs.foldlevel(1))
+ eq(1, fn.foldlevel(1))
end)
it('updates correctly with indent method and visual blockwise insertion #22898', function()
@@ -452,8 +452,8 @@ a]],
]])
command('setlocal foldmethod=indent shiftwidth=2')
feed('gg0<C-v>jI <Esc>') -- indent both lines using visual blockwise mode
- eq(1, funcs.foldlevel(1))
- eq(1, funcs.foldlevel(2))
+ eq(1, fn.foldlevel(1))
+ eq(1, fn.foldlevel(2))
end)
it("doesn't open folds with indent method when inserting lower foldlevel line", function()
@@ -464,22 +464,22 @@ a]],
keep this line folded 2
]])
command('set foldmethod=indent shiftwidth=2 noautoindent')
- eq(1, funcs.foldlevel(1))
- eq(1, funcs.foldlevel(2))
- eq(2, funcs.foldlevel(3))
- eq(2, funcs.foldlevel(4))
+ eq(1, fn.foldlevel(1))
+ eq(1, fn.foldlevel(2))
+ eq(2, fn.foldlevel(3))
+ eq(2, fn.foldlevel(4))
feed('zo') -- open the outer fold
- neq(-1, funcs.foldclosed(3)) -- make sure the inner fold is not open
+ neq(-1, fn.foldclosed(3)) -- make sure the inner fold is not open
feed('gg0oa<Esc>') -- insert unindented line
- eq(1, funcs.foldlevel(1)) --| insert an unindented line under this line
- eq(0, funcs.foldlevel(2)) --|a
- eq(1, funcs.foldlevel(3)) --| keep the lines under this line folded
- eq(2, funcs.foldlevel(4)) --| keep this line folded 1
- eq(2, funcs.foldlevel(5)) --| keep this line folded 2
+ eq(1, fn.foldlevel(1)) --| insert an unindented line under this line
+ eq(0, fn.foldlevel(2)) --|a
+ eq(1, fn.foldlevel(3)) --| keep the lines under this line folded
+ eq(2, fn.foldlevel(4)) --| keep this line folded 1
+ eq(2, fn.foldlevel(5)) --| keep this line folded 2
- neq(-1, funcs.foldclosed(4)) -- make sure the inner fold is still not open
+ neq(-1, fn.foldclosed(4)) -- make sure the inner fold is still not open
end)
end)
diff --git a/test/functional/editor/jump_spec.lua b/test/functional/editor/jump_spec.lua
index 8787fd60f1..717284b7d1 100644
--- a/test/functional/editor/jump_spec.lua
+++ b/test/functional/editor/jump_spec.lua
@@ -4,11 +4,11 @@ local Screen = require('test.functional.ui.screen')
local clear = helpers.clear
local command = helpers.command
local eq = helpers.eq
-local funcs = helpers.funcs
+local fn = helpers.fn
local feed = helpers.feed
local exec_capture = helpers.exec_capture
local write_file = helpers.write_file
-local meths = helpers.meths
+local api = helpers.api
describe('jumplist', function()
local fname1 = 'Xtest-functional-normal-jump'
@@ -20,7 +20,7 @@ describe('jumplist', function()
end)
it('does not add a new entry on startup', function()
- eq('\n jump line col file/text\n>', funcs.execute('jumps'))
+ eq('\n jump line col file/text\n>', fn.execute('jumps'))
end)
it('does not require two <C-O> strokes to jump back', function()
@@ -28,25 +28,25 @@ describe('jumplist', function()
write_file(fname2, 'second file contents')
command('args ' .. fname1 .. ' ' .. fname2)
- local buf1 = funcs.bufnr(fname1)
- local buf2 = funcs.bufnr(fname2)
+ local buf1 = fn.bufnr(fname1)
+ local buf2 = fn.bufnr(fname2)
command('next')
feed('<C-O>')
- eq(buf1, funcs.bufnr('%'))
+ eq(buf1, fn.bufnr('%'))
command('first')
command('snext')
feed('<C-O>')
- eq(buf1, funcs.bufnr('%'))
+ eq(buf1, fn.bufnr('%'))
feed('<C-I>')
- eq(buf2, funcs.bufnr('%'))
+ eq(buf2, fn.bufnr('%'))
feed('<C-O>')
- eq(buf1, funcs.bufnr('%'))
+ eq(buf1, fn.bufnr('%'))
command('drop ' .. fname2)
feed('<C-O>')
- eq(buf1, funcs.bufnr('%'))
+ eq(buf1, fn.bufnr('%'))
end)
it('<C-O> scrolls cursor halfway when switching buffer #25763', function()
@@ -284,7 +284,7 @@ describe('jumpoptions=view', function()
screen:attach()
command('edit ' .. file1)
feed('7GzbG')
- meths.nvim_buf_set_lines(0, 0, 2, true, {})
+ api.nvim_buf_set_lines(0, 0, 2, true, {})
-- Move to line 7, and set it as the last line visible on the view with zb, meaning to recover
-- the view it needs to put the cursor 7 lines from the top line. Then go to the end of the
-- file, delete 2 lines before line 7, meaning the jump/mark is moved 2 lines up to line 5.
diff --git a/test/functional/editor/langmap_spec.lua b/test/functional/editor/langmap_spec.lua
index 5ad81ce5c2..b2a4b21a89 100644
--- a/test/functional/editor/langmap_spec.lua
+++ b/test/functional/editor/langmap_spec.lua
@@ -4,7 +4,7 @@ local eq, neq, call = helpers.eq, helpers.neq, helpers.call
local eval, feed, clear = helpers.eval, helpers.feed, helpers.clear
local command, insert, expect = helpers.command, helpers.insert, helpers.expect
local feed_command = helpers.feed_command
-local curwin = helpers.meths.nvim_get_current_win
+local curwin = helpers.api.nvim_get_current_win
describe("'langmap'", function()
before_each(function()
@@ -215,7 +215,7 @@ describe("'langmap'", function()
feed('qa' .. command_string .. 'q')
expect(expect_string)
eq(
- expect_macro or helpers.funcs.nvim_replace_termcodes(command_string, true, true, true),
+ expect_macro or helpers.fn.nvim_replace_termcodes(command_string, true, true, true),
eval('@a')
)
if setup_function then
diff --git a/test/functional/editor/macro_spec.lua b/test/functional/editor/macro_spec.lua
index 1d2df8ce70..c97befdf07 100644
--- a/test/functional/editor/macro_spec.lua
+++ b/test/functional/editor/macro_spec.lua
@@ -6,8 +6,8 @@ local feed = helpers.feed
local clear = helpers.clear
local expect = helpers.expect
local command = helpers.command
-local funcs = helpers.funcs
-local meths = helpers.meths
+local fn = helpers.fn
+local api = helpers.api
local insert = helpers.insert
describe('macros', function()
@@ -40,18 +40,18 @@ hello]]
feed [[gg]]
feed [[qqAFOO<esc>q]]
- eq({ 'helloFOO', 'hello', 'hello' }, meths.nvim_buf_get_lines(0, 0, -1, false))
+ eq({ 'helloFOO', 'hello', 'hello' }, api.nvim_buf_get_lines(0, 0, -1, false))
feed [[Q]]
- eq({ 'helloFOOFOO', 'hello', 'hello' }, meths.nvim_buf_get_lines(0, 0, -1, false))
+ eq({ 'helloFOOFOO', 'hello', 'hello' }, api.nvim_buf_get_lines(0, 0, -1, false))
feed [[G3Q]]
- eq({ 'helloFOOFOO', 'hello', 'helloFOOFOOFOO' }, meths.nvim_buf_get_lines(0, 0, -1, false))
+ eq({ 'helloFOOFOO', 'hello', 'helloFOOFOOFOO' }, api.nvim_buf_get_lines(0, 0, -1, false))
feed [[ggV3jQ]]
eq(
{ 'helloFOOFOOFOO', 'helloFOO', 'helloFOOFOOFOOFOO' },
- meths.nvim_buf_get_lines(0, 0, -1, false)
+ api.nvim_buf_get_lines(0, 0, -1, false)
)
end)
@@ -62,18 +62,18 @@ hello]]
feed [[gg]]
feed [[qqAFOO<esc>q]]
- eq({ 'helloFOO', 'hello', 'hello' }, meths.nvim_buf_get_lines(0, 0, -1, false))
+ eq({ 'helloFOO', 'hello', 'hello' }, api.nvim_buf_get_lines(0, 0, -1, false))
feed [[Q]]
- eq({ 'helloFOOFOO', 'hello', 'hello' }, meths.nvim_buf_get_lines(0, 0, -1, false))
+ eq({ 'helloFOOFOO', 'hello', 'hello' }, api.nvim_buf_get_lines(0, 0, -1, false))
feed [[G3@@]]
- eq({ 'helloFOOFOO', 'hello', 'helloFOOFOOFOO' }, meths.nvim_buf_get_lines(0, 0, -1, false))
+ eq({ 'helloFOOFOO', 'hello', 'helloFOOFOOFOO' }, api.nvim_buf_get_lines(0, 0, -1, false))
feed [[ggV2j@@]]
eq(
{ 'helloFOOFOOFOO', 'helloFOO', 'helloFOOFOOFOOFOO' },
- meths.nvim_buf_get_lines(0, 0, -1, false)
+ api.nvim_buf_get_lines(0, 0, -1, false)
)
end)
@@ -84,17 +84,17 @@ hello]]
feed [[gg]]
feed [[qqAFOO<esc>qu]]
- eq({ 'hello', 'hello', 'hello' }, meths.nvim_buf_get_lines(0, 0, -1, false))
+ eq({ 'hello', 'hello', 'hello' }, api.nvim_buf_get_lines(0, 0, -1, false))
feed [[qwA123<esc>qu]]
- eq({ 'hello', 'hello', 'hello' }, meths.nvim_buf_get_lines(0, 0, -1, false))
+ eq({ 'hello', 'hello', 'hello' }, api.nvim_buf_get_lines(0, 0, -1, false))
feed [[V3j@q]]
- eq({ 'helloFOO', 'helloFOO', 'helloFOO' }, meths.nvim_buf_get_lines(0, 0, -1, false))
+ eq({ 'helloFOO', 'helloFOO', 'helloFOO' }, api.nvim_buf_get_lines(0, 0, -1, false))
feed [[gg]]
feed [[Vj@w]]
- eq({ 'helloFOO123', 'helloFOO123', 'helloFOO' }, meths.nvim_buf_get_lines(0, 0, -1, false))
+ eq({ 'helloFOO123', 'helloFOO123', 'helloFOO' }, api.nvim_buf_get_lines(0, 0, -1, false))
end)
it('can be replayed with @q and @w visual-block', function()
@@ -104,17 +104,17 @@ hello]]
feed [[gg]]
feed [[qqAFOO<esc>qu]]
- eq({ 'hello', 'hello', 'hello' }, meths.nvim_buf_get_lines(0, 0, -1, false))
+ eq({ 'hello', 'hello', 'hello' }, api.nvim_buf_get_lines(0, 0, -1, false))
feed [[qwA123<esc>qu]]
- eq({ 'hello', 'hello', 'hello' }, meths.nvim_buf_get_lines(0, 0, -1, false))
+ eq({ 'hello', 'hello', 'hello' }, api.nvim_buf_get_lines(0, 0, -1, false))
feed [[<C-v>3j@q]]
- eq({ 'helloFOO', 'helloFOO', 'helloFOO' }, meths.nvim_buf_get_lines(0, 0, -1, false))
+ eq({ 'helloFOO', 'helloFOO', 'helloFOO' }, api.nvim_buf_get_lines(0, 0, -1, false))
feed [[gg]]
feed [[<C-v>j@w]]
- eq({ 'helloFOO123', 'helloFOO123', 'helloFOO' }, meths.nvim_buf_get_lines(0, 0, -1, false))
+ eq({ 'helloFOO123', 'helloFOO123', 'helloFOO' }, api.nvim_buf_get_lines(0, 0, -1, false))
end)
end)
@@ -127,13 +127,13 @@ describe('immediately after a macro has finished executing,', function()
describe('reg_executing() from RPC returns an empty string', function()
it('if the macro does not end with a <Nop> mapping', function()
feed('@a')
- eq('', funcs.reg_executing())
+ eq('', fn.reg_executing())
end)
it('if the macro ends with a <Nop> mapping', function()
command('nnoremap 0 <Nop>')
feed('@a')
- eq('', funcs.reg_executing())
+ eq('', fn.reg_executing())
end)
end)
@@ -144,7 +144,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.nvim_get_mode())
+ eq({ mode = 'n', blocking = false }, api.nvim_get_mode())
expect('')
eq('', eval('@a'))
end)
@@ -152,7 +152,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.nvim_get_mode())
+ eq({ mode = 'n', blocking = false }, api.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 67234b9b90..de905a86ba 100644
--- a/test/functional/editor/mark_spec.lua
+++ b/test/functional/editor/mark_spec.lua
@@ -1,15 +1,15 @@
local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
-local meths = helpers.meths
+local api = helpers.api
local clear = helpers.clear
local command = helpers.command
-local funcs = helpers.funcs
+local fn = helpers.fn
local eq = helpers.eq
local feed = helpers.feed
local write_file = helpers.write_file
local pcall_err = helpers.pcall_err
local cursor = function()
- return helpers.meths.nvim_win_get_cursor(0)
+ return helpers.api.nvim_win_get_cursor(0)
end
describe('named marks', function()
@@ -28,13 +28,13 @@ describe('named marks', function()
it('can be set', function()
command('edit ' .. file1)
command('mark a')
- eq({ 1, 0 }, meths.nvim_buf_get_mark(0, 'a'))
+ eq({ 1, 0 }, api.nvim_buf_get_mark(0, 'a'))
feed('jmb')
- eq({ 2, 0 }, meths.nvim_buf_get_mark(0, 'b'))
+ eq({ 2, 0 }, api.nvim_buf_get_mark(0, 'b'))
feed('jmB')
- eq({ 3, 0 }, meths.nvim_buf_get_mark(0, 'B'))
+ eq({ 3, 0 }, api.nvim_buf_get_mark(0, 'B'))
command('4kc')
- eq({ 4, 0 }, meths.nvim_buf_get_mark(0, 'c'))
+ eq({ 4, 0 }, api.nvim_buf_get_mark(0, 'c'))
end)
it('errors when set out of range with :mark', function()
@@ -104,7 +104,7 @@ describe('named marks', function()
feed('mA')
command('next')
feed("'A")
- eq(1, meths.nvim_get_current_buf().id)
+ eq(1, api.nvim_get_current_buf().id)
eq({ 2, 0 }, cursor())
end)
@@ -117,7 +117,7 @@ describe('named marks', function()
feed('mA')
command('next')
feed('`A')
- eq(1, meths.nvim_get_current_buf().id)
+ eq(1, api.nvim_get_current_buf().id)
eq({ 2, 2 }, cursor())
end)
@@ -130,7 +130,7 @@ describe('named marks', function()
feed('mA')
command('next')
feed("g'A")
- eq(1, meths.nvim_get_current_buf().id)
+ eq(1, api.nvim_get_current_buf().id)
eq({ 2, 0 }, cursor())
end)
@@ -143,7 +143,7 @@ describe('named marks', function()
feed('mA')
command('next')
feed('g`A')
- eq(1, meths.nvim_get_current_buf().id)
+ eq(1, api.nvim_get_current_buf().id)
eq({ 2, 2 }, cursor())
end)
@@ -157,7 +157,7 @@ describe('named marks', function()
feed('mA')
command('next')
command("'A")
- eq(1, meths.nvim_get_current_buf().id)
+ eq(1, api.nvim_get_current_buf().id)
eq({ 2, 0 }, cursor())
end)
@@ -267,59 +267,59 @@ describe('named marks', function()
feed('jzfG') -- Fold from the second line to the end
command('3mark a')
feed('G') -- On top of the fold
- assert(funcs.foldclosed('.') ~= -1) -- folded
+ assert(fn.foldclosed('.') ~= -1) -- folded
feed("'a")
- eq(-1, funcs.foldclosed('.'))
+ eq(-1, fn.foldclosed('.'))
feed('zc')
- assert(funcs.foldclosed('.') ~= -1) -- folded
+ assert(fn.foldclosed('.') ~= -1) -- folded
-- TODO: remove this workaround after fixing #15873
feed('k`a')
- eq(-1, funcs.foldclosed('.'))
+ eq(-1, fn.foldclosed('.'))
feed('zc')
- assert(funcs.foldclosed('.') ~= -1) -- folded
+ assert(fn.foldclosed('.') ~= -1) -- folded
feed("kg'a")
- eq(-1, funcs.foldclosed('.'))
+ eq(-1, fn.foldclosed('.'))
feed('zc')
- assert(funcs.foldclosed('.') ~= -1) -- folded
+ assert(fn.foldclosed('.') ~= -1) -- folded
feed('kg`a')
- eq(-1, funcs.foldclosed('.'))
+ eq(-1, fn.foldclosed('.'))
end)
it("do not open folds when moving to them doesn't move the cursor", function()
command('edit ' .. file1)
feed('jzfG') -- Fold from the second line to the end
- assert(funcs.foldclosed('.') == 2) -- folded
+ assert(fn.foldclosed('.') == 2) -- folded
feed('ma')
feed("'a")
feed('`a')
feed("g'a")
feed('g`a')
-- should still be folded
- eq(2, funcs.foldclosed('.'))
+ eq(2, fn.foldclosed('.'))
end)
it("getting '{ '} '( ') does not move cursor", function()
- 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.nvim_win_get_cursor(0))
- funcs.getpos("'}")
- eq({ 2, 0 }, meths.nvim_win_get_cursor(0))
- funcs.getpos("'(")
- eq({ 2, 0 }, meths.nvim_win_get_cursor(0))
- funcs.getpos("')")
- eq({ 2, 0 }, meths.nvim_win_get_cursor(0))
+ api.nvim_buf_set_lines(0, 0, 0, true, { 'aaaaa', 'bbbbb', 'ccccc', 'ddddd', 'eeeee' })
+ api.nvim_win_set_cursor(0, { 2, 0 })
+ fn.getpos("'{")
+ eq({ 2, 0 }, api.nvim_win_get_cursor(0))
+ fn.getpos("'}")
+ eq({ 2, 0 }, api.nvim_win_get_cursor(0))
+ fn.getpos("'(")
+ eq({ 2, 0 }, api.nvim_win_get_cursor(0))
+ fn.getpos("')")
+ eq({ 2, 0 }, api.nvim_win_get_cursor(0))
end)
it('in command range does not move cursor #19248', function()
- 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 })
+ api.nvim_create_user_command('Test', ':', { range = true })
+ api.nvim_buf_set_lines(0, 0, 0, true, { 'aaaaa', 'bbbbb', 'ccccc', 'ddddd', 'eeeee' })
+ api.nvim_win_set_cursor(0, { 2, 0 })
command([['{,'}Test]])
- eq({ 2, 0 }, meths.nvim_win_get_cursor(0))
+ eq({ 2, 0 }, api.nvim_win_get_cursor(0))
end)
end)
diff --git a/test/functional/editor/meta_key_spec.lua b/test/functional/editor/meta_key_spec.lua
index 3b66c8fc05..b57f5c3c35 100644
--- a/test/functional/editor/meta_key_spec.lua
+++ b/test/functional/editor/meta_key_spec.lua
@@ -4,7 +4,7 @@ local command = helpers.command
local exec_lua = helpers.exec_lua
local eval = helpers.eval
local expect = helpers.expect
-local funcs = helpers.funcs
+local fn = helpers.fn
local eq = helpers.eq
describe('meta-keys #8226 #13042', function()
@@ -66,11 +66,11 @@ describe('meta-keys #8226 #13042', function()
command('inoremap <A-j> alt-j')
feed('i<M-l> xxx <A-j><M-h>a<A-h>')
expect('meta-l xxx alt-j')
- eq({ 0, 1, 14, 0 }, funcs.getpos('.'))
+ eq({ 0, 1, 14, 0 }, fn.getpos('.'))
-- Unmapped ALT-chord behaves as ESC+c.
command('iunmap <M-l>')
feed('0i<M-l>')
- eq({ 0, 1, 2, 0 }, funcs.getpos('.'))
+ eq({ 0, 1, 2, 0 }, fn.getpos('.'))
-- Unmapped ALT-chord has same `undo` characteristics as ESC+<key>
command('0,$d')
feed('ahello<M-.>')
@@ -101,7 +101,7 @@ describe('meta-keys #8226 #13042', function()
eq(meta_l_seq .. 'yyy' .. meta_l_seq .. 'alt-j', exec_lua([[return _G.input_data]]))
eq('t', eval('mode(1)'))
feed('<Esc>j')
- eq({ 0, 2, 1, 0 }, funcs.getpos('.'))
+ eq({ 0, 2, 1, 0 }, fn.getpos('.'))
eq('nt', eval('mode(1)'))
end)
diff --git a/test/functional/editor/mode_cmdline_spec.lua b/test/functional/editor/mode_cmdline_spec.lua
index 2aa4542cb7..06efe53718 100644
--- a/test/functional/editor/mode_cmdline_spec.lua
+++ b/test/functional/editor/mode_cmdline_spec.lua
@@ -2,11 +2,11 @@
local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
-local clear, insert, funcs, eq, feed =
- helpers.clear, helpers.insert, helpers.funcs, helpers.eq, helpers.feed
+local clear, insert, fn, eq, feed =
+ helpers.clear, helpers.insert, helpers.fn, helpers.eq, helpers.feed
local eval = helpers.eval
local command = helpers.command
-local meths = helpers.meths
+local api = helpers.api
describe('cmdline', function()
before_each(clear)
@@ -20,22 +20,22 @@ describe('cmdline', function()
-- Yank 2 lines linewise, then paste to cmdline.
feed([[<C-\><C-N>gg0yj:<C-R>0]])
-- <CR> inserted between lines, NOT after the final line.
- eq('line1abc\rline2somemoretext', funcs.getcmdline())
+ eq('line1abc\rline2somemoretext', fn.getcmdline())
-- Yank 2 lines charwise, then paste to cmdline.
feed([[<C-\><C-N>gg05lyvj:<C-R>0]])
-- <CR> inserted between lines, NOT after the final line.
- eq('abc\rline2', funcs.getcmdline())
+ eq('abc\rline2', fn.getcmdline())
-- Yank 1 line linewise, then paste to cmdline.
feed([[<C-\><C-N>ggyy:<C-R>0]])
-- No <CR> inserted.
- eq('line1abc', funcs.getcmdline())
+ eq('line1abc', fn.getcmdline())
end)
it('pasting special register inserts <CR>, <NL>', function()
feed([[:<C-R>="foo\nbar\rbaz"<CR>]])
- eq('foo\nbar\rbaz', funcs.getcmdline())
+ eq('foo\nbar\rbaz', fn.getcmdline())
end)
end)
@@ -77,30 +77,30 @@ describe('cmdline', function()
it('correctly clears start of the history', function()
-- Regression test: check absence of the memory leak when clearing start of
-- the history using cmdhist.c/clr_history().
- eq(1, funcs.histadd(':', 'foo'))
- eq(1, funcs.histdel(':'))
- eq('', funcs.histget(':', -1))
+ eq(1, fn.histadd(':', 'foo'))
+ eq(1, fn.histdel(':'))
+ eq('', fn.histget(':', -1))
end)
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.nvim_set_option_value('history', 1, {})
- eq(1, funcs.histadd(':', 'foo'))
- eq(1, funcs.histdel(':'))
- eq('', funcs.histget(':', -1))
+ api.nvim_set_option_value('history', 1, {})
+ eq(1, fn.histadd(':', 'foo'))
+ eq(1, fn.histdel(':'))
+ eq('', fn.histget(':', -1))
end)
it('correctly removes item from history', function()
-- Regression test: check that cmdhist.c/del_history_idx() correctly clears
-- history index after removing history entry. If it does not then deleting
-- history will result in a double free.
- eq(1, funcs.histadd(':', 'foo'))
- eq(1, funcs.histadd(':', 'bar'))
- eq(1, funcs.histadd(':', 'baz'))
- eq(1, funcs.histdel(':', -2))
- eq(1, funcs.histdel(':'))
- eq('', funcs.histget(':', -1))
+ eq(1, fn.histadd(':', 'foo'))
+ eq(1, fn.histadd(':', 'bar'))
+ eq(1, fn.histadd(':', 'baz'))
+ eq(1, fn.histdel(':', -2))
+ eq(1, fn.histdel(':'))
+ eq('', fn.histget(':', -1))
end)
end)
end)
diff --git a/test/functional/editor/put_spec.lua b/test/functional/editor/put_spec.lua
index da9ba49aa5..414b289222 100644
--- a/test/functional/editor/put_spec.lua
+++ b/test/functional/editor/put_spec.lua
@@ -11,7 +11,7 @@ local filter = vim.tbl_filter
local feed_command = helpers.feed_command
local command = helpers.command
local curbuf_contents = helpers.curbuf_contents
-local funcs = helpers.funcs
+local fn = helpers.fn
local dedent = helpers.dedent
local function reset()
@@ -21,9 +21,9 @@ local function reset()
Line of words 2]])
command('goto 1')
feed('itest_string.<esc>u')
- funcs.setreg('a', 'test_stringa', 'V')
- funcs.setreg('b', 'test_stringb\ntest_stringb\ntest_stringb', 'b')
- funcs.setreg('"', 'test_string"', 'v')
+ fn.setreg('a', 'test_stringa', 'V')
+ fn.setreg('b', 'test_stringb\ntest_stringb\ntest_stringb', 'b')
+ fn.setreg('"', 'test_string"', 'v')
end
-- We check the last inserted register ". in each of these tests because it is
@@ -35,12 +35,12 @@ describe('put command', function()
before_each(reset)
local function visual_marks_zero()
- for _, v in pairs(funcs.getpos("'<")) do
+ for _, v in pairs(fn.getpos("'<")) do
if v ~= 0 then
return false
end
end
- for _, v in pairs(funcs.getpos("'>")) do
+ for _, v in pairs(fn.getpos("'>")) do
if v ~= 0 then
return false
end
@@ -55,7 +55,7 @@ describe('put command', function()
extra_setup()
end
local init_contents = curbuf_contents()
- local init_cursorpos = funcs.getcurpos()
+ local init_cursorpos = fn.getcurpos()
local assert_no_change = function(exception_table, after_undo)
expect(init_contents)
-- When putting the ". register forwards, undo doesn't move
@@ -65,7 +65,7 @@ describe('put command', function()
-- one place to the right (unless we were at the end of the
-- line when we pasted).
if not (exception_table.undo_position and after_undo) then
- eq(init_cursorpos, funcs.getcurpos())
+ eq(init_cursorpos, fn.getcurpos())
end
end
@@ -74,7 +74,7 @@ describe('put command', function()
if extra_setup then
extra_setup()
end
- local orig_dotstr = funcs.getreg('.')
+ local orig_dotstr = fn.getreg('.')
helpers.ok(visual_marks_zero())
-- Make sure every test starts from the same conditions
assert_no_change(test.exception_table, false)
@@ -89,7 +89,7 @@ describe('put command', function()
-- If we paste the ". register with a count we can't avoid
-- changing this register, hence avoid this check.
if not test.exception_table.dot_reg_changed then
- eq(orig_dotstr, funcs.getreg('.'))
+ eq(orig_dotstr, fn.getreg('.'))
end
-- Doing something, undoing it, and then redoing it should
@@ -105,7 +105,7 @@ describe('put command', function()
end
if test.exception_table.undo_position then
- funcs.setpos('.', init_cursorpos)
+ fn.setpos('.', init_cursorpos)
end
if was_cli then
feed('@:')
@@ -151,7 +151,7 @@ describe('put command', function()
-- it was in.
-- This returns the cursor position that would leave the 'x' in that
-- place if we feed 'ix<esc>' and the string existed before it.
- for linenum, line in pairs(funcs.split(expect_string, '\n', 1)) do
+ for linenum, line in pairs(fn.split(expect_string, '\n', 1)) do
local column = line:find('x')
if column then
return { linenum, column }, expect_string:gsub('x', '')
@@ -184,16 +184,16 @@ describe('put command', function()
return function(exception_table, after_redo)
expect(expect_string)
- -- Have to use getcurpos() instead of meths.nvim_win_get_cursor(0) in
+ -- Have to use getcurpos() instead of api.nvim_win_get_cursor(0) in
-- order to account for virtualedit.
-- We always want the curswant element in getcurpos(), which is
-- sometimes different to the column element in
- -- meths.nvim_win_get_cursor(0).
+ -- api.nvim_win_get_cursor(0).
-- NOTE: The ".gp command leaves the cursor after the pasted text
-- when running, but does not when the command is redone with the
-- '.' command.
if not (exception_table.redo_position and after_redo) then
- local actual_position = funcs.getcurpos()
+ local actual_position = fn.getcurpos()
eq(cursor_position, { actual_position[2], actual_position[5] })
end
end
@@ -349,7 +349,7 @@ describe('put command', function()
local prev_line
local rettab = {}
local string_found = false
- for _, line in pairs(funcs.split(string, '\n', 1)) do
+ for _, line in pairs(fn.split(string, '\n', 1)) do
if line:find('test_string') then
string_found = true
table.insert(rettab, line)
@@ -476,7 +476,7 @@ describe('put command', function()
local prev_line
local rettab = {}
local prev_in_block = false
- for _, line in pairs(funcs.split(expect_base, '\n', 1)) do
+ for _, line in pairs(fn.split(expect_base, '\n', 1)) do
if line:find('test_string') then
if prev_line then
prev_line = prev_line:gsub('x', '')
@@ -524,10 +524,10 @@ describe('put command', function()
test_expect(exception_table, after_redo)
if selection_string then
if not conversion_table.put_backwards then
- eq(selection_string, funcs.getreg('"'))
+ eq(selection_string, fn.getreg('"'))
end
else
- eq('test_string"', funcs.getreg('"'))
+ eq('test_string"', fn.getreg('"'))
end
end
end
@@ -657,10 +657,10 @@ describe('put command', function()
xtest_string"]],
'put',
function()
- funcs.setline('$', ' Line of words 2')
+ fn.setline('$', ' Line of words 2')
-- Set curswant to '8' to be at the end of the tab character
-- This is where the cursor is put back after the 'u' command.
- funcs.setpos('.', { 0, 2, 1, 0, 8 })
+ fn.setpos('.', { 0, 2, 1, 0, 8 })
command('set autoindent')
end
)
@@ -671,9 +671,9 @@ describe('put command', function()
Line of words 1
test_stringx" Line of words 2]]
run_normal_mode_tests(test_string, 'p', function()
- funcs.setline('$', ' Line of words 2')
+ fn.setline('$', ' Line of words 2')
command('setlocal virtualedit=all')
- funcs.setpos('.', { 0, 2, 1, 2, 3 })
+ fn.setpos('.', { 0, 2, 1, 2, 3 })
end)
end)
@@ -683,9 +683,9 @@ describe('put command', function()
Line of words 1 test_stringx"
Line of words 2]]
run_normal_mode_tests(test_string, 'p', function()
- funcs.setline('$', ' Line of words 2')
+ fn.setline('$', ' Line of words 2')
command('setlocal virtualedit=all')
- funcs.setpos('.', { 0, 1, 16, 1, 17 })
+ fn.setpos('.', { 0, 1, 16, 1, 17 })
end, true)
end)
@@ -699,7 +699,7 @@ describe('put command', function()
describe('over trailing newline', function()
local test_string = 'Line of test_stringx"Line of words 2'
run_normal_mode_tests(test_string, 'v$p', function()
- funcs.setpos('.', { 0, 1, 9, 0, 9 })
+ fn.setpos('.', { 0, 1, 9, 0, 9 })
end, nil, 'words 1\n')
end)
describe('linewise mode', function()
@@ -720,7 +720,7 @@ describe('put command', function()
expect_vis_linewise
),
function()
- funcs.setpos('.', { 0, 1, 1, 0, 1 })
+ fn.setpos('.', { 0, 1, 1, 0, 1 })
end
)
@@ -732,7 +732,7 @@ describe('put command', function()
return function(exception_table, after_redo)
test_expect(exception_table, after_redo)
if not conversion_table.put_backwards then
- eq('Line of words 1\n', funcs.getreg('"'))
+ eq('Line of words 1\n', fn.getreg('"'))
end
end
end
@@ -749,7 +749,7 @@ describe('put command', function()
),
function()
feed('i test_string.<esc>u')
- funcs.setreg('"', ' test_string"', 'v')
+ fn.setreg('"', ' test_string"', 'v')
end
)
end)
@@ -767,7 +767,7 @@ describe('put command', function()
return function(e, c)
test_expect(e, c)
if not conversion_table.put_backwards then
- eq('Lin\nLin', funcs.getreg('"'))
+ eq('Lin\nLin', fn.getreg('"'))
end
end
end
@@ -804,7 +804,7 @@ describe('put command', function()
expect_block_creator
),
function()
- funcs.setpos('.', { 0, 2, 1, 0, 1 })
+ fn.setpos('.', { 0, 2, 1, 0, 1 })
end
)
@@ -820,16 +820,16 @@ describe('put command', function()
feed('u')
-- Have to use feed('u') here to set curswant, because
-- ex_undo() doesn't do that.
- eq({ 0, 1, 1, 0, 1 }, funcs.getcurpos())
+ eq({ 0, 1, 1, 0, 1 }, fn.getcurpos())
feed('<C-r>')
- eq({ 0, 1, 1, 0, 1 }, funcs.getcurpos())
+ eq({ 0, 1, 1, 0, 1 }, fn.getcurpos())
end
end
run_test_variations(
create_test_defs(undo_redo_no, '<C-v>kllp', create_p_action, test_base, assertion_creator),
function()
- funcs.setpos('.', { 0, 2, 1, 0, 1 })
+ fn.setpos('.', { 0, 2, 1, 0, 1 })
end
)
end)
@@ -841,9 +841,9 @@ describe('put command', function()
Line of words 1
test_stringx" Line of words 2]]
run_normal_mode_tests(base_expect_string, 'vp', function()
- funcs.setline('$', ' Line of words 2')
+ fn.setline('$', ' Line of words 2')
command('setlocal virtualedit=all')
- funcs.setpos('.', { 0, 2, 1, 2, 3 })
+ fn.setpos('.', { 0, 2, 1, 2, 3 })
end, nil, ' ')
end)
describe('after end of line', function()
@@ -852,7 +852,7 @@ describe('put command', function()
Line of words 2]]
run_normal_mode_tests(base_expect_string, 'vp', function()
command('setlocal virtualedit=all')
- funcs.setpos('.', { 0, 1, 16, 2, 18 })
+ fn.setpos('.', { 0, 1, 16, 2, 18 })
end, true, ' ')
end)
end)
@@ -917,14 +917,14 @@ describe('put command', function()
-- Even if the last character is a multibyte character.
reset()
- funcs.setline(1, 'helloม')
+ fn.setline(1, 'helloม')
bell_test(function()
feed('$".gp')
end)
end)
it('should not ring the bell with gp and end of file', function()
- funcs.setpos('.', { 0, 2, 1, 0 })
+ fn.setpos('.', { 0, 2, 1, 0 })
bell_test(function()
feed('$vl".gp')
end)
@@ -942,9 +942,9 @@ describe('put command', function()
end)
it('should restore cursor position after undo of ".p', function()
- local origpos = funcs.getcurpos()
+ local origpos = fn.getcurpos()
feed('".pu')
- eq(origpos, funcs.getcurpos())
+ eq(origpos, fn.getcurpos())
end)
it("should be unaffected by 'autoindent' with V\".2p", function()
diff --git a/test/functional/editor/tabpage_spec.lua b/test/functional/editor/tabpage_spec.lua
index 2087695465..f64e099344 100644
--- a/test/functional/editor/tabpage_spec.lua
+++ b/test/functional/editor/tabpage_spec.lua
@@ -8,9 +8,9 @@ local neq = helpers.neq
local feed = helpers.feed
local eval = helpers.eval
local exec = helpers.exec
-local funcs = helpers.funcs
-local meths = helpers.meths
-local curwin = helpers.meths.nvim_get_current_win
+local fn = helpers.fn
+local api = helpers.api
+local curwin = helpers.api.nvim_get_current_win
local assert_alive = helpers.assert_alive
describe('tabpage', function()
@@ -74,29 +74,29 @@ describe('tabpage', function()
end)
it('nvim_win_close and nvim_win_hide update tabline #20285', function()
- eq(1, #meths.nvim_list_tabpages())
- eq({ 1, 1 }, funcs.win_screenpos(0))
+ eq(1, #api.nvim_list_tabpages())
+ eq({ 1, 1 }, fn.win_screenpos(0))
local win1 = curwin().id
command('tabnew')
- eq(2, #meths.nvim_list_tabpages())
- eq({ 2, 1 }, funcs.win_screenpos(0))
+ eq(2, #api.nvim_list_tabpages())
+ eq({ 2, 1 }, fn.win_screenpos(0))
local win2 = curwin().id
- meths.nvim_win_close(win1, true)
+ api.nvim_win_close(win1, true)
eq(win2, curwin().id)
- eq(1, #meths.nvim_list_tabpages())
- eq({ 1, 1 }, funcs.win_screenpos(0))
+ eq(1, #api.nvim_list_tabpages())
+ eq({ 1, 1 }, fn.win_screenpos(0))
command('tabnew')
- eq(2, #meths.nvim_list_tabpages())
- eq({ 2, 1 }, funcs.win_screenpos(0))
+ eq(2, #api.nvim_list_tabpages())
+ eq({ 2, 1 }, fn.win_screenpos(0))
local win3 = curwin().id
- meths.nvim_win_hide(win2)
+ api.nvim_win_hide(win2)
eq(win3, curwin().id)
- eq(1, #meths.nvim_list_tabpages())
- eq({ 1, 1 }, funcs.win_screenpos(0))
+ eq(1, #api.nvim_list_tabpages())
+ eq({ 1, 1 }, fn.win_screenpos(0))
end)
it('switching tabpage after setting laststatus=3 #19591', function()
@@ -135,15 +135,15 @@ describe('tabpage', function()
it(':tabmove handles modifiers and addr', function()
command('tabnew | tabnew | tabnew')
- eq(4, funcs.nvim_tabpage_get_number(0))
+ eq(4, fn.nvim_tabpage_get_number(0))
command(' silent :keepalt :: ::: silent! - tabmove')
- eq(3, funcs.nvim_tabpage_get_number(0))
+ eq(3, fn.nvim_tabpage_get_number(0))
command(' silent :keepalt :: ::: silent! -2 tabmove')
- eq(1, funcs.nvim_tabpage_get_number(0))
+ eq(1, fn.nvim_tabpage_get_number(0))
end)
it(':tabs does not overflow IObuff with long path with comma #20850', function()
- meths.nvim_buf_set_name(0, ('x'):rep(1024) .. ',' .. ('x'):rep(1024))
+ api.nvim_buf_set_name(0, ('x'):rep(1024) .. ',' .. ('x'):rep(1024))
command('tabs')
assert_alive()
end)
diff --git a/test/functional/editor/undo_spec.lua b/test/functional/editor/undo_spec.lua
index a2dc34a6b9..c101bf02a0 100644
--- a/test/functional/editor/undo_spec.lua
+++ b/test/functional/editor/undo_spec.lua
@@ -8,12 +8,12 @@ local eq = helpers.eq
local feed = helpers.feed
local feed_command = helpers.feed_command
local insert = helpers.insert
-local funcs = helpers.funcs
+local fn = helpers.fn
local exec = helpers.exec
local exec_lua = helpers.exec_lua
local function lastmessage()
- local messages = funcs.split(funcs.execute('messages'), '\n')
+ local messages = fn.split(fn.execute('messages'), '\n')
return messages[#messages]
end
diff --git a/test/functional/ex_cmds/append_spec.lua b/test/functional/ex_cmds/append_spec.lua
index 27e56de54e..5eb8d49c74 100644
--- a/test/functional/ex_cmds/append_spec.lua
+++ b/test/functional/ex_cmds/append_spec.lua
@@ -5,20 +5,20 @@ local dedent = helpers.dedent
local exec = helpers.exec
local feed = helpers.feed
local clear = helpers.clear
-local funcs = helpers.funcs
+local fn = helpers.fn
local command = helpers.command
-local meths = helpers.meths
+local api = helpers.api
local Screen = require('test.functional.ui.screen')
local cmdtest = function(cmd, prep, ret1)
describe(':' .. cmd, function()
before_each(function()
clear()
- meths.nvim_buf_set_lines(0, 0, 1, true, { 'foo', 'bar', 'baz' })
+ api.nvim_buf_set_lines(0, 0, 1, true, { 'foo', 'bar', 'baz' })
end)
local buffer_contents = function()
- return meths.nvim_buf_get_lines(0, 0, -1, false)
+ return api.nvim_buf_get_lines(0, 0, -1, false)
end
it(cmd .. 's' .. prep .. ' the current line by default', function()
@@ -38,15 +38,15 @@ local cmdtest = function(cmd, prep, ret1)
feed(':' .. hisline .. '<CR>')
feed(':' .. cmd .. '<CR>abc<CR>def<C-f>')
eq({ 'def' }, buffer_contents())
- eq(hisline, funcs.histget(':', -2))
- eq(cmd, funcs.histget(':'))
+ eq(hisline, fn.histget(':', -2))
+ eq(cmd, fn.histget(':'))
-- Test that command-line window was launched
- eq('nofile', meths.nvim_get_option_value('buftype', {}))
- eq('n', funcs.mode(1))
+ eq('nofile', api.nvim_get_option_value('buftype', {}))
+ eq('n', fn.mode(1))
feed('<CR>')
- eq('c', funcs.mode(1))
+ eq('c', fn.mode(1))
feed('.<CR>')
- eq('n', funcs.mode(1))
+ eq('n', fn.mode(1))
eq(ret1, buffer_contents())
end)
end)
diff --git a/test/functional/ex_cmds/arg_spec.lua b/test/functional/ex_cmds/arg_spec.lua
index 1cb758cd23..810b001ec0 100644
--- a/test/functional/ex_cmds/arg_spec.lua
+++ b/test/functional/ex_cmds/arg_spec.lua
@@ -1,5 +1,5 @@
local helpers = require('test.functional.helpers')(after_each)
-local eq, command, funcs = helpers.eq, helpers.command, helpers.funcs
+local eq, command, fn = helpers.eq, helpers.command, helpers.fn
local ok = helpers.ok
local clear = helpers.clear
@@ -13,17 +13,17 @@ describe(':argument', function()
helpers.feed([[<C-\><C-N>]])
command('argadd')
helpers.feed([[<C-\><C-N>]])
- local bufname_before = funcs.bufname('%')
- local bufnr_before = funcs.bufnr('%')
+ local bufname_before = fn.bufname('%')
+ local bufnr_before = fn.bufnr('%')
helpers.ok(nil ~= string.find(bufname_before, '^term://')) -- sanity
command('argument 1')
helpers.feed([[<C-\><C-N>]])
- local bufname_after = funcs.bufname('%')
- local bufnr_after = funcs.bufnr('%')
+ local bufname_after = fn.bufname('%')
+ local bufnr_after = fn.bufnr('%')
eq('[' .. bufname_before .. ']', helpers.eval('trim(execute("args"))'))
- ok(funcs.line('$') > 1)
+ ok(fn.line('$') > 1)
eq(bufname_before, bufname_after)
eq(bufnr_before, bufnr_after)
end)
diff --git a/test/functional/ex_cmds/cmd_map_spec.lua b/test/functional/ex_cmds/cmd_map_spec.lua
index c1a4fee38d..da7d686e5b 100644
--- a/test/functional/ex_cmds/cmd_map_spec.lua
+++ b/test/functional/ex_cmds/cmd_map_spec.lua
@@ -4,7 +4,7 @@ local feed = helpers.feed
local eq = helpers.eq
local expect = helpers.expect
local eval = helpers.eval
-local funcs = helpers.funcs
+local fn = helpers.fn
local insert = helpers.insert
local write_file = helpers.write_file
local exc_exec = helpers.exc_exec
@@ -329,12 +329,12 @@ describe('mappings with <Cmd>', function()
{1:~ }|*5
{4:-- VISUAL --} |
]])
- eq('v', funcs.mode(1))
+ eq('v', fn.mode(1))
-- can invoke operator, ending visual mode
feed('<F5>')
- eq('n', funcs.mode(1))
- eq({ 'some short l' }, funcs.getreg('a', 1, 1))
+ eq('n', fn.mode(1))
+ eq({ 'some short l' }, fn.getreg('a', 1, 1))
-- error doesn't interrupt visual mode
feed('ggvw<F6>')
@@ -356,7 +356,7 @@ describe('mappings with <Cmd>', function()
{1:~ }|*5
{4:-- VISUAL --} |
]])
- eq('v', funcs.mode(1))
+ eq('v', fn.mode(1))
feed('<F7>')
screen:expect([[
so{5:me short lines} |
@@ -364,7 +364,7 @@ describe('mappings with <Cmd>', function()
{1:~ }|*5
{4:-- VISUAL --} |
]])
- eq('v', funcs.mode(1))
+ eq('v', fn.mode(1))
-- startinsert gives "-- (insert) VISUAL --" mode
feed('<F8>')
@@ -390,17 +390,17 @@ describe('mappings with <Cmd>', function()
{1:~ }|*5
{4:-- SELECT --} |
]])
- eq('s', funcs.mode(1))
+ eq('s', fn.mode(1))
-- visual mapping in select mode restart select mode after operator
feed('<F5>')
- eq('s', funcs.mode(1))
- eq({ 'some short l' }, funcs.getreg('a', 1, 1))
+ eq('s', fn.mode(1))
+ eq({ 'some short l' }, fn.getreg('a', 1, 1))
-- select mode mapping works, and does not restart select mode
feed('<F2>')
- eq('n', funcs.mode(1))
- eq({ 'some short l' }, funcs.getreg('b', 1, 1))
+ eq('n', fn.mode(1))
+ eq({ 'some short l' }, fn.getreg('b', 1, 1))
-- error doesn't interrupt temporary visual mode
feed('<esc>ggvw<c-g><F6>')
@@ -423,7 +423,7 @@ describe('mappings with <Cmd>', function()
{4:-- VISUAL --} |
]])
-- quirk: restoration of select mode is not performed
- eq('v', funcs.mode(1))
+ eq('v', fn.mode(1))
-- error doesn't interrupt select mode
feed('<esc>ggvw<c-g><F1>')
@@ -446,7 +446,7 @@ describe('mappings with <Cmd>', function()
{4:-- SELECT --} |
]])
-- quirk: restoration of select mode is not performed
- eq('s', funcs.mode(1))
+ eq('s', fn.mode(1))
feed('<F7>')
screen:expect([[
@@ -455,7 +455,7 @@ describe('mappings with <Cmd>', function()
{1:~ }|*5
{4:-- SELECT --} |
]])
- eq('s', funcs.mode(1))
+ eq('s', fn.mode(1))
-- startinsert gives "-- SELECT (insert) --" mode
feed('<F8>')
@@ -475,11 +475,11 @@ describe('mappings with <Cmd>', function()
expect([[
lines
of test text]])
- eq({ 'some short ' }, funcs.getreg('"', 1, 1))
+ eq({ 'some short ' }, fn.getreg('"', 1, 1))
feed('.')
expect([[
test text]])
- eq({ 'lines', 'of ' }, funcs.getreg('"', 1, 1))
+ eq({ 'lines', 'of ' }, fn.getreg('"', 1, 1))
feed('uu')
expect([[
some short lines
@@ -505,7 +505,7 @@ describe('mappings with <Cmd>', function()
feed('"bd<F7>')
expect([[
soest text]])
- eq(funcs.getreg('b', 1, 1), { 'me short lines', 'of t' })
+ eq(fn.getreg('b', 1, 1), { 'me short lines', 'of t' })
-- startinsert aborts operator
feed('d<F8>')
@@ -561,7 +561,7 @@ describe('mappings with <Cmd>', function()
of stuff test text]])
feed('<F5>')
- eq(funcs.getreg('a', 1, 1), { 'deed some short little lines', 'of stuff t' })
+ eq(fn.getreg('a', 1, 1), { 'deed some short little lines', 'of stuff t' })
-- still in insert
screen:expect([[
diff --git a/test/functional/ex_cmds/dict_notifications_spec.lua b/test/functional/ex_cmds/dict_notifications_spec.lua
index 439d28d59a..15fbb750f6 100644
--- a/test/functional/ex_cmds/dict_notifications_spec.lua
+++ b/test/functional/ex_cmds/dict_notifications_spec.lua
@@ -1,7 +1,7 @@
local helpers = require('test.functional.helpers')(after_each)
local assert_alive = helpers.assert_alive
local clear, source = helpers.clear, helpers.source
-local meths = helpers.meths
+local api = helpers.api
local insert = helpers.insert
local eq, next_msg = helpers.eq, helpers.next_msg
local exc_exec = helpers.exc_exec
@@ -14,8 +14,8 @@ describe('Vimscript dictionary notifications', function()
before_each(function()
clear()
- channel = meths.nvim_get_api_info()[1]
- meths.nvim_set_var('channel', channel)
+ channel = api.nvim_get_api_info()[1]
+ api.nvim_set_var('channel', channel)
end)
-- the same set of tests are applied to top-level dictionaries(g:, b:, w: and
diff --git a/test/functional/ex_cmds/echo_spec.lua b/test/functional/ex_cmds/echo_spec.lua
index bfc8f57632..e9176a6204 100644
--- a/test/functional/ex_cmds/echo_spec.lua
+++ b/test/functional/ex_cmds/echo_spec.lua
@@ -4,8 +4,8 @@ local eq = helpers.eq
local NIL = vim.NIL
local eval = helpers.eval
local clear = helpers.clear
-local meths = helpers.meths
-local funcs = helpers.funcs
+local api = helpers.api
+local fn = helpers.fn
local source = helpers.source
local dedent = helpers.dedent
local command = helpers.command
@@ -17,12 +17,12 @@ describe(':echo :echon :echomsg :echoerr', function()
local fn_tbl = { 'String', 'StringN', 'StringMsg', 'StringErr' }
local function assert_same_echo_dump(expected, input, use_eval)
for _, v in pairs(fn_tbl) do
- eq(expected, use_eval and eval(v .. '(' .. input .. ')') or funcs[v](input))
+ eq(expected, use_eval and eval(v .. '(' .. input .. ')') or fn[v](input))
end
end
local function assert_matches_echo_dump(expected, input, use_eval)
for _, v in pairs(fn_tbl) do
- matches(expected, use_eval and eval(v .. '(' .. input .. ')') or funcs[v](input))
+ matches(expected, use_eval and eval(v .. '(' .. input .. ')') or fn[v](input))
end
end
@@ -68,21 +68,21 @@ describe(':echo :echon :echomsg :echoerr', function()
eq('v:true', eval('String(v:true)'))
eq('v:false', eval('String(v:false)'))
eq('v:null', eval('String(v:null)'))
- eq('v:true', funcs.String(true))
- eq('v:false', funcs.String(false))
- eq('v:null', funcs.String(NIL))
+ eq('v:true', fn.String(true))
+ eq('v:false', fn.String(false))
+ eq('v:null', fn.String(NIL))
eq('v:true', eval('StringMsg(v:true)'))
eq('v:false', eval('StringMsg(v:false)'))
eq('v:null', eval('StringMsg(v:null)'))
- eq('v:true', funcs.StringMsg(true))
- eq('v:false', funcs.StringMsg(false))
- eq('v:null', funcs.StringMsg(NIL))
+ eq('v:true', fn.StringMsg(true))
+ eq('v:false', fn.StringMsg(false))
+ eq('v:null', fn.StringMsg(NIL))
eq('v:true', eval('StringErr(v:true)'))
eq('v:false', eval('StringErr(v:false)'))
eq('v:null', eval('StringErr(v:null)'))
- eq('v:true', funcs.StringErr(true))
- eq('v:false', funcs.StringErr(false))
- eq('v:null', funcs.StringErr(NIL))
+ eq('v:true', fn.StringErr(true))
+ eq('v:false', fn.StringErr(false))
+ eq('v:null', fn.StringErr(NIL))
end)
it('dumps values with at most six digits after the decimal point', function()
@@ -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.nvim_set_var('d', { v = true })
+ api.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.nvim_set_var('l', {})
+ api.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.nvim_set_var('d', { v = true })
- meths.nvim_set_var('l', {})
+ api.nvim_set_var('d', { v = true })
+ api.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.nvim_set_var('l', {})
+ api.nvim_set_var('l', {})
eval('add(l, l)')
eq(0, exc_exec('echo String(l)'))
end)
it('dumps recursive lists without error', function()
- meths.nvim_set_var('l', {})
+ api.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.nvim_set_var('d', { d = 1 })
+ api.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.nvim_set_var('d', { d = 1 })
+ api.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})'))
@@ -358,43 +358,43 @@ describe(':echo :echon :echomsg :echoerr', function()
it('displays hex as hex', function()
-- Regression: due to missing (uint8_t) cast \x80 was represented as
-- ~@<80>.
- eq('<80>', funcs.String(chr(0x80)))
- eq('<81>', funcs.String(chr(0x81)))
- eq('<8e>', funcs.String(chr(0x8e)))
- eq('<c2>', funcs.String(('«'):sub(1, 1)))
- eq('«', funcs.String(('«'):sub(1, 2)))
-
- eq('<80>', funcs.StringMsg(chr(0x80)))
- eq('<81>', funcs.StringMsg(chr(0x81)))
- eq('<8e>', funcs.StringMsg(chr(0x8e)))
- eq('<c2>', funcs.StringMsg(('«'):sub(1, 1)))
- eq('«', funcs.StringMsg(('«'):sub(1, 2)))
+ eq('<80>', fn.String(chr(0x80)))
+ eq('<81>', fn.String(chr(0x81)))
+ eq('<8e>', fn.String(chr(0x8e)))
+ eq('<c2>', fn.String(('«'):sub(1, 1)))
+ eq('«', fn.String(('«'):sub(1, 2)))
+
+ eq('<80>', fn.StringMsg(chr(0x80)))
+ eq('<81>', fn.StringMsg(chr(0x81)))
+ eq('<8e>', fn.StringMsg(chr(0x8e)))
+ eq('<c2>', fn.StringMsg(('«'):sub(1, 1)))
+ eq('«', fn.StringMsg(('«'):sub(1, 2)))
end)
it('displays ASCII control characters using ^X notation', function()
- eq('^C', funcs.String(ctrl('c')))
- eq('^A', funcs.String(ctrl('a')))
- eq('^F', funcs.String(ctrl('f')))
- eq('^C', funcs.StringMsg(ctrl('c')))
- eq('^A', funcs.StringMsg(ctrl('a')))
- eq('^F', funcs.StringMsg(ctrl('f')))
+ eq('^C', fn.String(ctrl('c')))
+ eq('^A', fn.String(ctrl('a')))
+ eq('^F', fn.String(ctrl('f')))
+ eq('^C', fn.StringMsg(ctrl('c')))
+ eq('^A', fn.StringMsg(ctrl('a')))
+ eq('^F', fn.StringMsg(ctrl('f')))
end)
it('prints CR, NL and tab as-is', function()
- eq('\n', funcs.String('\n'))
- eq('\r', funcs.String('\r'))
- eq('\t', funcs.String('\t'))
+ eq('\n', fn.String('\n'))
+ eq('\r', fn.String('\r'))
+ eq('\t', fn.String('\t'))
end)
it('prints non-printable UTF-8 in <> notation', function()
-- SINGLE SHIFT TWO, unicode control
- eq('<8e>', funcs.String(funcs.nr2char(0x8E)))
- eq('<8e>', funcs.StringMsg(funcs.nr2char(0x8E)))
+ eq('<8e>', fn.String(fn.nr2char(0x8E)))
+ eq('<8e>', fn.StringMsg(fn.nr2char(0x8E)))
-- Surrogate pair: U+1F0A0 PLAYING CARD BACK is represented in UTF-16 as
-- 0xD83C 0xDCA0. This is not valid in UTF-8.
- eq('<d83c>', funcs.String(funcs.nr2char(0xD83C)))
- eq('<dca0>', funcs.String(funcs.nr2char(0xDCA0)))
- eq('<d83c><dca0>', funcs.String(funcs.nr2char(0xD83C) .. funcs.nr2char(0xDCA0)))
- eq('<d83c>', funcs.StringMsg(funcs.nr2char(0xD83C)))
- eq('<dca0>', funcs.StringMsg(funcs.nr2char(0xDCA0)))
- eq('<d83c><dca0>', funcs.StringMsg(funcs.nr2char(0xD83C) .. funcs.nr2char(0xDCA0)))
+ eq('<d83c>', fn.String(fn.nr2char(0xD83C)))
+ eq('<dca0>', fn.String(fn.nr2char(0xDCA0)))
+ eq('<d83c><dca0>', fn.String(fn.nr2char(0xD83C) .. fn.nr2char(0xDCA0)))
+ eq('<d83c>', fn.StringMsg(fn.nr2char(0xD83C)))
+ eq('<dca0>', fn.StringMsg(fn.nr2char(0xDCA0)))
+ eq('<d83c><dca0>', fn.StringMsg(fn.nr2char(0xD83C) .. fn.nr2char(0xDCA0)))
end)
end)
end)
diff --git a/test/functional/ex_cmds/edit_spec.lua b/test/functional/ex_cmds/edit_spec.lua
index 48ae99a0fa..b927fa418a 100644
--- a/test/functional/ex_cmds/edit_spec.lua
+++ b/test/functional/ex_cmds/edit_spec.lua
@@ -1,5 +1,5 @@
local helpers = require('test.functional.helpers')(after_each)
-local eq, command, funcs = helpers.eq, helpers.command, helpers.funcs
+local eq, command, fn = helpers.eq, helpers.command, helpers.fn
local ok = helpers.ok
local clear = helpers.clear
local feed = helpers.feed
@@ -12,15 +12,15 @@ describe(':edit', function()
it('without arguments does not restart :terminal buffer', function()
command('terminal')
feed([[<C-\><C-N>]])
- local bufname_before = funcs.bufname('%')
- local bufnr_before = funcs.bufnr('%')
+ local bufname_before = fn.bufname('%')
+ local bufnr_before = fn.bufnr('%')
helpers.ok(nil ~= string.find(bufname_before, '^term://')) -- sanity
command('edit')
- local bufname_after = funcs.bufname('%')
- local bufnr_after = funcs.bufnr('%')
- ok(funcs.line('$') > 1)
+ local bufname_after = fn.bufname('%')
+ local bufnr_after = fn.bufnr('%')
+ ok(fn.line('$') > 1)
eq(bufname_before, bufname_after)
eq(bufnr_before, bufnr_after)
end)
diff --git a/test/functional/ex_cmds/excmd_spec.lua b/test/functional/ex_cmds/excmd_spec.lua
index 030816c6cb..d16a52ee62 100644
--- a/test/functional/ex_cmds/excmd_spec.lua
+++ b/test/functional/ex_cmds/excmd_spec.lua
@@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')(after_each)
local command = helpers.command
local eq = helpers.eq
local clear = helpers.clear
-local funcs = helpers.funcs
+local fn = helpers.fn
local pcall_err = helpers.pcall_err
local assert_alive = helpers.assert_alive
@@ -49,15 +49,15 @@ describe('Ex cmds', function()
it(':def is an unknown command #23149', function()
eq('Vim:E492: Not an editor command: def', pcall_err(command, 'def'))
- eq(1, funcs.exists(':d'))
- eq('delete', funcs.fullcommand('d'))
- eq(1, funcs.exists(':de'))
- eq('delete', funcs.fullcommand('de'))
- eq(0, funcs.exists(':def'))
- eq('', funcs.fullcommand('def'))
- eq(1, funcs.exists(':defe'))
- eq('defer', funcs.fullcommand('defe'))
- eq(2, funcs.exists(':defer'))
- eq('defer', funcs.fullcommand('defer'))
+ eq(1, fn.exists(':d'))
+ eq('delete', fn.fullcommand('d'))
+ eq(1, fn.exists(':de'))
+ eq('delete', fn.fullcommand('de'))
+ eq(0, fn.exists(':def'))
+ eq('', fn.fullcommand('def'))
+ eq(1, fn.exists(':defe'))
+ eq('defer', fn.fullcommand('defe'))
+ eq(2, fn.exists(':defer'))
+ eq('defer', fn.fullcommand('defer'))
end)
end)
diff --git a/test/functional/ex_cmds/file_spec.lua b/test/functional/ex_cmds/file_spec.lua
index ce55b61d53..a48c408600 100644
--- a/test/functional/ex_cmds/file_spec.lua
+++ b/test/functional/ex_cmds/file_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
local rmdir = helpers.rmdir
local mkdir = helpers.mkdir
@@ -29,6 +29,6 @@ describe(':file', function()
command('edit! ' .. testfile)
-- Before #6487 this gave "E301: Oops, lost the swap file !!!" on Windows.
command('file ' .. testfile_renamed)
- eq(testfile_renamed .. '.swp', string.match(funcs.execute('swapname'), '[^%%]+$'))
+ eq(testfile_renamed .. '.swp', string.match(fn.execute('swapname'), '[^%%]+$'))
end)
end)
diff --git a/test/functional/ex_cmds/help_spec.lua b/test/functional/ex_cmds/help_spec.lua
index de79fadd6d..cee33de1a6 100644
--- a/test/functional/ex_cmds/help_spec.lua
+++ b/test/functional/ex_cmds/help_spec.lua
@@ -3,8 +3,8 @@ 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 meths = helpers.meths
+local fn = helpers.fn
+local api = helpers.api
local mkdir = helpers.mkdir
local rmdir = helpers.rmdir
local write_file = helpers.write_file
@@ -15,19 +15,19 @@ describe(':help', function()
it('window closed makes cursor return to a valid win/buf #9773', function()
helpers.add_builddir_to_rtp()
command('help help')
- eq(1001, funcs.win_getid())
+ eq(1001, fn.win_getid())
command('quit')
- eq(1000, funcs.win_getid())
+ eq(1000, fn.win_getid())
command('autocmd WinNew * wincmd p')
command('help help')
-- Window 1002 is opened, but the autocmd switches back to 1000 and
-- creates the help buffer there instead.
- eq(1000, funcs.win_getid())
+ eq(1000, fn.win_getid())
command('quit')
-- Before #9773, Nvim would crash on quitting the help window.
- eq(1002, funcs.win_getid())
+ eq(1002, fn.win_getid())
end)
it('multibyte help tags work #23975', function()
@@ -40,6 +40,6 @@ describe(':help', function()
command('helptags Xhelptags/doc')
command('set rtp+=Xhelptags')
command('help …')
- eq('*…*', meths.nvim_get_current_line())
+ eq('*…*', api.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 f572728b4d..897a2997bc 100644
--- a/test/functional/ex_cmds/highlight_spec.lua
+++ b/test/functional/ex_cmds/highlight_spec.lua
@@ -4,8 +4,8 @@ local eq, command = helpers.eq, helpers.command
local clear = helpers.clear
local eval, exc_exec = helpers.eval, helpers.exc_exec
local exec = helpers.exec
-local funcs = helpers.funcs
-local meths = helpers.meths
+local fn = helpers.fn
+local api = helpers.api
describe(':highlight', function()
local screen
@@ -53,18 +53,18 @@ describe(':highlight', function()
end)
it('clear', function()
- meths.nvim_set_var('colors_name', 'foo')
- eq(1, funcs.exists('g:colors_name'))
+ api.nvim_set_var('colors_name', 'foo')
+ eq(1, fn.exists('g:colors_name'))
command('hi clear')
- eq(0, funcs.exists('g:colors_name'))
- meths.nvim_set_var('colors_name', 'foo')
- eq(1, funcs.exists('g:colors_name'))
+ eq(0, fn.exists('g:colors_name'))
+ api.nvim_set_var('colors_name', 'foo')
+ eq(1, fn.exists('g:colors_name'))
exec([[
func HiClear()
hi clear
endfunc
]])
- funcs.HiClear()
- eq(0, funcs.exists('g:colors_name'))
+ fn.HiClear()
+ eq(0, fn.exists('g:colors_name'))
end)
end)
diff --git a/test/functional/ex_cmds/ls_spec.lua b/test/functional/ex_cmds/ls_spec.lua
index 0dac810ef7..5f59402d10 100644
--- a/test/functional/ex_cmds/ls_spec.lua
+++ b/test/functional/ex_cmds/ls_spec.lua
@@ -4,7 +4,7 @@ local command = helpers.command
local eq = helpers.eq
local eval = helpers.eval
local feed = helpers.feed
-local meths = helpers.meths
+local api = helpers.api
local testprg = helpers.testprg
local retry = helpers.retry
@@ -14,7 +14,7 @@ describe(':ls', function()
end)
it('R, F for :terminal buffers', function()
- meths.nvim_set_option_value('shell', string.format('"%s" INTERACT', testprg('shell-test')), {})
+ api.nvim_set_option_value('shell', string.format('"%s" INTERACT', testprg('shell-test')), {})
command('edit foo')
command('set hidden')
diff --git a/test/functional/ex_cmds/make_spec.lua b/test/functional/ex_cmds/make_spec.lua
index a91ee23bb8..dd47bdec58 100644
--- a/test/functional/ex_cmds/make_spec.lua
+++ b/test/functional/ex_cmds/make_spec.lua
@@ -3,7 +3,7 @@ local clear = helpers.clear
local eval = helpers.eval
local has_powershell = helpers.has_powershell
local matches = helpers.matches
-local meths = helpers.meths
+local api = helpers.api
local testprg = helpers.testprg
describe(':make', function()
@@ -22,7 +22,7 @@ describe(':make', function()
end)
it('captures stderr & non zero exit code #14349', function()
- meths.nvim_set_option_value('makeprg', testprg('shell-test') .. ' foo', {})
+ api.nvim_set_option_value('makeprg', testprg('shell-test') .. ' foo', {})
local out = eval('execute("make")')
-- Error message is captured in the file and printed in the footer
matches(
@@ -32,7 +32,7 @@ describe(':make', function()
end)
it('captures stderr & zero exit code #14349', function()
- meths.nvim_set_option_value('makeprg', testprg('shell-test'), {})
+ api.nvim_set_option_value('makeprg', testprg('shell-test'), {})
local out = eval('execute("make")')
-- Ensure there are no "shell returned X" messages between
-- command and last line (indicating zero exit)
diff --git a/test/functional/ex_cmds/map_spec.lua b/test/functional/ex_cmds/map_spec.lua
index 16df6f58b5..d3b027e6f4 100644
--- a/test/functional/ex_cmds/map_spec.lua
+++ b/test/functional/ex_cmds/map_spec.lua
@@ -5,7 +5,7 @@ local eq = helpers.eq
local exec = helpers.exec
local exec_capture = helpers.exec_capture
local feed = helpers.feed
-local meths = helpers.meths
+local api = helpers.api
local clear = helpers.clear
local command = helpers.command
local expect = helpers.expect
@@ -16,13 +16,13 @@ describe(':*map', function()
before_each(clear)
it('are not affected by &isident', function()
- meths.nvim_set_var('counter', 0)
+ api.nvim_set_var('counter', 0)
command('nnoremap <C-x> :let counter+=1<CR>')
- meths.nvim_set_option_value('isident', ('%u'):format(('>'):byte()), {})
+ api.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.nvim_get_var('counter'))
+ eq(4, api.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.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' })
+ api.nvim_set_keymap('n', 'asdf1', 'qwert', { desc = 'do the one thing' })
+ api.nvim_set_keymap('n', 'asdf2', 'qwert', { desc = 'doesnot really do anything' })
+ api.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.nvim_eval('x'))
+ eq(0, api.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.nvim_eval('x'))
+ eq(1, api.nvim_eval('x'))
feed('increase_x_noremap')
- eq(2, meths.nvim_eval('x'))
+ eq(2, api.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.nvim_eval('x'))
+ eq(0, api.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.nvim_eval('x'))
+ eq(1, api.nvim_eval('x'))
eq('Some text', eval("getline('.')"))
feed('increase_x_noremap')
- eq(2, meths.nvim_eval('x'))
+ eq(2, api.nvim_eval('x'))
eq('Some te', eval("getline('.')"))
end)
diff --git a/test/functional/ex_cmds/menu_spec.lua b/test/functional/ex_cmds/menu_spec.lua
index cd5f4d870c..bb6ef72787 100644
--- a/test/functional/ex_cmds/menu_spec.lua
+++ b/test/functional/ex_cmds/menu_spec.lua
@@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')(after_each)
local clear, command = helpers.clear, helpers.command
local expect, feed = helpers.expect, helpers.feed
local eq, eval = helpers.eq, helpers.eval
-local funcs = helpers.funcs
+local fn = helpers.fn
describe(':emenu', function()
before_each(function()
@@ -80,7 +80,7 @@ describe('menu_get', function()
end)
it("path='', modes='a'", function()
- local m = funcs.menu_get('', 'a')
+ local m = fn.menu_get('', 'a')
-- HINT: To print the expected table and regenerate the tests:
-- print(require('vim.inspect')(m))
local expected = {
@@ -308,7 +308,7 @@ describe('menu_get', function()
end)
it('matching path, all modes', function()
- local m = funcs.menu_get('Export', 'a')
+ local m = fn.menu_get('Export', 'a')
local expected = {
{
hidden = 0,
@@ -337,7 +337,7 @@ describe('menu_get', function()
end)
it('no path, matching modes', function()
- local m = funcs.menu_get('', 'i')
+ local m = fn.menu_get('', 'i')
local expected = {
{
shortcut = 'T',
@@ -366,7 +366,7 @@ describe('menu_get', function()
end)
it('matching path and modes', function()
- local m = funcs.menu_get('Test', 'i')
+ local m = fn.menu_get('Test', 'i')
local expected = {
{
shortcut = 'T',
@@ -412,7 +412,7 @@ describe('menu_get', function()
command('nnoremenu &Test.Test8 <NoP>')
command('nnoremenu &Test.Test9 ""')
- local m = funcs.menu_get('')
+ local m = fn.menu_get('')
local expected = {
{
shortcut = 'T',
@@ -565,7 +565,7 @@ describe('menu_get', function()
command('nnoremenu &Test\\ 1.Test\\ 2 Wargl')
command('nnoremenu &Test4.Test<Tab>3 i space<Esc>')
- local m = funcs.menu_get('')
+ local m = fn.menu_get('')
local expected = {
{
shortcut = 'T',
diff --git a/test/functional/ex_cmds/mksession_spec.lua b/test/functional/ex_cmds/mksession_spec.lua
index 2a62bff6e9..16c608b156 100644
--- a/test/functional/ex_cmds/mksession_spec.lua
+++ b/test/functional/ex_cmds/mksession_spec.lua
@@ -6,12 +6,12 @@ local command = helpers.command
local get_pathsep = helpers.get_pathsep
local eq = helpers.eq
local neq = helpers.neq
-local funcs = helpers.funcs
+local fn = helpers.fn
local matches = helpers.matches
local pesc = vim.pesc
local rmdir = helpers.rmdir
local sleep = vim.uv.sleep
-local meths = helpers.meths
+local api = helpers.api
local skip = helpers.skip
local is_os = helpers.is_os
local mkdir = helpers.mkdir
@@ -54,8 +54,8 @@ describe(':mksession', function()
-- Restore session.
command('source ' .. session_file)
- eq(funcs.winbufnr(1), funcs.winbufnr(2))
- neq(funcs.winbufnr(1), funcs.winbufnr(3))
+ eq(fn.winbufnr(1), fn.winbufnr(2))
+ neq(fn.winbufnr(1), fn.winbufnr(3))
end)
-- common testing procedure for testing "sessionoptions-=terminal"
@@ -70,7 +70,7 @@ describe(':mksession', function()
-- Restore session.
command('source ' .. session_file)
- eq(expected_buf_count, #meths.nvim_list_bufs())
+ eq(expected_buf_count, #api.nvim_list_bufs())
end
it(
@@ -80,54 +80,54 @@ describe(':mksession', function()
command('edit ' .. tmpfile_base)
command('terminal')
- local buf_count = #meths.nvim_list_bufs()
+ local buf_count = #api.nvim_list_bufs()
eq(2, buf_count)
- eq('terminal', meths.nvim_get_option_value('buftype', {}))
+ eq('terminal', api.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.nvim_get_option_value('buftype', { buf = meths.nvim_list_bufs()[1] }))
- eq('', meths.nvim_get_option_value('buftype', { buf = meths.nvim_list_bufs()[2] }))
+ eq('', api.nvim_get_option_value('buftype', { buf = api.nvim_list_bufs()[1] }))
+ eq('', api.nvim_get_option_value('buftype', { buf = api.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.nvim_get_current_buf()
+ local terminal_bufnr = api.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.nvim_list_bufs()
+ local buf_count = #api.nvim_list_bufs()
eq(2, buf_count)
- eq(1, funcs.getbufinfo(terminal_bufnr)[1].hidden)
+ eq(1, fn.getbufinfo(terminal_bufnr)[1].hidden)
test_terminal_session_disabled(1)
-- no terminal should exist here
- neq('', meths.nvim_buf_get_name(meths.nvim_list_bufs()[1]))
+ neq('', api.nvim_buf_get_name(api.nvim_list_bufs()[1]))
end)
it('do not restore :terminal if not set in sessionoptions, only buffer #13078', function()
command('terminal')
- eq('terminal', meths.nvim_get_option_value('buftype', {}))
+ eq('terminal', api.nvim_get_option_value('buftype', {}))
- local buf_count = #meths.nvim_list_bufs()
+ local buf_count = #api.nvim_list_bufs()
eq(1, buf_count)
test_terminal_session_disabled(1)
-- no terminal should be set
- eq('', meths.nvim_get_option_value('buftype', {}))
+ eq('', api.nvim_get_option_value('buftype', {}))
end)
it('restores tab-local working directories', function()
local tmpfile_base = file_prefix .. '-tmpfile'
- local cwd_dir = funcs.getcwd()
+ local cwd_dir = fn.getcwd()
-- :mksession does not save empty tabs, so create some buffers.
command('edit ' .. tmpfile_base .. '1')
@@ -143,15 +143,15 @@ describe(':mksession', function()
command('source ' .. session_file)
-- First tab should have the original working directory.
command('tabnext 1')
- eq(cwd_dir, funcs.getcwd())
+ eq(cwd_dir, fn.getcwd())
-- Second tab should have the tab-local working directory.
command('tabnext 2')
- eq(cwd_dir .. get_pathsep() .. tab_dir, funcs.getcwd())
+ eq(cwd_dir .. get_pathsep() .. tab_dir, fn.getcwd())
end)
it('restores buffers with tab-local CWD', function()
local tmpfile_base = file_prefix .. '-tmpfile'
- local cwd_dir = funcs.getcwd()
+ local cwd_dir = fn.getcwd()
local session_path = cwd_dir .. get_pathsep() .. session_file
command('edit ' .. tmpfile_base .. '1')
@@ -167,13 +167,13 @@ describe(':mksession', function()
-- Use :silent to avoid press-enter prompt due to long path
command('silent source ' .. session_path)
command('tabnext 1')
- eq(cwd_dir .. get_pathsep() .. tmpfile_base .. '1', funcs.expand('%:p'))
+ eq(cwd_dir .. get_pathsep() .. tmpfile_base .. '1', fn.expand('%:p'))
command('tabnext 2')
- eq(cwd_dir .. get_pathsep() .. tmpfile_base .. '2', funcs.expand('%:p'))
+ eq(cwd_dir .. get_pathsep() .. tmpfile_base .. '2', fn.expand('%:p'))
end)
it('restores CWD for :terminal buffers #11288', function()
- local cwd_dir = funcs.fnamemodify('.', ':p:~'):gsub([[[\/]*$]], '')
+ local cwd_dir = fn.fnamemodify('.', ':p:~'):gsub([[[\/]*$]], '')
cwd_dir = cwd_dir:gsub([[\]], '/') -- :mksession always uses unix slashes.
local session_path = cwd_dir .. '/' .. session_file
@@ -191,7 +191,7 @@ describe(':mksession', function()
command('silent source ' .. session_path)
local expected_cwd = cwd_dir .. '/' .. tab_dir
- matches('^term://' .. pesc(expected_cwd) .. '//%d+:', funcs.expand('%'))
+ matches('^term://' .. pesc(expected_cwd) .. '//%d+:', fn.expand('%'))
command('%bwipeout!')
if is_os('win') then
sleep(100) -- Make sure all child processes have exited.
@@ -202,7 +202,7 @@ describe(':mksession', function()
skip(is_os('win'), 'N/A for Windows')
local screen
- local cwd_dir = funcs.fnamemodify('.', ':p:~'):gsub([[[\/]*$]], '')
+ local cwd_dir = fn.fnamemodify('.', ':p:~'):gsub([[[\/]*$]], '')
local session_path = cwd_dir .. '/' .. session_file
screen = Screen.new(50, 6)
@@ -238,7 +238,7 @@ describe(':mksession', function()
local tmpfile = file_prefix .. '-tmpfile-float'
command('edit ' .. tmpfile)
- local buf = meths.nvim_create_buf(false, true)
+ local buf = api.nvim_create_buf(false, true)
local config = {
relative = 'editor',
focusable = false,
@@ -248,8 +248,8 @@ describe(':mksession', function()
col = 1,
style = 'minimal',
}
- meths.nvim_open_win(buf, false, config)
- local cmdheight = meths.nvim_get_option_value('cmdheight', {})
+ api.nvim_open_win(buf, false, config)
+ local cmdheight = api.nvim_get_option_value('cmdheight', {})
command('mksession ' .. session_file)
-- Create a new test instance of Nvim.
@@ -257,12 +257,12 @@ describe(':mksession', function()
command('source ' .. session_file)
- eq(tmpfile, funcs.expand('%'))
+ eq(tmpfile, fn.expand('%'))
-- Check that there is only a single window, which indicates the floating
-- window was not restored.
- eq(1, funcs.winnr('$'))
+ eq(1, fn.winnr('$'))
-- The command-line height should remain the same as it was.
- eq(cmdheight, meths.nvim_get_option_value('cmdheight', {}))
+ eq(cmdheight, api.nvim_get_option_value('cmdheight', {}))
os.remove(tmpfile)
end)
diff --git a/test/functional/ex_cmds/mkview_spec.lua b/test/functional/ex_cmds/mkview_spec.lua
index fa8da6e981..de0a4fe0ea 100644
--- a/test/functional/ex_cmds/mkview_spec.lua
+++ b/test/functional/ex_cmds/mkview_spec.lua
@@ -4,7 +4,7 @@ local clear = helpers.clear
local command = helpers.command
local get_pathsep = helpers.get_pathsep
local eq = helpers.eq
-local funcs = helpers.funcs
+local fn = helpers.fn
local rmdir = helpers.rmdir
local mkdir = helpers.mkdir
@@ -28,7 +28,7 @@ describe(':mkview', function()
end)
it('viewoption curdir restores local current directory', function()
- local cwd_dir = funcs.getcwd()
+ local cwd_dir = fn.getcwd()
local set_view_dir_command = 'set viewdir=' .. cwd_dir .. get_pathsep() .. view_dir
-- By default the local current directory should save
@@ -55,11 +55,11 @@ describe(':mkview', function()
command('edit ' .. tmp_file_base .. '2')
command('loadview')
-- The view's current directory should not have changed
- eq(cwd_dir, funcs.getcwd())
+ eq(cwd_dir, fn.getcwd())
-- Load the view with a saved local current directory
command('edit ' .. tmp_file_base .. '1')
command('loadview')
-- The view's local directory should have been saved
- eq(cwd_dir .. get_pathsep() .. local_dir, funcs.getcwd())
+ eq(cwd_dir .. get_pathsep() .. local_dir, fn.getcwd())
end)
end)
diff --git a/test/functional/ex_cmds/normal_spec.lua b/test/functional/ex_cmds/normal_spec.lua
index 009f1d6516..723bfefcf4 100644
--- a/test/functional/ex_cmds/normal_spec.lua
+++ b/test/functional/ex_cmds/normal_spec.lua
@@ -1,7 +1,7 @@
local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
local command = helpers.command
-local funcs = helpers.funcs
+local fn = helpers.fn
local feed = helpers.feed
local expect = helpers.expect
local eq = helpers.eq
@@ -29,10 +29,10 @@ describe(':normal!', function()
it('can stop Visual mode without closing cmdwin vim-patch:9.0.0234', function()
feed('q:')
feed('v')
- eq('v', funcs.mode(1))
- eq(':', funcs.getcmdwintype())
+ eq('v', fn.mode(1))
+ eq(':', fn.getcmdwintype())
command('normal! \027')
- eq('n', funcs.mode(1))
- eq(':', funcs.getcmdwintype())
+ eq('n', fn.mode(1))
+ eq(':', fn.getcmdwintype())
end)
end)
diff --git a/test/functional/ex_cmds/oldfiles_spec.lua b/test/functional/ex_cmds/oldfiles_spec.lua
index ee2bbdc4e7..8d1469f343 100644
--- a/test/functional/ex_cmds/oldfiles_spec.lua
+++ b/test/functional/ex_cmds/oldfiles_spec.lua
@@ -4,7 +4,7 @@ local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
local command = helpers.command
local expect_exit = helpers.expect_exit
-local meths, eq, feed_command = helpers.meths, helpers.eq, helpers.feed_command
+local api, eq, feed_command = helpers.api, helpers.eq, helpers.feed_command
local feed, poke_eventloop = helpers.feed, helpers.poke_eventloop
local ok = helpers.ok
local eval = helpers.eval
@@ -42,7 +42,7 @@ describe(':oldfiles', function()
feed_command('edit testfile2')
feed_command('wshada')
feed_command('rshada!')
- local oldfiles = meths.nvim_get_vvar('oldfiles')
+ local oldfiles = api.nvim_get_vvar('oldfiles')
feed_command('oldfiles')
screen:expect([[
|
@@ -56,11 +56,11 @@ describe(':oldfiles', function()
it('can be filtered with :filter', function()
feed_command('edit file_one.txt')
- local file1 = meths.nvim_buf_get_name(0)
+ local file1 = api.nvim_buf_get_name(0)
feed_command('edit file_two.txt')
- local file2 = meths.nvim_buf_get_name(0)
+ local file2 = api.nvim_buf_get_name(0)
feed_command('edit another.txt')
- local another = meths.nvim_buf_get_name(0)
+ local another = api.nvim_buf_get_name(0)
feed_command('wshada')
feed_command('rshada!')
@@ -95,9 +95,9 @@ describe(':browse oldfiles', function()
before_each(function()
_clear()
feed_command('edit testfile1')
- filename = meths.nvim_buf_get_name(0)
+ filename = api.nvim_buf_get_name(0)
feed_command('edit testfile2')
- filename2 = meths.nvim_buf_get_name(0)
+ filename2 = api.nvim_buf_get_name(0)
feed_command('wshada')
poke_eventloop()
_clear()
@@ -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.nvim_get_vvar('oldfiles')
+ oldfiles = helpers.api.nvim_get_vvar('oldfiles')
eq(2, #oldfiles)
ok(filename == oldfiles[1] or filename == oldfiles[2])
ok(filename2 == oldfiles[1] or filename2 == oldfiles[2])
@@ -123,16 +123,16 @@ describe(':browse oldfiles', function()
it('provides a prompt and edits the chosen file', function()
feed('2<cr>')
- eq(oldfiles[2], meths.nvim_buf_get_name(0))
+ eq(oldfiles[2], api.nvim_buf_get_name(0))
end)
it('provides a prompt and does nothing on <cr>', function()
feed('<cr>')
- eq('', meths.nvim_buf_get_name(0))
+ eq('', api.nvim_buf_get_name(0))
end)
it('provides a prompt and does nothing if choice is out-of-bounds', function()
feed('3<cr>')
- eq('', meths.nvim_buf_get_name(0))
+ eq('', api.nvim_buf_get_name(0))
end)
end)
diff --git a/test/functional/ex_cmds/print_commands_spec.lua b/test/functional/ex_cmds/print_commands_spec.lua
index bcb3c437ed..ba5ec7d2d1 100644
--- a/test/functional/ex_cmds/print_commands_spec.lua
+++ b/test/functional/ex_cmds/print_commands_spec.lua
@@ -1,11 +1,11 @@
local helpers = require('test.functional.helpers')(after_each)
-local clear, eq, command, funcs = helpers.clear, helpers.eq, helpers.command, helpers.funcs
+local clear, eq, command, fn = helpers.clear, helpers.eq, helpers.command, helpers.fn
describe(':z^', function()
before_each(clear)
it('correctly sets the cursor after :z^', function()
command('z^')
- eq(1, funcs.line('.'))
+ eq(1, fn.line('.'))
end)
end)
diff --git a/test/functional/ex_cmds/quickfix_commands_spec.lua b/test/functional/ex_cmds/quickfix_commands_spec.lua
index 74283fcb4e..5af0198ffe 100644
--- a/test/functional/ex_cmds/quickfix_commands_spec.lua
+++ b/test/functional/ex_cmds/quickfix_commands_spec.lua
@@ -4,11 +4,11 @@ local Screen = require('test.functional.ui.screen')
local feed = helpers.feed
local eq = helpers.eq
local clear = helpers.clear
-local funcs = helpers.funcs
+local fn = helpers.fn
local command = helpers.command
local exc_exec = helpers.exc_exec
local write_file = helpers.write_file
-local meths = helpers.meths
+local api = helpers.api
local source = helpers.source
local file_base = 'Xtest-functional-ex_cmds-quickfix_commands'
@@ -20,8 +20,8 @@ for _, c in ipairs({ 'l', 'c' }) do
local filecmd = c .. 'file'
local getfcmd = c .. 'getfile'
local addfcmd = c .. 'addfile'
- local getlist = (c == 'c') and funcs.getqflist or function()
- return funcs.getloclist(0)
+ local getlist = (c == 'c') and fn.getqflist or function()
+ return fn.getloclist(0)
end
describe((':%s*file commands'):format(c), function()
@@ -73,13 +73,13 @@ for _, c in ipairs({ 'l', 'c' }) do
},
}
eq(list, getlist())
- eq(('%s-1.res'):format(file), funcs.bufname(list[1].bufnr))
- eq(('%s-2.res'):format(file), funcs.bufname(list[2].bufnr))
+ eq(('%s-1.res'):format(file), fn.bufname(list[1].bufnr))
+ eq(('%s-2.res'):format(file), fn.bufname(list[2].bufnr))
-- Run cfile/lfile from a modified buffer
command('set nohidden')
command('enew!')
- meths.nvim_buf_set_lines(0, 1, 1, true, { 'Quickfix' })
+ api.nvim_buf_set_lines(0, 1, 1, true, { 'Quickfix' })
eq(
('Vim(%s):E37: No write since last change (add ! to override)'):format(filecmd),
exc_exec(('%s %s'):format(filecmd, file))
@@ -107,7 +107,7 @@ for _, c in ipairs({ 'l', 'c' }) do
['type'] = '',
}
eq(list, getlist())
- eq(('%s-3.res'):format(file), funcs.bufname(list[3].bufnr))
+ eq(('%s-3.res'):format(file), fn.bufname(list[3].bufnr))
write_file(
file,
@@ -149,8 +149,8 @@ for _, c in ipairs({ 'l', 'c' }) do
},
}
eq(list, getlist())
- eq(('%s-1.res'):format(file), funcs.bufname(list[1].bufnr))
- eq(('%s-2.res'):format(file), funcs.bufname(list[2].bufnr))
+ eq(('%s-1.res'):format(file), fn.bufname(list[1].bufnr))
+ eq(('%s-2.res'):format(file), fn.bufname(list[2].bufnr))
end)
end)
end
@@ -178,7 +178,7 @@ describe('quickfix', function()
call append(0, ['New line 1', 'New line 2', 'New line 3'])
silent ll
]])
- eq({ 0, 6, 1, 0, 1 }, funcs.getcurpos())
+ eq({ 0, 6, 1, 0, 1 }, fn.getcurpos())
end)
it('BufAdd does not cause E16 when reusing quickfix buffer #18135', function()
diff --git a/test/functional/ex_cmds/script_spec.lua b/test/functional/ex_cmds/script_spec.lua
index 20fd65fc69..ebdaa0f656 100644
--- a/test/functional/ex_cmds/script_spec.lua
+++ b/test/functional/ex_cmds/script_spec.lua
@@ -5,7 +5,7 @@ local neq = helpers.neq
local command = helpers.command
local exec_capture = helpers.exec_capture
local write_file = helpers.write_file
-local meths = helpers.meths
+local api = helpers.api
local clear = helpers.clear
local dedent = helpers.dedent
local exc_exec = helpers.exc_exec
@@ -83,7 +83,7 @@ describe('script_get-based command', function()
]])):format(cmd, garbage)
)
)
- neq(0, meths.nvim_get_var('exc'))
+ neq(0, api.nvim_get_var('exc'))
end
end)
end)
diff --git a/test/functional/ex_cmds/sign_spec.lua b/test/functional/ex_cmds/sign_spec.lua
index a0783264a7..06de7f23a9 100644
--- a/test/functional/ex_cmds/sign_spec.lua
+++ b/test/functional/ex_cmds/sign_spec.lua
@@ -1,7 +1,7 @@
local helpers = require('test.functional.helpers')(after_each)
local clear, eq, assert_alive = helpers.clear, helpers.eq, helpers.assert_alive
local command = helpers.command
-local meths = helpers.meths
+local api = helpers.api
describe('sign', function()
before_each(clear)
@@ -10,16 +10,16 @@ describe('sign', function()
it('deletes the sign from all buffers', function()
-- place a sign with id 34 to first buffer
command('sign define Foo text=+ texthl=Delimiter linehl=Comment numhl=Number')
- local buf1 = meths.nvim_eval('bufnr("%")')
+ local buf1 = api.nvim_eval('bufnr("%")')
command('sign place 34 line=3 name=Foo buffer=' .. buf1)
-- create a second buffer and place the sign on it as well
command('new')
- local buf2 = meths.nvim_eval('bufnr("%")')
+ local buf2 = api.nvim_eval('bufnr("%")')
command('sign place 34 line=3 name=Foo buffer=' .. buf2)
-- now unplace without specifying a buffer
command('sign unplace 34')
- eq('--- Signs ---\n', meths.nvim_exec('sign place buffer=' .. buf1, true))
- eq('--- Signs ---\n', meths.nvim_exec('sign place buffer=' .. buf2, true))
+ eq('--- Signs ---\n', api.nvim_exec('sign place buffer=' .. buf1, true))
+ eq('--- Signs ---\n', api.nvim_exec('sign place buffer=' .. buf2, true))
end)
end)
end)
diff --git a/test/functional/ex_cmds/source_spec.lua b/test/functional/ex_cmds/source_spec.lua
index 765f5d4b05..5ce0e395bd 100644
--- a/test/functional/ex_cmds/source_spec.lua
+++ b/test/functional/ex_cmds/source_spec.lua
@@ -3,7 +3,7 @@ local command = helpers.command
local insert = helpers.insert
local eq = helpers.eq
local clear = helpers.clear
-local meths = helpers.meths
+local api = helpers.api
local feed = helpers.feed
local feed_command = helpers.feed_command
local write_file = helpers.write_file
@@ -49,7 +49,7 @@ describe(':source', function()
pending("'shellslash' only works on Windows")
return
end
- meths.nvim_set_option_value('shellslash', false, {})
+ api.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.nvim_get_var('stack1'))
- matches([[Xshellslash/Xstack%.vim]], meths.nvim_get_var('stack2'))
- matches([[Xshellslash\Xstack%.vim]], meths.nvim_get_var('stack3'))
+ matches([[Xshellslash\Xstack%.vim]], api.nvim_get_var('stack1'))
+ matches([[Xshellslash/Xstack%.vim]], api.nvim_get_var('stack2'))
+ matches([[Xshellslash\Xstack%.vim]], api.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.nvim_get_var('stack1'))
- matches([[Xshellslash/Xstack%.lua]], meths.nvim_get_var('stack2'))
- matches([[Xshellslash\Xstack%.lua]], meths.nvim_get_var('stack3'))
+ matches([[Xshellslash\Xstack%.lua]], api.nvim_get_var('stack1'))
+ matches([[Xshellslash/Xstack%.lua]], api.nvim_get_var('stack2'))
+ matches([[Xshellslash\Xstack%.lua]], api.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.nvim_get_var('sfile_value'))
- matches([[/test%.lua$]], meths.nvim_get_var('stack_value'))
- matches([[/test%.lua$]], meths.nvim_get_var('script_value'))
+ matches([[/test%.lua$]], api.nvim_get_var('sfile_value'))
+ matches([[/test%.lua$]], api.nvim_get_var('stack_value'))
+ matches([[/test%.lua$]], api.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.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'))
+ eq(':source (no file)', api.nvim_get_var('sfile_value'))
+ eq(':source (no file)', api.nvim_get_var('stack_value'))
+ eq(':source (no file)', api.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 99191a2a57..4c2e54cc6b 100644
--- a/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua
+++ b/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua
@@ -6,7 +6,7 @@ local assert_alive = helpers.assert_alive
local clear = helpers.clear
local command = helpers.command
local feed = helpers.feed
-local funcs = helpers.funcs
+local fn = helpers.fn
local nvim_prog = helpers.nvim_prog
local ok = helpers.ok
local rmdir = helpers.rmdir
@@ -21,7 +21,7 @@ local expect_msg_seq = helpers.expect_msg_seq
local pcall_err = helpers.pcall_err
local mkdir = helpers.mkdir
local poke_eventloop = helpers.poke_eventloop
-local meths = helpers.meths
+local api = helpers.api
local retry = helpers.retry
local write_file = helpers.write_file
@@ -114,7 +114,7 @@ describe("preserve and (R)ecover with custom 'directory'", function()
local screen0 = Screen.new()
screen0:attach()
local child_server = new_pipename()
- funcs.termopen({ nvim_prog, '-u', 'NONE', '-i', 'NONE', '--listen', child_server }, {
+ fn.termopen({ nvim_prog, '-u', 'NONE', '-i', 'NONE', '--listen', child_server }, {
env = { VIMRUNTIME = os.getenv('VIMRUNTIME') },
})
screen0:expect({ any = pesc('[No Name]') }) -- Wait for the child process to start.
@@ -246,7 +246,7 @@ describe('swapfile detection', function()
command('edit Xfile1')
command("put ='some text...'")
command('preserve') -- Make sure the swap file exists.
- local nvimpid = funcs.getpid()
+ local nvimpid = fn.getpid()
local nvim1 = spawn(new_argv(), true, nil, true)
set_session(nvim1)
@@ -352,7 +352,7 @@ describe('swapfile detection', function()
edit Xswaptest
call setline(1, ['a', 'b', 'c'])
]])
- local swname = funcs.CopySwapfile()
+ local swname = fn.CopySwapfile()
-- Forget we edited this file
exec([[
@@ -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.nvim_ui_attach(80, 30, {})
+ api.nvim_ui_attach(80, 30, {})
end)
after_each(function()
rmdir(swapdir)
@@ -447,7 +447,7 @@ describe('quitting swapfile dialog on startup stops TUI properly', function()
end)
it('(Q)uit at first file argument', function()
- local chan = funcs.termopen(
+ local chan = fn.termopen(
{ nvim_prog, '-u', 'NONE', '-i', 'NONE', '--cmd', init_dir, '--cmd', init_set, testfile },
{
env = { VIMRUNTIME = os.getenv('VIMRUNTIME') },
@@ -459,7 +459,7 @@ describe('quitting swapfile dialog on startup stops TUI properly', function()
eval("getline('$')->trim(' ', 2)")
)
end)
- meths.nvim_chan_send(chan, 'q')
+ api.nvim_chan_send(chan, 'q')
retry(nil, nil, function()
eq(
{ '', '[Process exited 1]', '' },
@@ -469,7 +469,7 @@ describe('quitting swapfile dialog on startup stops TUI properly', function()
end)
it('(A)bort at second file argument with -p', function()
- local chan = funcs.termopen({
+ local chan = fn.termopen({
nvim_prog,
'-u',
'NONE',
@@ -491,7 +491,7 @@ describe('quitting swapfile dialog on startup stops TUI properly', function()
eval("getline('$')->trim(' ', 2)")
)
end)
- meths.nvim_chan_send(chan, 'a')
+ api.nvim_chan_send(chan, 'a')
retry(nil, nil, function()
eq(
{ '', '[Process exited 1]', '' },
@@ -509,7 +509,7 @@ describe('quitting swapfile dialog on startup stops TUI properly', function()
second %s /^ \zssecond$/
third %s /^ \zsthird$/]]):format(testfile, testfile, testfile)
)
- local chan = funcs.termopen({
+ local chan = fn.termopen({
nvim_prog,
'-u',
'NONE',
@@ -531,11 +531,11 @@ describe('quitting swapfile dialog on startup stops TUI properly', function()
eval("getline('$')->trim(' ', 2)")
)
end)
- meths.nvim_chan_send(chan, 'q')
+ api.nvim_chan_send(chan, 'q')
retry(nil, nil, function()
eq('Press ENTER or type command to continue', eval("getline('$')->trim(' ', 2)"))
end)
- meths.nvim_chan_send(chan, '\r')
+ api.nvim_chan_send(chan, '\r')
retry(nil, nil, function()
eq(
{ '', '[Process exited 1]', '' },
diff --git a/test/functional/ex_cmds/trust_spec.lua b/test/functional/ex_cmds/trust_spec.lua
index 953b25ba35..2997b504fa 100644
--- a/test/functional/ex_cmds/trust_spec.lua
+++ b/test/functional/ex_cmds/trust_spec.lua
@@ -7,7 +7,7 @@ local exec_capture = helpers.exec_capture
local matches = helpers.matches
local pathsep = helpers.get_pathsep()
local is_os = helpers.is_os
-local funcs = helpers.funcs
+local fn = helpers.fn
describe(':trust', function()
local xstate = 'Xstate'
@@ -30,53 +30,53 @@ describe(':trust', function()
end)
it('trust then deny then remove a file using current buffer', function()
- local cwd = funcs.getcwd()
- local hash = funcs.sha256(helpers.read_file('test_file'))
+ local cwd = fn.getcwd()
+ local hash = fn.sha256(helpers.read_file('test_file'))
command('edit test_file')
matches('^Allowed ".*test_file" in trust database%.$', exec_capture('trust'))
- local trust = helpers.read_file(funcs.stdpath('state') .. pathsep .. 'trust')
+ local trust = helpers.read_file(fn.stdpath('state') .. pathsep .. 'trust')
eq(string.format('%s %s', hash, cwd .. pathsep .. 'test_file'), vim.trim(trust))
matches('^Denied ".*test_file" in trust database%.$', exec_capture('trust ++deny'))
- trust = helpers.read_file(funcs.stdpath('state') .. pathsep .. 'trust')
+ trust = helpers.read_file(fn.stdpath('state') .. pathsep .. 'trust')
eq(string.format('! %s', cwd .. pathsep .. 'test_file'), vim.trim(trust))
matches('^Removed ".*test_file" from trust database%.$', exec_capture('trust ++remove'))
- trust = helpers.read_file(funcs.stdpath('state') .. pathsep .. 'trust')
+ trust = helpers.read_file(fn.stdpath('state') .. pathsep .. 'trust')
eq(string.format(''), vim.trim(trust))
end)
it('deny then trust then remove a file using current buffer', function()
- local cwd = funcs.getcwd()
- local hash = funcs.sha256(helpers.read_file('test_file'))
+ local cwd = fn.getcwd()
+ local hash = fn.sha256(helpers.read_file('test_file'))
command('edit test_file')
matches('^Denied ".*test_file" in trust database%.$', exec_capture('trust ++deny'))
- local trust = helpers.read_file(funcs.stdpath('state') .. pathsep .. 'trust')
+ local trust = helpers.read_file(fn.stdpath('state') .. pathsep .. 'trust')
eq(string.format('! %s', cwd .. pathsep .. 'test_file'), vim.trim(trust))
matches('^Allowed ".*test_file" in trust database%.$', exec_capture('trust'))
- trust = helpers.read_file(funcs.stdpath('state') .. pathsep .. 'trust')
+ trust = helpers.read_file(fn.stdpath('state') .. pathsep .. 'trust')
eq(string.format('%s %s', hash, cwd .. pathsep .. 'test_file'), vim.trim(trust))
matches('^Removed ".*test_file" from trust database%.$', exec_capture('trust ++remove'))
- trust = helpers.read_file(funcs.stdpath('state') .. pathsep .. 'trust')
+ trust = helpers.read_file(fn.stdpath('state') .. pathsep .. 'trust')
eq(string.format(''), vim.trim(trust))
end)
it('deny then remove a file using file path', function()
- local cwd = funcs.getcwd()
+ local cwd = fn.getcwd()
matches('^Denied ".*test_file" in trust database%.$', exec_capture('trust ++deny test_file'))
- local trust = helpers.read_file(funcs.stdpath('state') .. pathsep .. 'trust')
+ local trust = helpers.read_file(fn.stdpath('state') .. pathsep .. 'trust')
eq(string.format('! %s', cwd .. pathsep .. 'test_file'), vim.trim(trust))
matches(
'^Removed ".*test_file" from trust database%.$',
exec_capture('trust ++remove test_file')
)
- trust = helpers.read_file(funcs.stdpath('state') .. pathsep .. 'trust')
+ trust = helpers.read_file(fn.stdpath('state') .. pathsep .. 'trust')
eq(string.format(''), vim.trim(trust))
end)
end)
diff --git a/test/functional/ex_cmds/verbose_spec.lua b/test/functional/ex_cmds/verbose_spec.lua
index dbc81cf5d8..7ceb2460d3 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.nvim_call_function
+local call_viml_function = helpers.api.nvim_call_function
local function last_set_tests(cmd)
local script_location, script_file
diff --git a/test/functional/ex_cmds/wincmd_spec.lua b/test/functional/ex_cmds/wincmd_spec.lua
index 1948cf017a..98c6358f45 100644
--- a/test/functional/ex_cmds/wincmd_spec.lua
+++ b/test/functional/ex_cmds/wincmd_spec.lua
@@ -1,13 +1,13 @@
local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
local eq = helpers.eq
-local funcs = helpers.funcs
+local fn = helpers.fn
local command = helpers.command
it(':wincmd accepts a count', function()
clear()
command('vsplit')
- eq(1, funcs.winnr())
+ eq(1, fn.winnr())
command('wincmd 2 w')
- eq(2, funcs.winnr())
+ eq(2, fn.winnr())
end)
diff --git a/test/functional/ex_cmds/write_spec.lua b/test/functional/ex_cmds/write_spec.lua
index 403e3426f9..f711731072 100644
--- a/test/functional/ex_cmds/write_spec.lua
+++ b/test/functional/ex_cmds/write_spec.lua
@@ -4,8 +4,8 @@ local eq, eval, clear, write_file, source, insert =
local pcall_err = helpers.pcall_err
local command = helpers.command
local feed_command = helpers.feed_command
-local funcs = helpers.funcs
-local meths = helpers.meths
+local fn = helpers.fn
+local api = helpers.api
local skip = helpers.skip
local is_os = helpers.is_os
local is_ci = helpers.is_ci
@@ -112,11 +112,11 @@ describe(':write', function()
eq('Vim(write):E32: No file name', pcall_err(command, 'write ++p test_write/'))
if not is_os('win') then
eq(
- ('Vim(write):E17: "' .. funcs.fnamemodify('.', ':p:h') .. '" is a directory'),
+ ('Vim(write):E17: "' .. fn.fnamemodify('.', ':p:h') .. '" is a directory'),
pcall_err(command, 'write ++p .')
)
eq(
- ('Vim(write):E17: "' .. funcs.fnamemodify('.', ':p:h') .. '" is a directory'),
+ ('Vim(write):E17: "' .. fn.fnamemodify('.', ':p:h') .. '" is a directory'),
pcall_err(command, 'write ++p ./')
)
end
@@ -125,26 +125,26 @@ describe(':write', function()
it('errors out correctly', function()
skip(is_ci('cirrus'))
command('let $HOME=""')
- eq(funcs.fnamemodify('.', ':p:h'), funcs.fnamemodify('.', ':p:h:~'))
+ eq(fn.fnamemodify('.', ':p:h'), fn.fnamemodify('.', ':p:h:~'))
-- Message from check_overwrite
if not is_os('win') then
eq(
- ('Vim(write):E17: "' .. funcs.fnamemodify('.', ':p:h') .. '" is a directory'),
+ ('Vim(write):E17: "' .. fn.fnamemodify('.', ':p:h') .. '" is a directory'),
pcall_err(command, 'write .')
)
end
- meths.nvim_set_option_value('writeany', true, {})
+ api.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.nvim_set_option_value('backupdir', '.', {})
- meths.nvim_set_option_value('backup', true, {})
+ fn.mkdir(fname_bak)
+ api.nvim_set_option_value('backupdir', '.', {})
+ api.nvim_set_option_value('backup', true, {})
write_file(fname, 'content0')
command('edit ' .. fname)
- funcs.setline(1, 'TTY')
+ fn.setline(1, 'TTY')
eq("Vim(write):E510: Can't make backup file (add ! to override)", pcall_err(command, 'write'))
- meths.nvim_set_option_value('backup', false, {})
- funcs.setfperm(fname, 'r--------')
+ api.nvim_set_option_value('backup', false, {})
+ fn.setfperm(fname, 'r--------')
eq(
'Vim(write):E505: "Xtest-functional-ex_cmds-write" is read-only (add ! to override)',
pcall_err(command, 'write')
diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua
index 5c66c50648..e9f8f30aa0 100644
--- a/test/functional/helpers.lua
+++ b/test/functional/helpers.lua
@@ -622,7 +622,7 @@ end
module.async_meths = module.create_callindex(module.nvim_async)
module.uimeths = module.create_callindex(ui)
-local function create_api(request, call)
+local function create_bridge(request, call)
local function nvim(method, ...)
if vim.startswith(method, 'nvim_') then
return request(method, ...)
@@ -631,18 +631,13 @@ local function create_api(request, call)
end
return {
- funcs = module.create_callindex(call),
- meths = module.create_callindex(nvim),
+ fn = module.create_callindex(call),
+ api = module.create_callindex(nvim),
}
end
-module.rpc = {
- api = create_api(module.request, module.call),
-}
-
-module.lua = {
- api = create_api(module.request_lua, module.call_lua),
-}
+module.rpc = create_bridge(module.request, module.call)
+module.lua = create_bridge(module.request_lua, module.call_lua)
module.describe_lua_and_rpc = function(describe)
return function(what, tests)
@@ -658,16 +653,16 @@ module.describe_lua_and_rpc = function(describe)
end
--- add for typing. The for loop after will overwrite this
-module.meths = vim.api
-module.funcs = vim.fn
+module.api = vim.api
+module.fn = vim.fn
-for name, fn in pairs(module.rpc.api) do
- module[name] = fn
+for name, fns in pairs(module.rpc) do
+ module[name] = fns
end
-- Executes an ex-command. Vimscript errors manifest as client (lua) errors, but
-- v:errmsg will not be updated.
-module.command = module.meths.nvim_command
+module.command = module.api.nvim_command
function module.poke_eventloop()
-- Execute 'nvim_eval' (a deferred function) to
@@ -682,7 +677,7 @@ end
---@see buf_lines()
function module.curbuf_contents()
module.poke_eventloop() -- Before inspecting the buffer, do whatever.
- return table.concat(module.meths.nvim_buf_get_lines(0, 0, -1, true), '\n')
+ return table.concat(module.api.nvim_buf_get_lines(0, 0, -1, true), '\n')
end
function module.expect(contents)
@@ -719,15 +714,15 @@ end
-- Asserts that buffer is loaded and visible in the current tabpage.
function module.assert_visible(bufnr, visible)
assert(type(visible) == 'boolean')
- eq(visible, module.meths.nvim_buf_is_loaded(bufnr))
+ eq(visible, module.api.nvim_buf_is_loaded(bufnr))
if visible then
assert(
- -1 ~= module.funcs.bufwinnr(bufnr),
+ -1 ~= module.fn.bufwinnr(bufnr),
'expected buffer to be visible in current tabpage: ' .. tostring(bufnr)
)
else
assert(
- -1 == module.funcs.bufwinnr(bufnr),
+ -1 == module.fn.bufwinnr(bufnr),
'expected buffer NOT visible in current tabpage: ' .. tostring(bufnr)
)
end
@@ -827,17 +822,17 @@ function module.skip_fragile(pending_fn, cond)
end
function module.exec(code)
- module.meths.nvim_exec2(code, {})
+ module.api.nvim_exec2(code, {})
end
function module.exec_capture(code)
- return module.meths.nvim_exec2(code, { output = true }).output
+ return module.api.nvim_exec2(code, { output = true }).output
end
--- @param code string
--- @return any
function module.exec_lua(code, ...)
- return module.meths.exec_lua(code, { ... })
+ return module.api.exec_lua(code, { ... })
end
function module.get_pathsep()
@@ -869,7 +864,7 @@ end
function module.new_pipename()
-- HACK: Start a server temporarily, get the name, then stop it.
local pipename = module.eval('serverstart()')
- module.funcs.serverstop(pipename)
+ module.fn.serverstop(pipename)
-- Remove the pipe so that trying to connect to it without a server listening
-- will be an error instead of a hang.
os.remove(pipename)
@@ -878,11 +873,11 @@ end
function module.missing_provider(provider)
if provider == 'ruby' or provider == 'node' or provider == 'perl' then
- local e = module.funcs['provider#' .. provider .. '#Detect']()[2]
+ local e = module.fn['provider#' .. provider .. '#Detect']()[2]
return e ~= '' and e or false
elseif provider == 'python' or provider == 'python3' then
local py_major_version = (provider == 'python3' and 3 or 2)
- local e = module.funcs['provider#pythonx#Detect'](py_major_version)[2]
+ local e = module.fn['provider#pythonx#Detect'](py_major_version)[2]
return e ~= '' and e or false
else
assert(false, 'Unknown provider: ' .. provider)
diff --git a/test/functional/legacy/012_directory_spec.lua b/test/functional/legacy/012_directory_spec.lua
index 368ab382c0..b428318e3f 100644
--- a/test/functional/legacy/012_directory_spec.lua
+++ b/test/functional/legacy/012_directory_spec.lua
@@ -8,8 +8,8 @@ local helpers = require('test.functional.helpers')(after_each)
local eq = helpers.eq
local neq = helpers.neq
local poke_eventloop = helpers.poke_eventloop
-local funcs = helpers.funcs
-local meths = helpers.meths
+local fn = helpers.fn
+local api = helpers.api
local clear = helpers.clear
local insert = helpers.insert
local command = helpers.command
@@ -56,21 +56,21 @@ describe("'directory' option", function()
line 3 Abcdefghij
end of testfile]])
- meths.nvim_set_option_value('swapfile', true, {})
- meths.nvim_set_option_value('swapfile', true, {})
- meths.nvim_set_option_value('directory', '.', {})
+ api.nvim_set_option_value('swapfile', true, {})
+ api.nvim_set_option_value('swapfile', true, {})
+ api.nvim_set_option_value('directory', '.', {})
-- sanity check: files should not exist yet.
eq(nil, vim.uv.fs_stat('.Xtest1.swp'))
command('edit! Xtest1')
poke_eventloop()
- eq('Xtest1', funcs.buffer_name('%'))
+ eq('Xtest1', fn.buffer_name('%'))
-- Verify that the swapfile exists. In the legacy test this was done by
-- reading the output from :!ls.
neq(nil, vim.uv.fs_stat('.Xtest1.swp'))
- meths.nvim_set_option_value('directory', './Xtest2,.', {})
+ api.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.nvim_set_option_value('directory', 'Xtest.je', {})
+ api.nvim_set_option_value('directory', 'Xtest.je', {})
command('bdelete')
command('edit Xtest2/Xtest3')
- eq(true, meths.nvim_get_option_value('swapfile', {}))
+ eq(true, api.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 5387883570..626035d74c 100644
--- a/test/functional/legacy/039_visual_block_mode_commands_spec.lua
+++ b/test/functional/legacy/039_visual_block_mode_commands_spec.lua
@@ -2,7 +2,7 @@
-- And test "U" in Visual mode, also on German sharp S.
local helpers = require('test.functional.helpers')(after_each)
-local nvim, eq = helpers.meths, helpers.eq
+local nvim, eq = helpers.api, helpers.eq
local insert, feed = helpers.insert, helpers.feed
local clear, expect = helpers.clear, helpers.expect
local feed_command = helpers.feed_command
diff --git a/test/functional/legacy/assert_spec.lua b/test/functional/legacy/assert_spec.lua
index 038bdd48f2..04c90281a7 100644
--- a/test/functional/legacy/assert_spec.lua
+++ b/test/functional/legacy/assert_spec.lua
@@ -1,5 +1,5 @@
local helpers = require('test.functional.helpers')(after_each)
-local nvim, call = helpers.meths, helpers.call
+local nvim, call = helpers.api, helpers.call
local clear, eq = helpers.clear, helpers.eq
local source, command = helpers.source, helpers.command
local exc_exec = helpers.exc_exec
diff --git a/test/functional/legacy/autochdir_spec.lua b/test/functional/legacy/autochdir_spec.lua
index aca7ba9b39..e5980f5942 100644
--- a/test/functional/legacy/autochdir_spec.lua
+++ b/test/functional/legacy/autochdir_spec.lua
@@ -1,11 +1,11 @@
local helpers = require('test.functional.helpers')(after_each)
local clear, eq, matches = helpers.clear, helpers.eq, helpers.matches
-local eval, command, call, meths = helpers.eval, helpers.command, helpers.call, helpers.meths
+local eval, command, call, api = helpers.eval, helpers.command, helpers.call, helpers.api
local source, exec_capture = helpers.source, helpers.exec_capture
local mkdir = helpers.mkdir
local function expected_empty()
- eq({}, meths.nvim_get_vvar('errors'))
+ eq({}, api.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 d2c41043ac..9966df263b 100644
--- a/test/functional/legacy/autocmd_option_spec.lua
+++ b/test/functional/legacy/autocmd_option_spec.lua
@@ -1,9 +1,9 @@
local helpers = require('test.functional.helpers')(after_each)
-local nvim = helpers.meths
+local nvim = helpers.api
local clear, eq, neq, eval = helpers.clear, helpers.eq, helpers.neq, helpers.eval
-local meths = helpers.meths
-local curbuf = helpers.meths.nvim_get_current_buf
-local curwin = helpers.meths.nvim_get_current_win
+local api = helpers.api
+local curbuf = helpers.api.nvim_get_current_buf
+local curwin = helpers.api.nvim_get_current_win
local exec_capture = helpers.exec_capture
local source, command = helpers.source, helpers.command
@@ -211,7 +211,7 @@ describe('au OptionSet', function()
it('should trigger if the current buffer is different from the targeted buffer', function()
local new_buffer = make_buffer()
- local new_bufnr = meths.nvim_buf_get_number(new_buffer)
+ local new_bufnr = api.nvim_buf_get_number(new_buffer)
command('call setbufvar(' .. new_bufnr .. ', "&buftype", "nofile")')
expected_combination({
@@ -648,7 +648,7 @@ describe('au OptionSet', function()
set_hook('buftype')
local new_buffer = make_buffer()
- local new_bufnr = meths.nvim_buf_get_number(new_buffer)
+ local new_bufnr = api.nvim_buf_get_number(new_buffer)
command('call setbufvar(' .. new_bufnr .. ', "&buftype", "nofile")')
expected_combination({
diff --git a/test/functional/legacy/buffer_spec.lua b/test/functional/legacy/buffer_spec.lua
index 605cd72bf6..b3964540f0 100644
--- a/test/functional/legacy/buffer_spec.lua
+++ b/test/functional/legacy/buffer_spec.lua
@@ -1,16 +1,16 @@
local helpers = require('test.functional.helpers')(after_each)
local clear, source = helpers.clear, helpers.source
-local call, eq, meths = helpers.call, helpers.eq, helpers.meths
+local call, eq, api = helpers.call, helpers.eq, helpers.api
local function expected_empty()
- eq({}, meths.nvim_get_vvar('errors'))
+ eq({}, api.nvim_get_vvar('errors'))
end
describe('buffer', function()
before_each(function()
clear()
- meths.nvim_ui_attach(80, 24, {})
- meths.nvim_set_option_value('hidden', false, {})
+ api.nvim_ui_attach(80, 24, {})
+ api.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 ea6d8409ba..8c94451f9a 100644
--- a/test/functional/legacy/cmdline_spec.lua
+++ b/test/functional/legacy/cmdline_spec.lua
@@ -5,7 +5,7 @@ local command = helpers.command
local feed = helpers.feed
local feed_command = helpers.feed_command
local exec = helpers.exec
-local meths = helpers.meths
+local api = helpers.api
local pesc = vim.pesc
describe('cmdline', function()
@@ -198,9 +198,9 @@ describe('cmdline', function()
[3] = { reverse = true }, -- TabLineFill
})
screen:attach()
- meths.nvim_set_option_value('laststatus', 2, {})
- meths.nvim_set_option_value('showtabline', 2, {})
- meths.nvim_set_option_value('cmdheight', 1, {})
+ api.nvim_set_option_value('laststatus', 2, {})
+ api.nvim_set_option_value('showtabline', 2, {})
+ api.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.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, {})
+ api.nvim_set_option_value('ruler', true, {})
+ api.nvim_set_option_value('rulerformat', 'longish', {})
+ api.nvim_set_option_value('laststatus', 0, {})
+ api.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 85057938e3..ae4c4309d1 100644
--- a/test/functional/legacy/ex_mode_spec.lua
+++ b/test/functional/legacy/ex_mode_spec.lua
@@ -5,7 +5,7 @@ local command = helpers.command
local eq = helpers.eq
local eval = helpers.eval
local feed = helpers.feed
-local meths = helpers.meths
+local api = helpers.api
local poke_eventloop = helpers.poke_eventloop
before_each(clear)
@@ -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.nvim_replace_termcodes(expected, true, true, true), ret)
+ eq(api.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 160be8acd1..41f14c4645 100644
--- a/test/functional/legacy/excmd_spec.lua
+++ b/test/functional/legacy/excmd_spec.lua
@@ -6,8 +6,8 @@ local exec = helpers.exec
local exec_lua = helpers.exec_lua
local expect_exit = helpers.expect_exit
local feed = helpers.feed
-local funcs = helpers.funcs
-local meths = helpers.meths
+local fn = helpers.fn
+local api = helpers.api
local read_file = helpers.read_file
local source = helpers.source
local eq = helpers.eq
@@ -24,7 +24,7 @@ end
describe('Ex command', function()
before_each(clear)
after_each(function()
- eq({}, meths.nvim_get_vvar('errors'))
+ eq({}, api.nvim_get_vvar('errors'))
end)
it('checks for address line overflow', function()
@@ -340,7 +340,7 @@ describe(':confirm command dialog', function()
feed('<CR>') -- suppress hit-enter prompt
-- Try to write with read-only file permissions.
- funcs.setfperm('Xconfirm_write_ro', 'r--r--r--')
+ fn.setfperm('Xconfirm_write_ro', 'r--r--r--')
feed(':set noro | silent undo | confirm w\n')
screen:expect([[
foobar |
diff --git a/test/functional/legacy/filechanged_spec.lua b/test/functional/legacy/filechanged_spec.lua
index 0a088772a5..46ecfdcd63 100644
--- a/test/functional/legacy/filechanged_spec.lua
+++ b/test/functional/legacy/filechanged_spec.lua
@@ -1,19 +1,19 @@
local helpers = require('test.functional.helpers')(after_each)
local clear, source = helpers.clear, helpers.source
-local call, eq, meths = helpers.call, helpers.eq, helpers.meths
+local call, eq, api = helpers.call, helpers.eq, helpers.api
local is_os = helpers.is_os
local skip = helpers.skip
local function expected_empty()
- eq({}, meths.nvim_get_vvar('errors'))
+ eq({}, api.nvim_get_vvar('errors'))
end
describe('file changed dialog', function()
before_each(function()
clear()
- meths.nvim_ui_attach(80, 24, {})
- meths.nvim_set_option_value('autoread', false, {})
- meths.nvim_set_option_value('fsync', true, {})
+ api.nvim_ui_attach(80, 24, {})
+ api.nvim_set_option_value('autoread', false, {})
+ api.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 c6beb6d7df..570b523d92 100644
--- a/test/functional/legacy/fnamemodify_spec.lua
+++ b/test/functional/legacy/fnamemodify_spec.lua
@@ -2,7 +2,7 @@
local helpers = require('test.functional.helpers')(after_each)
local clear, source = helpers.clear, helpers.source
-local call, eq, nvim = helpers.call, helpers.eq, helpers.meths
+local call, eq, nvim = helpers.call, helpers.eq, helpers.api
local function expected_empty()
eq({}, nvim.nvim_get_vvar('errors'))
diff --git a/test/functional/legacy/increment_spec.lua b/test/functional/legacy/increment_spec.lua
index 9e19841375..a81044114c 100644
--- a/test/functional/legacy/increment_spec.lua
+++ b/test/functional/legacy/increment_spec.lua
@@ -3,7 +3,7 @@
local helpers = require('test.functional.helpers')(after_each)
local source, command = helpers.source, helpers.command
local call, clear = helpers.call, helpers.clear
-local eq, nvim = helpers.eq, helpers.meths
+local eq, nvim = helpers.eq, helpers.api
describe('Ctrl-A/Ctrl-X on visual selections', function()
before_each(function()
diff --git a/test/functional/legacy/mapping_spec.lua b/test/functional/legacy/mapping_spec.lua
index 7058e70c4f..9eddec40f7 100644
--- a/test/functional/legacy/mapping_spec.lua
+++ b/test/functional/legacy/mapping_spec.lua
@@ -3,7 +3,7 @@
local helpers = require('test.functional.helpers')(after_each)
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local expect, poke_eventloop = helpers.expect, helpers.poke_eventloop
-local command, eq, eval, meths = helpers.command, helpers.eq, helpers.eval, helpers.meths
+local command, eq, eval, api = helpers.command, helpers.eq, helpers.eval, helpers.api
local sleep = vim.uv.sleep
describe('mapping', function()
@@ -134,9 +134,9 @@ describe('mapping', function()
command('nnoremap <LeftDrag> <LeftDrag><Cmd><CR>')
poke_eventloop()
- meths.nvim_input_mouse('left', 'press', '', 0, 0, 0)
+ api.nvim_input_mouse('left', 'press', '', 0, 0, 0)
poke_eventloop()
- meths.nvim_input_mouse('left', 'drag', '', 0, 0, 1)
+ api.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.nvim_input_mouse('left', 'press', '', 0, 0, 0)
+ api.nvim_input_mouse('left', 'press', '', 0, 0, 0)
poke_eventloop()
- meths.nvim_input_mouse('left', 'drag', '', 0, 0, 1)
+ api.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.nvim_input_mouse('left', 'press', '', 0, 0, 0)
+ api.nvim_input_mouse('left', 'press', '', 0, 0, 0)
poke_eventloop()
- meths.nvim_input_mouse('left', 'drag', '', 0, 0, 1)
+ api.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 c416ebfc99..593d03fa90 100644
--- a/test/functional/legacy/messages_spec.lua
+++ b/test/functional/legacy/messages_spec.lua
@@ -4,7 +4,7 @@ local clear = helpers.clear
local command = helpers.command
local exec = helpers.exec
local feed = helpers.feed
-local meths = helpers.meths
+local api = helpers.api
local nvim_dir = helpers.nvim_dir
local assert_alive = helpers.assert_alive
@@ -410,9 +410,9 @@ describe('messages', function()
screen:attach()
command('cd ' .. nvim_dir)
- 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
+ api.nvim_set_option_value('shell', './shell-test', {})
+ api.nvim_set_option_value('shellcmdflag', 'REP 20', {})
+ api.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/mksession_spec.lua b/test/functional/legacy/mksession_spec.lua
index bca9cd833c..689d918cd9 100644
--- a/test/functional/legacy/mksession_spec.lua
+++ b/test/functional/legacy/mksession_spec.lua
@@ -1,7 +1,7 @@
local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
local command = helpers.command
-local funcs = helpers.funcs
+local fn = helpers.fn
local eq = helpers.eq
describe('mksession', function()
@@ -18,7 +18,7 @@ describe('mksession', function()
command('mksession! Xtest_mks.out')
local found_rtp = 0
local found_pp = 0
- for _, line in pairs(funcs.readfile('Xtest_mks.out', 'b')) do
+ for _, line in pairs(fn.readfile('Xtest_mks.out', 'b')) do
if line:find('set runtimepath') then
found_rtp = found_rtp + 1
end
@@ -32,7 +32,7 @@ describe('mksession', function()
command('set sessionoptions+=skiprtp')
command('mksession! Xtest_mks.out')
local found_rtp_or_pp = 0
- for _, line in pairs(funcs.readfile('Xtest_mks.out', 'b')) do
+ for _, line in pairs(fn.readfile('Xtest_mks.out', 'b')) do
if line:find('set runtimepath') or line:find('set packpath') then
found_rtp_or_pp = found_rtp_or_pp + 1
end
diff --git a/test/functional/legacy/move_spec.lua b/test/functional/legacy/move_spec.lua
index 512823be6c..1500d48ad9 100644
--- a/test/functional/legacy/move_spec.lua
+++ b/test/functional/legacy/move_spec.lua
@@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local clear = helpers.clear
local feed = helpers.feed
-local funcs = helpers.funcs
+local fn = helpers.fn
before_each(clear)
@@ -15,7 +15,7 @@ describe(':move', function()
})
screen:attach()
- funcs.setline(1, { 'First', 'Second', 'Third', 'Fourth' })
+ fn.setline(1, { 'First', 'Second', 'Third', 'Fourth' })
feed('gg:move +1<CR>')
screen:expect([[
Second |
diff --git a/test/functional/legacy/prompt_buffer_spec.lua b/test/functional/legacy/prompt_buffer_spec.lua
index e372d713c4..0c6898526e 100644
--- a/test/functional/legacy/prompt_buffer_spec.lua
+++ b/test/functional/legacy/prompt_buffer_spec.lua
@@ -5,7 +5,7 @@ local source = helpers.source
local clear = helpers.clear
local command = helpers.command
local poke_eventloop = helpers.poke_eventloop
-local meths = helpers.meths
+local api = helpers.api
local eq = helpers.eq
local neq = helpers.neq
@@ -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.nvim_get_mode())
+ eq({ mode = 'i', blocking = false }, api.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.nvim_get_current_win()
+ local prev_win = api.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.nvim_get_var('entered'))
- neq(prev_win, meths.nvim_get_current_win())
+ eq('something', api.nvim_get_var('entered'))
+ neq(prev_win, api.nvim_get_current_win())
feed('exit<CR>')
- eq(prev_win, meths.nvim_get_current_win())
- eq({ mode = 'n', blocking = false }, meths.nvim_get_mode())
+ eq(prev_win, api.nvim_get_current_win())
+ eq({ mode = 'n', blocking = false }, api.nvim_get_mode())
command('call DoAppend()')
- eq({ mode = 'n', blocking = false }, meths.nvim_get_mode())
+ eq({ mode = 'n', blocking = false }, api.nvim_get_mode())
feed('i')
- eq({ mode = 'i', blocking = false }, meths.nvim_get_mode())
+ eq({ mode = 'i', blocking = false }, api.nvim_get_mode())
command('call DoAppend()')
- eq({ mode = 'i', blocking = false }, meths.nvim_get_mode())
+ eq({ mode = 'i', blocking = false }, api.nvim_get_mode())
end)
end)
diff --git a/test/functional/legacy/put_spec.lua b/test/functional/legacy/put_spec.lua
index 1678d8f2d8..c78946d690 100644
--- a/test/functional/legacy/put_spec.lua
+++ b/test/functional/legacy/put_spec.lua
@@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local clear = helpers.clear
local exec_lua = helpers.exec_lua
-local meths = helpers.meths
+local api = helpers.api
local source = helpers.source
local eq = helpers.eq
@@ -16,7 +16,7 @@ end
describe('put', function()
before_each(clear)
after_each(function()
- eq({}, meths.nvim_get_vvar('errors'))
+ eq({}, api.nvim_get_vvar('errors'))
end)
it('very large count 64-bit', function()
diff --git a/test/functional/legacy/search_spec.lua b/test/functional/legacy/search_spec.lua
index 7ddf81cff8..70748c9d27 100644
--- a/test/functional/legacy/search_spec.lua
+++ b/test/functional/legacy/search_spec.lua
@@ -5,7 +5,7 @@ local command = helpers.command
local eq = helpers.eq
local eval = helpers.eval
local feed = helpers.feed
-local funcs = helpers.funcs
+local fn = helpers.fn
local poke_eventloop = helpers.poke_eventloop
local exec = helpers.exec
@@ -27,7 +27,7 @@ describe('search cmdline', function()
end)
local function tenlines()
- funcs.setline(1, {
+ fn.setline(1, {
' 1',
' 2 these',
' 3 the',
@@ -68,7 +68,7 @@ describe('search cmdline', function()
3 {inc:the} |
/the^ |
]])
- eq({ 0, 0, 0, 0 }, funcs.getpos('"'))
+ eq({ 0, 0, 0, 0 }, fn.getpos('"'))
feed('<C-G>')
screen:expect([[
3 the |
@@ -125,7 +125,7 @@ describe('search cmdline', function()
end,
}
feed('<CR>')
- eq({ 0, 0, 0, 0 }, funcs.getpos('"'))
+ eq({ 0, 0, 0, 0 }, fn.getpos('"'))
end
end
@@ -368,7 +368,7 @@ describe('search cmdline', function()
end)
it('can traverse matches in the same line with <C-G>/<C-T>', function()
- funcs.setline(1, { ' 1', ' 2 these', ' 3 the theother' })
+ fn.setline(1, { ' 1', ' 2 these', ' 3 the theother' })
command('1')
command('set incsearch')
@@ -465,7 +465,7 @@ describe('search cmdline', function()
coladd = 0,
skipcol = 0,
curswant = 4,
- }, funcs.winsaveview())
+ }, fn.winsaveview())
end)
it('restores original view after failed search', function()
@@ -500,14 +500,14 @@ describe('search cmdline', function()
coladd = 0,
skipcol = 0,
curswant = 0,
- }, funcs.winsaveview())
+ }, fn.winsaveview())
end)
-- oldtest: Test_search_cmdline4().
it("CTRL-G with 'incsearch' and ? goes in the right direction", function()
screen:try_resize(40, 4)
command('enew!')
- funcs.setline(1, { ' 1 the first', ' 2 the second', ' 3 the third' })
+ fn.setline(1, { ' 1 the first', ' 2 the second', ' 3 the third' })
command('set laststatus=0 shortmess+=s')
command('set incsearch')
command('$')
@@ -608,7 +608,7 @@ describe('search cmdline', function()
it('incsearch works with :sort', function()
screen:try_resize(20, 4)
command('set incsearch hlsearch scrolloff=0')
- funcs.setline(1, { 'another one 2', 'that one 3', 'the one 1' })
+ fn.setline(1, { 'another one 2', 'that one 3', 'the one 1' })
feed(':sort ni u /on')
screen:expect([[
@@ -624,7 +624,7 @@ describe('search cmdline', function()
it('incsearch works with :vimgrep family', function()
screen:try_resize(30, 4)
command('set incsearch hlsearch scrolloff=0')
- funcs.setline(1, { 'another one 2', 'that one 3', 'the one 1' })
+ fn.setline(1, { 'another one 2', 'that one 3', 'the one 1' })
feed(':vimgrep on')
screen:expect([[
diff --git a/test/functional/legacy/undolevels_spec.lua b/test/functional/legacy/undolevels_spec.lua
index a22cda27b6..e8badc6864 100644
--- a/test/functional/legacy/undolevels_spec.lua
+++ b/test/functional/legacy/undolevels_spec.lua
@@ -1,6 +1,6 @@
local helpers = require('test.functional.helpers')(after_each)
local source, clear = helpers.source, helpers.clear
-local eq, nvim = helpers.eq, helpers.meths
+local eq, nvim = helpers.eq, helpers.api
describe('undolevel', function()
setup(clear)
diff --git a/test/functional/legacy/vimscript_spec.lua b/test/functional/legacy/vimscript_spec.lua
index eb3c70ecc6..8b0a920a3e 100644
--- a/test/functional/legacy/vimscript_spec.lua
+++ b/test/functional/legacy/vimscript_spec.lua
@@ -3,7 +3,7 @@ local Screen = require('test.functional.ui.screen')
local clear = helpers.clear
local exec = helpers.exec
local feed = helpers.feed
-local meths = helpers.meths
+local api = helpers.api
before_each(clear)
@@ -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.nvim_set_option_value('laststatus', 2, {})
+ api.nvim_set_option_value('laststatus', 2, {})
exec([[
" Deep nesting of if ... endif
func Test1()
diff --git a/test/functional/lua/api_spec.lua b/test/functional/lua/api_spec.lua
index d10802440f..acd56a0ddb 100644
--- a/test/functional/lua/api_spec.lua
+++ b/test/functional/lua/api_spec.lua
@@ -3,7 +3,7 @@ local helpers = require('test.functional.helpers')(after_each)
local exc_exec = helpers.exc_exec
local remove_trace = helpers.remove_trace
-local funcs = helpers.funcs
+local fn = helpers.fn
local clear = helpers.clear
local eval = helpers.eval
local NIL = vim.NIL
@@ -17,39 +17,39 @@ describe('luaeval(vim.api.…)', function()
describe('with channel_id and buffer handle', function()
describe('nvim_buf_get_lines', function()
it('works', function()
- funcs.setline(1, { 'abc', 'def', 'a\nb', 'ttt' })
- eq({ 'a\000b' }, funcs.luaeval('vim.api.nvim_buf_get_lines(1, 2, 3, false)'))
+ fn.setline(1, { 'abc', 'def', 'a\nb', 'ttt' })
+ eq({ 'a\000b' }, fn.luaeval('vim.api.nvim_buf_get_lines(1, 2, 3, false)'))
end)
end)
describe('nvim_buf_set_lines', function()
it('works', function()
- funcs.setline(1, { 'abc', 'def', 'a\nb', 'ttt' })
- eq(NIL, funcs.luaeval('vim.api.nvim_buf_set_lines(1, 1, 2, false, {"b\\0a"})'))
+ fn.setline(1, { 'abc', 'def', 'a\nb', 'ttt' })
+ eq(NIL, fn.luaeval('vim.api.nvim_buf_set_lines(1, 1, 2, false, {"b\\0a"})'))
eq(
{ 'abc', 'b\000a', 'a\000b', 'ttt' },
- funcs.luaeval('vim.api.nvim_buf_get_lines(1, 0, 4, false)')
+ fn.luaeval('vim.api.nvim_buf_get_lines(1, 0, 4, false)')
)
end)
end)
end)
describe('with errors', function()
it('transforms API error from nvim_buf_set_lines into lua error', function()
- funcs.setline(1, { 'abc', 'def', 'a\nb', 'ttt' })
+ fn.setline(1, { 'abc', 'def', 'a\nb', 'ttt' })
eq(
{ false, "'replacement string' item contains newlines" },
- funcs.luaeval('{pcall(vim.api.nvim_buf_set_lines, 1, 1, 2, false, {"b\\na"})}')
+ fn.luaeval('{pcall(vim.api.nvim_buf_set_lines, 1, 1, 2, false, {"b\\na"})}')
)
end)
it('transforms API error from nvim_win_set_cursor into lua error', function()
eq(
{ false, 'Argument "pos" must be a [row, col] array' },
- funcs.luaeval('{pcall(vim.api.nvim_win_set_cursor, 0, {1, 2, 3})}')
+ fn.luaeval('{pcall(vim.api.nvim_win_set_cursor, 0, {1, 2, 3})}')
)
-- Used to produce a memory leak due to a bug in nvim_win_set_cursor
eq(
{ false, 'Invalid window id: -1' },
- funcs.luaeval('{pcall(vim.api.nvim_win_set_cursor, -1, {1, 2, 3})}')
+ fn.luaeval('{pcall(vim.api.nvim_win_set_cursor, -1, {1, 2, 3})}')
)
end)
@@ -58,7 +58,7 @@ describe('luaeval(vim.api.…)', function()
function()
eq(
{ false, 'Argument "pos" must be a [row, col] array' },
- funcs.luaeval('{pcall(vim.api.nvim_win_set_cursor, 0, {"b\\na"})}')
+ fn.luaeval('{pcall(vim.api.nvim_win_set_cursor, 0, {"b\\na"})}')
)
end
)
@@ -74,20 +74,20 @@ describe('luaeval(vim.api.…)', function()
]=])')
]==])]===]):gsub('\n', ' ')
)
- eq(1, funcs.luaeval(str))
+ eq(1, fn.luaeval(str))
end)
it('correctly converts from API objects', function()
- eq(1, funcs.luaeval('vim.api.nvim_eval("1")'))
- eq('1', funcs.luaeval([[vim.api.nvim_eval('"1"')]]))
- eq('Blobby', funcs.luaeval('vim.api.nvim_eval("0z426c6f626279")'))
- eq({}, funcs.luaeval('vim.api.nvim_eval("[]")'))
- eq({}, funcs.luaeval('vim.api.nvim_eval("{}")'))
- eq(1, funcs.luaeval('vim.api.nvim_eval("1.0")'))
- eq('\000', funcs.luaeval('vim.api.nvim_eval("0z00")'))
- eq(true, funcs.luaeval('vim.api.nvim_eval("v:true")'))
- eq(false, funcs.luaeval('vim.api.nvim_eval("v:false")'))
- eq(NIL, funcs.luaeval('vim.api.nvim_eval("v:null")'))
+ eq(1, fn.luaeval('vim.api.nvim_eval("1")'))
+ eq('1', fn.luaeval([[vim.api.nvim_eval('"1"')]]))
+ eq('Blobby', fn.luaeval('vim.api.nvim_eval("0z426c6f626279")'))
+ eq({}, fn.luaeval('vim.api.nvim_eval("[]")'))
+ eq({}, fn.luaeval('vim.api.nvim_eval("{}")'))
+ eq(1, fn.luaeval('vim.api.nvim_eval("1.0")'))
+ eq('\000', fn.luaeval('vim.api.nvim_eval("0z00")'))
+ eq(true, fn.luaeval('vim.api.nvim_eval("v:true")'))
+ eq(false, fn.luaeval('vim.api.nvim_eval("v:false")'))
+ eq(NIL, fn.luaeval('vim.api.nvim_eval("v:null")'))
eq(0, eval([[type(luaeval('vim.api.nvim_eval("1")'))]]))
eq(1, eval([[type(luaeval('vim.api.nvim_eval("''1''")'))]]))
@@ -99,25 +99,25 @@ describe('luaeval(vim.api.…)', function()
eq(6, eval([[type(luaeval('vim.api.nvim_eval("v:false")'))]]))
eq(7, eval([[type(luaeval('vim.api.nvim_eval("v:null")'))]]))
- eq({ foo = 42 }, funcs.luaeval([[vim.api.nvim_eval('{"foo": 42}')]]))
- eq({ 42 }, funcs.luaeval([[vim.api.nvim_eval('[42]')]]))
+ eq({ foo = 42 }, fn.luaeval([[vim.api.nvim_eval('{"foo": 42}')]]))
+ eq({ 42 }, fn.luaeval([[vim.api.nvim_eval('[42]')]]))
eq(
{ foo = { bar = 42 }, baz = 50 },
- funcs.luaeval([[vim.api.nvim_eval('{"foo": {"bar": 42}, "baz": 50}')]])
+ fn.luaeval([[vim.api.nvim_eval('{"foo": {"bar": 42}, "baz": 50}')]])
)
- eq({ { 42 }, {} }, funcs.luaeval([=[vim.api.nvim_eval('[[42], []]')]=]))
+ eq({ { 42 }, {} }, fn.luaeval([=[vim.api.nvim_eval('[[42], []]')]=]))
end)
it('correctly converts to API objects', function()
- eq(1, funcs.luaeval('vim.api.nvim__id(1)'))
- eq('1', funcs.luaeval('vim.api.nvim__id("1")'))
- eq({ 1 }, funcs.luaeval('vim.api.nvim__id({1})'))
- eq({ foo = 1 }, funcs.luaeval('vim.api.nvim__id({foo=1})'))
- eq(1.5, funcs.luaeval('vim.api.nvim__id(1.5)'))
- eq(true, funcs.luaeval('vim.api.nvim__id(true)'))
- eq(false, funcs.luaeval('vim.api.nvim__id(false)'))
- eq(NIL, funcs.luaeval('vim.api.nvim__id(nil)'))
+ eq(1, fn.luaeval('vim.api.nvim__id(1)'))
+ eq('1', fn.luaeval('vim.api.nvim__id("1")'))
+ eq({ 1 }, fn.luaeval('vim.api.nvim__id({1})'))
+ eq({ foo = 1 }, fn.luaeval('vim.api.nvim__id({foo=1})'))
+ eq(1.5, fn.luaeval('vim.api.nvim__id(1.5)'))
+ eq(true, fn.luaeval('vim.api.nvim__id(true)'))
+ eq(false, fn.luaeval('vim.api.nvim__id(false)'))
+ eq(NIL, fn.luaeval('vim.api.nvim__id(nil)'))
-- API strings from Blobs can work as NUL-terminated C strings
eq(
@@ -138,10 +138,10 @@ describe('luaeval(vim.api.…)', function()
eq(
{ foo = 1, bar = { 42, { { baz = true }, 5 } } },
- funcs.luaeval('vim.api.nvim__id({foo=1, bar={42, {{baz=true}, 5}}})')
+ fn.luaeval('vim.api.nvim__id({foo=1, bar={42, {{baz=true}, 5}}})')
)
- eq(true, funcs.luaeval('vim.api.nvim__id(vim.api.nvim__id)(true)'))
+ eq(true, fn.luaeval('vim.api.nvim__id(vim.api.nvim__id)(true)'))
eq(
42,
exec_lua [[
@@ -159,30 +159,30 @@ describe('luaeval(vim.api.…)', function()
eq(4, eval([[type(luaeval('vim.api.nvim__id({[vim.type_idx]=vim.types.dictionary})'))]]))
eq(3, eval([[type(luaeval('vim.api.nvim__id({[vim.type_idx]=vim.types.array})'))]]))
- eq({}, funcs.luaeval('vim.api.nvim__id({[vim.type_idx]=vim.types.array})'))
+ eq({}, fn.luaeval('vim.api.nvim__id({[vim.type_idx]=vim.types.array})'))
-- Presence of type_idx makes Vim ignore some keys
eq(
{ 42 },
- funcs.luaeval(
+ fn.luaeval(
'vim.api.nvim__id({[vim.type_idx]=vim.types.array, [vim.val_idx]=10, [5]=1, foo=2, [1]=42})'
)
)
eq(
{ foo = 2 },
- funcs.luaeval(
+ fn.luaeval(
'vim.api.nvim__id({[vim.type_idx]=vim.types.dictionary, [vim.val_idx]=10, [5]=1, foo=2, [1]=42})'
)
)
eq(
10,
- funcs.luaeval(
+ fn.luaeval(
'vim.api.nvim__id({[vim.type_idx]=vim.types.float, [vim.val_idx]=10, [5]=1, foo=2, [1]=42})'
)
)
eq(
{},
- funcs.luaeval(
+ fn.luaeval(
'vim.api.nvim__id({[vim.type_idx]=vim.types.array, [vim.val_idx]=10, [5]=1, foo=2})'
)
)
@@ -191,34 +191,34 @@ describe('luaeval(vim.api.…)', function()
it('correctly converts arrays with type_idx to API objects', function()
eq(3, eval([[type(luaeval('vim.api.nvim__id_array({[vim.type_idx]=vim.types.array})'))]]))
- eq({}, funcs.luaeval('vim.api.nvim__id_array({[vim.type_idx]=vim.types.array})'))
+ eq({}, fn.luaeval('vim.api.nvim__id_array({[vim.type_idx]=vim.types.array})'))
eq(
{ 42 },
- funcs.luaeval(
+ fn.luaeval(
'vim.api.nvim__id_array({[vim.type_idx]=vim.types.array, [vim.val_idx]=10, [5]=1, foo=2, [1]=42})'
)
)
eq(
{ { foo = 2 } },
- funcs.luaeval(
+ fn.luaeval(
'vim.api.nvim__id_array({{[vim.type_idx]=vim.types.dictionary, [vim.val_idx]=10, [5]=1, foo=2, [1]=42}})'
)
)
eq(
{ 10 },
- funcs.luaeval(
+ fn.luaeval(
'vim.api.nvim__id_array({{[vim.type_idx]=vim.types.float, [vim.val_idx]=10, [5]=1, foo=2, [1]=42}})'
)
)
eq(
{},
- funcs.luaeval(
+ fn.luaeval(
'vim.api.nvim__id_array({[vim.type_idx]=vim.types.array, [vim.val_idx]=10, [5]=1, foo=2})'
)
)
- eq({}, funcs.luaeval('vim.api.nvim__id_array({})'))
+ eq({}, fn.luaeval('vim.api.nvim__id_array({})'))
eq(3, eval([[type(luaeval('vim.api.nvim__id_array({})'))]]))
end)
@@ -228,36 +228,36 @@ describe('luaeval(vim.api.…)', function()
eval([[type(luaeval('vim.api.nvim__id_dictionary({[vim.type_idx]=vim.types.dictionary})'))]])
)
- eq({}, funcs.luaeval('vim.api.nvim__id_dictionary({[vim.type_idx]=vim.types.dictionary})'))
+ eq({}, fn.luaeval('vim.api.nvim__id_dictionary({[vim.type_idx]=vim.types.dictionary})'))
eq(
{ v = { 42 } },
- funcs.luaeval(
+ fn.luaeval(
'vim.api.nvim__id_dictionary({v={[vim.type_idx]=vim.types.array, [vim.val_idx]=10, [5]=1, foo=2, [1]=42}})'
)
)
eq(
{ foo = 2 },
- funcs.luaeval(
+ fn.luaeval(
'vim.api.nvim__id_dictionary({[vim.type_idx]=vim.types.dictionary, [vim.val_idx]=10, [5]=1, foo=2, [1]=42})'
)
)
eq(
{ v = 10 },
- funcs.luaeval(
+ fn.luaeval(
'vim.api.nvim__id_dictionary({v={[vim.type_idx]=vim.types.float, [vim.val_idx]=10, [5]=1, foo=2, [1]=42}})'
)
)
eq(
{ v = {} },
- funcs.luaeval(
+ fn.luaeval(
'vim.api.nvim__id_dictionary({v={[vim.type_idx]=vim.types.array, [vim.val_idx]=10, [5]=1, foo=2}})'
)
)
-- If API requests dictionary, then empty table will be the one. This is not
-- the case normally because empty table is an empty array.
- eq({}, funcs.luaeval('vim.api.nvim__id_dictionary({})'))
+ eq({}, fn.luaeval('vim.api.nvim__id_dictionary({})'))
eq(4, eval([[type(luaeval('vim.api.nvim__id_dictionary({})'))]]))
end)
@@ -384,13 +384,11 @@ describe('luaeval(vim.api.…)', function()
end)
it('accepts any value as API Boolean', function()
- eq('', funcs.luaeval('vim.api.nvim_replace_termcodes("", vim, false, nil)'))
- eq('', funcs.luaeval('vim.api.nvim_replace_termcodes("", 0, 1.5, "test")'))
+ eq('', fn.luaeval('vim.api.nvim_replace_termcodes("", vim, false, nil)'))
+ eq('', fn.luaeval('vim.api.nvim_replace_termcodes("", 0, 1.5, "test")'))
eq(
'',
- funcs.luaeval(
- 'vim.api.nvim_replace_termcodes("", true, {}, {[vim.type_idx]=vim.types.array})'
- )
+ fn.luaeval('vim.api.nvim_replace_termcodes("", true, {}, {[vim.type_idx]=vim.types.array})')
)
end)
diff --git a/test/functional/lua/buffer_updates_spec.lua b/test/functional/lua/buffer_updates_spec.lua
index 5e11349b67..ba298acc7e 100644
--- a/test/functional/lua/buffer_updates_spec.lua
+++ b/test/functional/lua/buffer_updates_spec.lua
@@ -2,8 +2,8 @@
local helpers = require('test.functional.helpers')(after_each)
local command = helpers.command
-local meths = helpers.meths
-local funcs = helpers.funcs
+local api = helpers.api
+local fn = helpers.fn
local clear = helpers.clear
local eq = helpers.eq
local fail = helpers.fail
@@ -54,9 +54,9 @@ end)
describe('lua buffer event callbacks: on_lines', function()
local function setup_eventcheck(verify, utf_sizes, lines)
local lastsize
- meths.nvim_buf_set_lines(0, 0, -1, true, lines)
+ api.nvim_buf_set_lines(0, 0, -1, true, lines)
if verify then
- lastsize = meths.nvim_buf_get_offset(0, meths.nvim_buf_line_count(0))
+ lastsize = api.nvim_buf_get_offset(0, api.nvim_buf_line_count(0))
end
exec_lua('return test_register(...)', 0, 'on_lines', 'test1', false, utf_sizes)
local verify_name = 'test1'
@@ -76,9 +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.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 newrange = api.nvim_buf_get_offset(0, endline)
+ - api.nvim_buf_get_offset(0, startline)
+ local newsize = api.nvim_buf_get_offset(0, api.nvim_buf_line_count(0))
local oldrange = newrange + lastsize - newsize
eq(oldrange, event[8])
lastsize = newsize
@@ -98,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.nvim_buf_get_changedtick(0)
+ local tick = api.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.nvim_buf_set_lines(0, 3, 5, true, { 'changed line' })
+ api.nvim_buf_set_lines(0, 3, 5, true, { 'changed line' })
tick = tick + 1
check_events { { 'test1', 'lines', 1, tick, 3, 5, 4, 32 } }
@@ -142,7 +142,7 @@ describe('lua buffer event callbacks: on_lines', function()
-- simulate next callback returning true
exec_lua("test_unreg = 'test1'")
- meths.nvim_buf_set_lines(0, 6, 7, true, { 'x1', 'x2', 'x3' })
+ api.nvim_buf_set_lines(0, 6, 7, true, { 'x1', 'x2', 'x3' })
tick = tick + 1
-- plugins can opt in to receive changedtick events, or choose
@@ -154,7 +154,7 @@ describe('lua buffer event callbacks: on_lines', function()
verify_name 'test2'
- meths.nvim_buf_set_lines(0, 1, 1, true, { 'added' })
+ api.nvim_buf_set_lines(0, 1, 1, true, { 'added' })
tick = tick + 1
check_events { { 'test2', 'lines', 1, tick, 1, 1, 2, 0 } }
@@ -206,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.nvim_buf_get_changedtick(0)
+ local tick = api.nvim_buf_get_changedtick(0)
feed('ggdd')
tick = tick + 1
@@ -254,7 +254,7 @@ describe('lua buffer event callbacks: on_lines', function()
end)
it('has valid cursor position while shifting', function()
- meths.nvim_buf_set_lines(0, 0, -1, true, { 'line1' })
+ api.nvim_buf_set_lines(0, 0, -1, true, { 'line1' })
exec_lua([[
vim.api.nvim_buf_attach(0, false, {
on_lines = function()
@@ -263,15 +263,15 @@ describe('lua buffer event callbacks: on_lines', function()
})
]])
feed('>>')
- eq(1, meths.nvim_get_var('listener_cursor_line'))
+ eq(1, api.nvim_get_var('listener_cursor_line'))
end)
it('has valid cursor position while deleting lines', function()
- 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])
+ api.nvim_buf_set_lines(0, 0, -1, true, { 'line_1', 'line_2', 'line_3', 'line_4' })
+ api.nvim_win_set_cursor(0, { 2, 0 })
+ eq(2, api.nvim_win_get_cursor(0)[1])
+ api.nvim_buf_set_lines(0, 0, -1, true, { 'line_1', 'line_2', 'line_3' })
+ eq(2, api.nvim_win_get_cursor(0)[1])
end)
it('does not SEGFAULT when accessing window buffer info in on_detach #14998', function()
@@ -299,7 +299,7 @@ describe('lua buffer event callbacks: on_lines', function()
end)
it('#12718 lnume', function()
- meths.nvim_buf_set_lines(0, 0, -1, true, { '1', '2', '3' })
+ api.nvim_buf_set_lines(0, 0, -1, true, { '1', '2', '3' })
exec_lua([[
vim.api.nvim_buf_attach(0, false, {
on_lines = function(...)
@@ -312,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.nvim_get_var('linesev'), { 'lines', 1, 4, 2, 3, 5, 4 })
+ eq(api.nvim_get_var('linesev'), { 'lines', 1, 4, 2, 3, 5, 4 })
feed('2G0')
feed('p')
- eq(meths.nvim_get_var('linesev'), { 'lines', 1, 5, 1, 4, 4, 8 })
+ eq(api.nvim_get_var('linesev'), { 'lines', 1, 5, 1, 4, 4, 8 })
feed('1G0')
feed('P')
- eq(meths.nvim_get_var('linesev'), { 'lines', 1, 6, 0, 3, 3, 9 })
+ eq(api.nvim_get_var('linesev'), { 'lines', 1, 6, 0, 3, 3, 9 })
end)
it(
@@ -334,7 +334,7 @@ describe('lua buffer event callbacks: on_lines', function()
})
]])
feed('itest123<Esc><C-A>')
- eq('test124', meths.nvim_get_current_line())
+ eq('test124', api.nvim_get_current_line())
end
)
end)
@@ -346,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.nvim_buf_set_lines(0, 0, -1, true, start_txt)
+ api.nvim_buf_set_lines(0, 0, -1, true, start_txt)
else
- start_txt = meths.nvim_buf_get_lines(0, 0, -1, true)
+ start_txt = api.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.nvim_buf_get_offset(0, meths.nvim_buf_line_count(0))
+ local len = api.nvim_buf_get_offset(0, api.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.nvim_buf_get_changedtick(0)
+ api.nvim_buf_get_changedtick(0)
local verify_name = 'test1'
local function check_events(expected)
@@ -385,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.nvim_buf_get_lines(0, 0, -1, true), '\n') .. '\n'
+ shadowbytes = table.concat(api.nvim_buf_get_lines(0, 0, -1, true), '\n') .. '\n'
end
end
- local text = meths.nvim_buf_get_lines(0, 0, -1, true)
+ local text = api.nvim_buf_get_lines(0, 0, -1, true)
local bytes = table.concat(text, '\n') .. '\n'
eq(
@@ -426,7 +426,7 @@ describe('lua: nvim_buf_attach on_bytes', function()
it('opening lines', function()
local check_events = setup_eventcheck(verify, origlines)
- -- meths.nvim_set_option_value('autoindent', true, {})
+ -- api.nvim_set_option_value('autoindent', true, {})
feed 'Go'
check_events {
{ 'test1', 'bytes', 1, 3, 7, 0, 114, 0, 0, 0, 1, 0, 1 },
@@ -439,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.nvim_set_option_value('autoindent', true, {})
+ api.nvim_set_option_value('autoindent', true, {})
feed 'Go'
check_events {
{ 'test1', 'bytes', 1, 3, 7, 0, 114, 0, 0, 0, 1, 0, 5 },
@@ -453,19 +453,19 @@ describe('lua: nvim_buf_attach on_bytes', function()
it('setline(num, line)', function()
local check_events = setup_eventcheck(verify, origlines)
- funcs.setline(2, 'babla')
+ fn.setline(2, 'babla')
check_events {
{ 'test1', 'bytes', 1, 3, 1, 0, 16, 0, 15, 15, 0, 5, 5 },
}
- funcs.setline(2, { 'foo', 'bar' })
+ fn.setline(2, { 'foo', 'bar' })
check_events {
{ 'test1', 'bytes', 1, 4, 1, 0, 16, 0, 5, 5, 0, 3, 3 },
{ 'test1', 'bytes', 1, 5, 2, 0, 20, 0, 15, 15, 0, 3, 3 },
}
- local buf_len = meths.nvim_buf_line_count(0)
- funcs.setline(buf_len + 1, 'baz')
+ local buf_len = api.nvim_buf_line_count(0)
+ fn.setline(buf_len + 1, 'baz')
check_events {
{ 'test1', 'bytes', 1, 6, 7, 0, 90, 0, 0, 0, 1, 0, 4 },
}
@@ -473,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.nvim_set_option_value('formatoptions', 'ro', {})
- meths.nvim_set_option_value('filetype', 'c', {})
+ api.nvim_set_option_value('formatoptions', 'ro', {})
+ api.nvim_set_option_value('filetype', 'c', {})
feed 'A<CR>'
check_events {
{ 'test1', 'bytes', 1, 4, 0, 10, 10, 0, 0, 0, 1, 3, 4 },
@@ -555,7 +555,7 @@ describe('lua: nvim_buf_attach on_bytes', function()
it('visual charwise paste', function()
local check_events = setup_eventcheck(verify, { '1234567890' })
- funcs.setreg('a', '___')
+ fn.setreg('a', '___')
feed '1G1|vll'
check_events {}
@@ -612,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.nvim_set_option_value('inccommand', 'nosplit', {})
+ api.nvim_set_option_value('inccommand', 'nosplit', {})
-- linewise substitute
feed(':%s/bcd/')
@@ -697,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.nvim_buf_set_text(0, 0, 3, 0, 3, { 'fiol', 'kontra' })
+ api.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.nvim_buf_set_text(0, 1, 6, 1, 6, { 'punkt', 'syntgitarr', 'övnings' })
+ api.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.nvim_buf_get_lines(0, 0, -1, true)
+ api.nvim_buf_get_lines(0, 0, -1, true)
)
end)
it('nvim_buf_set_text replace', function()
local check_events = setup_eventcheck(verify, origlines)
- meths.nvim_buf_set_text(0, 2, 3, 2, 8, { 'very text' })
+ api.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.nvim_buf_set_text(0, 3, 5, 3, 7, { ' splitty', 'line ' })
+ api.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.nvim_buf_set_text(0, 0, 8, 1, 2, { 'JOINY' })
+ api.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.nvim_buf_set_text(0, 4, 0, 6, 0, { 'was 5,6', '' })
+ api.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 },
}
@@ -743,20 +743,20 @@ describe('lua: nvim_buf_attach on_bytes', function()
'line l line 4',
'was 5,6',
' indented line',
- }, meths.nvim_buf_get_lines(0, 0, -1, true))
+ }, api.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.nvim_buf_set_text(0, 0, 0, 1, 0, {})
+ api.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.nvim_buf_set_text(0, 4, 15, 5, 17, { '' })
+ api.nvim_buf_set_text(0, 4, 15, 5, 17, { '' })
check_events {
{ 'test1', 'bytes', 1, 4, 4, 15, 79, 1, 17, 18, 0, 0, 0 },
}
@@ -766,7 +766,7 @@ describe('lua: nvim_buf_attach on_bytes', function()
'original line 4',
'original line 5',
'original line 6',
- }, meths.nvim_buf_get_lines(0, 0, -1, true))
+ }, api.nvim_buf_get_lines(0, 0, -1, true))
end)
it('checktime autoread', function()
@@ -801,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.nvim_buf_get_lines(0, 0, -1, true))
+ eq({ 'new line 1 new line 2', 'new line 3' }, api.nvim_buf_get_lines(0, 0, -1, true))
-- check we can undo and redo a reload event.
feed 'u'
@@ -925,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.nvim_buf_set_extmark(0, ns, 0, 0, {})
+ api.nvim_buf_set_extmark(0, ns, 0, 0, {})
- eq({ '12345', 'hello world' }, meths.nvim_buf_get_lines(0, 0, -1, true))
+ eq({ '12345', 'hello world' }, api.nvim_buf_get_lines(0, 0, -1, true))
-- splice
feed('gg0d2l')
- eq({ '345', 'hello world' }, meths.nvim_buf_get_lines(0, 0, -1, true))
+ eq({ '345', 'hello world' }, api.nvim_buf_get_lines(0, 0, -1, true))
-- move
command('.m+1')
- eq({ 'hello world', '345' }, meths.nvim_buf_get_lines(0, 0, -1, true))
+ eq({ 'hello world', '345' }, api.nvim_buf_get_lines(0, 0, -1, true))
-- reload undofile and undo changes
command('w')
@@ -950,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.nvim_buf_get_lines(0, 0, -1, true))
+ eq({ '345', 'hello world' }, api.nvim_buf_get_lines(0, 0, -1, true))
check_events {
{ 'test1', 'bytes', 2, 6, 1, 0, 12, 1, 0, 4, 0, 0, 0 },
@@ -958,7 +958,7 @@ describe('lua: nvim_buf_attach on_bytes', function()
}
feed('u')
- eq({ '12345', 'hello world' }, meths.nvim_buf_get_lines(0, 0, -1, true))
+ eq({ '12345', 'hello world' }, api.nvim_buf_get_lines(0, 0, -1, true))
check_events {
{ 'test1', 'bytes', 2, 8, 0, 0, 0, 0, 0, 0, 0, 2, 2 },
@@ -969,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.nvim_buf_get_lines(0, 0, -1, true))
+ -- eq({}, api.nvim_buf_get_lines(0, 0, -1, true))
feed('gg0<c-v>jj$d')
check_events {
@@ -1023,7 +1023,7 @@ describe('lua: nvim_buf_attach on_bytes', function()
it('virtual edit', function()
local check_events = setup_eventcheck(verify, { '', ' ' })
- meths.nvim_set_option_value('virtualedit', 'all', {})
+ api.nvim_set_option_value('virtualedit', 'all', {})
feed [[<Right><Right>iab<ESC>]]
@@ -1042,7 +1042,7 @@ describe('lua: nvim_buf_attach on_bytes', function()
it('block visual paste', function()
local check_events = setup_eventcheck(verify, { 'AAA', 'BBB', 'CCC', 'DDD', 'EEE', 'FFF' })
- funcs.setreg('a', '___')
+ fn.setreg('a', '___')
feed([[gg0l<c-v>3jl"ap]])
check_events {
@@ -1077,20 +1077,20 @@ describe('lua: nvim_buf_attach on_bytes', function()
local check_events = setup_eventcheck(verify, { 'AAA', 'BBB' })
-- delete
- meths.nvim_buf_set_lines(0, 0, 1, true, {})
+ api.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.nvim_buf_set_lines(0, 0, 0, true, { 'asdf' })
+ api.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.nvim_buf_set_lines(0, 0, 1, true, { 'asdf', 'fdsa' })
+ api.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 },
}
@@ -1202,13 +1202,13 @@ describe('lua: nvim_buf_attach on_bytes', function()
command('diffthis')
command('new')
command('diffthis')
- meths.nvim_buf_set_lines(0, 0, -1, true, { 'AAA', 'BBB' })
+ api.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.nvim_buf_set_lines(0, 0, -1, true, { 'AAA', 'CCC' })
+ api.nvim_buf_set_lines(0, 0, -1, true, { 'AAA', 'CCC' })
feed('<C-w>pG')
command('diffget')
check_events {
@@ -1250,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.nvim_buf_get_lines(0, 0, -1, true), '|'))
+ eq('CCC|BBBB|', table.concat(api.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 2efb57828d..28a99a86f8 100644
--- a/test/functional/lua/commands_spec.lua
+++ b/test/functional/lua/commands_spec.lua
@@ -8,10 +8,10 @@ local eval = helpers.eval
local feed = helpers.feed
local clear = helpers.clear
local matches = helpers.matches
-local meths = helpers.meths
+local api = helpers.api
local exec_lua = helpers.exec_lua
local exec_capture = helpers.exec_capture
-local funcs = helpers.funcs
+local fn = helpers.fn
local source = helpers.source
local dedent = helpers.dedent
local command = helpers.command
@@ -25,23 +25,23 @@ before_each(clear)
describe(':lua command', function()
it('works', function()
eq('', exec_capture('lua vim.api.nvim_buf_set_lines(1, 1, 2, false, {"TEST"})'))
- eq({ '', 'TEST' }, meths.nvim_buf_get_lines(0, 0, 100, false))
+ eq({ '', 'TEST' }, api.nvim_buf_get_lines(0, 0, 100, false))
source([[
lua << EOF
vim.api.nvim_buf_set_lines(1, 1, 2, false, {"TSET"})
EOF]])
- eq({ '', 'TSET' }, meths.nvim_buf_get_lines(0, 0, 100, false))
+ eq({ '', 'TSET' }, api.nvim_buf_get_lines(0, 0, 100, false))
source([[
lua << EOF
vim.api.nvim_buf_set_lines(1, 1, 2, false, {"SETT"})]])
- eq({ '', 'SETT' }, meths.nvim_buf_get_lines(0, 0, 100, false))
+ eq({ '', 'SETT' }, api.nvim_buf_get_lines(0, 0, 100, false))
source([[
lua << EOF
vim.api.nvim_buf_set_lines(1, 1, 2, false, {"ETTS"})
vim.api.nvim_buf_set_lines(1, 2, 3, false, {"TTSE"})
vim.api.nvim_buf_set_lines(1, 3, 4, false, {"STTE"})
EOF]])
- eq({ '', 'ETTS', 'TTSE', 'STTE' }, meths.nvim_buf_get_lines(0, 0, 100, false))
+ eq({ '', 'ETTS', 'TTSE', 'STTE' }, api.nvim_buf_get_lines(0, 0, 100, false))
matches(
'.*Vim%(lua%):E15: Invalid expression: .*',
pcall_err(
@@ -67,7 +67,7 @@ describe(':lua command', function()
[[Vim(lua):E5108: Error executing lua [string ":lua"]:1: Invalid buffer id: -10]],
remove_trace(exc_exec('lua vim.api.nvim_buf_set_lines(-10, 1, 1, false, {"TEST"})'))
)
- eq({ '' }, meths.nvim_buf_get_lines(0, 0, 100, false))
+ eq({ '' }, api.nvim_buf_get_lines(0, 0, 100, false))
end)
it('works with NULL errors', function()
eq([=[Vim(lua):E5108: Error executing lua [NULL]]=], exc_exec('lua error(nil)'))
@@ -81,13 +81,13 @@ describe(':lua command', function()
vim.api.nvim_buf_set_lines(1, 2, 3, false, {"TTSE"})
vim.api.nvim_buf_set_lines(1, 3, 4, false, {"STTE"})
]])
- eq({ '', 'ETTS', 'TTSE', 'STTE' }, meths.nvim_buf_get_lines(0, 0, 100, false))
+ eq({ '', 'ETTS', 'TTSE', 'STTE' }, api.nvim_buf_get_lines(0, 0, 100, false))
end)
it('preserves global and not preserves local variables', function()
eq('', exec_capture('lua gvar = 42'))
eq('', exec_capture('lua local lvar = 100500'))
- eq(NIL, funcs.luaeval('lvar'))
- eq(42, funcs.luaeval('gvar'))
+ eq(NIL, fn.luaeval('lvar'))
+ eq(42, fn.luaeval('gvar'))
end)
it('works with long strings', function()
local s = ('x'):rep(100500)
@@ -96,10 +96,10 @@ describe(':lua command', function()
'Vim(lua):E5107: Error loading lua [string ":lua"]:0: unfinished string near \'<eof>\'',
pcall_err(command, ('lua vim.api.nvim_buf_set_lines(1, 1, 2, false, {"%s})'):format(s))
)
- eq({ '' }, meths.nvim_buf_get_lines(0, 0, -1, false))
+ eq({ '' }, api.nvim_buf_get_lines(0, 0, -1, false))
eq('', exec_capture(('lua vim.api.nvim_buf_set_lines(1, 1, 2, false, {"%s"})'):format(s)))
- eq({ '', s }, meths.nvim_buf_get_lines(0, 0, -1, false))
+ eq({ '', s }, api.nvim_buf_get_lines(0, 0, -1, false))
end)
it('can show multiline error messages', function()
@@ -196,31 +196,31 @@ end)
describe(':luado command', function()
it('works', function()
- meths.nvim_buf_set_lines(0, 0, 1, false, { 'ABC', 'def', 'gHi' })
+ api.nvim_buf_set_lines(0, 0, 1, false, { 'ABC', 'def', 'gHi' })
eq('', exec_capture('luado lines = (lines or {}) lines[#lines + 1] = {linenr, line}'))
- eq({ 'ABC', 'def', 'gHi' }, meths.nvim_buf_get_lines(0, 0, -1, false))
- eq({ { 1, 'ABC' }, { 2, 'def' }, { 3, 'gHi' } }, funcs.luaeval('lines'))
+ eq({ 'ABC', 'def', 'gHi' }, api.nvim_buf_get_lines(0, 0, -1, false))
+ eq({ { 1, 'ABC' }, { 2, 'def' }, { 3, 'gHi' } }, fn.luaeval('lines'))
-- Automatic transformation of numbers
eq('', exec_capture('luado return linenr'))
- eq({ '1', '2', '3' }, meths.nvim_buf_get_lines(0, 0, -1, false))
+ eq({ '1', '2', '3' }, api.nvim_buf_get_lines(0, 0, -1, false))
eq('', exec_capture('luado return ("<%02x>"):format(line:byte())'))
- eq({ '<31>', '<32>', '<33>' }, meths.nvim_buf_get_lines(0, 0, -1, false))
+ eq({ '<31>', '<32>', '<33>' }, api.nvim_buf_get_lines(0, 0, -1, false))
end)
it('stops processing lines when suddenly out of lines', function()
- meths.nvim_buf_set_lines(0, 0, 1, false, { 'ABC', 'def', 'gHi' })
+ api.nvim_buf_set_lines(0, 0, 1, false, { 'ABC', 'def', 'gHi' })
eq('', exec_capture('2,$luado runs = ((runs or 0) + 1) vim.api.nvim_command("%d")'))
- eq({ '' }, meths.nvim_buf_get_lines(0, 0, -1, false))
- eq(1, funcs.luaeval('runs'))
+ eq({ '' }, api.nvim_buf_get_lines(0, 0, -1, false))
+ eq(1, fn.luaeval('runs'))
end)
it('works correctly when changing lines out of range', function()
- meths.nvim_buf_set_lines(0, 0, 1, false, { 'ABC', 'def', 'gHi' })
+ api.nvim_buf_set_lines(0, 0, 1, false, { 'ABC', 'def', 'gHi' })
eq(
'Vim(luado):E322: Line number out of range: 1 past the end',
pcall_err(command, '2,$luado vim.api.nvim_command("%d") return linenr')
)
- eq({ '' }, meths.nvim_buf_get_lines(0, 0, -1, false))
+ eq({ '' }, api.nvim_buf_get_lines(0, 0, -1, false))
end)
it('fails on errors', function()
eq(
@@ -236,12 +236,12 @@ describe(':luado command', function()
eq([=[Vim(luado):E5111: Error calling lua: [NULL]]=], exc_exec('luado error(nil)'))
end)
it('fails in sandbox when needed', function()
- meths.nvim_buf_set_lines(0, 0, 1, false, { 'ABC', 'def', 'gHi' })
+ api.nvim_buf_set_lines(0, 0, 1, false, { 'ABC', 'def', 'gHi' })
eq(
'Vim(luado):E48: Not allowed in sandbox: sandbox luado runs = (runs or 0) + 1',
pcall_err(command, 'sandbox luado runs = (runs or 0) + 1')
)
- eq(NIL, funcs.luaeval('runs'))
+ eq(NIL, fn.luaeval('runs'))
end)
it('works with long strings', function()
local s = ('x'):rep(100500)
@@ -250,10 +250,10 @@ describe(':luado command', function()
'Vim(luado):E5109: Error loading lua: [string ":luado"]:0: unfinished string near \'<eof>\'',
pcall_err(command, ('luado return "%s'):format(s))
)
- eq({ '' }, meths.nvim_buf_get_lines(0, 0, -1, false))
+ eq({ '' }, api.nvim_buf_get_lines(0, 0, -1, false))
eq('', exec_capture(('luado return "%s"'):format(s)))
- eq({ s }, meths.nvim_buf_get_lines(0, 0, -1, false))
+ eq({ s }, api.nvim_buf_get_lines(0, 0, -1, false))
end)
end)
@@ -274,7 +274,7 @@ describe(':luafile', function()
]]
)
eq('', exec_capture('luafile ' .. fname))
- eq({ '', 'ETTS', 'TTSE', 'STTE' }, meths.nvim_buf_get_lines(0, 0, 100, false))
+ eq({ '', 'ETTS', 'TTSE', 'STTE' }, api.nvim_buf_get_lines(0, 0, 100, false))
end)
it('correctly errors out', function()
diff --git a/test/functional/lua/diagnostic_spec.lua b/test/functional/lua/diagnostic_spec.lua
index 523e771266..5802925339 100644
--- a/test/functional/lua/diagnostic_spec.lua
+++ b/test/functional/lua/diagnostic_spec.lua
@@ -6,7 +6,7 @@ local clear = helpers.clear
local exec_lua = helpers.exec_lua
local eq = helpers.eq
local matches = helpers.matches
-local meths = helpers.meths
+local api = helpers.api
local pcall_err = helpers.pcall_err
describe('vim.diagnostic', function()
@@ -1563,8 +1563,8 @@ describe('vim.diagnostic', function()
it('can perform updates after insert_leave', function()
exec_lua [[vim.api.nvim_set_current_buf(diagnostic_bufnr)]]
- meths.nvim_input('o')
- eq({ mode = 'i', blocking = false }, meths.nvim_get_mode())
+ api.nvim_input('o')
+ eq({ mode = 'i', blocking = false }, api.nvim_get_mode())
-- Save the diagnostics
exec_lua [[
@@ -1577,15 +1577,15 @@ describe('vim.diagnostic', function()
]]
-- No diagnostics displayed yet.
- eq({ mode = 'i', blocking = false }, meths.nvim_get_mode())
+ eq({ mode = 'i', blocking = false }, api.nvim_get_mode())
eq(
1,
exec_lua [[return count_diagnostics(diagnostic_bufnr, vim.diagnostic.severity.ERROR, diagnostic_ns)]]
)
eq(0, exec_lua [[return count_extmarks(diagnostic_bufnr, diagnostic_ns)]])
- meths.nvim_input('<esc>')
- eq({ mode = 'n', blocking = false }, meths.nvim_get_mode())
+ api.nvim_input('<esc>')
+ eq({ mode = 'n', blocking = false }, api.nvim_get_mode())
eq(
1,
@@ -1596,8 +1596,8 @@ describe('vim.diagnostic', function()
it('does not perform updates when not needed', function()
exec_lua [[vim.api.nvim_set_current_buf(diagnostic_bufnr)]]
- meths.nvim_input('o')
- eq({ mode = 'i', blocking = false }, meths.nvim_get_mode())
+ api.nvim_input('o')
+ eq({ mode = 'i', blocking = false }, api.nvim_get_mode())
-- Save the diagnostics
exec_lua [[
@@ -1619,7 +1619,7 @@ describe('vim.diagnostic', function()
]]
-- No diagnostics displayed yet.
- eq({ mode = 'i', blocking = false }, meths.nvim_get_mode())
+ eq({ mode = 'i', blocking = false }, api.nvim_get_mode())
eq(
1,
exec_lua [[return count_diagnostics(diagnostic_bufnr, vim.diagnostic.severity.ERROR, diagnostic_ns)]]
@@ -1627,8 +1627,8 @@ describe('vim.diagnostic', function()
eq(0, exec_lua [[return count_extmarks(diagnostic_bufnr, diagnostic_ns)]])
eq(0, exec_lua [[return DisplayCount]])
- meths.nvim_input('<esc>')
- eq({ mode = 'n', blocking = false }, meths.nvim_get_mode())
+ api.nvim_input('<esc>')
+ eq({ mode = 'n', blocking = false }, api.nvim_get_mode())
eq(
1,
@@ -1638,11 +1638,11 @@ describe('vim.diagnostic', function()
eq(1, exec_lua [[return DisplayCount]])
-- Go in and out of insert mode one more time.
- meths.nvim_input('o')
- eq({ mode = 'i', blocking = false }, meths.nvim_get_mode())
+ api.nvim_input('o')
+ eq({ mode = 'i', blocking = false }, api.nvim_get_mode())
- meths.nvim_input('<esc>')
- eq({ mode = 'n', blocking = false }, meths.nvim_get_mode())
+ api.nvim_input('<esc>')
+ eq({ mode = 'n', blocking = false }, api.nvim_get_mode())
-- Should not have set the virtual text again.
eq(1, exec_lua [[return DisplayCount]])
@@ -1650,8 +1650,8 @@ describe('vim.diagnostic', function()
it('never sets virtual text, in combination with insert leave', function()
exec_lua [[vim.api.nvim_set_current_buf(diagnostic_bufnr)]]
- meths.nvim_input('o')
- eq({ mode = 'i', blocking = false }, meths.nvim_get_mode())
+ api.nvim_input('o')
+ eq({ mode = 'i', blocking = false }, api.nvim_get_mode())
-- Save the diagnostics
exec_lua [[
@@ -1674,7 +1674,7 @@ describe('vim.diagnostic', function()
]]
-- No diagnostics displayed yet.
- eq({ mode = 'i', blocking = false }, meths.nvim_get_mode())
+ eq({ mode = 'i', blocking = false }, api.nvim_get_mode())
eq(
1,
exec_lua [[return count_diagnostics(diagnostic_bufnr, vim.diagnostic.severity.ERROR, diagnostic_ns)]]
@@ -1682,8 +1682,8 @@ describe('vim.diagnostic', function()
eq(0, exec_lua [[return count_extmarks(diagnostic_bufnr, diagnostic_ns)]])
eq(0, exec_lua [[return DisplayCount]])
- meths.nvim_input('<esc>')
- eq({ mode = 'n', blocking = false }, meths.nvim_get_mode())
+ api.nvim_input('<esc>')
+ eq({ mode = 'n', blocking = false }, api.nvim_get_mode())
eq(
1,
@@ -1693,11 +1693,11 @@ describe('vim.diagnostic', function()
eq(0, exec_lua [[return DisplayCount]])
-- Go in and out of insert mode one more time.
- meths.nvim_input('o')
- eq({ mode = 'i', blocking = false }, meths.nvim_get_mode())
+ api.nvim_input('o')
+ eq({ mode = 'i', blocking = false }, api.nvim_get_mode())
- meths.nvim_input('<esc>')
- eq({ mode = 'n', blocking = false }, meths.nvim_get_mode())
+ api.nvim_input('<esc>')
+ eq({ mode = 'n', blocking = false }, api.nvim_get_mode())
-- Should not have set the virtual text still.
eq(0, exec_lua [[return DisplayCount]])
@@ -1705,8 +1705,8 @@ describe('vim.diagnostic', function()
it('can perform updates while in insert mode, if desired', function()
exec_lua [[vim.api.nvim_set_current_buf(diagnostic_bufnr)]]
- meths.nvim_input('o')
- eq({ mode = 'i', blocking = false }, meths.nvim_get_mode())
+ api.nvim_input('o')
+ eq({ mode = 'i', blocking = false }, api.nvim_get_mode())
-- Save the diagnostics
exec_lua [[
@@ -1720,15 +1720,15 @@ describe('vim.diagnostic', function()
]]
-- Diagnostics are displayed, because the user wanted them that way!
- eq({ mode = 'i', blocking = false }, meths.nvim_get_mode())
+ eq({ mode = 'i', blocking = false }, api.nvim_get_mode())
eq(
1,
exec_lua [[return count_diagnostics(diagnostic_bufnr, vim.diagnostic.severity.ERROR, diagnostic_ns)]]
)
eq(2, exec_lua [[return count_extmarks(diagnostic_bufnr, diagnostic_ns)]])
- meths.nvim_input('<esc>')
- eq({ mode = 'n', blocking = false }, meths.nvim_get_mode())
+ api.nvim_input('<esc>')
+ eq({ mode = 'n', blocking = false }, api.nvim_get_mode())
eq(
1,
@@ -1825,7 +1825,7 @@ describe('vim.diagnostic', function()
it('respects legacy signs placed with :sign define or sign_define #26618', function()
-- Legacy signs for diagnostics were deprecated in 0.10 and will be removed in 0.12
- eq(0, helpers.funcs.has('nvim-0.12'))
+ eq(0, helpers.fn.has('nvim-0.12'))
helpers.command(
'sign define DiagnosticSignError text= texthl= linehl=ErrorMsg numhl=ErrorMsg'
diff --git a/test/functional/lua/filetype_spec.lua b/test/functional/lua/filetype_spec.lua
index 3f61d1bc52..8b0e0a8beb 100644
--- a/test/functional/lua/filetype_spec.lua
+++ b/test/functional/lua/filetype_spec.lua
@@ -1,7 +1,7 @@
local helpers = require('test.functional.helpers')(after_each)
local exec_lua = helpers.exec_lua
local eq = helpers.eq
-local meths = helpers.meths
+local api = helpers.api
local clear = helpers.clear
local pathroot = helpers.pathroot
local command = helpers.command
@@ -165,6 +165,6 @@ describe('filetype.lua', function()
clear({
args = { '--clean', '--cmd', 'autocmd BufRead *.md set filetype=notmarkdown', 'README.md' },
})
- eq('notmarkdown', meths.nvim_get_option_value('filetype', {}))
+ eq('notmarkdown', api.nvim_get_option_value('filetype', {}))
end)
end)
diff --git a/test/functional/lua/loop_spec.lua b/test/functional/lua/loop_spec.lua
index 9452866b8e..71eaf29009 100644
--- a/test/functional/lua/loop_spec.lua
+++ b/test/functional/lua/loop_spec.lua
@@ -1,8 +1,8 @@
-- Test suite for testing interactions with API bindings
local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
-local funcs = helpers.funcs
-local meths = helpers.meths
+local fn = helpers.fn
+local api = helpers.api
local clear = helpers.clear
local sleep = vim.uv.sleep
local feed = helpers.feed
@@ -16,8 +16,8 @@ before_each(clear)
describe('vim.uv', function()
it('version', function()
- assert(funcs.luaeval('vim.uv.version()') >= 72961, 'libuv version too old')
- matches('(%d+)%.(%d+)%.(%d+)', funcs.luaeval('vim.uv.version_string()'))
+ assert(fn.luaeval('vim.uv.version()') >= 72961, 'libuv version too old')
+ matches('(%d+)%.(%d+)%.(%d+)', fn.luaeval('vim.uv.version_string()'))
end)
it('timer', function()
@@ -48,13 +48,13 @@ describe('vim.uv', function()
end)()
]]
- eq(0, meths.nvim_get_var('coroutine_cnt'))
+ eq(0, api.nvim_get_var('coroutine_cnt'))
exec_lua(code)
retry(2, nil, function()
sleep(50)
- eq(2, meths.nvim_get_var('coroutine_cnt'))
+ eq(2, api.nvim_get_var('coroutine_cnt'))
end)
- eq(3, meths.nvim_get_var('coroutine_cnt_1'))
+ eq(3, api.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 d461acafb5..6ed7af6b6e 100644
--- a/test/functional/lua/luaeval_spec.lua
+++ b/test/functional/lua/luaeval_spec.lua
@@ -7,8 +7,8 @@ local exc_exec = helpers.exc_exec
local remove_trace = helpers.remove_trace
local exec_lua = helpers.exec_lua
local command = helpers.command
-local meths = helpers.meths
-local funcs = helpers.funcs
+local api = helpers.api
+local fn = helpers.fn
local clear = helpers.clear
local eval = helpers.eval
local feed = helpers.feed
@@ -39,7 +39,7 @@ describe('luaeval()', function()
describe('second argument', function()
it('is successfully received', function()
local t = {t=true, f=false, --[[n=NIL,]] d={l={'string', 42, 0.42}}}
- eq(t, funcs.luaeval("_A", t))
+ eq(t, fn.luaeval("_A", t))
-- Not tested: nil, funcrefs, returned object identity: behaviour will
-- most likely change.
end)
@@ -47,37 +47,37 @@ describe('luaeval()', function()
describe('lua values', function()
it('are successfully transformed', function()
eq({n=1, f=1.5, s='string', l={4, 2}},
- funcs.luaeval('{n=1, f=1.5, s="string", l={4, 2}}'))
+ fn.luaeval('{n=1, f=1.5, s="string", l={4, 2}}'))
-- Not tested: nil inside containers: behaviour will most likely change.
- eq(NIL, funcs.luaeval('nil'))
- eq({['']=1}, funcs.luaeval('{[""]=1}'))
+ eq(NIL, fn.luaeval('nil'))
+ eq({['']=1}, fn.luaeval('{[""]=1}'))
end)
end)
describe('recursive lua values', function()
it('are successfully transformed', function()
command('lua rawset(_G, "d", {})')
command('lua rawset(d, "d", d)')
- eq('\n{\'d\': {...@0}}', funcs.execute('echo luaeval("d")'))
+ eq('\n{\'d\': {...@0}}', fn.execute('echo luaeval("d")'))
command('lua rawset(_G, "l", {})')
command('lua table.insert(l, l)')
- eq('\n[[...@0]]', funcs.execute('echo luaeval("l")'))
+ eq('\n[[...@0]]', fn.execute('echo luaeval("l")'))
end)
end)
describe('strings with NULs', function()
it('are successfully converted to blobs', function()
command([[let s = luaeval('"\0"')]])
- eq('\000', meths.nvim_get_var('s'))
+ eq('\000', api.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.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'))
+ eq({_TYPE={}, _VAL={{{_TYPE={}, _VAL={'\n'}}, 1}}}, api.nvim_get_var('d'))
+ eq(1, fn.eval('d._TYPE is v:msgpack_types.map'))
+ eq(1, fn.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.nvim_get_var('l'))
+ eq({'abc', 'a\000b', 'c\000d', 'def'}, api.nvim_get_var('l'))
end)
end)
@@ -86,68 +86,68 @@ describe('luaeval()', function()
it('correctly evaluates scalars', function()
-- Also test method call (->) syntax
- eq(1, funcs.luaeval('1'))
+ eq(1, fn.luaeval('1'))
eq(0, eval('"1"->luaeval()->type()'))
- eq(1.5, funcs.luaeval('1.5'))
+ eq(1.5, fn.luaeval('1.5'))
eq(5, eval('"1.5"->luaeval()->type()'))
- eq("test", funcs.luaeval('"test"'))
+ eq("test", fn.luaeval('"test"'))
eq(1, eval('"\'test\'"->luaeval()->type()'))
- eq('', funcs.luaeval('""'))
- eq('\000', funcs.luaeval([['\0']]))
- eq('\000\n\000', funcs.luaeval([['\0\n\0']]))
+ eq('', fn.luaeval('""'))
+ eq('\000', fn.luaeval([['\0']]))
+ eq('\000\n\000', fn.luaeval([['\0\n\0']]))
eq(10, eval([[type(luaeval("'\\0\\n\\0'"))]]))
- eq(true, funcs.luaeval('true'))
- eq(false, funcs.luaeval('false'))
- eq(NIL, funcs.luaeval('nil'))
+ eq(true, fn.luaeval('true'))
+ eq(false, fn.luaeval('false'))
+ eq(NIL, fn.luaeval('nil'))
end)
it('correctly evaluates containers', function()
- eq({}, funcs.luaeval('{}'))
+ eq({}, fn.luaeval('{}'))
eq(3, eval('type(luaeval("{}"))'))
- eq({test=1, foo=2}, funcs.luaeval('{test=1, foo=2}'))
+ eq({test=1, foo=2}, fn.luaeval('{test=1, foo=2}'))
eq(4, eval('type(luaeval("{test=1, foo=2}"))'))
- eq({4, 2}, funcs.luaeval('{4, 2}'))
+ eq({4, 2}, fn.luaeval('{4, 2}'))
eq(3, eval('type(luaeval("{4, 2}"))'))
- eq({NIL, 20}, funcs.luaeval('{[2] = 20}'))
+ eq({NIL, 20}, fn.luaeval('{[2] = 20}'))
eq(3, eval('type(luaeval("{[2] = 20}"))'))
- eq({10, NIL, 30}, funcs.luaeval('{[1] = 10, [3] = 30}'))
+ eq({10, NIL, 30}, fn.luaeval('{[1] = 10, [3] = 30}'))
eq(3, eval('type(luaeval("{[1] = 10, [3] = 30}"))'))
local level = 30
- eq(nested_by_level[level].o, funcs.luaeval(nested_by_level[level].s))
+ eq(nested_by_level[level].o, fn.luaeval(nested_by_level[level].s))
eq({_TYPE={}, _VAL={{{_TYPE={}, _VAL={'\n', '\n'}}, '\000\n\000\000'}}},
- funcs.luaeval([[{['\0\n\0']='\0\n\0\0'}]]))
+ fn.luaeval([[{['\0\n\0']='\0\n\0\0'}]]))
eq(1, eval([[luaeval('{["\0\n\0"]="\0\n\0\0"}')._TYPE is v:msgpack_types.map]]))
eq(1, eval([[luaeval('{["\0\n\0"]="\0\n\0\0"}')._VAL[0][0]._TYPE is v:msgpack_types.string]]))
eq({nested={{_TYPE={}, _VAL={{{_TYPE={}, _VAL={'\n', '\n'}}, '\000\n\000\000'}}}}},
- funcs.luaeval([[{nested={{['\0\n\0']='\0\n\0\0'}}}]]))
+ fn.luaeval([[{nested={{['\0\n\0']='\0\n\0\0'}}}]]))
end)
it('correctly passes scalars as argument', function()
- eq(1, funcs.luaeval('_A', 1))
- eq(1.5, funcs.luaeval('_A', 1.5))
- eq('', funcs.luaeval('_A', ''))
- eq('test', funcs.luaeval('_A', 'test'))
- eq(NIL, funcs.luaeval('_A', NIL))
- eq(true, funcs.luaeval('_A', true))
- eq(false, funcs.luaeval('_A', false))
+ eq(1, fn.luaeval('_A', 1))
+ eq(1.5, fn.luaeval('_A', 1.5))
+ eq('', fn.luaeval('_A', ''))
+ eq('test', fn.luaeval('_A', 'test'))
+ eq(NIL, fn.luaeval('_A', NIL))
+ eq(true, fn.luaeval('_A', true))
+ eq(false, fn.luaeval('_A', false))
end)
it('correctly passes containers as argument', function()
- eq({}, funcs.luaeval('_A', {}))
- eq({test=1}, funcs.luaeval('_A', {test=1}))
- eq({4, 2}, funcs.luaeval('_A', {4, 2}))
+ eq({}, fn.luaeval('_A', {}))
+ eq({test=1}, fn.luaeval('_A', {test=1}))
+ eq({4, 2}, fn.luaeval('_A', {4, 2}))
local level = 28
- eq(nested_by_level[level].o, funcs.luaeval('_A', nested_by_level[level].o))
+ eq(nested_by_level[level].o, fn.luaeval('_A', nested_by_level[level].o))
end)
local function sp(typ, val)
@@ -399,26 +399,26 @@ describe('luaeval()', function()
eq(4, eval([[type(luaeval('{[vim.type_idx]=vim.types.dictionary}'))]]))
eq(3, eval([[type(luaeval('{[vim.type_idx]=vim.types.array}'))]]))
- eq({}, funcs.luaeval('{[vim.type_idx]=vim.types.array}'))
+ eq({}, fn.luaeval('{[vim.type_idx]=vim.types.array}'))
-- Presence of type_idx makes Vim ignore some keys
- eq({42}, funcs.luaeval('{[vim.type_idx]=vim.types.array, [vim.val_idx]=10, [5]=1, foo=2, [1]=42}'))
- eq({foo=2}, funcs.luaeval('{[vim.type_idx]=vim.types.dictionary, [vim.val_idx]=10, [5]=1, foo=2, [1]=42}'))
- eq(10, funcs.luaeval('{[vim.type_idx]=vim.types.float, [vim.val_idx]=10, [5]=1, foo=2, [1]=42}'))
+ eq({42}, fn.luaeval('{[vim.type_idx]=vim.types.array, [vim.val_idx]=10, [5]=1, foo=2, [1]=42}'))
+ eq({foo=2}, fn.luaeval('{[vim.type_idx]=vim.types.dictionary, [vim.val_idx]=10, [5]=1, foo=2, [1]=42}'))
+ eq(10, fn.luaeval('{[vim.type_idx]=vim.types.float, [vim.val_idx]=10, [5]=1, foo=2, [1]=42}'))
-- The following should not crash
- eq({}, funcs.luaeval('{[vim.type_idx]=vim.types.dictionary}'))
+ eq({}, fn.luaeval('{[vim.type_idx]=vim.types.dictionary}'))
end)
it('correctly converts self-containing containers', function()
- meths.nvim_set_var('l', {})
+ api.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.nvim_set_var('d', {foo=42})
+ api.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])'))
@@ -441,7 +441,7 @@ describe('luaeval()', function()
local s = ('x'):rep(65536)
eq('Vim(call):E5107: Error loading lua [string "luaeval()"]:1: unexpected symbol near \')\'',
exc_exec([[call luaeval("(']] .. s ..[[' + )")]]))
- eq(s, funcs.luaeval('"' .. s .. '"'))
+ eq(s, fn.luaeval('"' .. s .. '"'))
end)
end)
@@ -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.nvim_get_current_line())
+ eq("hey eval", api.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.nvim_get_current_line())
+ eq("hey there", api.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.nvim_get_current_line())
+ eq("hey command", api.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.nvim_set_option_value('omnifunc', 'v:lua.mymod.omni', {})
+ api.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.nvim_set_option_value('operatorfunc', 'v:lua.mymod.noisy', {})
+ api.nvim_set_option_value('operatorfunc', 'v:lua.mymod.noisy', {})
feed('<Esc>g@g@')
- eq("hey line", meths.nvim_get_current_line())
+ eq("hey line", api.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 12110a86c9..ecbdde3bfd 100644
--- a/test/functional/lua/overrides_spec.lua
+++ b/test/functional/lua/overrides_spec.lua
@@ -6,8 +6,8 @@ local eq = helpers.eq
local NIL = vim.NIL
local feed = helpers.feed
local clear = helpers.clear
-local funcs = helpers.funcs
-local meths = helpers.meths
+local fn = helpers.fn
+local api = helpers.api
local command = helpers.command
local write_file = helpers.write_file
local exec_capture = helpers.exec_capture
@@ -25,15 +25,15 @@ end)
describe('print', function()
it('returns nothing', function()
- eq(NIL, funcs.luaeval('print("abc")'))
- eq(0, funcs.luaeval('select("#", print("abc"))'))
+ eq(NIL, fn.luaeval('print("abc")'))
+ eq(0, fn.luaeval('select("#", print("abc"))'))
end)
it('allows catching printed text with :execute', function()
- eq('\nabc', funcs.execute('lua print("abc")'))
- eq('\nabc', funcs.execute('luado print("abc")'))
- eq('\nabc', funcs.execute('call luaeval("print(\'abc\')")'))
+ eq('\nabc', fn.execute('lua print("abc")'))
+ eq('\nabc', fn.execute('luado print("abc")'))
+ eq('\nabc', fn.execute('call luaeval("print(\'abc\')")'))
write_file(fname, 'print("abc")')
- eq('\nabc', funcs.execute('luafile ' .. fname))
+ eq('\nabc', fn.execute('luafile ' .. fname))
eq('abc', exec_capture('lua print("abc")'))
eq('abc', exec_capture('luado print("abc")'))
@@ -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.nvim_set_option_value('more', true, {})
+ api.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")]])
@@ -332,17 +332,17 @@ end)
describe('os.getenv', function()
it('returns nothing for undefined env var', function()
- eq(NIL, funcs.luaeval('os.getenv("XTEST_1")'))
+ eq(NIL, fn.luaeval('os.getenv("XTEST_1")'))
end)
it('returns env var set by the parent process', function()
local value = 'foo'
clear({ env = { ['XTEST_1'] = value } })
- eq(value, funcs.luaeval('os.getenv("XTEST_1")'))
+ eq(value, fn.luaeval('os.getenv("XTEST_1")'))
end)
it('returns env var set by let', function()
local value = 'foo'
command('let $XTEST_1 = "' .. value .. '"')
- eq(value, funcs.luaeval('os.getenv("XTEST_1")'))
+ eq(value, fn.luaeval('os.getenv("XTEST_1")'))
end)
end)
diff --git a/test/functional/lua/runtime_spec.lua b/test/functional/lua/runtime_spec.lua
index 84948490ae..6f36ccfb9e 100644
--- a/test/functional/lua/runtime_spec.lua
+++ b/test/functional/lua/runtime_spec.lua
@@ -4,7 +4,7 @@ local clear = helpers.clear
local eq = helpers.eq
local eval = helpers.eval
local exec = helpers.exec
-local funcs = helpers.funcs
+local fn = helpers.fn
local mkdir_p = helpers.mkdir_p
local rmdir = helpers.rmdir
local write_file = helpers.write_file
@@ -48,8 +48,8 @@ describe('runtime:', function()
local colorscheme_file = table.concat({ colorscheme_folder, 'new_colorscheme.lua' }, sep)
write_file(colorscheme_file, [[vim.g.lua_colorscheme = 1]])
- eq({ 'new_colorscheme' }, funcs.getcompletion('new_c', 'color'))
- eq({ 'colors/new_colorscheme.lua' }, funcs.getcompletion('colors/new_c', 'runtime'))
+ eq({ 'new_colorscheme' }, fn.getcompletion('new_c', 'color'))
+ eq({ 'colors/new_colorscheme.lua' }, fn.getcompletion('colors/new_c', 'runtime'))
exec('colorscheme new_colorscheme')
@@ -126,8 +126,8 @@ describe('runtime:', function()
local compiler_file = compiler_folder .. sep .. 'new_compiler.lua'
write_file(compiler_file, [[vim.b.lua_compiler = 1]])
- eq({ 'new_compiler' }, funcs.getcompletion('new_c', 'compiler'))
- eq({ 'compiler/new_compiler.lua' }, funcs.getcompletion('compiler/new_c', 'runtime'))
+ eq({ 'new_compiler' }, fn.getcompletion('new_c', 'compiler'))
+ eq({ 'compiler/new_compiler.lua' }, fn.getcompletion('compiler/new_c', 'runtime'))
exec('compiler new_compiler')
@@ -168,8 +168,8 @@ describe('runtime:', function()
local ftplugin_file = table.concat({ ftplugin_folder, 'new-ft.lua' }, sep)
write_file(ftplugin_file, [[vim.b.lua_ftplugin = 1]])
- eq({ 'new-ft' }, funcs.getcompletion('new-f', 'filetype'))
- eq({ 'ftplugin/new-ft.lua' }, funcs.getcompletion('ftplugin/new-f', 'runtime'))
+ eq({ 'new-ft' }, fn.getcompletion('new-f', 'filetype'))
+ eq({ 'ftplugin/new-ft.lua' }, fn.getcompletion('ftplugin/new-f', 'runtime'))
exec [[set filetype=new-ft]]
eq(1, eval('b:lua_ftplugin'))
@@ -281,8 +281,8 @@ describe('runtime:', function()
local indent_file = table.concat({ indent_folder, 'new-ft.lua' }, sep)
write_file(indent_file, [[vim.b.lua_indent = 1]])
- eq({ 'new-ft' }, funcs.getcompletion('new-f', 'filetype'))
- eq({ 'indent/new-ft.lua' }, funcs.getcompletion('indent/new-f', 'runtime'))
+ eq({ 'new-ft' }, fn.getcompletion('new-f', 'filetype'))
+ eq({ 'indent/new-ft.lua' }, fn.getcompletion('indent/new-f', 'runtime'))
exec [[set filetype=new-ft]]
eq(1, eval('b:lua_indent'))
@@ -338,9 +338,9 @@ describe('runtime:', function()
end)
it('lua syntaxes are included in cmdline completion', function()
- eq({ 'my-lang' }, funcs.getcompletion('my-l', 'filetype'))
- eq({ 'my-lang' }, funcs.getcompletion('my-l', 'syntax'))
- eq({ 'syntax/my-lang.lua' }, funcs.getcompletion('syntax/my-l', 'runtime'))
+ eq({ 'my-lang' }, fn.getcompletion('my-l', 'filetype'))
+ eq({ 'my-lang' }, fn.getcompletion('my-l', 'syntax'))
+ eq({ 'syntax/my-lang.lua' }, fn.getcompletion('syntax/my-l', 'runtime'))
end)
it("'rtp' order is respected", function()
diff --git a/test/functional/lua/secure_spec.lua b/test/functional/lua/secure_spec.lua
index 0773988256..7aed711b23 100644
--- a/test/functional/lua/secure_spec.lua
+++ b/test/functional/lua/secure_spec.lua
@@ -6,11 +6,11 @@ local clear = helpers.clear
local command = helpers.command
local pathsep = helpers.get_pathsep()
local is_os = helpers.is_os
-local meths = helpers.meths
+local api = helpers.api
local exec_lua = helpers.exec_lua
local feed_command = helpers.feed_command
local feed = helpers.feed
-local funcs = helpers.funcs
+local fn = helpers.fn
local pcall_err = helpers.pcall_err
local matches = helpers.matches
@@ -45,7 +45,7 @@ describe('vim.secure', function()
})
--- XXX: screen:expect() may fail if this path is too long.
- local cwd = funcs.getcwd()
+ local cwd = fn.getcwd()
-- Need to use feed_command instead of exec_lua because of the confirmation prompt
feed_command([[lua vim.secure.read('Xfile')]])
@@ -71,11 +71,11 @@ describe('vim.secure', function()
]],
}
- local trust = helpers.read_file(funcs.stdpath('state') .. pathsep .. 'trust')
+ local trust = helpers.read_file(fn.stdpath('state') .. pathsep .. 'trust')
eq(string.format('! %s', cwd .. pathsep .. 'Xfile'), vim.trim(trust))
eq(vim.NIL, exec_lua([[return vim.secure.read('Xfile')]]))
- os.remove(funcs.stdpath('state') .. pathsep .. 'trust')
+ os.remove(fn.stdpath('state') .. pathsep .. 'trust')
feed_command([[lua vim.secure.read('Xfile')]])
screen:expect {
@@ -100,12 +100,12 @@ describe('vim.secure', function()
]],
}
- local hash = funcs.sha256(helpers.read_file('Xfile'))
- trust = helpers.read_file(funcs.stdpath('state') .. pathsep .. 'trust')
+ local hash = fn.sha256(helpers.read_file('Xfile'))
+ trust = helpers.read_file(fn.stdpath('state') .. pathsep .. 'trust')
eq(string.format('%s %s', hash, cwd .. pathsep .. 'Xfile'), vim.trim(trust))
eq(vim.NIL, exec_lua([[vim.secure.read('Xfile')]]))
- os.remove(funcs.stdpath('state') .. pathsep .. 'trust')
+ os.remove(fn.stdpath('state') .. pathsep .. 'trust')
feed_command([[lua vim.secure.read('Xfile')]])
screen:expect {
@@ -131,7 +131,7 @@ describe('vim.secure', function()
}
-- Trust database is not updated
- trust = helpers.read_file(funcs.stdpath('state') .. pathsep .. 'trust')
+ trust = helpers.read_file(fn.stdpath('state') .. pathsep .. 'trust')
eq(nil, trust)
feed_command([[lua vim.secure.read('Xfile')]])
@@ -154,7 +154,7 @@ describe('vim.secure', function()
^let g:foobar = 42 |
{1:~ }|*2
{2:]]
- .. funcs.fnamemodify(cwd, ':~')
+ .. fn.fnamemodify(cwd, ':~')
.. pathsep
.. [[Xfile [RO]{MATCH:%s+}}|
|
@@ -165,12 +165,12 @@ describe('vim.secure', function()
}
-- Trust database is not updated
- trust = helpers.read_file(funcs.stdpath('state') .. pathsep .. 'trust')
+ trust = helpers.read_file(fn.stdpath('state') .. pathsep .. 'trust')
eq(nil, trust)
-- Cannot write file
pcall_err(command, 'write')
- eq(true, meths.nvim_get_option_value('readonly', {}))
+ eq(true, api.nvim_get_option_value('readonly', {}))
end)
end)
@@ -209,71 +209,71 @@ describe('vim.secure', function()
end)
it('trust then deny then remove a file using bufnr', function()
- local cwd = funcs.getcwd()
- local hash = funcs.sha256(helpers.read_file('test_file'))
+ local cwd = fn.getcwd()
+ local hash = fn.sha256(helpers.read_file('test_file'))
local full_path = cwd .. pathsep .. 'test_file'
command('edit test_file')
eq({ true, full_path }, exec_lua([[return {vim.secure.trust({action='allow', bufnr=0})}]]))
- local trust = helpers.read_file(funcs.stdpath('state') .. pathsep .. 'trust')
+ local trust = helpers.read_file(fn.stdpath('state') .. pathsep .. 'trust')
eq(string.format('%s %s', hash, full_path), vim.trim(trust))
eq({ true, full_path }, exec_lua([[return {vim.secure.trust({action='deny', bufnr=0})}]]))
- trust = helpers.read_file(funcs.stdpath('state') .. pathsep .. 'trust')
+ trust = helpers.read_file(fn.stdpath('state') .. pathsep .. 'trust')
eq(string.format('! %s', full_path), vim.trim(trust))
eq({ true, full_path }, exec_lua([[return {vim.secure.trust({action='remove', bufnr=0})}]]))
- trust = helpers.read_file(funcs.stdpath('state') .. pathsep .. 'trust')
+ trust = helpers.read_file(fn.stdpath('state') .. pathsep .. 'trust')
eq('', vim.trim(trust))
end)
it('deny then trust then remove a file using bufnr', function()
- local cwd = funcs.getcwd()
- local hash = funcs.sha256(helpers.read_file('test_file'))
+ local cwd = fn.getcwd()
+ local hash = fn.sha256(helpers.read_file('test_file'))
local full_path = cwd .. pathsep .. 'test_file'
command('edit test_file')
eq({ true, full_path }, exec_lua([[return {vim.secure.trust({action='deny', bufnr=0})}]]))
- local trust = helpers.read_file(funcs.stdpath('state') .. pathsep .. 'trust')
+ local trust = helpers.read_file(fn.stdpath('state') .. pathsep .. 'trust')
eq(string.format('! %s', full_path), vim.trim(trust))
eq({ true, full_path }, exec_lua([[return {vim.secure.trust({action='allow', bufnr=0})}]]))
- trust = helpers.read_file(funcs.stdpath('state') .. pathsep .. 'trust')
+ trust = helpers.read_file(fn.stdpath('state') .. pathsep .. 'trust')
eq(string.format('%s %s', hash, full_path), vim.trim(trust))
eq({ true, full_path }, exec_lua([[return {vim.secure.trust({action='remove', bufnr=0})}]]))
- trust = helpers.read_file(funcs.stdpath('state') .. pathsep .. 'trust')
+ trust = helpers.read_file(fn.stdpath('state') .. pathsep .. 'trust')
eq('', vim.trim(trust))
end)
it('trust using bufnr then deny then remove a file using path', function()
- local cwd = funcs.getcwd()
- local hash = funcs.sha256(helpers.read_file('test_file'))
+ local cwd = fn.getcwd()
+ local hash = fn.sha256(helpers.read_file('test_file'))
local full_path = cwd .. pathsep .. 'test_file'
command('edit test_file')
eq({ true, full_path }, exec_lua([[return {vim.secure.trust({action='allow', bufnr=0})}]]))
- local trust = helpers.read_file(funcs.stdpath('state') .. pathsep .. 'trust')
+ local trust = helpers.read_file(fn.stdpath('state') .. pathsep .. 'trust')
eq(string.format('%s %s', hash, full_path), vim.trim(trust))
eq(
{ true, full_path },
exec_lua([[return {vim.secure.trust({action='deny', path='test_file'})}]])
)
- trust = helpers.read_file(funcs.stdpath('state') .. pathsep .. 'trust')
+ trust = helpers.read_file(fn.stdpath('state') .. pathsep .. 'trust')
eq(string.format('! %s', full_path), vim.trim(trust))
eq(
{ true, full_path },
exec_lua([[return {vim.secure.trust({action='remove', path='test_file'})}]])
)
- trust = helpers.read_file(funcs.stdpath('state') .. pathsep .. 'trust')
+ trust = helpers.read_file(fn.stdpath('state') .. pathsep .. 'trust')
eq('', vim.trim(trust))
end)
it('deny then trust then remove a file using bufnr', function()
- local cwd = funcs.getcwd()
- local hash = funcs.sha256(helpers.read_file('test_file'))
+ local cwd = fn.getcwd()
+ local hash = fn.sha256(helpers.read_file('test_file'))
local full_path = cwd .. pathsep .. 'test_file'
command('edit test_file')
@@ -281,18 +281,18 @@ describe('vim.secure', function()
{ true, full_path },
exec_lua([[return {vim.secure.trust({action='deny', path='test_file'})}]])
)
- local trust = helpers.read_file(funcs.stdpath('state') .. pathsep .. 'trust')
+ local trust = helpers.read_file(fn.stdpath('state') .. pathsep .. 'trust')
eq(string.format('! %s', full_path), vim.trim(trust))
eq({ true, full_path }, exec_lua([[return {vim.secure.trust({action='allow', bufnr=0})}]]))
- trust = helpers.read_file(funcs.stdpath('state') .. pathsep .. 'trust')
+ trust = helpers.read_file(fn.stdpath('state') .. pathsep .. 'trust')
eq(string.format('%s %s', hash, full_path), vim.trim(trust))
eq(
{ true, full_path },
exec_lua([[return {vim.secure.trust({action='remove', path='test_file'})}]])
)
- trust = helpers.read_file(funcs.stdpath('state') .. pathsep .. 'trust')
+ trust = helpers.read_file(fn.stdpath('state') .. pathsep .. 'trust')
eq('', vim.trim(trust))
end)
diff --git a/test/functional/lua/ui_event_spec.lua b/test/functional/lua/ui_event_spec.lua
index 9f9e5271de..3e46018682 100644
--- a/test/functional/lua/ui_event_spec.lua
+++ b/test/functional/lua/ui_event_spec.lua
@@ -4,7 +4,7 @@ local eq = helpers.eq
local exec_lua = helpers.exec_lua
local clear = helpers.clear
local feed = helpers.feed
-local funcs = helpers.funcs
+local fn = helpers.fn
describe('vim.ui_attach', function()
local screen
@@ -51,7 +51,7 @@ describe('vim.ui_attach', function()
]],
}
- funcs.complete(1, { 'food', 'foobar', 'foo' })
+ fn.complete(1, { 'food', 'foobar', 'foo' })
screen:expect {
grid = [[
food^ |
@@ -107,7 +107,7 @@ describe('vim.ui_attach', function()
end)
it('does not crash on exit', function()
- funcs.system({
+ fn.system({
helpers.nvim_prog,
'-u',
'NONE',
diff --git a/test/functional/lua/vim_spec.lua b/test/functional/lua/vim_spec.lua
index e938f05703..73fb4c1917 100644
--- a/test/functional/lua/vim_spec.lua
+++ b/test/functional/lua/vim_spec.lua
@@ -3,8 +3,8 @@ local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local nvim_prog = helpers.nvim_prog
-local funcs = helpers.funcs
-local meths = helpers.meths
+local fn = helpers.fn
+local api = helpers.api
local command = helpers.command
local dedent = helpers.dedent
local insert = helpers.insert
@@ -39,93 +39,93 @@ describe('lua stdlib', function()
-- Note: Built-in Nvim comparison (on systems lacking `strcasecmp`) works
-- only on ASCII characters.
it('vim.stricmp', function()
- eq(0, funcs.luaeval('vim.stricmp("a", "A")'))
- eq(0, funcs.luaeval('vim.stricmp("A", "a")'))
- eq(0, funcs.luaeval('vim.stricmp("a", "a")'))
- eq(0, funcs.luaeval('vim.stricmp("A", "A")'))
-
- eq(0, funcs.luaeval('vim.stricmp("", "")'))
- eq(0, funcs.luaeval('vim.stricmp("\\0", "\\0")'))
- eq(0, funcs.luaeval('vim.stricmp("\\0\\0", "\\0\\0")'))
- eq(0, funcs.luaeval('vim.stricmp("\\0\\0\\0", "\\0\\0\\0")'))
- eq(0, funcs.luaeval('vim.stricmp("\\0\\0\\0A", "\\0\\0\\0a")'))
- eq(0, funcs.luaeval('vim.stricmp("\\0\\0\\0a", "\\0\\0\\0A")'))
- eq(0, funcs.luaeval('vim.stricmp("\\0\\0\\0a", "\\0\\0\\0a")'))
-
- eq(0, funcs.luaeval('vim.stricmp("a\\0", "A\\0")'))
- eq(0, funcs.luaeval('vim.stricmp("A\\0", "a\\0")'))
- eq(0, funcs.luaeval('vim.stricmp("a\\0", "a\\0")'))
- eq(0, funcs.luaeval('vim.stricmp("A\\0", "A\\0")'))
-
- eq(0, funcs.luaeval('vim.stricmp("\\0a", "\\0A")'))
- eq(0, funcs.luaeval('vim.stricmp("\\0A", "\\0a")'))
- eq(0, funcs.luaeval('vim.stricmp("\\0a", "\\0a")'))
- eq(0, funcs.luaeval('vim.stricmp("\\0A", "\\0A")'))
-
- eq(0, funcs.luaeval('vim.stricmp("\\0a\\0", "\\0A\\0")'))
- eq(0, funcs.luaeval('vim.stricmp("\\0A\\0", "\\0a\\0")'))
- eq(0, funcs.luaeval('vim.stricmp("\\0a\\0", "\\0a\\0")'))
- eq(0, funcs.luaeval('vim.stricmp("\\0A\\0", "\\0A\\0")'))
-
- eq(-1, funcs.luaeval('vim.stricmp("a", "B")'))
- eq(-1, funcs.luaeval('vim.stricmp("A", "b")'))
- eq(-1, funcs.luaeval('vim.stricmp("a", "b")'))
- eq(-1, funcs.luaeval('vim.stricmp("A", "B")'))
-
- eq(-1, funcs.luaeval('vim.stricmp("", "\\0")'))
- eq(-1, funcs.luaeval('vim.stricmp("\\0", "\\0\\0")'))
- eq(-1, funcs.luaeval('vim.stricmp("\\0\\0", "\\0\\0\\0")'))
- eq(-1, funcs.luaeval('vim.stricmp("\\0\\0\\0A", "\\0\\0\\0b")'))
- eq(-1, funcs.luaeval('vim.stricmp("\\0\\0\\0a", "\\0\\0\\0B")'))
- eq(-1, funcs.luaeval('vim.stricmp("\\0\\0\\0a", "\\0\\0\\0b")'))
-
- eq(-1, funcs.luaeval('vim.stricmp("a\\0", "B\\0")'))
- eq(-1, funcs.luaeval('vim.stricmp("A\\0", "b\\0")'))
- eq(-1, funcs.luaeval('vim.stricmp("a\\0", "b\\0")'))
- eq(-1, funcs.luaeval('vim.stricmp("A\\0", "B\\0")'))
-
- eq(-1, funcs.luaeval('vim.stricmp("\\0a", "\\0B")'))
- eq(-1, funcs.luaeval('vim.stricmp("\\0A", "\\0b")'))
- eq(-1, funcs.luaeval('vim.stricmp("\\0a", "\\0b")'))
- eq(-1, funcs.luaeval('vim.stricmp("\\0A", "\\0B")'))
-
- eq(-1, funcs.luaeval('vim.stricmp("\\0a\\0", "\\0B\\0")'))
- eq(-1, funcs.luaeval('vim.stricmp("\\0A\\0", "\\0b\\0")'))
- eq(-1, funcs.luaeval('vim.stricmp("\\0a\\0", "\\0b\\0")'))
- eq(-1, funcs.luaeval('vim.stricmp("\\0A\\0", "\\0B\\0")'))
-
- eq(1, funcs.luaeval('vim.stricmp("c", "B")'))
- eq(1, funcs.luaeval('vim.stricmp("C", "b")'))
- eq(1, funcs.luaeval('vim.stricmp("c", "b")'))
- eq(1, funcs.luaeval('vim.stricmp("C", "B")'))
-
- eq(1, funcs.luaeval('vim.stricmp("\\0", "")'))
- eq(1, funcs.luaeval('vim.stricmp("\\0\\0", "\\0")'))
- eq(1, funcs.luaeval('vim.stricmp("\\0\\0\\0", "\\0\\0")'))
- eq(1, funcs.luaeval('vim.stricmp("\\0\\0\\0\\0", "\\0\\0\\0")'))
- eq(1, funcs.luaeval('vim.stricmp("\\0\\0\\0C", "\\0\\0\\0b")'))
- eq(1, funcs.luaeval('vim.stricmp("\\0\\0\\0c", "\\0\\0\\0B")'))
- eq(1, funcs.luaeval('vim.stricmp("\\0\\0\\0c", "\\0\\0\\0b")'))
-
- eq(1, funcs.luaeval('vim.stricmp("c\\0", "B\\0")'))
- eq(1, funcs.luaeval('vim.stricmp("C\\0", "b\\0")'))
- eq(1, funcs.luaeval('vim.stricmp("c\\0", "b\\0")'))
- eq(1, funcs.luaeval('vim.stricmp("C\\0", "B\\0")'))
-
- eq(1, funcs.luaeval('vim.stricmp("c\\0", "B")'))
- eq(1, funcs.luaeval('vim.stricmp("C\\0", "b")'))
- eq(1, funcs.luaeval('vim.stricmp("c\\0", "b")'))
- eq(1, funcs.luaeval('vim.stricmp("C\\0", "B")'))
-
- eq(1, funcs.luaeval('vim.stricmp("\\0c", "\\0B")'))
- eq(1, funcs.luaeval('vim.stricmp("\\0C", "\\0b")'))
- eq(1, funcs.luaeval('vim.stricmp("\\0c", "\\0b")'))
- eq(1, funcs.luaeval('vim.stricmp("\\0C", "\\0B")'))
-
- eq(1, funcs.luaeval('vim.stricmp("\\0c\\0", "\\0B\\0")'))
- eq(1, funcs.luaeval('vim.stricmp("\\0C\\0", "\\0b\\0")'))
- eq(1, funcs.luaeval('vim.stricmp("\\0c\\0", "\\0b\\0")'))
- eq(1, funcs.luaeval('vim.stricmp("\\0C\\0", "\\0B\\0")'))
+ eq(0, fn.luaeval('vim.stricmp("a", "A")'))
+ eq(0, fn.luaeval('vim.stricmp("A", "a")'))
+ eq(0, fn.luaeval('vim.stricmp("a", "a")'))
+ eq(0, fn.luaeval('vim.stricmp("A", "A")'))
+
+ eq(0, fn.luaeval('vim.stricmp("", "")'))
+ eq(0, fn.luaeval('vim.stricmp("\\0", "\\0")'))
+ eq(0, fn.luaeval('vim.stricmp("\\0\\0", "\\0\\0")'))
+ eq(0, fn.luaeval('vim.stricmp("\\0\\0\\0", "\\0\\0\\0")'))
+ eq(0, fn.luaeval('vim.stricmp("\\0\\0\\0A", "\\0\\0\\0a")'))
+ eq(0, fn.luaeval('vim.stricmp("\\0\\0\\0a", "\\0\\0\\0A")'))
+ eq(0, fn.luaeval('vim.stricmp("\\0\\0\\0a", "\\0\\0\\0a")'))
+
+ eq(0, fn.luaeval('vim.stricmp("a\\0", "A\\0")'))
+ eq(0, fn.luaeval('vim.stricmp("A\\0", "a\\0")'))
+ eq(0, fn.luaeval('vim.stricmp("a\\0", "a\\0")'))
+ eq(0, fn.luaeval('vim.stricmp("A\\0", "A\\0")'))
+
+ eq(0, fn.luaeval('vim.stricmp("\\0a", "\\0A")'))
+ eq(0, fn.luaeval('vim.stricmp("\\0A", "\\0a")'))
+ eq(0, fn.luaeval('vim.stricmp("\\0a", "\\0a")'))
+ eq(0, fn.luaeval('vim.stricmp("\\0A", "\\0A")'))
+
+ eq(0, fn.luaeval('vim.stricmp("\\0a\\0", "\\0A\\0")'))
+ eq(0, fn.luaeval('vim.stricmp("\\0A\\0", "\\0a\\0")'))
+ eq(0, fn.luaeval('vim.stricmp("\\0a\\0", "\\0a\\0")'))
+ eq(0, fn.luaeval('vim.stricmp("\\0A\\0", "\\0A\\0")'))
+
+ eq(-1, fn.luaeval('vim.stricmp("a", "B")'))
+ eq(-1, fn.luaeval('vim.stricmp("A", "b")'))
+ eq(-1, fn.luaeval('vim.stricmp("a", "b")'))
+ eq(-1, fn.luaeval('vim.stricmp("A", "B")'))
+
+ eq(-1, fn.luaeval('vim.stricmp("", "\\0")'))
+ eq(-1, fn.luaeval('vim.stricmp("\\0", "\\0\\0")'))
+ eq(-1, fn.luaeval('vim.stricmp("\\0\\0", "\\0\\0\\0")'))
+ eq(-1, fn.luaeval('vim.stricmp("\\0\\0\\0A", "\\0\\0\\0b")'))
+ eq(-1, fn.luaeval('vim.stricmp("\\0\\0\\0a", "\\0\\0\\0B")'))
+ eq(-1, fn.luaeval('vim.stricmp("\\0\\0\\0a", "\\0\\0\\0b")'))
+
+ eq(-1, fn.luaeval('vim.stricmp("a\\0", "B\\0")'))
+ eq(-1, fn.luaeval('vim.stricmp("A\\0", "b\\0")'))
+ eq(-1, fn.luaeval('vim.stricmp("a\\0", "b\\0")'))
+ eq(-1, fn.luaeval('vim.stricmp("A\\0", "B\\0")'))
+
+ eq(-1, fn.luaeval('vim.stricmp("\\0a", "\\0B")'))
+ eq(-1, fn.luaeval('vim.stricmp("\\0A", "\\0b")'))
+ eq(-1, fn.luaeval('vim.stricmp("\\0a", "\\0b")'))
+ eq(-1, fn.luaeval('vim.stricmp("\\0A", "\\0B")'))
+
+ eq(-1, fn.luaeval('vim.stricmp("\\0a\\0", "\\0B\\0")'))
+ eq(-1, fn.luaeval('vim.stricmp("\\0A\\0", "\\0b\\0")'))
+ eq(-1, fn.luaeval('vim.stricmp("\\0a\\0", "\\0b\\0")'))
+ eq(-1, fn.luaeval('vim.stricmp("\\0A\\0", "\\0B\\0")'))
+
+ eq(1, fn.luaeval('vim.stricmp("c", "B")'))
+ eq(1, fn.luaeval('vim.stricmp("C", "b")'))
+ eq(1, fn.luaeval('vim.stricmp("c", "b")'))
+ eq(1, fn.luaeval('vim.stricmp("C", "B")'))
+
+ eq(1, fn.luaeval('vim.stricmp("\\0", "")'))
+ eq(1, fn.luaeval('vim.stricmp("\\0\\0", "\\0")'))
+ eq(1, fn.luaeval('vim.stricmp("\\0\\0\\0", "\\0\\0")'))
+ eq(1, fn.luaeval('vim.stricmp("\\0\\0\\0\\0", "\\0\\0\\0")'))
+ eq(1, fn.luaeval('vim.stricmp("\\0\\0\\0C", "\\0\\0\\0b")'))
+ eq(1, fn.luaeval('vim.stricmp("\\0\\0\\0c", "\\0\\0\\0B")'))
+ eq(1, fn.luaeval('vim.stricmp("\\0\\0\\0c", "\\0\\0\\0b")'))
+
+ eq(1, fn.luaeval('vim.stricmp("c\\0", "B\\0")'))
+ eq(1, fn.luaeval('vim.stricmp("C\\0", "b\\0")'))
+ eq(1, fn.luaeval('vim.stricmp("c\\0", "b\\0")'))
+ eq(1, fn.luaeval('vim.stricmp("C\\0", "B\\0")'))
+
+ eq(1, fn.luaeval('vim.stricmp("c\\0", "B")'))
+ eq(1, fn.luaeval('vim.stricmp("C\\0", "b")'))
+ eq(1, fn.luaeval('vim.stricmp("c\\0", "b")'))
+ eq(1, fn.luaeval('vim.stricmp("C\\0", "B")'))
+
+ eq(1, fn.luaeval('vim.stricmp("\\0c", "\\0B")'))
+ eq(1, fn.luaeval('vim.stricmp("\\0C", "\\0b")'))
+ eq(1, fn.luaeval('vim.stricmp("\\0c", "\\0b")'))
+ eq(1, fn.luaeval('vim.stricmp("\\0C", "\\0B")'))
+
+ eq(1, fn.luaeval('vim.stricmp("\\0c\\0", "\\0B\\0")'))
+ eq(1, fn.luaeval('vim.stricmp("\\0C\\0", "\\0b\\0")'))
+ eq(1, fn.luaeval('vim.stricmp("\\0c\\0", "\\0b\\0")'))
+ eq(1, fn.luaeval('vim.stricmp("\\0C\\0", "\\0B\\0")'))
end)
it('vim.deprecate', function()
@@ -157,14 +157,14 @@ describe('lua stdlib', function()
end)
it('vim.startswith', function()
- eq(true, funcs.luaeval('vim.startswith("123", "1")'))
- eq(true, funcs.luaeval('vim.startswith("123", "")'))
- eq(true, funcs.luaeval('vim.startswith("123", "123")'))
- eq(true, funcs.luaeval('vim.startswith("", "")'))
+ eq(true, fn.luaeval('vim.startswith("123", "1")'))
+ eq(true, fn.luaeval('vim.startswith("123", "")'))
+ eq(true, fn.luaeval('vim.startswith("123", "123")'))
+ eq(true, fn.luaeval('vim.startswith("", "")'))
- eq(false, funcs.luaeval('vim.startswith("123", " ")'))
- eq(false, funcs.luaeval('vim.startswith("123", "2")'))
- eq(false, funcs.luaeval('vim.startswith("123", "1234")'))
+ eq(false, fn.luaeval('vim.startswith("123", " ")'))
+ eq(false, fn.luaeval('vim.startswith("123", "2")'))
+ eq(false, fn.luaeval('vim.startswith("123", "1234")'))
matches(
'prefix: expected string, got nil',
@@ -174,14 +174,14 @@ describe('lua stdlib', function()
end)
it('vim.endswith', function()
- eq(true, funcs.luaeval('vim.endswith("123", "3")'))
- eq(true, funcs.luaeval('vim.endswith("123", "")'))
- eq(true, funcs.luaeval('vim.endswith("123", "123")'))
- eq(true, funcs.luaeval('vim.endswith("", "")'))
+ eq(true, fn.luaeval('vim.endswith("123", "3")'))
+ eq(true, fn.luaeval('vim.endswith("123", "")'))
+ eq(true, fn.luaeval('vim.endswith("123", "123")'))
+ eq(true, fn.luaeval('vim.endswith("", "")'))
- eq(false, funcs.luaeval('vim.endswith("123", " ")'))
- eq(false, funcs.luaeval('vim.endswith("123", "2")'))
- eq(false, funcs.luaeval('vim.endswith("123", "1234")'))
+ eq(false, fn.luaeval('vim.endswith("123", " ")'))
+ eq(false, fn.luaeval('vim.endswith("123", "2")'))
+ eq(false, fn.luaeval('vim.endswith("123", "1234")'))
matches(
'suffix: expected string, got nil',
@@ -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.nvim_get_current_line())
+ eq('meow', api.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.nvim_get_current_line())
+ eq('foo', api.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.nvim_get_var('yy'))
+ eq({ 3, NIL }, api.nvim_get_var('yy'))
exec_lua([[timer:close()]])
end)
@@ -1426,11 +1426,11 @@ describe('lua stdlib', function()
vim.api.nvim_set_var("to_delete", {hello="world"})
]]
- eq('hi', funcs.luaeval 'vim.g.testing')
- eq(123, funcs.luaeval 'vim.g.other')
- eq(5120.1, funcs.luaeval 'vim.g.floaty')
- eq(NIL, funcs.luaeval 'vim.g.nonexistent')
- eq(NIL, funcs.luaeval 'vim.g.nullvar')
+ eq('hi', fn.luaeval 'vim.g.testing')
+ eq(123, fn.luaeval 'vim.g.other')
+ eq(5120.1, fn.luaeval 'vim.g.floaty')
+ eq(NIL, fn.luaeval 'vim.g.nonexistent')
+ eq(NIL, fn.luaeval 'vim.g.nullvar')
-- lost over RPC, so test locally:
eq(
{ false, true },
@@ -1439,11 +1439,11 @@ describe('lua stdlib', function()
]]
)
- eq({ hello = 'world' }, funcs.luaeval 'vim.g.to_delete')
+ eq({ hello = 'world' }, fn.luaeval 'vim.g.to_delete')
exec_lua [[
vim.g.to_delete = nil
]]
- eq(NIL, funcs.luaeval 'vim.g.to_delete')
+ eq(NIL, fn.luaeval 'vim.g.to_delete')
matches([[attempt to index .* nil value]], pcall_err(exec_lua, 'return vim.g[0].testing'))
@@ -1453,7 +1453,7 @@ describe('lua stdlib', function()
local function get_counter() return counter end
vim.g.AddCounter = add_counter
vim.g.GetCounter = get_counter
- vim.g.funcs = {add = add_counter, get = get_counter}
+ vim.g.fn = {add = add_counter, get = get_counter}
vim.g.AddParens = function(s) return '(' .. s .. ')' end
]]
@@ -1466,10 +1466,10 @@ describe('lua stdlib', function()
eq(3, exec_lua([[return vim.g.GetCounter()]]))
exec_lua([[vim.api.nvim_get_var('AddCounter')()]])
eq(4, exec_lua([[return vim.api.nvim_get_var('GetCounter')()]]))
- exec_lua([[vim.g.funcs.add()]])
- eq(5, exec_lua([[return vim.g.funcs.get()]]))
- exec_lua([[vim.api.nvim_get_var('funcs').add()]])
- eq(6, exec_lua([[return vim.api.nvim_get_var('funcs').get()]]))
+ exec_lua([[vim.g.fn.add()]])
+ eq(5, exec_lua([[return vim.g.fn.get()]]))
+ exec_lua([[vim.api.nvim_get_var('fn').add()]])
+ eq(6, exec_lua([[return vim.api.nvim_get_var('fn').get()]]))
eq('((foo))', eval([['foo'->AddParens()->AddParens()]]))
exec_lua [[
@@ -1478,7 +1478,7 @@ describe('lua stdlib', function()
local function get_counter() return counter end
vim.api.nvim_set_var('AddCounter', add_counter)
vim.api.nvim_set_var('GetCounter', get_counter)
- vim.api.nvim_set_var('funcs', {add = add_counter, get = get_counter})
+ vim.api.nvim_set_var('fn', {add = add_counter, get = get_counter})
vim.api.nvim_set_var('AddParens', function(s) return '(' .. s .. ')' end)
]]
@@ -1491,10 +1491,10 @@ describe('lua stdlib', function()
eq(3, exec_lua([[return vim.g.GetCounter()]]))
exec_lua([[vim.api.nvim_get_var('AddCounter')()]])
eq(4, exec_lua([[return vim.api.nvim_get_var('GetCounter')()]]))
- exec_lua([[vim.g.funcs.add()]])
- eq(5, exec_lua([[return vim.g.funcs.get()]]))
- exec_lua([[vim.api.nvim_get_var('funcs').add()]])
- eq(6, exec_lua([[return vim.api.nvim_get_var('funcs').get()]]))
+ exec_lua([[vim.g.fn.add()]])
+ eq(5, exec_lua([[return vim.g.fn.get()]]))
+ exec_lua([[vim.api.nvim_get_var('fn').add()]])
+ eq(6, exec_lua([[return vim.api.nvim_get_var('fn').get()]]))
eq('((foo))', eval([['foo'->AddParens()->AddParens()]]))
exec([[
@@ -1534,13 +1534,13 @@ describe('lua stdlib', function()
vim.api.nvim_buf_set_var(BUF, "testing", "bye")
]]
- eq('hi', funcs.luaeval 'vim.b.testing')
- eq('bye', funcs.luaeval 'vim.b[BUF].testing')
- eq(123, funcs.luaeval 'vim.b.other')
- eq(5120.1, funcs.luaeval 'vim.b.floaty')
- eq(NIL, funcs.luaeval 'vim.b.nonexistent')
- eq(NIL, funcs.luaeval 'vim.b[BUF].nonexistent')
- eq(NIL, funcs.luaeval 'vim.b.nullvar')
+ eq('hi', fn.luaeval 'vim.b.testing')
+ eq('bye', fn.luaeval 'vim.b[BUF].testing')
+ eq(123, fn.luaeval 'vim.b.other')
+ eq(5120.1, fn.luaeval 'vim.b.floaty')
+ eq(NIL, fn.luaeval 'vim.b.nonexistent')
+ eq(NIL, fn.luaeval 'vim.b[BUF].nonexistent')
+ eq(NIL, fn.luaeval 'vim.b.nullvar')
-- lost over RPC, so test locally:
eq(
{ false, true },
@@ -1551,11 +1551,11 @@ describe('lua stdlib', function()
matches([[attempt to index .* nil value]], pcall_err(exec_lua, 'return vim.b[BUF][0].testing'))
- eq({ hello = 'world' }, funcs.luaeval 'vim.b.to_delete')
+ eq({ hello = 'world' }, fn.luaeval 'vim.b.to_delete')
exec_lua [[
vim.b.to_delete = nil
]]
- eq(NIL, funcs.luaeval 'vim.b.to_delete')
+ eq(NIL, fn.luaeval 'vim.b.to_delete')
exec_lua [[
local counter = 0
@@ -1563,7 +1563,7 @@ describe('lua stdlib', function()
local function get_counter() return counter end
vim.b.AddCounter = add_counter
vim.b.GetCounter = get_counter
- vim.b.funcs = {add = add_counter, get = get_counter}
+ vim.b.fn = {add = add_counter, get = get_counter}
vim.b.AddParens = function(s) return '(' .. s .. ')' end
]]
@@ -1576,10 +1576,10 @@ describe('lua stdlib', function()
eq(3, exec_lua([[return vim.b.GetCounter()]]))
exec_lua([[vim.api.nvim_buf_get_var(0, 'AddCounter')()]])
eq(4, exec_lua([[return vim.api.nvim_buf_get_var(0, 'GetCounter')()]]))
- exec_lua([[vim.b.funcs.add()]])
- eq(5, exec_lua([[return vim.b.funcs.get()]]))
- exec_lua([[vim.api.nvim_buf_get_var(0, 'funcs').add()]])
- eq(6, exec_lua([[return vim.api.nvim_buf_get_var(0, 'funcs').get()]]))
+ exec_lua([[vim.b.fn.add()]])
+ eq(5, exec_lua([[return vim.b.fn.get()]]))
+ exec_lua([[vim.api.nvim_buf_get_var(0, 'fn').add()]])
+ eq(6, exec_lua([[return vim.api.nvim_buf_get_var(0, 'fn').get()]]))
eq('((foo))', eval([['foo'->b:AddParens()->b:AddParens()]]))
exec_lua [[
@@ -1588,7 +1588,7 @@ describe('lua stdlib', function()
local function get_counter() return counter end
vim.api.nvim_buf_set_var(0, 'AddCounter', add_counter)
vim.api.nvim_buf_set_var(0, 'GetCounter', get_counter)
- vim.api.nvim_buf_set_var(0, 'funcs', {add = add_counter, get = get_counter})
+ vim.api.nvim_buf_set_var(0, 'fn', {add = add_counter, get = get_counter})
vim.api.nvim_buf_set_var(0, 'AddParens', function(s) return '(' .. s .. ')' end)
]]
@@ -1601,10 +1601,10 @@ describe('lua stdlib', function()
eq(3, exec_lua([[return vim.b.GetCounter()]]))
exec_lua([[vim.api.nvim_buf_get_var(0, 'AddCounter')()]])
eq(4, exec_lua([[return vim.api.nvim_buf_get_var(0, 'GetCounter')()]]))
- exec_lua([[vim.b.funcs.add()]])
- eq(5, exec_lua([[return vim.b.funcs.get()]]))
- exec_lua([[vim.api.nvim_buf_get_var(0, 'funcs').add()]])
- eq(6, exec_lua([[return vim.api.nvim_buf_get_var(0, 'funcs').get()]]))
+ exec_lua([[vim.b.fn.add()]])
+ eq(5, exec_lua([[return vim.b.fn.get()]]))
+ exec_lua([[vim.api.nvim_buf_get_var(0, 'fn').add()]])
+ eq(6, exec_lua([[return vim.api.nvim_buf_get_var(0, 'fn').get()]]))
eq('((foo))', eval([['foo'->b:AddParens()->b:AddParens()]]))
exec([[
@@ -1622,9 +1622,9 @@ describe('lua stdlib', function()
vim.cmd "vnew"
]]
- eq(NIL, funcs.luaeval 'vim.b.testing')
- eq(NIL, funcs.luaeval 'vim.b.other')
- eq(NIL, funcs.luaeval 'vim.b.nonexistent')
+ eq(NIL, fn.luaeval 'vim.b.testing')
+ eq(NIL, fn.luaeval 'vim.b.other')
+ eq(NIL, fn.luaeval 'vim.b.nonexistent')
end)
it('vim.w', function()
@@ -1640,19 +1640,19 @@ describe('lua stdlib', function()
vim.api.nvim_win_set_var(WIN, "testing", "bye")
]]
- eq('hi', funcs.luaeval 'vim.w.testing')
- eq('bye', funcs.luaeval 'vim.w[WIN].testing')
- eq(123, funcs.luaeval 'vim.w.other')
- eq(NIL, funcs.luaeval 'vim.w.nonexistent')
- eq(NIL, funcs.luaeval 'vim.w[WIN].nonexistent')
+ eq('hi', fn.luaeval 'vim.w.testing')
+ eq('bye', fn.luaeval 'vim.w[WIN].testing')
+ eq(123, fn.luaeval 'vim.w.other')
+ eq(NIL, fn.luaeval 'vim.w.nonexistent')
+ eq(NIL, fn.luaeval 'vim.w[WIN].nonexistent')
matches([[attempt to index .* nil value]], pcall_err(exec_lua, 'return vim.w[WIN][0].testing'))
- eq({ hello = 'world' }, funcs.luaeval 'vim.w.to_delete')
+ eq({ hello = 'world' }, fn.luaeval 'vim.w.to_delete')
exec_lua [[
vim.w.to_delete = nil
]]
- eq(NIL, funcs.luaeval 'vim.w.to_delete')
+ eq(NIL, fn.luaeval 'vim.w.to_delete')
exec_lua [[
local counter = 0
@@ -1660,7 +1660,7 @@ describe('lua stdlib', function()
local function get_counter() return counter end
vim.w.AddCounter = add_counter
vim.w.GetCounter = get_counter
- vim.w.funcs = {add = add_counter, get = get_counter}
+ vim.w.fn = {add = add_counter, get = get_counter}
vim.w.AddParens = function(s) return '(' .. s .. ')' end
]]
@@ -1673,10 +1673,10 @@ describe('lua stdlib', function()
eq(3, exec_lua([[return vim.w.GetCounter()]]))
exec_lua([[vim.api.nvim_win_get_var(0, 'AddCounter')()]])
eq(4, exec_lua([[return vim.api.nvim_win_get_var(0, 'GetCounter')()]]))
- exec_lua([[vim.w.funcs.add()]])
- eq(5, exec_lua([[return vim.w.funcs.get()]]))
- exec_lua([[vim.api.nvim_win_get_var(0, 'funcs').add()]])
- eq(6, exec_lua([[return vim.api.nvim_win_get_var(0, 'funcs').get()]]))
+ exec_lua([[vim.w.fn.add()]])
+ eq(5, exec_lua([[return vim.w.fn.get()]]))
+ exec_lua([[vim.api.nvim_win_get_var(0, 'fn').add()]])
+ eq(6, exec_lua([[return vim.api.nvim_win_get_var(0, 'fn').get()]]))
eq('((foo))', eval([['foo'->w:AddParens()->w:AddParens()]]))
exec_lua [[
@@ -1685,7 +1685,7 @@ describe('lua stdlib', function()
local function get_counter() return counter end
vim.api.nvim_win_set_var(0, 'AddCounter', add_counter)
vim.api.nvim_win_set_var(0, 'GetCounter', get_counter)
- vim.api.nvim_win_set_var(0, 'funcs', {add = add_counter, get = get_counter})
+ vim.api.nvim_win_set_var(0, 'fn', {add = add_counter, get = get_counter})
vim.api.nvim_win_set_var(0, 'AddParens', function(s) return '(' .. s .. ')' end)
]]
@@ -1698,10 +1698,10 @@ describe('lua stdlib', function()
eq(3, exec_lua([[return vim.w.GetCounter()]]))
exec_lua([[vim.api.nvim_win_get_var(0, 'AddCounter')()]])
eq(4, exec_lua([[return vim.api.nvim_win_get_var(0, 'GetCounter')()]]))
- exec_lua([[vim.w.funcs.add()]])
- eq(5, exec_lua([[return vim.w.funcs.get()]]))
- exec_lua([[vim.api.nvim_win_get_var(0, 'funcs').add()]])
- eq(6, exec_lua([[return vim.api.nvim_win_get_var(0, 'funcs').get()]]))
+ exec_lua([[vim.w.fn.add()]])
+ eq(5, exec_lua([[return vim.w.fn.get()]]))
+ exec_lua([[vim.api.nvim_win_get_var(0, 'fn').add()]])
+ eq(6, exec_lua([[return vim.api.nvim_win_get_var(0, 'fn').get()]]))
eq('((foo))', eval([['foo'->w:AddParens()->w:AddParens()]]))
exec([[
@@ -1719,9 +1719,9 @@ describe('lua stdlib', function()
vim.cmd "vnew"
]]
- eq(NIL, funcs.luaeval 'vim.w.testing')
- eq(NIL, funcs.luaeval 'vim.w.other')
- eq(NIL, funcs.luaeval 'vim.w.nonexistent')
+ eq(NIL, fn.luaeval 'vim.w.testing')
+ eq(NIL, fn.luaeval 'vim.w.other')
+ eq(NIL, fn.luaeval 'vim.w.nonexistent')
end)
it('vim.t', function()
@@ -1731,20 +1731,20 @@ describe('lua stdlib', function()
vim.api.nvim_tabpage_set_var(0, "to_delete", {hello="world"})
]]
- eq('hi', funcs.luaeval 'vim.t.testing')
- eq(123, funcs.luaeval 'vim.t.other')
- eq(NIL, funcs.luaeval 'vim.t.nonexistent')
- eq('hi', funcs.luaeval 'vim.t[0].testing')
- eq(123, funcs.luaeval 'vim.t[0].other')
- eq(NIL, funcs.luaeval 'vim.t[0].nonexistent')
+ eq('hi', fn.luaeval 'vim.t.testing')
+ eq(123, fn.luaeval 'vim.t.other')
+ eq(NIL, fn.luaeval 'vim.t.nonexistent')
+ eq('hi', fn.luaeval 'vim.t[0].testing')
+ eq(123, fn.luaeval 'vim.t[0].other')
+ eq(NIL, fn.luaeval 'vim.t[0].nonexistent')
matches([[attempt to index .* nil value]], pcall_err(exec_lua, 'return vim.t[0][0].testing'))
- eq({ hello = 'world' }, funcs.luaeval 'vim.t.to_delete')
+ eq({ hello = 'world' }, fn.luaeval 'vim.t.to_delete')
exec_lua [[
vim.t.to_delete = nil
]]
- eq(NIL, funcs.luaeval 'vim.t.to_delete')
+ eq(NIL, fn.luaeval 'vim.t.to_delete')
exec_lua [[
local counter = 0
@@ -1752,7 +1752,7 @@ describe('lua stdlib', function()
local function get_counter() return counter end
vim.t.AddCounter = add_counter
vim.t.GetCounter = get_counter
- vim.t.funcs = {add = add_counter, get = get_counter}
+ vim.t.fn = {add = add_counter, get = get_counter}
vim.t.AddParens = function(s) return '(' .. s .. ')' end
]]
@@ -1765,10 +1765,10 @@ describe('lua stdlib', function()
eq(3, exec_lua([[return vim.t.GetCounter()]]))
exec_lua([[vim.api.nvim_tabpage_get_var(0, 'AddCounter')()]])
eq(4, exec_lua([[return vim.api.nvim_tabpage_get_var(0, 'GetCounter')()]]))
- exec_lua([[vim.t.funcs.add()]])
- eq(5, exec_lua([[return vim.t.funcs.get()]]))
- exec_lua([[vim.api.nvim_tabpage_get_var(0, 'funcs').add()]])
- eq(6, exec_lua([[return vim.api.nvim_tabpage_get_var(0, 'funcs').get()]]))
+ exec_lua([[vim.t.fn.add()]])
+ eq(5, exec_lua([[return vim.t.fn.get()]]))
+ exec_lua([[vim.api.nvim_tabpage_get_var(0, 'fn').add()]])
+ eq(6, exec_lua([[return vim.api.nvim_tabpage_get_var(0, 'fn').get()]]))
eq('((foo))', eval([['foo'->t:AddParens()->t:AddParens()]]))
exec_lua [[
@@ -1777,7 +1777,7 @@ describe('lua stdlib', function()
local function get_counter() return counter end
vim.api.nvim_tabpage_set_var(0, 'AddCounter', add_counter)
vim.api.nvim_tabpage_set_var(0, 'GetCounter', get_counter)
- vim.api.nvim_tabpage_set_var(0, 'funcs', {add = add_counter, get = get_counter})
+ vim.api.nvim_tabpage_set_var(0, 'fn', {add = add_counter, get = get_counter})
vim.api.nvim_tabpage_set_var(0, 'AddParens', function(s) return '(' .. s .. ')' end)
]]
@@ -1790,45 +1790,45 @@ describe('lua stdlib', function()
eq(3, exec_lua([[return vim.t.GetCounter()]]))
exec_lua([[vim.api.nvim_tabpage_get_var(0, 'AddCounter')()]])
eq(4, exec_lua([[return vim.api.nvim_tabpage_get_var(0, 'GetCounter')()]]))
- exec_lua([[vim.t.funcs.add()]])
- eq(5, exec_lua([[return vim.t.funcs.get()]]))
- exec_lua([[vim.api.nvim_tabpage_get_var(0, 'funcs').add()]])
- eq(6, exec_lua([[return vim.api.nvim_tabpage_get_var(0, 'funcs').get()]]))
+ exec_lua([[vim.t.fn.add()]])
+ eq(5, exec_lua([[return vim.t.fn.get()]]))
+ exec_lua([[vim.api.nvim_tabpage_get_var(0, 'fn').add()]])
+ eq(6, exec_lua([[return vim.api.nvim_tabpage_get_var(0, 'fn').get()]]))
eq('((foo))', eval([['foo'->t:AddParens()->t:AddParens()]]))
exec_lua [[
vim.cmd "tabnew"
]]
- eq(NIL, funcs.luaeval 'vim.t.testing')
- eq(NIL, funcs.luaeval 'vim.t.other')
- eq(NIL, funcs.luaeval 'vim.t.nonexistent')
+ eq(NIL, fn.luaeval 'vim.t.testing')
+ eq(NIL, fn.luaeval 'vim.t.other')
+ eq(NIL, fn.luaeval 'vim.t.nonexistent')
end)
it('vim.env', function()
exec_lua([[vim.fn.setenv('A', 123)]])
- eq('123', funcs.luaeval('vim.env.A'))
+ eq('123', fn.luaeval('vim.env.A'))
exec_lua([[vim.env.A = 456]])
- eq('456', funcs.luaeval('vim.env.A'))
+ eq('456', fn.luaeval('vim.env.A'))
exec_lua([[vim.env.A = nil]])
- eq(NIL, funcs.luaeval('vim.env.A'))
+ eq(NIL, fn.luaeval('vim.env.A'))
- eq(true, funcs.luaeval('vim.env.B == nil'))
+ eq(true, fn.luaeval('vim.env.B == nil'))
command([[let $HOME = 'foo']])
- eq('foo', funcs.expand('~'))
- eq('foo', funcs.luaeval('vim.env.HOME'))
+ eq('foo', fn.expand('~'))
+ eq('foo', fn.luaeval('vim.env.HOME'))
exec_lua([[vim.env.HOME = nil]])
- eq('foo', funcs.expand('~'))
+ eq('foo', fn.expand('~'))
exec_lua([[vim.env.HOME = 'bar']])
- eq('bar', funcs.expand('~'))
- eq('bar', funcs.luaeval('vim.env.HOME'))
+ eq('bar', fn.expand('~'))
+ eq('bar', fn.luaeval('vim.env.HOME'))
end)
it('vim.v', function()
- eq(funcs.luaeval "vim.api.nvim_get_vvar('progpath')", funcs.luaeval 'vim.v.progpath')
- eq(false, funcs.luaeval "vim.v['false']")
- eq(NIL, funcs.luaeval 'vim.v.null')
+ eq(fn.luaeval "vim.api.nvim_get_vvar('progpath')", fn.luaeval 'vim.v.progpath')
+ eq(false, fn.luaeval "vim.v['false']")
+ eq(NIL, fn.luaeval 'vim.v.null')
matches([[attempt to index .* nil value]], pcall_err(exec_lua, 'return vim.v[0].progpath'))
eq('Key is read-only: count', pcall_err(exec_lua, [[vim.v.count = 42]]))
eq('Dictionary is locked', pcall_err(exec_lua, [[vim.v.nosuchvar = 42]]))
@@ -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.nvim_win_get_cursor(0))
+ eq({ 1, 1 }, api.nvim_win_get_cursor(0))
eq(1, eval('v:searchforward'))
feed('n')
- eq({ 1, 5 }, meths.nvim_win_get_cursor(0))
+ eq({ 1, 5 }, api.nvim_win_get_cursor(0))
exec_lua([[vim.v.searchforward = 0]])
eq(0, eval('v:searchforward'))
feed('n')
- eq({ 1, 1 }, meths.nvim_win_get_cursor(0))
+ eq({ 1, 1 }, api.nvim_win_get_cursor(0))
exec_lua([[vim.v.searchforward = 1]])
eq(1, eval('v:searchforward'))
feed('n')
- eq({ 1, 5 }, meths.nvim_win_get_cursor(0))
+ eq({ 1, 5 }, api.nvim_win_get_cursor(0))
local screen = Screen.new(60, 3)
screen:set_default_attr_ids({
@@ -1893,21 +1893,21 @@ describe('lua stdlib', function()
end)
it('vim.bo', function()
- eq('', funcs.luaeval 'vim.bo.filetype')
+ eq('', fn.luaeval 'vim.bo.filetype')
exec_lua [[
vim.api.nvim_set_option_value("filetype", "markdown", {})
BUF = vim.api.nvim_create_buf(false, true)
vim.api.nvim_set_option_value("modifiable", false, {buf = BUF})
]]
- eq(false, funcs.luaeval 'vim.bo.modified')
- eq('markdown', funcs.luaeval 'vim.bo.filetype')
- eq(false, funcs.luaeval 'vim.bo[BUF].modifiable')
+ eq(false, fn.luaeval 'vim.bo.modified')
+ eq('markdown', fn.luaeval 'vim.bo.filetype')
+ eq(false, fn.luaeval 'vim.bo[BUF].modifiable')
exec_lua [[
vim.bo.filetype = ''
vim.bo[BUF].modifiable = true
]]
- eq('', funcs.luaeval 'vim.bo.filetype')
- eq(true, funcs.luaeval 'vim.bo[BUF].modifiable')
+ eq('', fn.luaeval 'vim.bo.filetype')
+ eq(true, fn.luaeval 'vim.bo[BUF].modifiable')
matches("Unknown option 'nosuchopt'$", pcall_err(exec_lua, 'return vim.bo.nosuchopt'))
matches('Expected Lua string$', pcall_err(exec_lua, 'return vim.bo[0][0].autoread'))
matches('Invalid buffer id: %-1$', pcall_err(exec_lua, 'return vim.bo[-1].filetype'))
@@ -1919,32 +1919,32 @@ describe('lua stdlib', function()
vim.cmd "split"
vim.api.nvim_set_option_value("cole", 2, {})
]]
- eq(2, funcs.luaeval 'vim.wo.cole')
+ eq(2, fn.luaeval 'vim.wo.cole')
exec_lua [[
vim.wo.conceallevel = 0
]]
- eq(0, funcs.luaeval 'vim.wo.cole')
- eq(0, funcs.luaeval 'vim.wo[0].cole')
- eq(0, funcs.luaeval 'vim.wo[1001].cole')
+ eq(0, fn.luaeval 'vim.wo.cole')
+ eq(0, fn.luaeval 'vim.wo[0].cole')
+ eq(0, fn.luaeval 'vim.wo[1001].cole')
matches("Unknown option 'notanopt'$", pcall_err(exec_lua, 'return vim.wo.notanopt'))
matches('Invalid window id: %-1$', pcall_err(exec_lua, 'return vim.wo[-1].list'))
- eq(2, funcs.luaeval 'vim.wo[1000].cole')
+ eq(2, fn.luaeval 'vim.wo[1000].cole')
exec_lua [[
vim.wo[1000].cole = 0
]]
- eq(0, funcs.luaeval 'vim.wo[1000].cole')
+ eq(0, fn.luaeval 'vim.wo[1000].cole')
-- Can handle global-local values
exec_lua [[vim.o.scrolloff = 100]]
exec_lua [[vim.wo.scrolloff = 200]]
- eq(200, funcs.luaeval 'vim.wo.scrolloff')
+ eq(200, fn.luaeval 'vim.wo.scrolloff')
exec_lua [[vim.wo.scrolloff = -1]]
- eq(100, funcs.luaeval 'vim.wo.scrolloff')
+ eq(100, fn.luaeval 'vim.wo.scrolloff')
exec_lua [[
vim.wo[0][0].scrolloff = 200
vim.cmd "enew"
]]
- eq(100, funcs.luaeval 'vim.wo.scrolloff')
+ eq(100, fn.luaeval 'vim.wo.scrolloff')
end)
describe('vim.opt', function()
@@ -2866,15 +2866,15 @@ describe('lua stdlib', function()
vim.cmd "autocmd BufNew * ++once lua BUF = vim.fn.expand('<abuf>')"
vim.cmd "new"
]]
- eq('2', funcs.luaeval 'BUF')
- eq(2, funcs.luaeval '#vim.api.nvim_list_bufs()')
+ eq('2', fn.luaeval 'BUF')
+ eq(2, fn.luaeval '#vim.api.nvim_list_bufs()')
-- vim.cmd can be indexed with a command name
exec_lua [[
vim.cmd.let 'g:var = 2'
]]
- eq(2, funcs.luaeval 'vim.g.var')
+ eq(2, fn.luaeval 'vim.g.var')
end)
it('vim.regex', function()
@@ -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.nvim_buf_set_lines(0, 0, -1, true, { 'yy', 'abc abbc' })
+ api.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.nvim_create_namespace('unused1')
- meths.nvim_create_namespace('unused2')
- meths.nvim_create_namespace('unused3')
- meths.nvim_create_namespace('unused4')
+ api.nvim_create_namespace('unused1')
+ api.nvim_create_namespace('unused2')
+ api.nvim_create_namespace('unused3')
+ api.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.nvim_get_api_info()[1]
- meths.nvim_set_var('channel', channel)
+ local channel = api.nvim_get_api_info()[1]
+ api.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.nvim_get_current_buf().id
+ local buf1 = api.nvim_get_current_buf().id
local buf2 = exec_lua [[
buf2 = vim.api.nvim_create_buf(false, true)
return buf2
]]
- eq(false, meths.nvim_get_option_value('autoindent', { buf = buf1 }))
- eq(false, meths.nvim_get_option_value('autoindent', { buf = buf2 }))
+ eq(false, api.nvim_get_option_value('autoindent', { buf = buf1 }))
+ eq(false, api.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.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(false, api.nvim_get_option_value('autoindent', { buf = buf1 }))
+ eq(true, api.nvim_get_option_value('autoindent', { buf = buf2 }))
+ eq(buf1, api.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.nvim_get_current_win().id
+ local win1 = api.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.nvim_get_option_value('winhighlight', { win = win1 }))
- eq('', meths.nvim_get_option_value('winhighlight', { win = win2 }))
+ eq('', api.nvim_get_option_value('winhighlight', { win = win1 }))
+ eq('', api.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.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('', api.nvim_get_option_value('winhighlight', { win = win1 }))
+ eq('Normal:Normal', api.nvim_get_option_value('winhighlight', { win = win2 }))
+ eq(win1, api.nvim_get_current_win().id)
eq(win2, val)
end)
@@ -3819,15 +3819,13 @@ describe('lua: builtin modules', function()
clear()
command("let $VIMRUNTIME='fixtures/a'")
-- Use system([nvim,…]) instead of clear() to avoid stderr noise. #21844
- local out = funcs
- .system({
- nvim_prog,
- '--clean',
- '--luamod-dev',
- [[+call nvim_exec_lua('return vim.tbl_count {x=1,y=2}')]],
- '+qa!',
- })
- :gsub('\r\n', '\n')
+ local out = fn.system({
+ nvim_prog,
+ '--clean',
+ '--luamod-dev',
+ [[+call nvim_exec_lua('return vim.tbl_count {x=1,y=2}')]],
+ '+qa!',
+ }):gsub('\r\n', '\n')
eq(1, eval('v:shell_error'))
matches("'vim%.shared' not found", out)
end)
@@ -3882,7 +3880,7 @@ describe('vim.keymap', function()
feed('aa')
- eq({ 'π<M-π>foo<' }, meths.nvim_buf_get_lines(0, 0, -1, false))
+ eq({ 'π<M-π>foo<' }, api.nvim_buf_get_lines(0, 0, -1, false))
end)
it('can overwrite a mapping', function()
@@ -4001,14 +3999,14 @@ describe('Vimscript function exists()', function()
]]
)
- eq(1, funcs.exists('v:lua.require("mpack").decode'))
- eq(1, funcs.exists("v:lua.require('mpack').decode"))
- eq(1, funcs.exists('v:lua.require"mpack".decode'))
- eq(1, funcs.exists("v:lua.require'mpack'.decode"))
- eq(1, funcs.exists("v:lua.require('vim.lsp').start"))
- eq(1, funcs.exists('v:lua.require"vim.lsp".start'))
- eq(1, funcs.exists("v:lua.require'vim.lsp'.start"))
- eq(0, funcs.exists("v:lua.require'vim.lsp'.unknown"))
- eq(0, funcs.exists('v:lua.?'))
+ eq(1, fn.exists('v:lua.require("mpack").decode'))
+ eq(1, fn.exists("v:lua.require('mpack').decode"))
+ eq(1, fn.exists('v:lua.require"mpack".decode'))
+ eq(1, fn.exists("v:lua.require'mpack'.decode"))
+ eq(1, fn.exists("v:lua.require('vim.lsp').start"))
+ eq(1, fn.exists('v:lua.require"vim.lsp".start'))
+ eq(1, fn.exists("v:lua.require'vim.lsp'.start"))
+ eq(0, fn.exists("v:lua.require'vim.lsp'.unknown"))
+ eq(0, fn.exists('v:lua.?'))
end)
end)
diff --git a/test/functional/options/autochdir_spec.lua b/test/functional/options/autochdir_spec.lua
index 5d6cf5082a..11f71912a9 100644
--- a/test/functional/options/autochdir_spec.lua
+++ b/test/functional/options/autochdir_spec.lua
@@ -1,7 +1,7 @@
local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
local eq = helpers.eq
-local funcs = helpers.funcs
+local fn = helpers.fn
local command = helpers.command
local mkdir = helpers.mkdir
@@ -11,12 +11,12 @@ describe("'autochdir'", function()
-- By default 'autochdir' is off, thus getcwd() returns the repo root.
clear(targetdir .. '/tty-test.c')
- local rootdir = funcs.getcwd()
+ local rootdir = fn.getcwd()
local expected = rootdir .. '/' .. targetdir
-- With 'autochdir' on, we should get the directory of tty-test.c.
clear('--cmd', 'set autochdir', targetdir .. '/tty-test.c')
- eq(helpers.is_os('win') and expected:gsub('/', '\\') or expected, funcs.getcwd())
+ eq(helpers.is_os('win') and expected:gsub('/', '\\') or expected, fn.getcwd())
end)
it('is not overwritten by getwinvar() call #17609', function()
@@ -29,15 +29,15 @@ describe("'autochdir'", function()
command('set shellslash')
command('set autochdir')
command('edit ' .. dir_a .. '/file1')
- eq(dir_a, funcs.getcwd())
+ eq(dir_a, fn.getcwd())
command('lcd ' .. dir_b)
- eq(dir_b, funcs.getcwd())
+ eq(dir_b, fn.getcwd())
command('botright vnew ../file2')
- eq(curdir, funcs.getcwd())
+ eq(curdir, fn.getcwd())
command('wincmd w')
- eq(dir_a, funcs.getcwd())
- funcs.getwinvar(2, 'foo')
- eq(dir_a, funcs.getcwd())
+ eq(dir_a, fn.getcwd())
+ fn.getwinvar(2, 'foo')
+ eq(dir_a, fn.getcwd())
helpers.rmdir(dir_a)
helpers.rmdir(dir_b)
end)
diff --git a/test/functional/options/chars_spec.lua b/test/functional/options/chars_spec.lua
index acfcc70362..64de25112a 100644
--- a/test/functional/options/chars_spec.lua
+++ b/test/functional/options/chars_spec.lua
@@ -6,7 +6,7 @@ local eq = helpers.eq
local exc_exec = helpers.exc_exec
local insert = helpers.insert
local feed = helpers.feed
-local meths = helpers.meths
+local api = helpers.api
describe("'fillchars'", function()
local screen
@@ -203,7 +203,7 @@ describe("'listchars'", function()
|
]])
- meths.nvim__invalidate_glyph_cache()
+ api.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 234dc47f20..10a0baa30b 100644
--- a/test/functional/options/defaults_spec.lua
+++ b/test/functional/options/defaults_spec.lua
@@ -4,7 +4,7 @@ local Screen = require('test.functional.ui.screen')
local assert_alive = helpers.assert_alive
local assert_log = helpers.assert_log
-local meths = helpers.meths
+local api = helpers.api
local command = helpers.command
local clear = helpers.clear
local exc_exec = helpers.exc_exec
@@ -12,7 +12,7 @@ local exec_lua = helpers.exec_lua
local eval = helpers.eval
local eq = helpers.eq
local ok = helpers.ok
-local funcs = helpers.funcs
+local fn = helpers.fn
local insert = helpers.insert
local neq = helpers.neq
local mkdir = helpers.mkdir
@@ -149,7 +149,7 @@ describe('startup defaults', function()
]])
-- change "vert" character to single-cell
- funcs.setcellwidths({ { 0x2502, 0x2502, 1 } })
+ fn.setcellwidths({ { 0x2502, 0x2502, 1 } })
screen:expect([[
1 │1 |
^+-- 2 lines: 2----------│+-- 2 lines: 2---------|
@@ -159,7 +159,7 @@ describe('startup defaults', function()
]])
-- change "vert" character to double-cell
- funcs.setcellwidths({ { 0x2502, 0x2502, 2 } })
+ fn.setcellwidths({ { 0x2502, 0x2502, 2 } })
screen:expect([[
1 |1 |
^+-- 2 lines: 2----------|+-- 2 lines: 2---------|
@@ -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.nvim_get_option_value('shadafile', {}))
- eq('', meths.nvim_get_option_value('viminfofile', {}))
+ eq('', api.nvim_get_option_value('shadafile', {}))
+ eq('', api.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.nvim_get_option_value('runtimepath', {}), meths.nvim_get_option_value('packpath', {}))
+ eq(api.nvim_get_option_value('runtimepath', {}), api.nvim_get_option_value('packpath', {}))
-- Does not follow modifications to runtimepath.
command('set runtimepath+=foo')
- neq(meths.nvim_get_option_value('runtimepath', {}), meths.nvim_get_option_value('packpath', {}))
+ neq(api.nvim_get_option_value('runtimepath', {}), api.nvim_get_option_value('packpath', {}))
command('set packpath+=foo')
- eq(meths.nvim_get_option_value('runtimepath', {}), meths.nvim_get_option_value('packpath', {}))
+ eq(api.nvim_get_option_value('runtimepath', {}), api.nvim_get_option_value('packpath', {}))
end)
it('v:progpath is set to the absolute path', function()
@@ -316,11 +316,11 @@ describe('XDG defaults', function()
},
})
- 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)
+ eq('.', api.nvim_get_option_value('backupdir', {}))
+ eq('.', api.nvim_get_option_value('viewdir', {}))
+ eq('.', api.nvim_get_option_value('directory', {}))
+ eq('.', api.nvim_get_option_value('undodir', {}))
+ ok((fn.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.nvim__get_lib_dir()
+ local libdir = api.nvim__get_lib_dir()
return vimruntime, libdir
end
@@ -428,7 +428,7 @@ describe('XDG defaults', function()
.. '/nvim/after'
):gsub('\\', '/')
),
- (meths.nvim_get_option_value('runtimepath', {})):gsub('\\', '/')
+ (api.nvim_get_option_value('runtimepath', {})):gsub('\\', '/')
)
command('set runtimepath&')
command('set backupdir&')
@@ -499,23 +499,23 @@ describe('XDG defaults', function()
.. '/nvim/after'
):gsub('\\', '/')
),
- (meths.nvim_get_option_value('runtimepath', {})):gsub('\\', '/')
+ (api.nvim_get_option_value('runtimepath', {})):gsub('\\', '/')
)
eq(
'.,' .. root_path .. ('/X'):rep(4096) .. '/' .. state_dir .. '/backup//',
- (meths.nvim_get_option_value('backupdir', {}):gsub('\\', '/'))
+ (api.nvim_get_option_value('backupdir', {}):gsub('\\', '/'))
)
eq(
root_path .. ('/X'):rep(4096) .. '/' .. state_dir .. '/swap//',
- (meths.nvim_get_option_value('directory', {})):gsub('\\', '/')
+ (api.nvim_get_option_value('directory', {})):gsub('\\', '/')
)
eq(
root_path .. ('/X'):rep(4096) .. '/' .. state_dir .. '/undo//',
- (meths.nvim_get_option_value('undodir', {})):gsub('\\', '/')
+ (api.nvim_get_option_value('undodir', {})):gsub('\\', '/')
)
eq(
root_path .. ('/X'):rep(4096) .. '/' .. state_dir .. '/view//',
- (meths.nvim_get_option_value('viewdir', {})):gsub('\\', '/')
+ (api.nvim_get_option_value('viewdir', {})):gsub('\\', '/')
)
end)
end)
@@ -571,7 +571,7 @@ describe('XDG defaults', function()
.. ',$XDG_DATA_HOME/nvim/after'
):gsub('\\', '/')
),
- (meths.nvim_get_option_value('runtimepath', {})):gsub('\\', '/')
+ (api.nvim_get_option_value('runtimepath', {})):gsub('\\', '/')
)
command('set runtimepath&')
command('set backupdir&')
@@ -599,23 +599,23 @@ describe('XDG defaults', function()
.. ',$XDG_DATA_HOME/nvim/after'
):gsub('\\', '/')
),
- (meths.nvim_get_option_value('runtimepath', {})):gsub('\\', '/')
+ (api.nvim_get_option_value('runtimepath', {})):gsub('\\', '/')
)
eq(
('.,$XDG_CONFIG_HOME/' .. state_dir .. '/backup//'),
- meths.nvim_get_option_value('backupdir', {}):gsub('\\', '/')
+ api.nvim_get_option_value('backupdir', {}):gsub('\\', '/')
)
eq(
('$XDG_CONFIG_HOME/' .. state_dir .. '/swap//'),
- meths.nvim_get_option_value('directory', {}):gsub('\\', '/')
+ api.nvim_get_option_value('directory', {}):gsub('\\', '/')
)
eq(
('$XDG_CONFIG_HOME/' .. state_dir .. '/undo//'),
- meths.nvim_get_option_value('undodir', {}):gsub('\\', '/')
+ api.nvim_get_option_value('undodir', {}):gsub('\\', '/')
)
eq(
('$XDG_CONFIG_HOME/' .. state_dir .. '/view//'),
- meths.nvim_get_option_value('viewdir', {}):gsub('\\', '/')
+ api.nvim_get_option_value('viewdir', {}):gsub('\\', '/')
)
command('set all&')
eq(
@@ -637,25 +637,25 @@ describe('XDG defaults', function()
.. ',$XDG_DATA_DIRS/nvim/after'
.. ',$XDG_DATA_HOME/nvim/after'
):gsub('\\', '/'),
- (meths.nvim_get_option_value('runtimepath', {})):gsub('\\', '/')
+ (api.nvim_get_option_value('runtimepath', {})):gsub('\\', '/')
)
eq(
('.,$XDG_CONFIG_HOME/' .. state_dir .. '/backup//'),
- meths.nvim_get_option_value('backupdir', {}):gsub('\\', '/')
+ api.nvim_get_option_value('backupdir', {}):gsub('\\', '/')
)
eq(
('$XDG_CONFIG_HOME/' .. state_dir .. '/swap//'),
- meths.nvim_get_option_value('directory', {}):gsub('\\', '/')
+ api.nvim_get_option_value('directory', {}):gsub('\\', '/')
)
eq(
('$XDG_CONFIG_HOME/' .. state_dir .. '/undo//'),
- meths.nvim_get_option_value('undodir', {}):gsub('\\', '/')
+ api.nvim_get_option_value('undodir', {}):gsub('\\', '/')
)
eq(
('$XDG_CONFIG_HOME/' .. state_dir .. '/view//'),
- meths.nvim_get_option_value('viewdir', {}):gsub('\\', '/')
+ api.nvim_get_option_value('viewdir', {}):gsub('\\', '/')
)
- eq(nil, (funcs.tempname()):match('XDG_RUNTIME_DIR'))
+ eq(nil, (fn.tempname()):match('XDG_RUNTIME_DIR'))
end)
end)
@@ -743,7 +743,7 @@ describe('XDG defaults', function()
.. path_sep
.. 'after'
),
- meths.nvim_get_option_value('runtimepath', {})
+ api.nvim_get_option_value('runtimepath', {})
)
command('set runtimepath&')
command('set backupdir&')
@@ -821,11 +821,11 @@ describe('XDG defaults', function()
.. path_sep
.. 'after'
),
- meths.nvim_get_option_value('runtimepath', {})
+ api.nvim_get_option_value('runtimepath', {})
)
eq(
'.,\\,=\\,=\\,' .. path_sep .. state_dir .. '' .. path_sep .. 'backup' .. (path_sep):rep(2),
- meths.nvim_get_option_value('backupdir', {})
+ api.nvim_get_option_value('backupdir', {})
)
eq(
'\\,=\\,=\\,'
@@ -836,7 +836,7 @@ describe('XDG defaults', function()
.. path_sep
.. 'swap'
.. (path_sep):rep(2),
- meths.nvim_get_option_value('directory', {})
+ api.nvim_get_option_value('directory', {})
)
eq(
'\\,=\\,=\\,'
@@ -847,7 +847,7 @@ describe('XDG defaults', function()
.. path_sep
.. 'undo'
.. (path_sep):rep(2),
- meths.nvim_get_option_value('undodir', {})
+ api.nvim_get_option_value('undodir', {})
)
eq(
'\\,=\\,=\\,'
@@ -858,7 +858,7 @@ describe('XDG defaults', function()
.. path_sep
.. 'view'
.. (path_sep):rep(2),
- meths.nvim_get_option_value('viewdir', {})
+ api.nvim_get_option_value('viewdir', {})
)
end)
end)
@@ -878,29 +878,29 @@ describe('stdpath()', function()
it('acceptance', function()
clear() -- Do not explicitly set any env vars.
- eq('nvim', funcs.fnamemodify(funcs.stdpath('cache'), ':t'))
- eq('nvim', funcs.fnamemodify(funcs.stdpath('config'), ':t'))
- eq(datadir, funcs.fnamemodify(funcs.stdpath('data'), ':t'))
- eq(statedir, funcs.fnamemodify(funcs.stdpath('state'), ':t'))
- eq('table', type(funcs.stdpath('config_dirs')))
- eq('table', type(funcs.stdpath('data_dirs')))
- eq('string', type(funcs.stdpath('run')))
+ eq('nvim', fn.fnamemodify(fn.stdpath('cache'), ':t'))
+ eq('nvim', fn.fnamemodify(fn.stdpath('config'), ':t'))
+ eq(datadir, fn.fnamemodify(fn.stdpath('data'), ':t'))
+ eq(statedir, fn.fnamemodify(fn.stdpath('state'), ':t'))
+ eq('table', type(fn.stdpath('config_dirs')))
+ eq('table', type(fn.stdpath('data_dirs')))
+ eq('string', type(fn.stdpath('run')))
assert_alive() -- Check for crash. #8393
end)
it('reacts to $NVIM_APPNAME', function()
local appname = 'NVIM_APPNAME_TEST' .. ('_'):rep(106)
clear({ env = { NVIM_APPNAME = appname } })
- eq(appname, funcs.fnamemodify(funcs.stdpath('config'), ':t'))
- eq(appname, funcs.fnamemodify(funcs.stdpath('cache'), ':t'))
- eq(maybe_data(appname), funcs.fnamemodify(funcs.stdpath('log'), ':t'))
- eq(maybe_data(appname), funcs.fnamemodify(funcs.stdpath('data'), ':t'))
- eq(maybe_data(appname), funcs.fnamemodify(funcs.stdpath('state'), ':t'))
+ eq(appname, fn.fnamemodify(fn.stdpath('config'), ':t'))
+ eq(appname, fn.fnamemodify(fn.stdpath('cache'), ':t'))
+ eq(maybe_data(appname), fn.fnamemodify(fn.stdpath('log'), ':t'))
+ eq(maybe_data(appname), fn.fnamemodify(fn.stdpath('data'), ':t'))
+ eq(maybe_data(appname), fn.fnamemodify(fn.stdpath('state'), ':t'))
-- config_dirs and data_dirs are empty on windows, so don't check them on
-- that platform
if not is_os('win') then
- eq(appname, funcs.fnamemodify(funcs.stdpath('config_dirs')[1], ':t'))
- eq(appname, funcs.fnamemodify(funcs.stdpath('data_dirs')[1], ':t'))
+ eq(appname, fn.fnamemodify(fn.stdpath('config_dirs')[1], ':t'))
+ eq(appname, fn.fnamemodify(fn.stdpath('data_dirs')[1], ':t'))
end
assert_alive() -- Check for crash. #8393
@@ -938,16 +938,16 @@ describe('stdpath()', function()
XDG_CONFIG_HOME = alter_slashes('/home/docwhat/.config'),
},
})
- eq(alter_slashes('/home/docwhat/.config/nvim'), funcs.stdpath('config'))
+ eq(alter_slashes('/home/docwhat/.config/nvim'), fn.stdpath('config'))
end)
it('handles changes during runtime', function()
clear({ env = {
XDG_CONFIG_HOME = alter_slashes('/home/original'),
} })
- eq(alter_slashes('/home/original/nvim'), funcs.stdpath('config'))
+ eq(alter_slashes('/home/original/nvim'), fn.stdpath('config'))
command("let $XDG_CONFIG_HOME='" .. alter_slashes('/home/new') .. "'")
- eq(alter_slashes('/home/new/nvim'), funcs.stdpath('config'))
+ eq(alter_slashes('/home/new/nvim'), fn.stdpath('config'))
end)
it("doesn't expand $VARIABLES", function()
@@ -957,14 +957,14 @@ describe('stdpath()', function()
VARIABLES = 'this-should-not-happen',
},
})
- eq(alter_slashes('$VARIABLES/nvim'), funcs.stdpath('config'))
+ eq(alter_slashes('$VARIABLES/nvim'), fn.stdpath('config'))
end)
it("doesn't expand ~/", function()
clear({ env = {
XDG_CONFIG_HOME = alter_slashes('~/frobnitz'),
} })
- eq(alter_slashes('~/frobnitz/nvim'), funcs.stdpath('config'))
+ eq(alter_slashes('~/frobnitz/nvim'), fn.stdpath('config'))
end)
end)
@@ -973,16 +973,16 @@ describe('stdpath()', function()
clear({ env = {
XDG_DATA_HOME = alter_slashes('/home/docwhat/.local'),
} })
- eq(alter_slashes('/home/docwhat/.local/' .. datadir), funcs.stdpath('data'))
+ eq(alter_slashes('/home/docwhat/.local/' .. datadir), fn.stdpath('data'))
end)
it('handles changes during runtime', function()
clear({ env = {
XDG_DATA_HOME = alter_slashes('/home/original'),
} })
- eq(alter_slashes('/home/original/' .. datadir), funcs.stdpath('data'))
+ eq(alter_slashes('/home/original/' .. datadir), fn.stdpath('data'))
command("let $XDG_DATA_HOME='" .. alter_slashes('/home/new') .. "'")
- eq(alter_slashes('/home/new/' .. datadir), funcs.stdpath('data'))
+ eq(alter_slashes('/home/new/' .. datadir), fn.stdpath('data'))
end)
it("doesn't expand $VARIABLES", function()
@@ -992,14 +992,14 @@ describe('stdpath()', function()
VARIABLES = 'this-should-not-happen',
},
})
- eq(alter_slashes('$VARIABLES/' .. datadir), funcs.stdpath('data'))
+ eq(alter_slashes('$VARIABLES/' .. datadir), fn.stdpath('data'))
end)
it("doesn't expand ~/", function()
clear({ env = {
XDG_DATA_HOME = alter_slashes('~/frobnitz'),
} })
- eq(alter_slashes('~/frobnitz/' .. datadir), funcs.stdpath('data'))
+ eq(alter_slashes('~/frobnitz/' .. datadir), fn.stdpath('data'))
end)
end)
@@ -1010,16 +1010,16 @@ describe('stdpath()', function()
XDG_STATE_HOME = alter_slashes('/home/docwhat/.local'),
},
})
- eq(alter_slashes('/home/docwhat/.local/' .. statedir), funcs.stdpath('state'))
+ eq(alter_slashes('/home/docwhat/.local/' .. statedir), fn.stdpath('state'))
end)
it('handles changes during runtime', function()
clear({ env = {
XDG_STATE_HOME = alter_slashes('/home/original'),
} })
- eq(alter_slashes('/home/original/' .. statedir), funcs.stdpath('state'))
+ eq(alter_slashes('/home/original/' .. statedir), fn.stdpath('state'))
command("let $XDG_STATE_HOME='" .. alter_slashes('/home/new') .. "'")
- eq(alter_slashes('/home/new/' .. statedir), funcs.stdpath('state'))
+ eq(alter_slashes('/home/new/' .. statedir), fn.stdpath('state'))
end)
it("doesn't expand $VARIABLES", function()
@@ -1029,14 +1029,14 @@ describe('stdpath()', function()
VARIABLES = 'this-should-not-happen',
},
})
- eq(alter_slashes('$VARIABLES/' .. statedir), funcs.stdpath('state'))
+ eq(alter_slashes('$VARIABLES/' .. statedir), fn.stdpath('state'))
end)
it("doesn't expand ~/", function()
clear({ env = {
XDG_STATE_HOME = alter_slashes('~/frobnitz'),
} })
- eq(alter_slashes('~/frobnitz/' .. statedir), funcs.stdpath('state'))
+ eq(alter_slashes('~/frobnitz/' .. statedir), fn.stdpath('state'))
end)
end)
@@ -1047,16 +1047,16 @@ describe('stdpath()', function()
XDG_CACHE_HOME = alter_slashes('/home/docwhat/.cache'),
},
})
- eq(alter_slashes('/home/docwhat/.cache/nvim'), funcs.stdpath('cache'))
+ eq(alter_slashes('/home/docwhat/.cache/nvim'), fn.stdpath('cache'))
end)
it('handles changes during runtime', function()
clear({ env = {
XDG_CACHE_HOME = alter_slashes('/home/original'),
} })
- eq(alter_slashes('/home/original/nvim'), funcs.stdpath('cache'))
+ eq(alter_slashes('/home/original/nvim'), fn.stdpath('cache'))
command("let $XDG_CACHE_HOME='" .. alter_slashes('/home/new') .. "'")
- eq(alter_slashes('/home/new/nvim'), funcs.stdpath('cache'))
+ eq(alter_slashes('/home/new/nvim'), fn.stdpath('cache'))
end)
it("doesn't expand $VARIABLES", function()
@@ -1066,14 +1066,14 @@ describe('stdpath()', function()
VARIABLES = 'this-should-not-happen',
},
})
- eq(alter_slashes('$VARIABLES/nvim'), funcs.stdpath('cache'))
+ eq(alter_slashes('$VARIABLES/nvim'), fn.stdpath('cache'))
end)
it("doesn't expand ~/", function()
clear({ env = {
XDG_CACHE_HOME = alter_slashes('~/frobnitz'),
} })
- eq(alter_slashes('~/frobnitz/nvim'), funcs.stdpath('cache'))
+ eq(alter_slashes('~/frobnitz/nvim'), fn.stdpath('cache'))
end)
end)
end)
@@ -1112,7 +1112,7 @@ describe('stdpath()', function()
local function set_paths_at_runtime(var_name, paths)
clear({ env = base_env() })
- meths.nvim_set_var('env_val', table.concat(paths, env_sep))
+ api.nvim_set_var('env_val', table.concat(paths, env_sep))
command(('let $%s=g:env_val'):format(var_name))
end
@@ -1120,12 +1120,12 @@ describe('stdpath()', function()
describe(msg, function()
it('set via system', function()
set_paths_via_system(env_var_name, paths)
- eq(expected_paths, funcs.stdpath(stdpath_arg))
+ eq(expected_paths, fn.stdpath(stdpath_arg))
end)
it('set at runtime', function()
set_paths_at_runtime(env_var_name, paths)
- eq(expected_paths, funcs.stdpath(stdpath_arg))
+ eq(expected_paths, fn.stdpath(stdpath_arg))
end)
end)
end
diff --git a/test/functional/options/num_options_spec.lua b/test/functional/options/num_options_spec.lua
index 9a153fb507..0614bcf814 100644
--- a/test/functional/options/num_options_spec.lua
+++ b/test/functional/options/num_options_spec.lua
@@ -1,8 +1,8 @@
-- Tests for :setlocal and :setglobal
local helpers = require('test.functional.helpers')(after_each)
-local clear, feed_command, eval, eq, meths =
- helpers.clear, helpers.feed_command, helpers.eval, helpers.eq, helpers.meths
+local clear, feed_command, eval, eq, api =
+ helpers.clear, helpers.feed_command, helpers.eval, helpers.eq, helpers.api
local function should_fail(opt, value, errmsg)
feed_command('setglobal ' .. opt .. '=' .. value)
@@ -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.nvim_set_option_value, opt, value, {})
+ local status, err = pcall(api.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.nvim_set_option_value(opt, value, {})
- eq(value, meths.nvim_get_option_value(opt, {}))
+ api.nvim_set_option_value(opt, value, {})
+ eq(value, api.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.nvim_get_option_value('iminsert', { scope = 'global' }))
+ eq(0, api.nvim_get_option_value('iminsert', { scope = 'global' }))
feed_command('setlocal iminsert=1')
- eq(0, meths.nvim_get_option_value('iminsert', { scope = 'global' }))
- eq(-1, meths.nvim_get_option_value('imsearch', { scope = 'global' }))
+ eq(0, api.nvim_get_option_value('iminsert', { scope = 'global' }))
+ eq(-1, api.nvim_get_option_value('imsearch', { scope = 'global' }))
feed_command('setlocal imsearch=1')
- eq(-1, meths.nvim_get_option_value('imsearch', { scope = 'global' }))
+ eq(-1, api.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.nvim_set_option_value('window', -10, {})
- eq(23, meths.nvim_get_option_value('window', {}))
+ api.nvim_set_option_value('window', -10, {})
+ eq(23, api.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.nvim_set_option_value('maxcombine', value, {})
- eq(6, meths.nvim_get_option_value('maxcombine', {}))
+ api.nvim_set_option_value('maxcombine', value, {})
+ eq(6, api.nvim_get_option_value('maxcombine', {}))
eq('', eval('v:errmsg'))
end
setto(0)
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' },
diff --git a/test/functional/provider/clipboard_spec.lua b/test/functional/provider/clipboard_spec.lua
index 1b2e3ee689..0c4fd7aaa0 100644
--- a/test/functional/provider/clipboard_spec.lua
+++ b/test/functional/provider/clipboard_spec.lua
@@ -6,7 +6,7 @@ local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local feed_command, expect, eq, eval, source =
helpers.feed_command, helpers.expect, helpers.eq, helpers.eval, helpers.source
local command = helpers.command
-local meths = helpers.meths
+local api = helpers.api
local function basic_register_test(noblock)
insert('some words')
@@ -188,7 +188,7 @@ describe('clipboard', function()
it('valid g:clipboard', function()
-- provider#clipboard#Executable() only checks the structure.
- meths.nvim_set_var('clipboard', {
+ api.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.nvim_get_current_line())
+ eq('textstar', api.nvim_get_current_line())
end)
it('Block paste works correctly', function()
diff --git a/test/functional/provider/define_spec.lua b/test/functional/provider/define_spec.lua
index 5f51ad76e6..a1109935d2 100644
--- a/test/functional/provider/define_spec.lua
+++ b/test/functional/provider/define_spec.lua
@@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')(after_each)
local eval, command = helpers.eval, helpers.command
local eq, run, stop = helpers.eq, helpers.run, helpers.stop
local clear = helpers.clear
-local meths = helpers.meths
+local api = helpers.api
local function get_prefix(sync)
if sync then
@@ -362,7 +362,7 @@ local function function_specs_for(fn, sync, first_arg_factory, init)
end
local function channel()
- return meths.nvim_get_api_info()[1]
+ return api.nvim_get_api_info()[1]
end
local function host()
diff --git a/test/functional/provider/perl_spec.lua b/test/functional/provider/perl_spec.lua
index d0a9ea618e..e9a031eb07 100644
--- a/test/functional/provider/perl_spec.lua
+++ b/test/functional/provider/perl_spec.lua
@@ -5,7 +5,7 @@ local command = helpers.command
local write_file = helpers.write_file
local eval = helpers.eval
local retry = helpers.retry
-local meths = helpers.meths
+local api = helpers.api
local insert = helpers.insert
local expect = helpers.expect
local feed = helpers.feed
@@ -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.nvim_get_option_value('modified', {}))
+ eq(false, api.nvim_get_option_value('modified', {}))
-- insert some text
insert('abc\ndef\nghi')
expect([[
diff --git a/test/functional/provider/python3_spec.lua b/test/functional/provider/python3_spec.lua
index 8d81b86c9c..1419d7f651 100644
--- a/test/functional/provider/python3_spec.lua
+++ b/test/functional/provider/python3_spec.lua
@@ -8,7 +8,7 @@ local source = helpers.source
local missing_provider = helpers.missing_provider
local matches = helpers.matches
local pcall_err = helpers.pcall_err
-local funcs = helpers.funcs
+local fn = helpers.fn
local dedent = helpers.dedent
do
@@ -113,7 +113,7 @@ describe('python3 provider', function()
describe('py3eval()', function()
it('works', function()
- eq({ 1, 2, { ['key'] = 'val' } }, funcs.py3eval('[1, 2, {"key": "val"}]'))
+ eq({ 1, 2, { ['key'] = 'val' } }, fn.py3eval('[1, 2, {"key": "val"}]'))
end)
it('errors out when given non-string', function()
@@ -166,11 +166,11 @@ end)
describe('python2 feature test', function()
-- python2 is not supported, so correct behaviour is to return 0
it('works', function()
- eq(0, funcs.has('python2'))
- eq(0, funcs.has('python'))
- eq(0, funcs.has('python_compiled'))
- eq(0, funcs.has('python_dynamic'))
- eq(0, funcs.has('python_dynamic_'))
- eq(0, funcs.has('python_'))
+ eq(0, fn.has('python2'))
+ eq(0, fn.has('python'))
+ eq(0, fn.has('python_compiled'))
+ eq(0, fn.has('python_dynamic'))
+ eq(0, fn.has('python_dynamic_'))
+ eq(0, fn.has('python_'))
end)
end)
diff --git a/test/functional/provider/ruby_spec.lua b/test/functional/provider/ruby_spec.lua
index 2a64830bca..9b2531a23c 100644
--- a/test/functional/provider/ruby_spec.lua
+++ b/test/functional/provider/ruby_spec.lua
@@ -8,9 +8,9 @@ local exc_exec = helpers.exc_exec
local expect = helpers.expect
local feed = helpers.feed
local feed_command = helpers.feed_command
-local funcs = helpers.funcs
+local fn = helpers.fn
local insert = helpers.insert
-local meths = helpers.meths
+local api = helpers.api
local missing_provider = helpers.missing_provider
local matches = helpers.matches
local write_file = helpers.write_file
@@ -36,19 +36,19 @@ end)
describe('ruby feature test', function()
it('works', function()
- eq(1, funcs.has('ruby'))
+ eq(1, fn.has('ruby'))
end)
end)
describe(':ruby command', function()
it('evaluates ruby', function()
command('ruby VIM.command("let g:set_by_ruby = [100, 0]")')
- eq({ 100, 0 }, meths.nvim_get_var('set_by_ruby'))
+ eq({ 100, 0 }, api.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.nvim_get_var('set_by_nested_ruby'))
+ eq(555, api.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.nvim_get_var('set_by_rubyfile'))
+ eq(123, api.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.nvim_get_option_value('modified', {}))
+ eq(false, api.nvim_get_option_value('modified', {}))
end)
end)
@@ -112,11 +112,11 @@ end)
describe('rubyeval()', function()
it('evaluates ruby objects', function()
- eq({ 1, 2, { ['key'] = 'val' } }, funcs.rubyeval('[1, 2, {key: "val"}]'))
+ eq({ 1, 2, { ['key'] = 'val' } }, fn.rubyeval('[1, 2, {key: "val"}]'))
end)
it('returns nil for empty strings', function()
- eq(vim.NIL, funcs.rubyeval(''))
+ eq(vim.NIL, fn.rubyeval(''))
end)
it('errors out when given non-string', function()
diff --git a/test/functional/shada/buffers_spec.lua b/test/functional/shada/buffers_spec.lua
index 06b7167525..9fead98fed 100644
--- a/test/functional/shada/buffers_spec.lua
+++ b/test/functional/shada/buffers_spec.lua
@@ -1,6 +1,6 @@
-- shada buffer list saving/reading support
local helpers = require('test.functional.helpers')(after_each)
-local nvim_command, funcs, eq, meths = helpers.command, helpers.funcs, helpers.eq, helpers.meths
+local nvim_command, fn, eq, api = helpers.command, helpers.fn, helpers.eq, helpers.api
local expect_exit = helpers.expect_exit
local shada_helpers = require('test.functional.shada.helpers')
@@ -17,10 +17,10 @@ describe('shada support code', function()
nvim_command('edit ' .. testfilename_2)
expect_exit(nvim_command, 'qall')
reset('set shada+=%')
- eq(3, funcs.bufnr('$'))
- eq('', funcs.bufname(1))
- eq(testfilename, funcs.bufname(2))
- eq(testfilename_2, funcs.bufname(3))
+ eq(3, fn.bufnr('$'))
+ eq('', fn.bufname(1))
+ eq(testfilename, fn.bufname(2))
+ eq(testfilename_2, fn.bufname(3))
end)
it('does not restore buffer list without % in &shada', function()
@@ -29,8 +29,8 @@ describe('shada support code', function()
nvim_command('edit ' .. testfilename_2)
expect_exit(nvim_command, 'qall')
reset()
- eq(1, funcs.bufnr('$'))
- eq('', funcs.bufname(1))
+ eq(1, fn.bufnr('$'))
+ eq('', fn.bufname(1))
end)
it('does not dump buffer list without % in &shada', function()
@@ -39,44 +39,44 @@ describe('shada support code', function()
nvim_command('edit ' .. testfilename_2)
expect_exit(nvim_command, 'qall')
reset('set shada+=%')
- eq(1, funcs.bufnr('$'))
- eq('', funcs.bufname(1))
+ eq(1, fn.bufnr('$'))
+ eq('', fn.bufname(1))
end)
it('does not dump unlisted buffer', function()
reset('set shada+=%')
nvim_command('edit ' .. testfilename)
nvim_command('edit ' .. testfilename_2)
- meths.nvim_set_option_value('buflisted', false, {})
+ api.nvim_set_option_value('buflisted', false, {})
expect_exit(nvim_command, 'qall')
reset('set shada+=%')
- eq(2, funcs.bufnr('$'))
- eq('', funcs.bufname(1))
- eq(testfilename, funcs.bufname(2))
+ eq(2, fn.bufnr('$'))
+ eq('', fn.bufname(1))
+ eq(testfilename, fn.bufname(2))
end)
it('does not dump quickfix buffer', function()
reset('set shada+=%')
nvim_command('edit ' .. testfilename)
nvim_command('edit ' .. testfilename_2)
- meths.nvim_set_option_value('buftype', 'quickfix', {})
+ api.nvim_set_option_value('buftype', 'quickfix', {})
expect_exit(nvim_command, 'qall')
reset('set shada+=%')
- eq(2, funcs.bufnr('$'))
- eq('', funcs.bufname(1))
- eq(testfilename, funcs.bufname(2))
+ eq(2, fn.bufnr('$'))
+ eq('', fn.bufname(1))
+ eq(testfilename, fn.bufname(2))
end)
it('does not dump unnamed buffers', function()
reset('set shada+=% hidden')
- meths.nvim_buf_set_lines(0, 0, 1, true, { 'foo' })
+ api.nvim_buf_set_lines(0, 0, 1, true, { 'foo' })
nvim_command('enew')
- meths.nvim_buf_set_lines(0, 0, 1, true, { 'bar' })
- eq(2, funcs.bufnr('$'))
+ api.nvim_buf_set_lines(0, 0, 1, true, { 'bar' })
+ eq(2, fn.bufnr('$'))
expect_exit(nvim_command, 'qall!')
reset('set shada+=% hidden')
- eq(1, funcs.bufnr('$'))
- eq('', funcs.bufname(1))
+ eq(1, fn.bufnr('$'))
+ eq('', fn.bufname(1))
end)
it('restores 1 buffer with %1 in &shada, #5759', function()
@@ -85,8 +85,8 @@ describe('shada support code', function()
nvim_command('edit ' .. testfilename_2)
expect_exit(nvim_command, 'qall')
reset('set shada+=%1')
- eq(2, funcs.bufnr('$'))
- eq('', funcs.bufname(1))
- eq(testfilename, funcs.bufname(2))
+ eq(2, fn.bufnr('$'))
+ eq('', fn.bufname(1))
+ eq(testfilename, fn.bufname(2))
end)
end)
diff --git a/test/functional/shada/compatibility_spec.lua b/test/functional/shada/compatibility_spec.lua
index 13797590f7..bc4e9675c6 100644
--- a/test/functional/shada/compatibility_spec.lua
+++ b/test/functional/shada/compatibility_spec.lua
@@ -1,6 +1,6 @@
-- ShaDa compatibility support
local helpers = require('test.functional.helpers')(after_each)
-local nvim_command, funcs, eq = helpers.command, helpers.funcs, helpers.eq
+local nvim_command, fn, eq = helpers.command, helpers.fn, helpers.eq
local exc_exec = helpers.exc_exec
local shada_helpers = require('test.functional.shada.helpers')
@@ -49,11 +49,11 @@ describe('ShaDa forward compatibility support code', function()
end
end
eq(true, found)
- funcs.garbagecollect(1)
- funcs.garbagecollect(1)
+ fn.garbagecollect(1)
+ fn.garbagecollect(1)
nvim_command('rshada! ' .. shada_fname)
- funcs.garbagecollect(1)
- funcs.garbagecollect(1)
+ fn.garbagecollect(1)
+ fn.garbagecollect(1)
end)
it('works with s/search pattern item with BOOL unknown (sX) key value', function()
@@ -81,11 +81,11 @@ describe('ShaDa forward compatibility support code', function()
end
end
eq(true, found)
- funcs.garbagecollect(1)
- funcs.garbagecollect(1)
+ fn.garbagecollect(1)
+ fn.garbagecollect(1)
nvim_command('rshada!' .. shada_fname)
- funcs.garbagecollect(1)
- funcs.garbagecollect(1)
+ fn.garbagecollect(1)
+ fn.garbagecollect(1)
end)
it('works with replacement item with BOOL additional value in list', function()
@@ -114,11 +114,11 @@ describe('ShaDa forward compatibility support code', function()
end
end
eq(true, found)
- funcs.garbagecollect(1)
- funcs.garbagecollect(1)
+ fn.garbagecollect(1)
+ fn.garbagecollect(1)
nvim_command('rshada!' .. shada_fname)
- funcs.garbagecollect(1)
- funcs.garbagecollect(1)
+ fn.garbagecollect(1)
+ fn.garbagecollect(1)
end)
for _, v in ipairs({
@@ -138,8 +138,8 @@ describe('ShaDa forward compatibility support code', function()
}) do
it('works with ' .. v.name .. ' item with BOOL unknown (mX) key value', function()
nvim_command('silent noautocmd edit ' .. mock_file_path .. 'c')
- eq('' .. mock_file_path .. 'c', funcs.bufname('%'))
- funcs.setline('.', { '1', '2', '3' })
+ eq('' .. mock_file_path .. 'c', fn.bufname('%'))
+ fn.setline('.', { '1', '2', '3' })
wshada(v.mpack)
eq(0, exc_exec(sdrcmd(true)))
os.remove(shada_fname)
@@ -155,7 +155,7 @@ describe('ShaDa forward compatibility support code', function()
eq(true, found)
eq(0, exc_exec(sdrcmd()))
nvim_command('bwipeout!')
- funcs.setpos("'A", { 0, 1, 1, 0 })
+ fn.setpos("'A", { 0, 1, 1, 0 })
os.remove(shada_fname)
nvim_command('wshada ' .. shada_fname)
found = false
@@ -167,18 +167,18 @@ describe('ShaDa forward compatibility support code', function()
end
end
eq(false, found)
- funcs.garbagecollect(1)
- funcs.garbagecollect(1)
+ fn.garbagecollect(1)
+ fn.garbagecollect(1)
nvim_command('rshada!' .. shada_fname)
- funcs.garbagecollect(1)
- funcs.garbagecollect(1)
+ fn.garbagecollect(1)
+ fn.garbagecollect(1)
end)
if v.name == 'global mark' or v.name == 'local mark' then
it('works with ' .. v.name .. ' item with <C-a> name', function()
nvim_command('silent noautocmd edit ' .. mock_file_path .. 'c')
- eq('' .. mock_file_path .. 'c', funcs.bufname('%'))
- funcs.setline('.', { '1', '2', '3' })
+ eq('' .. mock_file_path .. 'c', fn.bufname('%'))
+ fn.setline('.', { '1', '2', '3' })
wshada(
v.mpack:gsub('n.$', 'n\001')
.. v.mpack:gsub('n.$', 'n\002')
@@ -213,11 +213,11 @@ describe('ShaDa forward compatibility support code', function()
end
end
eq(0, found)
- funcs.garbagecollect(1)
- funcs.garbagecollect(1)
+ fn.garbagecollect(1)
+ fn.garbagecollect(1)
nvim_command('rshada!' .. shada_fname)
- funcs.garbagecollect(1)
- funcs.garbagecollect(1)
+ fn.garbagecollect(1)
+ fn.garbagecollect(1)
end)
end
end
@@ -245,11 +245,11 @@ describe('ShaDa forward compatibility support code', function()
end
end
eq(false, found)
- funcs.garbagecollect(1)
- funcs.garbagecollect(1)
+ fn.garbagecollect(1)
+ fn.garbagecollect(1)
nvim_command('rshada!' .. shada_fname)
- funcs.garbagecollect(1)
- funcs.garbagecollect(1)
+ fn.garbagecollect(1)
+ fn.garbagecollect(1)
end)
it('works with register item with <C-a> name', function()
@@ -281,18 +281,18 @@ describe('ShaDa forward compatibility support code', function()
end
end
eq(0, found)
- funcs.garbagecollect(1)
- funcs.garbagecollect(1)
+ fn.garbagecollect(1)
+ fn.garbagecollect(1)
nvim_command('rshada!' .. shada_fname)
- funcs.garbagecollect(1)
- funcs.garbagecollect(1)
+ fn.garbagecollect(1)
+ fn.garbagecollect(1)
end)
it('works with register item with type 10', function()
wshada('\005\001\019\132\161na\162rX\194\162rc\145\196\001-\162rt\010')
eq(0, exc_exec(sdrcmd(true)))
- eq({}, funcs.getreg('a', 1, 1))
- eq('', funcs.getregtype('a'))
+ eq({}, fn.getreg('a', 1, 1))
+ eq('', fn.getregtype('a'))
nvim_command('wshada ' .. shada_fname)
local found = 0
for i, v in ipairs(read_shada_file(shada_fname)) do
@@ -319,19 +319,19 @@ describe('ShaDa forward compatibility support code', function()
end
end
eq(0, found)
- funcs.garbagecollect(1)
- funcs.garbagecollect(1)
+ fn.garbagecollect(1)
+ fn.garbagecollect(1)
nvim_command('rshada!' .. shada_fname)
- funcs.garbagecollect(1)
- funcs.garbagecollect(1)
+ fn.garbagecollect(1)
+ fn.garbagecollect(1)
end)
it('works with buffer list item with BOOL unknown (bX) key', function()
nvim_command('set shada+=%')
wshada('\009\000\016\145\130\161f\196\006' .. mock_file_path .. 'c\162bX\195')
eq(0, exc_exec(sdrcmd()))
- eq(2, funcs.bufnr('$'))
- eq('' .. mock_file_path .. 'c', funcs.bufname(2))
+ eq(2, fn.bufnr('$'))
+ eq('' .. mock_file_path .. 'c', fn.bufname(2))
os.remove(shada_fname)
nvim_command('wshada ' .. shada_fname)
local found = false
@@ -354,11 +354,11 @@ describe('ShaDa forward compatibility support code', function()
end
eq(false, found)
nvim_command('bwipeout!')
- funcs.garbagecollect(1)
- funcs.garbagecollect(1)
+ fn.garbagecollect(1)
+ fn.garbagecollect(1)
nvim_command('rshada!' .. shada_fname)
- funcs.garbagecollect(1)
- funcs.garbagecollect(1)
+ fn.garbagecollect(1)
+ fn.garbagecollect(1)
end)
it('works with history item with BOOL additional value in list', function()
@@ -377,8 +377,8 @@ describe('ShaDa forward compatibility support code', function()
eq(true, found)
eq(0, exc_exec(sdrcmd()))
os.remove(shada_fname)
- funcs.histadd(':', '--')
- funcs.histadd(':', '-')
+ fn.histadd(':', '--')
+ fn.histadd(':', '-')
nvim_command('wshada ' .. shada_fname)
found = false
for _, v in ipairs(read_shada_file(shada_fname)) do
@@ -388,11 +388,11 @@ describe('ShaDa forward compatibility support code', function()
end
end
eq(true, found)
- funcs.garbagecollect(1)
- funcs.garbagecollect(1)
+ fn.garbagecollect(1)
+ fn.garbagecollect(1)
nvim_command('rshada!' .. shada_fname)
- funcs.garbagecollect(1)
- funcs.garbagecollect(1)
+ fn.garbagecollect(1)
+ fn.garbagecollect(1)
end)
it('works with history item with type 10', function()
@@ -425,11 +425,11 @@ describe('ShaDa forward compatibility support code', function()
end
end
eq(0, found)
- funcs.garbagecollect(1)
- funcs.garbagecollect(1)
+ fn.garbagecollect(1)
+ fn.garbagecollect(1)
nvim_command('rshada!' .. shada_fname)
- funcs.garbagecollect(1)
- funcs.garbagecollect(1)
+ fn.garbagecollect(1)
+ fn.garbagecollect(1)
end)
it('works with item with 100 type', function()
@@ -462,10 +462,10 @@ describe('ShaDa forward compatibility support code', function()
end
end
eq(0, found)
- funcs.garbagecollect(1)
- funcs.garbagecollect(1)
+ fn.garbagecollect(1)
+ fn.garbagecollect(1)
nvim_command('rshada!' .. shada_fname)
- funcs.garbagecollect(1)
- funcs.garbagecollect(1)
+ fn.garbagecollect(1)
+ fn.garbagecollect(1)
end)
end)
diff --git a/test/functional/shada/helpers.lua b/test/functional/shada/helpers.lua
index 5235458528..baa27889f3 100644
--- a/test/functional/shada/helpers.lua
+++ b/test/functional/shada/helpers.lua
@@ -1,5 +1,5 @@
local helpers = require('test.functional.helpers')(nil)
-local meths = helpers.meths
+local api = helpers.api
local write_file = helpers.write_file
local concat_tables = helpers.concat_tables
@@ -28,7 +28,7 @@ local function reset(o)
args_rm = args_rm,
args = args,
}
- meths.nvim_set_var('tmpname', tmpname)
+ api.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 da0ce2def7..c8a19bb082 100644
--- a/test/functional/shada/history_spec.lua
+++ b/test/functional/shada/history_spec.lua
@@ -1,7 +1,7 @@
-- ShaDa history saving/reading support
local helpers = require('test.functional.helpers')(after_each)
-local nvim_command, funcs, meths, nvim_feed, eq =
- helpers.command, helpers.funcs, helpers.meths, helpers.feed, helpers.eq
+local nvim_command, fn, api, nvim_feed, eq =
+ helpers.command, helpers.fn, helpers.api, helpers.feed, helpers.eq
local assert_alive = helpers.assert_alive
local expect_exit = helpers.expect_exit
@@ -19,7 +19,7 @@ describe('ShaDa support code', function()
reset()
nvim_command("set shada='0")
nvim_command('rshada')
- eq('" Test', funcs.histget(':', -1))
+ eq('" Test', fn.histget(':', -1))
end)
it('is able to dump and read back 2 items in command-line history', function()
@@ -30,8 +30,8 @@ describe('ShaDa support code', function()
reset()
nvim_command("set shada='0 history=2")
nvim_command('rshada')
- eq('" Test 2', funcs.histget(':', -1))
- eq('" Test', funcs.histget(':', -2))
+ eq('" Test 2', fn.histget(':', -1))
+ eq('" Test', fn.histget(':', -2))
end)
it('respects &history when dumping', function()
@@ -42,8 +42,8 @@ describe('ShaDa support code', function()
reset()
nvim_command("set shada='0 history=2")
nvim_command('rshada')
- eq('" Test 2', funcs.histget(':', -1))
- eq('', funcs.histget(':', -2))
+ eq('" Test 2', fn.histget(':', -1))
+ eq('', fn.histget(':', -2))
end)
it('respects &history when loading', function()
@@ -54,8 +54,8 @@ describe('ShaDa support code', function()
reset()
nvim_command("set shada='0 history=1")
nvim_command('rshada')
- eq('" Test 2', funcs.histget(':', -1))
- eq('', funcs.histget(':', -2))
+ eq('" Test 2', fn.histget(':', -1))
+ eq('', fn.histget(':', -2))
end)
it('dumps only requested amount of command-line history items', function()
@@ -64,13 +64,13 @@ describe('ShaDa support code', function()
nvim_feed(':" Test 2\n')
nvim_command('wshada')
-- Regression test: :wshada should not alter or free history.
- eq('" Test 2', funcs.histget(':', -1))
- eq('" Test', funcs.histget(':', -2))
+ eq('" Test 2', fn.histget(':', -1))
+ eq('" Test', fn.histget(':', -2))
reset()
nvim_command("set shada='0")
nvim_command('rshada')
- eq('" Test 2', funcs.histget(':', -1))
- eq('', funcs.histget(':', -2))
+ eq('" Test 2', fn.histget(':', -1))
+ eq('', fn.histget(':', -2))
end)
it('does not respect number in &shada when loading history', function()
@@ -81,8 +81,8 @@ describe('ShaDa support code', function()
reset()
nvim_command("set shada='0,:1")
nvim_command('rshada')
- eq('" Test 2', funcs.histget(':', -1))
- eq('" Test', funcs.histget(':', -2))
+ eq('" Test 2', fn.histget(':', -1))
+ eq('" Test', fn.histget(':', -2))
end)
it('dumps and loads all kinds of histories', function()
@@ -96,48 +96,48 @@ describe('ShaDa support code', function()
nvim_command('wshada')
reset()
nvim_command('rshada')
- eq('" Test', funcs.histget(':', -1))
- eq('Test', funcs.histget('/', -1))
- eq('"Test"', funcs.histget('=', -1))
- eq('Test 2', funcs.histget('@', -1))
- eq('c', funcs.histget('>', -1))
+ eq('" Test', fn.histget(':', -1))
+ eq('Test', fn.histget('/', -1))
+ eq('"Test"', fn.histget('=', -1))
+ eq('Test 2', fn.histget('@', -1))
+ eq('c', fn.histget('>', -1))
end)
it('dumps and loads last search pattern with offset', function()
- meths.nvim_set_option_value('wrapscan', false, {})
- funcs.setline('.', { 'foo', 'bar--' })
+ api.nvim_set_option_value('wrapscan', false, {})
+ fn.setline('.', { 'foo', 'bar--' })
nvim_feed('gg0/a/e+1\n')
- eq({ 0, 2, 3, 0 }, funcs.getpos('.'))
+ eq({ 0, 2, 3, 0 }, fn.getpos('.'))
nvim_command('wshada')
reset()
- meths.nvim_set_option_value('wrapscan', false, {})
- funcs.setline('.', { 'foo', 'bar--' })
+ api.nvim_set_option_value('wrapscan', false, {})
+ fn.setline('.', { 'foo', 'bar--' })
nvim_feed('gg0n')
- eq({ 0, 2, 3, 0 }, funcs.getpos('.'))
- eq(1, meths.nvim_get_vvar('searchforward'))
+ eq({ 0, 2, 3, 0 }, fn.getpos('.'))
+ eq(1, api.nvim_get_vvar('searchforward'))
end)
it('dumps and loads last search pattern with offset and backward direction', function()
- meths.nvim_set_option_value('wrapscan', false, {})
- funcs.setline('.', { 'foo', 'bar--' })
+ api.nvim_set_option_value('wrapscan', false, {})
+ fn.setline('.', { 'foo', 'bar--' })
nvim_feed('G$?a?e+1\n')
- eq({ 0, 2, 3, 0 }, funcs.getpos('.'))
+ eq({ 0, 2, 3, 0 }, fn.getpos('.'))
nvim_command('wshada')
reset()
- meths.nvim_set_option_value('wrapscan', false, {})
- funcs.setline('.', { 'foo', 'bar--' })
+ api.nvim_set_option_value('wrapscan', false, {})
+ fn.setline('.', { 'foo', 'bar--' })
nvim_feed('G$n')
- eq({ 0, 2, 3, 0 }, funcs.getpos('.'))
- eq(0, meths.nvim_get_vvar('searchforward'))
+ eq({ 0, 2, 3, 0 }, fn.getpos('.'))
+ eq(0, api.nvim_get_vvar('searchforward'))
end)
it('saves v:hlsearch=1', function()
nvim_command('set hlsearch shada-=h')
nvim_feed('/test\n')
- eq(1, meths.nvim_get_vvar('hlsearch'))
+ eq(1, api.nvim_get_vvar('hlsearch'))
expect_exit(nvim_command, 'qall')
reset()
- eq(1, meths.nvim_get_vvar('hlsearch'))
+ eq(1, api.nvim_get_vvar('hlsearch'))
end)
it('saves v:hlsearch=0 with :nohl', function()
@@ -146,27 +146,27 @@ describe('ShaDa support code', function()
nvim_command('nohlsearch')
expect_exit(nvim_command, 'qall')
reset()
- eq(0, meths.nvim_get_vvar('hlsearch'))
+ eq(0, api.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.nvim_get_vvar('hlsearch'))
+ eq(1, api.nvim_get_vvar('hlsearch'))
expect_exit(nvim_command, 'qall')
reset()
- eq(0, meths.nvim_get_vvar('hlsearch'))
+ eq(0, api.nvim_get_vvar('hlsearch'))
end)
it('dumps and loads last substitute pattern and replacement string', function()
- funcs.setline('.', { 'foo', 'bar' })
+ fn.setline('.', { 'foo', 'bar' })
nvim_command('%s/f/g/g')
- eq('goo', funcs.getline(1))
+ eq('goo', fn.getline(1))
nvim_command('wshada')
reset()
- funcs.setline('.', { 'foo', 'bar' })
+ fn.setline('.', { 'foo', 'bar' })
nvim_command('&')
- eq('goo', funcs.getline(1))
+ eq('goo', fn.getline(1))
end)
it('dumps and loads history with UTF-8 characters', function()
@@ -174,25 +174,25 @@ describe('ShaDa support code', function()
nvim_feed(':echo "«"\n')
expect_exit(nvim_command, 'qall')
reset()
- eq('echo "«"', funcs.histget(':', -1))
+ eq('echo "«"', fn.histget(':', -1))
end)
it('dumps and loads replacement with UTF-8 characters', function()
nvim_command('substitute/./«/ge')
expect_exit(nvim_command, 'qall!')
reset()
- funcs.setline('.', { '.' })
+ fn.setline('.', { '.' })
nvim_command('&')
- eq('«', funcs.getline('.'))
+ eq('«', fn.getline('.'))
end)
it('dumps and loads substitute pattern with UTF-8 characters', function()
nvim_command('substitute/«/./ge')
expect_exit(nvim_command, 'qall!')
reset()
- funcs.setline('.', { '«\171' })
+ fn.setline('.', { '«\171' })
nvim_command('&')
- eq('.\171', funcs.getline('.'))
+ eq('.\171', fn.getline('.'))
end)
it('dumps and loads search pattern with UTF-8 characters', function()
@@ -200,10 +200,10 @@ describe('ShaDa support code', function()
nvim_command('set shada+=/0')
expect_exit(nvim_command, 'qall!')
reset()
- funcs.setline('.', { '\171«' })
+ fn.setline('.', { '\171«' })
nvim_command('~&')
- eq('\171', funcs.getline('.'))
- eq('', funcs.histget('/', -1))
+ eq('\171', fn.getline('.'))
+ eq('', fn.histget('/', -1))
end)
it('dumps and loads search pattern with 8-bit single-byte', function()
@@ -212,10 +212,10 @@ describe('ShaDa support code', function()
nvim_command('set shada+=/0')
expect_exit(nvim_command, 'qall!')
reset()
- funcs.setline('.', { '\171«' })
+ fn.setline('.', { '\171«' })
nvim_command('~&')
- eq('«', funcs.getline('.'))
- eq('', funcs.histget('/', -1))
+ eq('«', fn.getline('.'))
+ eq('', fn.histget('/', -1))
end)
it('does not crash when dumping last search pattern (#10945)', function()
diff --git a/test/functional/shada/marks_spec.lua b/test/functional/shada/marks_spec.lua
index 0850084d98..3f29a02506 100644
--- a/test/functional/shada/marks_spec.lua
+++ b/test/functional/shada/marks_spec.lua
@@ -1,6 +1,6 @@
-- ShaDa marks saving/reading support
local helpers = require('test.functional.helpers')(after_each)
-local meths, nvim_command, funcs, eq = helpers.meths, helpers.command, helpers.funcs, helpers.eq
+local api, nvim_command, fn, eq = helpers.api, helpers.command, helpers.fn, helpers.eq
local feed = helpers.feed
local exc_exec, exec_capture = helpers.exc_exec, helpers.exec_capture
local expect_exit = helpers.expect_exit
@@ -9,7 +9,7 @@ local shada_helpers = require('test.functional.shada.helpers')
local reset, clear = shada_helpers.reset, shada_helpers.clear
local nvim_current_line = function()
- return meths.nvim_win_get_cursor(0)[1]
+ return api.nvim_win_get_cursor(0)[1]
end
describe('ShaDa support code', function()
@@ -43,7 +43,7 @@ describe('ShaDa support code', function()
reset()
nvim_command('rshada')
nvim_command('normal! `A')
- eq(testfilename, funcs.fnamemodify(meths.nvim_buf_get_name(0), ':t'))
+ eq(testfilename, fn.fnamemodify(api.nvim_buf_get_name(0), ':t'))
eq(1, nvim_current_line())
nvim_command('normal! `B')
eq(2, nvim_current_line())
@@ -70,7 +70,7 @@ describe('ShaDa support code', function()
reset("set shada='0,f0")
nvim_command('language C')
nvim_command('normal! `A')
- eq(testfilename, funcs.fnamemodify(meths.nvim_buf_get_name(0), ':t'))
+ eq(testfilename, fn.fnamemodify(api.nvim_buf_get_name(0), ':t'))
eq(1, nvim_current_line())
end)
@@ -83,7 +83,7 @@ describe('ShaDa support code', function()
reset()
nvim_command('edit ' .. testfilename)
nvim_command('normal! `a')
- eq(testfilename, funcs.fnamemodify(meths.nvim_buf_get_name(0), ':t'))
+ eq(testfilename, fn.fnamemodify(api.nvim_buf_get_name(0), ':t'))
eq(1, nvim_current_line())
nvim_command('normal! `b')
eq(2, nvim_current_line())
@@ -113,12 +113,12 @@ describe('ShaDa support code', function()
it('is able to populate v:oldfiles', function()
nvim_command('edit ' .. testfilename)
- local tf_full = meths.nvim_buf_get_name(0)
+ local tf_full = api.nvim_buf_get_name(0)
nvim_command('edit ' .. testfilename_2)
- local tf_full_2 = meths.nvim_buf_get_name(0)
+ local tf_full_2 = api.nvim_buf_get_name(0)
expect_exit(nvim_command, 'qall')
reset()
- local oldfiles = meths.nvim_get_vvar('oldfiles')
+ local oldfiles = api.nvim_get_vvar('oldfiles')
table.sort(oldfiles)
eq(2, #oldfiles)
eq(testfilename, oldfiles[1]:sub(-#testfilename))
@@ -126,7 +126,7 @@ describe('ShaDa support code', function()
eq(tf_full, oldfiles[1])
eq(tf_full_2, oldfiles[2])
nvim_command('rshada!')
- oldfiles = meths.nvim_get_vvar('oldfiles')
+ oldfiles = api.nvim_get_vvar('oldfiles')
table.sort(oldfiles)
eq(2, #oldfiles)
eq(testfilename, oldfiles[1]:sub(-#testfilename))
@@ -159,8 +159,8 @@ describe('ShaDa support code', function()
nvim_command('quit')
nvim_command('rshada')
nvim_command('normal! \15') -- <C-o>
- eq(testfilename_2, funcs.bufname('%'))
- eq({ 2, 0 }, meths.nvim_win_get_cursor(0))
+ eq(testfilename_2, fn.bufname('%'))
+ eq({ 2, 0 }, api.nvim_win_get_cursor(0))
end)
it('is able to dump and restore jump list with different times (slow!)', function()
@@ -179,19 +179,19 @@ describe('ShaDa support code', function()
reset()
nvim_command('redraw')
nvim_command('edit ' .. testfilename)
- eq(testfilename, funcs.bufname('%'))
+ eq(testfilename, fn.bufname('%'))
eq(1, nvim_current_line())
nvim_command('execute "normal! \\<C-o>"')
- eq(testfilename, funcs.bufname('%'))
+ eq(testfilename, fn.bufname('%'))
eq(2, nvim_current_line())
nvim_command('execute "normal! \\<C-o>"')
- eq(testfilename_2, funcs.bufname('%'))
+ eq(testfilename_2, fn.bufname('%'))
eq(1, nvim_current_line())
nvim_command('execute "normal! \\<C-o>"')
- eq(testfilename_2, funcs.bufname('%'))
+ eq(testfilename_2, fn.bufname('%'))
eq(2, nvim_current_line())
nvim_command('execute "normal! \\<C-o>"')
- eq(testfilename_2, funcs.bufname('%'))
+ eq(testfilename_2, fn.bufname('%'))
eq(2, nvim_current_line())
end)
@@ -223,14 +223,14 @@ describe('ShaDa support code', function()
},
args = {
'-i',
- meths.nvim_get_var('tmpname'), -- Use same shada file as parent.
+ api.nvim_get_var('tmpname'), -- Use same shada file as parent.
'--cmd',
'silent edit ' .. non_existent_testfilename,
'-c',
'qall',
},
}
- eq('', funcs.system(argv))
+ eq('', fn.system(argv))
eq(0, exc_exec('rshada'))
end)
@@ -242,14 +242,14 @@ describe('ShaDa support code', function()
},
args = {
'-i',
- meths.nvim_get_var('tmpname'), -- Use same shada file as parent.
+ api.nvim_get_var('tmpname'), -- Use same shada file as parent.
'-c',
'silent edit ' .. non_existent_testfilename,
'-c',
'autocmd VimEnter * qall',
},
}
- eq('', funcs.system(argv))
+ eq('', fn.system(argv))
eq(0, exc_exec('rshada'))
end)
diff --git a/test/functional/shada/merging_spec.lua b/test/functional/shada/merging_spec.lua
index fd6bf9d7af..94e0ee6e82 100644
--- a/test/functional/shada/merging_spec.lua
+++ b/test/functional/shada/merging_spec.lua
@@ -1,8 +1,8 @@
-- ShaDa merging data support
local helpers = require('test.functional.helpers')(after_each)
-local nvim_command, funcs, eq = helpers.command, helpers.funcs, helpers.eq
+local nvim_command, fn, eq = helpers.command, helpers.fn, helpers.eq
local exc_exec, exec_capture = helpers.exc_exec, helpers.exec_capture
-local meths = helpers.meths
+local api = helpers.api
local shada_helpers = require('test.functional.shada.helpers')
local reset, clear, get_shada_rw =
@@ -138,7 +138,7 @@ describe('ShaDa history merging code', function()
eq(0, exc_exec('wshada! ' .. shada_fname))
local items = { 'ad', 'ab', 'ac', 'af', 'ae' }
for i, v in ipairs(items) do
- eq(v, funcs.histget(':', i))
+ eq(v, fn.histget(':', i))
end
local found = 0
for _, v in ipairs(read_shada_file(shada_fname)) do
@@ -239,7 +239,7 @@ describe('ShaDa search pattern support code', function()
eq(0, exc_exec(sdrcmd()))
wshada('\002\000\011\130\162sX\194\162sp\196\001?')
eq(0, exc_exec(sdrcmd()))
- eq('-', funcs.getreg('/'))
+ eq('-', fn.getreg('/'))
end)
it('uses last search pattern with gt tstamp from file when reading with bang', function()
@@ -247,7 +247,7 @@ describe('ShaDa search pattern support code', function()
eq(0, exc_exec(sdrcmd()))
wshada('\002\000\011\130\162sX\194\162sp\196\001?')
eq(0, exc_exec(sdrcmd(true)))
- eq('?', funcs.getreg('/'))
+ eq('?', fn.getreg('/'))
end)
it('uses last search pattern with eq timestamp from instance when reading', function()
@@ -255,7 +255,7 @@ describe('ShaDa search pattern support code', function()
eq(0, exc_exec(sdrcmd()))
wshada('\002\001\011\130\162sX\194\162sp\196\001?')
eq(0, exc_exec(sdrcmd()))
- eq('-', funcs.getreg('/'))
+ eq('-', fn.getreg('/'))
end)
it('uses last search pattern with gt timestamp from file when reading', function()
@@ -263,14 +263,14 @@ describe('ShaDa search pattern support code', function()
eq(0, exc_exec(sdrcmd()))
wshada('\002\002\011\130\162sX\194\162sp\196\001?')
eq(0, exc_exec(sdrcmd()))
- eq('?', funcs.getreg('/'))
+ eq('?', fn.getreg('/'))
end)
it('uses last search pattern with gt timestamp from instance when writing', function()
wshada('\002\001\011\130\162sX\194\162sp\196\001-')
eq(0, exc_exec(sdrcmd()))
wshada('\002\000\011\130\162sX\194\162sp\196\001?')
- eq('-', funcs.getreg('/'))
+ eq('-', fn.getreg('/'))
eq(0, exc_exec('wshada ' .. shada_fname))
local found = 0
for _, v in ipairs(read_shada_file(shada_fname)) do
@@ -285,7 +285,7 @@ describe('ShaDa search pattern support code', function()
wshada('\002\001\011\130\162sX\194\162sp\196\001-')
eq(0, exc_exec(sdrcmd()))
wshada('\002\001\011\130\162sX\194\162sp\196\001?')
- eq('-', funcs.getreg('/'))
+ eq('-', fn.getreg('/'))
eq(0, exc_exec('wshada ' .. shada_fname))
local found = 0
for _, v in ipairs(read_shada_file(shada_fname)) do
@@ -300,7 +300,7 @@ describe('ShaDa search pattern support code', function()
wshada('\002\001\011\130\162sX\194\162sp\196\001-')
eq(0, exc_exec(sdrcmd()))
wshada('\002\002\011\130\162sX\194\162sp\196\001?')
- eq('-', funcs.getreg('/'))
+ eq('-', fn.getreg('/'))
eq(0, exc_exec('wshada ' .. shada_fname))
local found = 0
for _, v in ipairs(read_shada_file(shada_fname)) do
@@ -316,7 +316,7 @@ describe('ShaDa search pattern support code', function()
eq(0, exc_exec(sdrcmd()))
wshada('\002\000\011\130\162ss\195\162sp\196\001?')
eq(0, exc_exec(sdrcmd()))
- eq('-', funcs.getreg('/'))
+ eq('-', fn.getreg('/'))
end)
it('uses last s/ pattern with gt timestamp from file when reading with !', function()
@@ -324,7 +324,7 @@ describe('ShaDa search pattern support code', function()
eq(0, exc_exec(sdrcmd()))
wshada('\002\000\011\130\162ss\195\162sp\196\001?')
eq(0, exc_exec(sdrcmd(true)))
- eq('?', funcs.getreg('/'))
+ eq('?', fn.getreg('/'))
end)
it('uses last s/ pattern with eq timestamp from instance when reading', function()
@@ -332,7 +332,7 @@ describe('ShaDa search pattern support code', function()
eq(0, exc_exec(sdrcmd()))
wshada('\002\001\011\130\162ss\195\162sp\196\001?')
eq(0, exc_exec(sdrcmd()))
- eq('-', funcs.getreg('/'))
+ eq('-', fn.getreg('/'))
end)
it('uses last s/ pattern with gt timestamp from file when reading', function()
@@ -340,14 +340,14 @@ describe('ShaDa search pattern support code', function()
eq(0, exc_exec(sdrcmd()))
wshada('\002\002\011\130\162ss\195\162sp\196\001?')
eq(0, exc_exec(sdrcmd()))
- eq('?', funcs.getreg('/'))
+ eq('?', fn.getreg('/'))
end)
it('uses last s/ pattern with gt timestamp from instance when writing', function()
wshada('\002\001\011\130\162ss\195\162sp\196\001-')
eq(0, exc_exec(sdrcmd()))
wshada('\002\000\011\130\162ss\195\162sp\196\001?')
- eq('-', funcs.getreg('/'))
+ eq('-', fn.getreg('/'))
eq(0, exc_exec('wshada ' .. shada_fname))
local found = 0
for _, v in ipairs(read_shada_file(shada_fname)) do
@@ -362,7 +362,7 @@ describe('ShaDa search pattern support code', function()
wshada('\002\001\011\130\162ss\195\162sp\196\001-')
eq(0, exc_exec(sdrcmd()))
wshada('\002\001\011\130\162ss\195\162sp\196\001?')
- eq('-', funcs.getreg('/'))
+ eq('-', fn.getreg('/'))
eq(0, exc_exec('wshada ' .. shada_fname))
local found = 0
for _, v in ipairs(read_shada_file(shada_fname)) do
@@ -377,7 +377,7 @@ describe('ShaDa search pattern support code', function()
wshada('\002\001\011\130\162ss\195\162sp\196\001-')
eq(0, exc_exec(sdrcmd()))
wshada('\002\002\011\130\162ss\195\162sp\196\001?')
- eq('-', funcs.getreg('/'))
+ eq('-', fn.getreg('/'))
eq(0, exc_exec('wshada ' .. shada_fname))
local found = 0
for _, v in ipairs(read_shada_file(shada_fname)) do
@@ -402,7 +402,7 @@ describe('ShaDa replacement string support code', function()
wshada('\003\000\004\145\196\001?')
eq(0, exc_exec(sdrcmd()))
nvim_command('s/.*/~')
- eq('-', funcs.getline('.'))
+ eq('-', fn.getline('.'))
nvim_command('bwipeout!')
end)
@@ -412,7 +412,7 @@ describe('ShaDa replacement string support code', function()
wshada('\003\000\004\145\196\001?')
eq(0, exc_exec(sdrcmd(true)))
nvim_command('s/.*/~')
- eq('?', funcs.getline('.'))
+ eq('?', fn.getline('.'))
nvim_command('bwipeout!')
end)
@@ -422,7 +422,7 @@ describe('ShaDa replacement string support code', function()
wshada('\003\001\004\145\196\001?')
eq(0, exc_exec(sdrcmd()))
nvim_command('s/.*/~')
- eq('-', funcs.getline('.'))
+ eq('-', fn.getline('.'))
nvim_command('bwipeout!')
end)
@@ -432,7 +432,7 @@ describe('ShaDa replacement string support code', function()
wshada('\003\002\004\145\196\001?')
eq(0, exc_exec(sdrcmd()))
nvim_command('s/.*/~')
- eq('?', funcs.getline('.'))
+ eq('?', fn.getline('.'))
nvim_command('bwipeout!')
end)
@@ -492,14 +492,14 @@ describe('ShaDa marks support code', function()
wshada('\007\000\018\131\162mX\195\161f\196\006' .. mock_file_path .. '?\161nA')
eq(0, exc_exec(sdrcmd()))
nvim_command('normal! `A')
- eq('-', funcs.fnamemodify(meths.nvim_buf_get_name(0), ':t'))
+ eq('-', fn.fnamemodify(api.nvim_buf_get_name(0), ':t'))
end)
it('can merge with file with mark 9 as the only numeric mark', function()
wshada('\007\001\014\130\161f\196\006' .. mock_file_path .. '-\161n9')
eq(0, exc_exec(sdrcmd()))
nvim_command('normal! `9oabc')
- eq('-', funcs.fnamemodify(meths.nvim_buf_get_name(0), ':t'))
+ eq('-', fn.fnamemodify(api.nvim_buf_get_name(0), ':t'))
eq(0, exc_exec('wshada ' .. shada_fname))
local found = {}
for _, v in ipairs(read_shada_file(shada_fname)) do
@@ -632,7 +632,7 @@ describe('ShaDa marks support code', function()
wshada('\007\000\018\131\162mX\195\161f\196\006' .. mock_file_path .. '?\161nA')
eq(0, exc_exec(sdrcmd(true)))
nvim_command('normal! `A')
- eq('?', funcs.fnamemodify(meths.nvim_buf_get_name(0), ':t'))
+ eq('?', fn.fnamemodify(api.nvim_buf_get_name(0), ':t'))
end)
it('uses last A mark with eq timestamp from instance when reading', function()
@@ -641,7 +641,7 @@ describe('ShaDa marks support code', function()
wshada('\007\001\018\131\162mX\195\161f\196\006' .. mock_file_path .. '?\161nA')
eq(0, exc_exec(sdrcmd()))
nvim_command('normal! `A')
- eq('-', funcs.fnamemodify(meths.nvim_buf_get_name(0), ':t'))
+ eq('-', fn.fnamemodify(api.nvim_buf_get_name(0), ':t'))
end)
it('uses last A mark with gt timestamp from file when reading', function()
@@ -650,7 +650,7 @@ describe('ShaDa marks support code', function()
wshada('\007\002\018\131\162mX\195\161f\196\006' .. mock_file_path .. '?\161nA')
eq(0, exc_exec(sdrcmd()))
nvim_command('normal! `A')
- eq('?', funcs.fnamemodify(meths.nvim_buf_get_name(0), ':t'))
+ eq('?', fn.fnamemodify(api.nvim_buf_get_name(0), ':t'))
end)
it('uses last A mark with gt timestamp from instance when writing', function()
@@ -658,7 +658,7 @@ describe('ShaDa marks support code', function()
eq(0, exc_exec(sdrcmd()))
wshada('\007\000\018\131\162mX\195\161f\196\006' .. mock_file_path .. '?\161nA')
nvim_command('normal! `A')
- eq('-', funcs.fnamemodify(meths.nvim_buf_get_name(0), ':t'))
+ eq('-', fn.fnamemodify(api.nvim_buf_get_name(0), ':t'))
eq(0, exc_exec('wshada ' .. shada_fname))
local found = {}
for _, v in ipairs(read_shada_file(shada_fname)) do
@@ -675,7 +675,7 @@ describe('ShaDa marks support code', function()
eq(0, exc_exec(sdrcmd()))
wshada('\007\001\018\131\162mX\195\161f\196\006' .. mock_file_path .. '?\161nA')
nvim_command('normal! `A')
- eq('-', funcs.fnamemodify(meths.nvim_buf_get_name(0), ':t'))
+ eq('-', fn.fnamemodify(api.nvim_buf_get_name(0), ':t'))
eq(0, exc_exec('wshada ' .. shada_fname))
local found = {}
for _, v in ipairs(read_shada_file(shada_fname)) do
@@ -692,7 +692,7 @@ describe('ShaDa marks support code', function()
eq(0, exc_exec(sdrcmd()))
wshada('\007\002\018\131\162mX\195\161f\196\006' .. mock_file_path .. '?\161nA')
nvim_command('normal! `A')
- eq('-', funcs.fnamemodify(meths.nvim_buf_get_name(0), ':t'))
+ eq('-', fn.fnamemodify(api.nvim_buf_get_name(0), ':t'))
eq(0, exc_exec('wshada ' .. shada_fname))
local found = {}
for _, v in ipairs(read_shada_file(shada_fname)) do
@@ -708,56 +708,56 @@ describe('ShaDa marks support code', function()
it('uses last a mark with gt timestamp from instance when reading', function()
nvim_command('edit ' .. mock_file_path .. '-')
- funcs.setline(1, { '-', '?' })
+ fn.setline(1, { '-', '?' })
wshada('\010\001\017\131\161l\001\161f\196\006' .. mock_file_path .. '-\161na')
eq(0, exc_exec(sdrcmd()))
wshada('\010\000\017\131\161l\002\161f\196\006' .. mock_file_path .. '-\161na')
eq(0, exc_exec(sdrcmd()))
nvim_command('normal! `a')
- eq('-', funcs.getline('.'))
+ eq('-', fn.getline('.'))
end)
it('uses last a mark with gt timestamp from file when reading with !', function()
nvim_command('edit ' .. mock_file_path .. '-')
- funcs.setline(1, { '-', '?' })
+ fn.setline(1, { '-', '?' })
wshada('\010\001\017\131\161l\001\161f\196\006' .. mock_file_path .. '-\161na')
eq(0, exc_exec(sdrcmd()))
wshada('\010\000\017\131\161l\002\161f\196\006' .. mock_file_path .. '-\161na')
eq(0, exc_exec(sdrcmd(true)))
nvim_command('normal! `a')
- eq('?', funcs.getline('.'))
+ eq('?', fn.getline('.'))
end)
it('uses last a mark with eq timestamp from instance when reading', function()
nvim_command('edit ' .. mock_file_path .. '-')
- funcs.setline(1, { '-', '?' })
+ fn.setline(1, { '-', '?' })
wshada('\010\001\017\131\161l\001\161f\196\006' .. mock_file_path .. '-\161na')
eq(0, exc_exec(sdrcmd()))
wshada('\010\001\017\131\161l\002\161f\196\006' .. mock_file_path .. '-\161na')
eq(0, exc_exec(sdrcmd()))
nvim_command('normal! `a')
- eq('-', funcs.getline('.'))
+ eq('-', fn.getline('.'))
end)
it('uses last a mark with gt timestamp from file when reading', function()
nvim_command('edit ' .. mock_file_path .. '-')
- funcs.setline(1, { '-', '?' })
+ fn.setline(1, { '-', '?' })
wshada('\010\001\017\131\161l\001\161f\196\006' .. mock_file_path .. '-\161na')
eq(0, exc_exec(sdrcmd()))
wshada('\010\002\017\131\161l\002\161f\196\006' .. mock_file_path .. '-\161na')
eq(0, exc_exec(sdrcmd()))
nvim_command('normal! `a')
- eq('?', funcs.getline('.'))
+ eq('?', fn.getline('.'))
end)
it('uses last a mark with gt timestamp from instance when writing', function()
nvim_command('edit ' .. mock_file_path .. '-')
- funcs.setline(1, { '-', '?' })
+ fn.setline(1, { '-', '?' })
wshada('\010\001\017\131\161l\001\161f\196\006' .. mock_file_path .. '-\161na')
eq(0, exc_exec(sdrcmd()))
wshada('\010\000\017\131\161l\002\161f\196\006' .. mock_file_path .. '-\161na')
nvim_command('normal! `a')
- eq('-', funcs.getline('.'))
+ eq('-', fn.getline('.'))
eq(0, exc_exec('wshada ' .. shada_fname))
local found = 0
for _, v in ipairs(read_shada_file(shada_fname)) do
@@ -775,12 +775,12 @@ describe('ShaDa marks support code', function()
it('uses last a mark with eq timestamp from instance when writing', function()
nvim_command('edit ' .. mock_file_path .. '-')
- funcs.setline(1, { '-', '?' })
+ fn.setline(1, { '-', '?' })
wshada('\010\001\017\131\161l\001\161f\196\006' .. mock_file_path .. '-\161na')
eq(0, exc_exec(sdrcmd()))
wshada('\010\001\017\131\161l\002\161f\196\006' .. mock_file_path .. '-\161na')
nvim_command('normal! `a')
- eq('-', funcs.getline('.'))
+ eq('-', fn.getline('.'))
eq(0, exc_exec('wshada ' .. shada_fname))
local found = 0
for _, v in ipairs(read_shada_file(shada_fname)) do
@@ -798,12 +798,12 @@ describe('ShaDa marks support code', function()
it('uses last a mark with gt timestamp from file when writing', function()
nvim_command('edit ' .. mock_file_path .. '-')
- funcs.setline(1, { '-', '?' })
+ fn.setline(1, { '-', '?' })
wshada('\010\001\017\131\161l\001\161f\196\006' .. mock_file_path .. '-\161na')
eq(0, exc_exec(sdrcmd()))
wshada('\010\002\017\131\161l\002\161f\196\006' .. mock_file_path .. '-\161na')
nvim_command('normal! `a')
- eq('-', funcs.fnamemodify(meths.nvim_buf_get_name(0), ':t'))
+ eq('-', fn.fnamemodify(api.nvim_buf_get_name(0), ':t'))
eq(0, exc_exec('wshada ' .. shada_fname))
local found = 0
for _, v in ipairs(read_shada_file(shada_fname)) do
@@ -832,7 +832,7 @@ describe('ShaDa registers support code', function()
eq(0, exc_exec(sdrcmd()))
wshada('\005\000\015\131\161na\162rX\194\162rc\145\196\001?')
eq(0, exc_exec(sdrcmd()))
- eq('-', funcs.getreg('a'))
+ eq('-', fn.getreg('a'))
end)
it('uses last a register with gt timestamp from file when reading with !', function()
@@ -840,7 +840,7 @@ describe('ShaDa registers support code', function()
eq(0, exc_exec(sdrcmd()))
wshada('\005\000\015\131\161na\162rX\194\162rc\145\196\001?')
eq(0, exc_exec(sdrcmd(true)))
- eq('?', funcs.getreg('a'))
+ eq('?', fn.getreg('a'))
end)
it('uses last a register with eq timestamp from instance when reading', function()
@@ -848,7 +848,7 @@ describe('ShaDa registers support code', function()
eq(0, exc_exec(sdrcmd()))
wshada('\005\001\015\131\161na\162rX\194\162rc\145\196\001?')
eq(0, exc_exec(sdrcmd()))
- eq('-', funcs.getreg('a'))
+ eq('-', fn.getreg('a'))
end)
it('uses last a register with gt timestamp from file when reading', function()
@@ -856,14 +856,14 @@ describe('ShaDa registers support code', function()
eq(0, exc_exec(sdrcmd()))
wshada('\005\002\015\131\161na\162rX\194\162rc\145\196\001?')
eq(0, exc_exec(sdrcmd()))
- eq('?', funcs.getreg('a'))
+ eq('?', fn.getreg('a'))
end)
it('uses last a register with gt timestamp from instance when writing', function()
wshada('\005\001\015\131\161na\162rX\194\162rc\145\196\001-')
eq(0, exc_exec(sdrcmd()))
wshada('\005\000\015\131\161na\162rX\194\162rc\145\196\001?')
- eq('-', funcs.getreg('a'))
+ eq('-', fn.getreg('a'))
eq(0, exc_exec('wshada ' .. shada_fname))
local found = 0
for _, v in ipairs(read_shada_file(shada_fname)) do
@@ -879,7 +879,7 @@ describe('ShaDa registers support code', function()
wshada('\005\001\015\131\161na\162rX\194\162rc\145\196\001-')
eq(0, exc_exec(sdrcmd()))
wshada('\005\001\015\131\161na\162rX\194\162rc\145\196\001?')
- eq('-', funcs.getreg('a'))
+ eq('-', fn.getreg('a'))
eq(0, exc_exec('wshada ' .. shada_fname))
local found = 0
for _, v in ipairs(read_shada_file(shada_fname)) do
@@ -895,7 +895,7 @@ describe('ShaDa registers support code', function()
wshada('\005\001\015\131\161na\162rX\194\162rc\145\196\001-')
eq(0, exc_exec(sdrcmd()))
wshada('\005\002\015\131\161na\162rX\194\162rc\145\196\001?')
- eq('-', funcs.getreg('a'))
+ eq('-', fn.getreg('a'))
eq(0, exc_exec('wshada ' .. shada_fname))
local found = 0
for _, v in ipairs(read_shada_file(shada_fname)) do
@@ -940,7 +940,7 @@ describe('ShaDa jumps support code', function()
.. 'f\161l\002'
)
eq(0, exc_exec(sdrcmd()))
- eq('', meths.nvim_buf_get_name(0))
+ eq('', api.nvim_buf_get_name(0))
eq(
' jump line col file/text\n'
.. ' 5 2 0 '
diff --git a/test/functional/shada/registers_spec.lua b/test/functional/shada/registers_spec.lua
index ceb3ddf2fe..ef15ab9a05 100644
--- a/test/functional/shada/registers_spec.lua
+++ b/test/functional/shada/registers_spec.lua
@@ -1,6 +1,6 @@
-- ShaDa registers saving/reading support
local helpers = require('test.functional.helpers')(after_each)
-local nvim_command, funcs, eq = helpers.command, helpers.funcs, helpers.eq
+local nvim_command, fn, eq = helpers.command, helpers.fn, helpers.eq
local shada_helpers = require('test.functional.shada.helpers')
local reset, clear = shada_helpers.reset, shada_helpers.clear
@@ -10,13 +10,13 @@ local setreg = function(name, contents, typ)
if type(contents) == 'string' then
contents = { contents }
end
- funcs.setreg(name, contents, typ)
+ fn.setreg(name, contents, typ)
end
local getreg = function(name)
return {
- funcs.getreg(name, 1, 1),
- funcs.getregtype(name),
+ fn.getreg(name, 1, 1),
+ fn.getregtype(name),
}
end
diff --git a/test/functional/shada/shada_spec.lua b/test/functional/shada/shada_spec.lua
index b16a19ef31..2942beab2f 100644
--- a/test/functional/shada/shada_spec.lua
+++ b/test/functional/shada/shada_spec.lua
@@ -1,6 +1,6 @@
-- Other ShaDa tests
local helpers = require('test.functional.helpers')(after_each)
-local meths, nvim_command, funcs, eq = helpers.meths, helpers.command, helpers.funcs, helpers.eq
+local api, nvim_command, fn, eq = helpers.api, helpers.command, helpers.fn, helpers.eq
local write_file, spawn, set_session, nvim_prog, exc_exec =
helpers.write_file, helpers.spawn, helpers.set_session, helpers.nvim_prog, helpers.exc_exec
local is_os = helpers.is_os
@@ -57,8 +57,8 @@ describe('ShaDa support code', function()
local hist1 = ('-'):rep(1024 - 5)
local hist2 = ('-'):rep(1025 - 5)
nvim_command('set shada-=s10 shada+=s1')
- funcs.histadd(':', hist1)
- funcs.histadd(':', hist2)
+ fn.histadd(':', hist1)
+ fn.histadd(':', hist2)
eq(0, exc_exec('wshada ' .. shada_fname))
local found = 0
for _, v in ipairs(read_shada_file(shada_fname)) do
@@ -175,7 +175,7 @@ describe('ShaDa support code', function()
it('correctly uses shada-r option', function()
nvim_command('set shellslash')
- meths.nvim_set_var('__home', paths.test_source_path)
+ api.nvim_set_var('__home', paths.test_source_path)
nvim_command('let $HOME = __home')
nvim_command('unlet __home')
nvim_command('edit ~/README.md')
@@ -183,7 +183,7 @@ describe('ShaDa support code', function()
nvim_command('undo')
nvim_command('set shada+=%')
nvim_command('wshada! ' .. shada_fname)
- local readme_fname = funcs.resolve(paths.test_source_path) .. '/README.md'
+ local readme_fname = fn.resolve(paths.test_source_path) .. '/README.md'
eq({ [7] = 2, [8] = 2, [9] = 1, [10] = 4, [11] = 1 }, find_file(readme_fname))
nvim_command('set shada+=r~')
nvim_command('wshada! ' .. shada_fname)
@@ -191,21 +191,19 @@ describe('ShaDa support code', function()
nvim_command('set shada-=r~')
nvim_command('wshada! ' .. shada_fname)
eq({ [7] = 2, [8] = 2, [9] = 1, [10] = 4, [11] = 1 }, find_file(readme_fname))
- nvim_command(
- 'set shada+=r' .. funcs.escape(funcs.escape(paths.test_source_path, '$~'), ' "\\,')
- )
+ nvim_command('set shada+=r' .. fn.escape(fn.escape(paths.test_source_path, '$~'), ' "\\,'))
nvim_command('wshada! ' .. shada_fname)
eq({}, find_file(readme_fname))
end)
it('correctly ignores case with shada-r option', function()
nvim_command('set shellslash')
- local pwd = funcs.getcwd()
+ local pwd = fn.getcwd()
local relfname = 'абв/test'
local fname = pwd .. '/' .. relfname
- meths.nvim_set_var('__fname', fname)
+ api.nvim_set_var('__fname', fname)
nvim_command('silent! edit `=__fname`')
- funcs.setline(1, { 'a', 'b', 'c', 'd' })
+ fn.setline(1, { 'a', 'b', 'c', 'd' })
nvim_command('normal! GmAggmaAabc')
nvim_command('undo')
nvim_command('set shada+=%')
@@ -217,30 +215,30 @@ describe('ShaDa support code', function()
end)
it('is able to set &shada after &viminfo', function()
- 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', {}))
+ api.nvim_set_option_value('viminfo', "'10", {})
+ eq("'10", api.nvim_get_option_value('viminfo', {}))
+ eq("'10", api.nvim_get_option_value('shada', {}))
+ api.nvim_set_option_value('shada', '', {})
+ eq('', api.nvim_get_option_value('viminfo', {}))
+ eq('', api.nvim_get_option_value('shada', {}))
end)
it('is able to set all& after setting &shada', function()
- meths.nvim_set_option_value('shada', "'10", {})
- eq("'10", meths.nvim_get_option_value('viminfo', {}))
- eq("'10", meths.nvim_get_option_value('shada', {}))
+ api.nvim_set_option_value('shada', "'10", {})
+ eq("'10", api.nvim_get_option_value('viminfo', {}))
+ eq("'10", api.nvim_get_option_value('shada', {}))
nvim_command('set all&')
- eq("!,'100,<50,s10,h", meths.nvim_get_option_value('viminfo', {}))
- eq("!,'100,<50,s10,h", meths.nvim_get_option_value('shada', {}))
+ eq("!,'100,<50,s10,h", api.nvim_get_option_value('viminfo', {}))
+ eq("!,'100,<50,s10,h", api.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.nvim_get_option_value('viminfo', {}))
- eq("'10", meths.nvim_get_option_value('shada', {}))
+ eq("'10", api.nvim_get_option_value('viminfo', {}))
+ eq("'10", api.nvim_get_option_value('shada', {}))
nvim_command('set shada=')
- eq('', meths.nvim_get_option_value('viminfo', {}))
- eq('', meths.nvim_get_option_value('shada', {}))
+ eq('', api.nvim_get_option_value('viminfo', {}))
+ eq('', api.nvim_get_option_value('shada', {}))
end)
it('setting &shada gives proper error message on missing number', function()
@@ -256,17 +254,17 @@ describe('ShaDa support code', function()
it('does not crash when ShaDa file directory is not writable', function()
skip(is_os('win'))
- funcs.mkdir(dirname, '', 0)
- eq(0, funcs.filewritable(dirname))
+ fn.mkdir(dirname, '', 0)
+ eq(0, fn.filewritable(dirname))
reset { shadafile = dirshada, args = { '--cmd', 'set shada=' } }
- meths.nvim_set_option_value('shada', "'10", {})
+ api.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.nvim_set_option_value('shada', '', {})
+ api.nvim_set_option_value('shada', '', {})
end)
end)
@@ -285,7 +283,7 @@ describe('ShaDa support code', function()
write_file('NONE', '\005\001\015\131\161na\162rX\194\162rc\145\196\001-')
local session = spawn({ nvim_prog, '-u', 'NONE', '-i', 'NONE', '--embed', '--headless' }, true)
set_session(session)
- eq('', funcs.getreg('a'))
+ eq('', fn.getreg('a'))
session:close()
os.remove('NONE')
end)
diff --git a/test/functional/shada/variables_spec.lua b/test/functional/shada/variables_spec.lua
index 6096c72bcb..d70f5deded 100644
--- a/test/functional/shada/variables_spec.lua
+++ b/test/functional/shada/variables_spec.lua
@@ -1,7 +1,7 @@
-- ShaDa variables saving/reading support
local helpers = require('test.functional.helpers')(after_each)
-local meths, funcs, nvim_command, eq, eval =
- helpers.meths, helpers.funcs, helpers.command, helpers.eq, helpers.eval
+local api, fn, nvim_command, eq, eval =
+ helpers.api, helpers.fn, helpers.command, helpers.eq, helpers.eval
local expect_exit = helpers.expect_exit
local shada_helpers = require('test.functional.shada.helpers')
@@ -12,13 +12,13 @@ describe('ShaDa support code', function()
after_each(clear)
it('is able to dump and read back string variable', function()
- meths.nvim_set_var('STRVAR', 'foo')
+ api.nvim_set_var('STRVAR', 'foo')
nvim_command('set shada+=!')
nvim_command('wshada')
reset()
nvim_command('set shada+=!')
nvim_command('rshada')
- eq('foo', meths.nvim_get_var('STRVAR'))
+ eq('foo', api.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.nvim_get_var(varname)
+ varval = api.nvim_get_var(varname)
else
- meths.nvim_set_var(varname, varval)
+ api.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.nvim_get_var(varname))
+ eq(varval, api.nvim_get_var(varname))
end)
end
@@ -53,113 +53,110 @@ describe('ShaDa support code', function()
autotest('blob (with NULs)', 'BLOBVARNULS', '0z004e554c7300', true)
it('does not read back variables without `!` in &shada', function()
- meths.nvim_set_var('STRVAR', 'foo')
+ api.nvim_set_var('STRVAR', 'foo')
nvim_command('set shada+=!')
nvim_command('wshada')
reset('set shada-=!')
nvim_command('rshada')
- eq(0, funcs.exists('g:STRVAR'))
+ eq(0, fn.exists('g:STRVAR'))
end)
it('does not dump variables without `!` in &shada', function()
nvim_command('set shada-=!')
- meths.nvim_set_var('STRVAR', 'foo')
+ api.nvim_set_var('STRVAR', 'foo')
nvim_command('wshada')
reset()
nvim_command('set shada+=!')
nvim_command('rshada')
- eq(0, funcs.exists('g:STRVAR'))
+ eq(0, fn.exists('g:STRVAR'))
end)
it('does not dump session variables', function()
nvim_command('set shada+=!')
- meths.nvim_set_var('StrVar', 'foo')
+ api.nvim_set_var('StrVar', 'foo')
nvim_command('wshada')
reset()
nvim_command('set shada+=!')
nvim_command('rshada')
- eq(0, funcs.exists('g:StrVar'))
+ eq(0, fn.exists('g:StrVar'))
end)
it('does not dump regular variables', function()
nvim_command('set shada+=!')
- meths.nvim_set_var('str_var', 'foo')
+ api.nvim_set_var('str_var', 'foo')
nvim_command('wshada')
reset()
nvim_command('set shada+=!')
nvim_command('rshada')
- eq(0, funcs.exists('g:str_var'))
+ eq(0, fn.exists('g:str_var'))
end)
it('dumps and loads variables correctly with utf-8 strings', function()
reset()
- meths.nvim_set_var('STRVAR', '«')
- meths.nvim_set_var('LSTVAR', { '«' })
- meths.nvim_set_var('DCTVAR', { ['«'] = '«' })
- meths.nvim_set_var('NESTEDVAR', { ['«'] = { { '«' }, { ['«'] = '«' }, { a = 'Test' } } })
+ api.nvim_set_var('STRVAR', '«')
+ api.nvim_set_var('LSTVAR', { '«' })
+ api.nvim_set_var('DCTVAR', { ['«'] = '«' })
+ api.nvim_set_var('NESTEDVAR', { ['«'] = { { '«' }, { ['«'] = '«' }, { a = 'Test' } } })
expect_exit(nvim_command, 'qall')
reset()
- 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')
- )
+ eq('«', api.nvim_get_var('STRVAR'))
+ eq({ '«' }, api.nvim_get_var('LSTVAR'))
+ eq({ ['«'] = '«' }, api.nvim_get_var('DCTVAR'))
+ eq({ ['«'] = { { '«' }, { ['«'] = '«' }, { a = 'Test' } } }, api.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.nvim_set_var('STRVAR', '\171')
- meths.nvim_set_var('LSTVAR', { '\171' })
- meths.nvim_set_var('DCTVAR', { ['«\171'] = '«\171' })
- meths.nvim_set_var(
+ api.nvim_set_var('STRVAR', '\171')
+ api.nvim_set_var('LSTVAR', { '\171' })
+ api.nvim_set_var('DCTVAR', { ['«\171'] = '«\171' })
+ api.nvim_set_var(
'NESTEDVAR',
{ ['\171'] = { { '\171«' }, { ['\171'] = '\171' }, { a = 'Test' } } }
)
expect_exit(nvim_command, 'qall')
reset()
- eq('\171', meths.nvim_get_var('STRVAR'))
- eq({ '\171' }, meths.nvim_get_var('LSTVAR'))
- eq({ ['«\171'] = '«\171' }, meths.nvim_get_var('DCTVAR'))
+ eq('\171', api.nvim_get_var('STRVAR'))
+ eq({ '\171' }, api.nvim_get_var('LSTVAR'))
+ eq({ ['«\171'] = '«\171' }, api.nvim_get_var('DCTVAR'))
eq(
{ ['\171'] = { { '\171«' }, { ['\171'] = '\171' }, { a = 'Test' } } },
- meths.nvim_get_var('NESTEDVAR')
+ api.nvim_get_var('NESTEDVAR')
)
end)
it('ignore when a funcref is stored in a variable', function()
nvim_command('let F = function("tr")')
- meths.nvim_set_var('U', '10')
+ api.nvim_set_var('U', '10')
nvim_command('set shada+=!')
nvim_command('wshada')
reset()
nvim_command('set shada+=!')
nvim_command('rshada')
- eq('10', meths.nvim_get_var('U'))
+ eq('10', api.nvim_get_var('U'))
end)
it('ignore when a partial is stored in a variable', function()
nvim_command('let P = { -> 1 }')
- meths.nvim_set_var('U', '10')
+ api.nvim_set_var('U', '10')
nvim_command('set shada+=!')
nvim_command('wshada')
reset()
nvim_command('set shada+=!')
nvim_command('rshada')
- eq('10', meths.nvim_get_var('U'))
+ eq('10', api.nvim_get_var('U'))
end)
it('ignore when a self-referencing list is stored in a variable', function()
- meths.nvim_set_var('L', {})
+ api.nvim_set_var('L', {})
nvim_command('call add(L, L)')
- meths.nvim_set_var('U', '10')
+ api.nvim_set_var('U', '10')
nvim_command('set shada+=!')
nvim_command('wshada')
reset()
nvim_command('rshada')
- eq('10', meths.nvim_get_var('U'))
+ eq('10', api.nvim_get_var('U'))
end)
end)
diff --git a/test/functional/terminal/altscreen_spec.lua b/test/functional/terminal/altscreen_spec.lua
index 3c41a68eda..c3be9ec6ca 100644
--- a/test/functional/terminal/altscreen_spec.lua
+++ b/test/functional/terminal/altscreen_spec.lua
@@ -1,6 +1,6 @@
local helpers = require('test.functional.helpers')(after_each)
local thelpers = require('test.functional.terminal.helpers')
-local clear, eq, meths = helpers.clear, helpers.eq, helpers.meths
+local clear, eq, api = helpers.clear, helpers.eq, helpers.api
local feed = helpers.feed
local feed_data = thelpers.feed_data
local enter_altscreen = thelpers.enter_altscreen
@@ -42,7 +42,7 @@ describe(':terminal altscreen', function()
{1: } |
{3:-- TERMINAL --} |
]])
- eq(10, meths.nvim_buf_line_count(0))
+ eq(10, api.nvim_buf_line_count(0))
end)
it('wont clear lines already in the scrollback', function()
@@ -107,7 +107,7 @@ describe(':terminal altscreen', function()
end)
it('wont modify line count', function()
- eq(10, meths.nvim_buf_line_count(0))
+ eq(10, api.nvim_buf_line_count(0))
end)
it('wont modify lines in the scrollback', function()
@@ -144,7 +144,7 @@ describe(':terminal altscreen', function()
rows: 4, cols: 50 |
|
]])
- eq(9, meths.nvim_buf_line_count(0))
+ eq(9, api.nvim_buf_line_count(0))
end)
describe('and after exit', function()
diff --git a/test/functional/terminal/buffer_spec.lua b/test/functional/terminal/buffer_spec.lua
index 7029b81de0..b6eb8ebdfd 100644
--- a/test/functional/terminal/buffer_spec.lua
+++ b/test/functional/terminal/buffer_spec.lua
@@ -8,7 +8,7 @@ local nvim_prog = helpers.nvim_prog
local eval, feed_command, source = helpers.eval, helpers.feed_command, helpers.source
local pcall_err = helpers.pcall_err
local eq, neq = helpers.eq, helpers.neq
-local meths = helpers.meths
+local api = helpers.api
local retry = helpers.retry
local write_file = helpers.write_file
local command = helpers.command
@@ -16,7 +16,7 @@ local exc_exec = helpers.exc_exec
local matches = helpers.matches
local exec_lua = helpers.exec_lua
local sleep = vim.uv.sleep
-local funcs = helpers.funcs
+local fn = helpers.fn
local is_os = helpers.is_os
local skip = helpers.skip
@@ -92,12 +92,12 @@ describe(':terminal buffer', function()
end)
it('does not create swap files', function()
- local swapfile = meths.nvim_exec('swapname', true):gsub('\n', '')
+ local swapfile = api.nvim_exec('swapname', true):gsub('\n', '')
eq(nil, io.open(swapfile))
end)
it('does not create undofiles files', function()
- local undofile = meths.nvim_eval('undofile(bufname("%"))')
+ local undofile = api.nvim_eval('undofile(bufname("%"))')
eq(nil, io.open(undofile))
end)
end)
@@ -172,7 +172,7 @@ describe(':terminal buffer', function()
it('handles loss of focus gracefully', function()
-- Change the statusline to avoid printing the file name, which varies.
- meths.nvim_set_option_value('statusline', '==========', {})
+ api.nvim_set_option_value('statusline', '==========', {})
-- Save the buffer number of the terminal for later testing.
local tbuf = eval('bufnr("%")')
@@ -277,7 +277,7 @@ describe(':terminal buffer', function()
end)
it([[can use temporary normal mode <c-\><c-o>]], function()
- eq('t', funcs.mode(1))
+ eq('t', fn.mode(1))
feed [[<c-\><c-o>]]
screen:expect {
grid = [[
@@ -287,7 +287,7 @@ describe(':terminal buffer', function()
{3:-- (terminal) --} |
]],
}
- eq('ntT', funcs.mode(1))
+ eq('ntT', fn.mode(1))
feed [[:let g:x = 17]]
screen:expect {
@@ -308,7 +308,7 @@ describe(':terminal buffer', function()
{3:-- TERMINAL --} |
]],
}
- eq('t', funcs.mode(1))
+ eq('t', fn.mode(1))
end)
it('writing to an existing file with :w fails #13549', function()
@@ -321,18 +321,18 @@ describe(':terminal buffer', function()
it('emits TermRequest events #26972', function()
command('split')
command('enew')
- local term = meths.nvim_open_term(0, {})
- local termbuf = meths.nvim_get_current_buf().id
+ local term = api.nvim_open_term(0, {})
+ local termbuf = api.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>")')
command('wincmd p')
-- cwd will be inserted in a file URI, which cannot contain backs
- local cwd = funcs.getcwd():gsub('\\', '/')
+ local cwd = fn.getcwd():gsub('\\', '/')
local parent = cwd:match('^(.+/)')
local expected = '\027]7;file://host' .. parent
- meths.nvim_chan_send(term, string.format('%s\027\\', expected))
+ api.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.nvim_open_term(0, {})
+ local chan = api.nvim_open_term(0, {})
local composing = ('a̳'):sub(2)
- meths.nvim_chan_send(chan, 'a' .. composing:rep(8))
+ api.nvim_chan_send(chan, 'a' .. composing:rep(8))
retry(nil, nil, function()
- eq('a' .. composing:rep(5), meths.nvim_get_current_line())
+ eq('a' .. composing:rep(5), api.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.nvim_get_current_line())
+ eq(key, api.nvim_get_current_line())
end)
end
end)
@@ -599,7 +599,7 @@ describe('termopen()', function()
feed('q:')
eq(
'Vim:E11: Invalid in command-line window; <CR> executes, CTRL-C quits',
- pcall_err(funcs.termopen, 'bar')
+ pcall_err(fn.termopen, 'bar')
)
end)
@@ -610,13 +610,13 @@ describe('termopen()', function()
before_each(function()
-- Outer value should never be propagated to :terminal
- funcs.setenv('COLORTERM', 'wrongvalue')
+ fn.setenv('COLORTERM', 'wrongvalue')
end)
local function test_term_colorterm(expected, opts)
local screen = Screen.new(50, 4)
screen:attach()
- funcs.termopen({
+ fn.termopen({
nvim_prog,
'-u',
'NONE',
diff --git a/test/functional/terminal/channel_spec.lua b/test/functional/terminal/channel_spec.lua
index 80333fcf2f..2b39c93f14 100644
--- a/test/functional/terminal/channel_spec.lua
+++ b/test/functional/terminal/channel_spec.lua
@@ -8,7 +8,7 @@ local pcall_err = helpers.pcall_err
local feed = helpers.feed
local poke_eventloop = helpers.poke_eventloop
local is_os = helpers.is_os
-local meths = helpers.meths
+local api = helpers.api
local async_meths = helpers.async_meths
local testprg = helpers.testprg
local assert_alive = helpers.assert_alive
@@ -140,7 +140,7 @@ describe('no crash when TermOpen autocommand', function()
before_each(function()
clear()
- meths.nvim_set_option_value('shell', testprg('shell-test'), {})
+ api.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.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')
+ local win = api.nvim_get_current_win()
+ local buf = api.nvim_create_buf(false, true)
+ local term = api.nvim_open_term(buf, { force_crlf = true })
+ api.nvim_win_set_buf(win, buf)
+ api.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.nvim_chan_send(term, '\nfirst')
+ api.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.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')
+ local win = api.nvim_get_current_win()
+ local buf = api.nvim_create_buf(false, true)
+ local term = api.nvim_open_term(buf, { force_crlf = false })
+ api.nvim_win_set_buf(win, buf)
+ api.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 754a681cff..f7ceb0a68b 100644
--- a/test/functional/terminal/edit_spec.lua
+++ b/test/functional/terminal/edit_spec.lua
@@ -3,8 +3,8 @@ local screen = require('test.functional.ui.screen')
local testprg = helpers.testprg
local command = helpers.command
-local funcs = helpers.funcs
-local meths = helpers.meths
+local fn = helpers.fn
+local api = helpers.api
local clear = helpers.clear
local eq = helpers.eq
local matches = helpers.matches
@@ -19,17 +19,17 @@ describe(':edit term://*', function()
before_each(function()
clear()
- meths.nvim_set_option_value('shell', testprg('shell-test'), {})
- meths.nvim_set_option_value('shellcmdflag', 'EXE', {})
+ api.nvim_set_option_value('shell', testprg('shell-test'), {})
+ api.nvim_set_option_value('shellcmdflag', 'EXE', {})
end)
it('runs TermOpen event', function()
- meths.nvim_set_var('termopen_runs', {})
+ api.nvim_set_var('termopen_runs', {})
command('autocmd TermOpen * :call add(g:termopen_runs, expand("<amatch>"))')
command('edit term://')
- local termopen_runs = meths.nvim_get_var('termopen_runs')
+ local termopen_runs = api.nvim_get_var('termopen_runs')
eq(1, #termopen_runs)
- local cwd = funcs.fnamemodify('.', ':p:~'):gsub([[[\/]*$]], '')
+ local cwd = fn.fnamemodify('.', ':p:~'):gsub([[[\/]*$]], '')
matches('^term://' .. pesc(cwd) .. '//%d+:$', termopen_runs[1])
end)
@@ -37,7 +37,7 @@ describe(':edit term://*', function()
local columns, lines = 20, 4
local scr = get_screen(columns, lines)
local rep = 97
- meths.nvim_set_option_value('shellcmdflag', 'REP ' .. rep, {})
+ api.nvim_set_option_value('shellcmdflag', 'REP ' .. rep, {})
command('set shellxquote=') -- win: avoid extra quotes
local sb = 10
command(
@@ -46,7 +46,7 @@ describe(':edit term://*', function()
command('edit term://foobar')
local bufcontents = {}
- local winheight = meths.nvim_win_get_height(0)
+ local winheight = api.nvim_win_get_height(0)
local buf_cont_start = rep - sb - winheight + 2
for i = buf_cont_start, (rep - 1) do
bufcontents[#bufcontents + 1] = ('%d: foobar'):format(i)
@@ -63,6 +63,6 @@ describe(':edit term://*', function()
exp_screen = exp_screen .. (' '):rep(columns) .. '|\n'
scr:expect(exp_screen)
- eq(bufcontents, meths.nvim_buf_get_lines(0, 0, -1, true))
+ eq(bufcontents, api.nvim_buf_get_lines(0, 0, -1, true))
end)
end)
diff --git a/test/functional/terminal/ex_terminal_spec.lua b/test/functional/terminal/ex_terminal_spec.lua
index 266a34feea..55ddfbab7b 100644
--- a/test/functional/terminal/ex_terminal_spec.lua
+++ b/test/functional/terminal/ex_terminal_spec.lua
@@ -5,8 +5,8 @@ local clear, poke_eventloop = helpers.clear, helpers.poke_eventloop
local testprg, source, eq = helpers.testprg, helpers.source, helpers.eq
local feed = helpers.feed
local feed_command, eval = helpers.feed_command, helpers.eval
-local funcs = helpers.funcs
-local meths = helpers.meths
+local fn = helpers.fn
+local api = helpers.api
local retry = helpers.retry
local ok = helpers.ok
local command = helpers.command
@@ -36,7 +36,7 @@ describe(':terminal', function()
poke_eventloop()
-- Wait for some terminal activity.
retry(nil, 4000, function()
- ok(funcs.line('$') > 6)
+ ok(fn.line('$') > 6)
end)
feed_command('messages')
screen:expect([[
@@ -80,7 +80,7 @@ describe(':terminal', function()
it('Enter/Leave does not increment jumplist #3723', function()
feed_command('terminal')
local function enter_and_leave()
- local lines_before = funcs.line('$')
+ local lines_before = fn.line('$')
-- Create a new line (in the shell). For a normal buffer this
-- increments the jumplist; for a terminal-buffer it should not. #3723
feed('i')
@@ -91,44 +91,44 @@ describe(':terminal', function()
poke_eventloop()
-- Wait for >=1 lines to be created.
retry(nil, 4000, function()
- ok(funcs.line('$') > lines_before)
+ ok(fn.line('$') > lines_before)
end)
end
enter_and_leave()
enter_and_leave()
enter_and_leave()
- ok(funcs.line('$') > 6) -- Verify assumption.
- local jumps = funcs.split(funcs.execute('jumps'), '\n')
+ ok(fn.line('$') > 6) -- Verify assumption.
+ local jumps = fn.split(fn.execute('jumps'), '\n')
eq(' jump line col file/text', jumps[1])
eq(3, #jumps)
end)
it('nvim_get_mode() in :terminal', function()
command('terminal')
- eq({ blocking = false, mode = 'nt' }, meths.nvim_get_mode())
+ eq({ blocking = false, mode = 'nt' }, api.nvim_get_mode())
feed('i')
- eq({ blocking = false, mode = 't' }, meths.nvim_get_mode())
+ eq({ blocking = false, mode = 't' }, api.nvim_get_mode())
feed([[<C-\><C-N>]])
- eq({ blocking = false, mode = 'nt' }, meths.nvim_get_mode())
+ eq({ blocking = false, mode = 'nt' }, api.nvim_get_mode())
end)
it(':stopinsert RPC request exits terminal-mode #7807', function()
command('terminal')
feed('i[tui] insert-mode')
- eq({ blocking = false, mode = 't' }, meths.nvim_get_mode())
+ eq({ blocking = false, mode = 't' }, api.nvim_get_mode())
command('stopinsert')
feed('<Ignore>') -- Add input to separate two RPC requests
- eq({ blocking = false, mode = 'nt' }, meths.nvim_get_mode())
+ eq({ blocking = false, mode = 'nt' }, api.nvim_get_mode())
end)
it(":stopinsert in normal mode doesn't break insert mode #9889", function()
command('terminal')
- eq({ blocking = false, mode = 'nt' }, meths.nvim_get_mode())
+ eq({ blocking = false, mode = 'nt' }, api.nvim_get_mode())
command('stopinsert')
feed('<Ignore>') -- Add input to separate two RPC requests
- eq({ blocking = false, mode = 'nt' }, meths.nvim_get_mode())
+ eq({ blocking = false, mode = 'nt' }, api.nvim_get_mode())
feed('a')
- eq({ blocking = false, mode = 't' }, meths.nvim_get_mode())
+ eq({ blocking = false, mode = 't' }, api.nvim_get_mode())
end)
it('switching to terminal buffer in Insert mode goes to Terminal mode #7164', function()
@@ -139,9 +139,9 @@ describe(':terminal', function()
command('autocmd InsertLeave * let g:events += ["InsertLeave"]')
command('autocmd TermEnter * let g:events += ["TermEnter"]')
command('inoremap <F2> <Cmd>wincmd p<CR>')
- eq({ blocking = false, mode = 'i' }, meths.nvim_get_mode())
+ eq({ blocking = false, mode = 'i' }, api.nvim_get_mode())
feed('<F2>')
- eq({ blocking = false, mode = 't' }, meths.nvim_get_mode())
+ eq({ blocking = false, mode = 't' }, api.nvim_get_mode())
eq({ 'InsertLeave', 'TermEnter' }, eval('g:events'))
end)
end)
@@ -159,9 +159,9 @@ local function test_terminal_with_fake_shell(backslash)
clear()
screen = Screen.new(50, 4)
screen:attach({ rgb = false })
- meths.nvim_set_option_value('shell', shell_path, {})
- meths.nvim_set_option_value('shellcmdflag', 'EXE', {})
- meths.nvim_set_option_value('shellxquote', '', {})
+ api.nvim_set_option_value('shell', shell_path, {})
+ api.nvim_set_option_value('shellcmdflag', 'EXE', {})
+ api.nvim_set_option_value('shellxquote', '', {})
end)
it('with no argument, acts like termopen()', function()
@@ -178,7 +178,7 @@ local function test_terminal_with_fake_shell(backslash)
end)
it("with no argument, and 'shell' is set to empty string", function()
- meths.nvim_set_option_value('shell', '', {})
+ api.nvim_set_option_value('shell', '', {})
feed_command('terminal')
screen:expect([[
^ |
@@ -188,7 +188,7 @@ local function test_terminal_with_fake_shell(backslash)
end)
it("with no argument, but 'shell' has arguments, acts like termopen()", function()
- meths.nvim_set_option_value('shell', shell_path .. ' INTERACT', {})
+ api.nvim_set_option_value('shell', shell_path .. ' INTERACT', {})
feed_command('terminal')
screen:expect([[
^interact $ |
@@ -209,7 +209,7 @@ local function test_terminal_with_fake_shell(backslash)
end)
it("executes a given command through the shell, when 'shell' has arguments", function()
- meths.nvim_set_option_value('shell', shell_path .. ' -t jeff', {})
+ api.nvim_set_option_value('shell', shell_path .. ' -t jeff', {})
command('set shellxquote=') -- win: avoid extra quotes
feed_command('terminal echo hi')
screen:expect([[
diff --git a/test/functional/terminal/helpers.lua b/test/functional/terminal/helpers.lua
index 59af0ab167..b878b9eb43 100644
--- a/test/functional/terminal/helpers.lua
+++ b/test/functional/terminal/helpers.lua
@@ -5,7 +5,7 @@ local helpers = require('test.functional.helpers')(nil)
local Screen = require('test.functional.ui.screen')
local testprg = helpers.testprg
local exec_lua = helpers.exec_lua
-local meths = helpers.meths
+local api = helpers.api
local nvim_prog = helpers.nvim_prog
local function feed_data(data)
@@ -89,8 +89,8 @@ local function screen_setup(extra_rows, command, cols, env, screen_opts)
command = command and command or default_command
cols = cols and cols or 50
- meths.nvim_command('highlight TermCursor cterm=reverse')
- meths.nvim_command('highlight TermCursorNC ctermbg=11')
+ api.nvim_command('highlight TermCursor cterm=reverse')
+ api.nvim_command('highlight TermCursorNC ctermbg=11')
local screen = Screen.new(cols, 7 + extra_rows)
screen:set_default_attr_ids({
@@ -113,17 +113,17 @@ local function screen_setup(extra_rows, command, cols, env, screen_opts)
screen:attach(screen_opts or { rgb = false })
- meths.nvim_command('enew')
- meths.nvim_call_function('termopen', { command, env and { env = env } or nil })
- meths.nvim_input('<CR>')
- local vim_errmsg = meths.nvim_eval('v:errmsg')
+ api.nvim_command('enew')
+ api.nvim_call_function('termopen', { command, env and { env = env } or nil })
+ api.nvim_input('<CR>')
+ local vim_errmsg = api.nvim_eval('v:errmsg')
if vim_errmsg and '' ~= vim_errmsg then
error(vim_errmsg)
end
- meths.nvim_command('setlocal scrollback=10')
- meths.nvim_command('startinsert')
- meths.nvim_input('<Ignore>') -- Add input to separate two RPC requests
+ api.nvim_command('setlocal scrollback=10')
+ api.nvim_command('startinsert')
+ api.nvim_input('<Ignore>') -- Add input to separate two RPC requests
-- tty-test puts the terminal into raw mode and echoes input. Tests work by
-- feeding termcodes to control the display and asserting by screen:expect.
@@ -147,7 +147,7 @@ local function screen_setup(extra_rows, command, cols, env, screen_opts)
screen:expect(table.concat(expected, '|\n') .. '|')
else
-- This eval also acts as a poke_eventloop().
- if 0 == meths.nvim_eval("exists('b:terminal_job_id')") then
+ if 0 == api.nvim_eval("exists('b:terminal_job_id')") then
error('terminal job failed to start')
end
end
diff --git a/test/functional/terminal/highlight_spec.lua b/test/functional/terminal/highlight_spec.lua
index a8e0f1ac27..ec057c6766 100644
--- a/test/functional/terminal/highlight_spec.lua
+++ b/test/functional/terminal/highlight_spec.lua
@@ -2,11 +2,11 @@ local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local thelpers = require('test.functional.terminal.helpers')
local feed, clear = helpers.feed, helpers.clear
-local meths = helpers.meths
+local api = helpers.api
local testprg, command = helpers.testprg, helpers.command
local nvim_prog_abs = helpers.nvim_prog_abs
local eq, eval = helpers.eq, helpers.eval
-local funcs = helpers.funcs
+local fn = helpers.fn
local nvim_set = helpers.nvim_set
local is_os = helpers.is_os
local skip = helpers.skip
@@ -151,7 +151,7 @@ it(':terminal highlight has lower precedence than editor #9964', function()
})
screen:attach({ rgb = true })
-- Child nvim process in :terminal (with cterm colors).
- funcs.termopen({
+ fn.termopen({
nvim_prog_abs(),
'-n',
'-u',
@@ -251,7 +251,7 @@ describe(':terminal highlight with custom palette', function()
[9] = { bold = true },
})
screen:attach({ rgb = true })
- meths.nvim_set_var('terminal_color_3', '#123456')
+ api.nvim_set_var('terminal_color_3', '#123456')
command(("enew | call termopen(['%s'])"):format(testprg('tty-test')))
feed('i')
screen:expect([[
diff --git a/test/functional/terminal/mouse_spec.lua b/test/functional/terminal/mouse_spec.lua
index e98b04090c..0395d5ee16 100644
--- a/test/functional/terminal/mouse_spec.lua
+++ b/test/functional/terminal/mouse_spec.lua
@@ -1,7 +1,7 @@
local helpers = require('test.functional.helpers')(after_each)
local thelpers = require('test.functional.terminal.helpers')
local clear, eq, eval = helpers.clear, helpers.eq, helpers.eval
-local feed, meths, command = helpers.feed, helpers.meths, helpers.command
+local feed, api, command = helpers.feed, helpers.api, helpers.command
local feed_data = thelpers.feed_data
local is_os = helpers.is_os
local skip = helpers.skip
@@ -11,7 +11,7 @@ describe(':terminal mouse', function()
before_each(function()
clear()
- meths.nvim_set_option_value('statusline', '==========', {})
+ api.nvim_set_option_value('statusline', '==========', {})
command('highlight StatusLine cterm=NONE')
command('highlight StatusLineNC cterm=NONE')
command('highlight VertSplit cterm=NONE')
@@ -514,7 +514,7 @@ describe(':terminal mouse', function()
end)
it('handles terminal size when switching buffers', function()
- meths.nvim_set_option_value('hidden', true, {})
+ api.nvim_set_option_value('hidden', true, {})
feed('<c-\\><c-n><c-w><c-w>')
screen:expect([[
{7: 27 }line │line30 |
diff --git a/test/functional/terminal/scrollback_spec.lua b/test/functional/terminal/scrollback_spec.lua
index bd58ef0b0a..858e23984d 100644
--- a/test/functional/terminal/scrollback_spec.lua
+++ b/test/functional/terminal/scrollback_spec.lua
@@ -7,7 +7,7 @@ local eval = helpers.eval
local command = helpers.command
local poke_eventloop = helpers.poke_eventloop
local retry = helpers.retry
-local meths = helpers.meths
+local api = helpers.api
local feed_data = thelpers.feed_data
local pcall_err = helpers.pcall_err
local exec_lua = helpers.exec_lua
@@ -85,7 +85,7 @@ describe(':terminal scrollback', function()
{1: } |
{3:-- TERMINAL --} |
]])
- eq(7, meths.nvim_buf_line_count(0))
+ eq(7, api.nvim_buf_line_count(0))
end)
describe('and then 3 more lines are printed', function()
@@ -169,7 +169,7 @@ describe(':terminal scrollback', function()
{2:^ } |
|
]])
- eq(8, meths.nvim_buf_line_count(0))
+ eq(8, api.nvim_buf_line_count(0))
feed([[3k]])
screen:expect([[
^line4 |
@@ -203,7 +203,7 @@ describe(':terminal scrollback', function()
|
{3:-- TERMINAL --} |
]])
- eq(4, meths.nvim_buf_line_count(0))
+ eq(4, api.nvim_buf_line_count(0))
end
it('will delete the last two empty lines', will_delete_last_two_lines)
@@ -221,7 +221,7 @@ describe(':terminal scrollback', function()
{1: } |
{3:-- TERMINAL --} |
]])
- eq(4, meths.nvim_buf_line_count(0))
+ eq(4, api.nvim_buf_line_count(0))
feed('<c-\\><c-n>gg')
screen:expect([[
^tty ready |
@@ -260,7 +260,7 @@ describe(':terminal scrollback', function()
{1: } |
{3:-- TERMINAL --} |
]])
- eq(7, meths.nvim_buf_line_count(0))
+ eq(7, api.nvim_buf_line_count(0))
end)
describe('and the height is increased by 1', function()
@@ -286,7 +286,7 @@ describe(':terminal scrollback', function()
describe('and then by 3', function()
before_each(function()
pop_then_push()
- eq(8, meths.nvim_buf_line_count(0))
+ eq(8, api.nvim_buf_line_count(0))
screen:try_resize(screen._width, screen._height + 3)
end)
@@ -301,7 +301,7 @@ describe(':terminal scrollback', function()
{1: } |
{3:-- TERMINAL --} |
]])
- eq(9, meths.nvim_buf_line_count(0))
+ eq(9, api.nvim_buf_line_count(0))
feed('<c-\\><c-n>gg')
screen:expect([[
^tty ready |
@@ -341,7 +341,7 @@ describe(':terminal scrollback', function()
]])
-- since there's an empty line after the cursor, the buffer line
-- count equals the terminal screen height
- eq(11, meths.nvim_buf_line_count(0))
+ eq(11, api.nvim_buf_line_count(0))
end)
end)
end)
@@ -380,7 +380,7 @@ describe("'scrollback' option", function()
end)
local function set_fake_shell()
- meths.nvim_set_option_value('shell', string.format('"%s" INTERACT', testprg('shell-test')), {})
+ api.nvim_set_option_value('shell', string.format('"%s" INTERACT', testprg('shell-test')), {})
end
local function expect_lines(expected, epsilon)
@@ -399,7 +399,7 @@ describe("'scrollback' option", function()
screen = thelpers.screen_setup(nil, { 'sh' }, 30)
end
- meths.nvim_set_option_value('scrollback', 0, {})
+ api.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()
@@ -417,7 +417,7 @@ describe("'scrollback' option", function()
screen = thelpers.screen_setup(nil, { 'sh' }, 30)
end
- meths.nvim_set_option_value('scrollback', 200, {})
+ api.nvim_set_option_value('scrollback', 200, {})
-- Wait for prompt.
screen:expect { any = '%$' }
@@ -428,12 +428,12 @@ describe("'scrollback' option", function()
retry(nil, nil, function()
expect_lines(33, 2)
end)
- meths.nvim_set_option_value('scrollback', 10, {})
+ api.nvim_set_option_value('scrollback', 10, {})
poke_eventloop()
retry(nil, nil, function()
expect_lines(16)
end)
- meths.nvim_set_option_value('scrollback', 10000, {})
+ api.nvim_set_option_value('scrollback', 10000, {})
retry(nil, nil, function()
expect_lines(16)
end)
@@ -494,18 +494,18 @@ describe("'scrollback' option", function()
]])
local term_height = 6 -- Actual terminal screen height, not the scrollback
-- Initial
- local scrollback = meths.nvim_get_option_value('scrollback', {})
+ local scrollback = api.nvim_get_option_value('scrollback', {})
eq(scrollback + term_height, eval('line("$")'))
-- Reduction
scrollback = scrollback - 2
- meths.nvim_set_option_value('scrollback', scrollback, {})
+ api.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.nvim_get_option_value('scrollback', {}))
+ eq(10000, api.nvim_get_option_value('scrollback', {}))
end)
it('error if set to invalid value', function()
@@ -518,7 +518,7 @@ describe("'scrollback' option", function()
it('defaults to -1 on normal buffers', function()
command('new')
- eq(-1, meths.nvim_get_option_value('scrollback', {}))
+ eq(-1, api.nvim_get_option_value('scrollback', {}))
end)
it(':setlocal in a :terminal buffer', function()
@@ -527,45 +527,45 @@ describe("'scrollback' option", function()
-- _Global_ scrollback=-1 defaults :terminal to 10_000.
command('setglobal scrollback=-1')
command('terminal')
- eq(10000, meths.nvim_get_option_value('scrollback', {}))
+ eq(10000, api.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.nvim_get_option_value('scrollback', {}))
+ eq(100000, api.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.nvim_get_option_value('scrollback', {}))
+ eq(100000, api.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.nvim_get_option_value('scrollback', {}))
+ eq(-1, api.nvim_get_option_value('scrollback', {}))
-- :setlocal to anything except -1. Currently, this just has no effect.
command('setlocal scrollback=42')
- eq(42, meths.nvim_get_option_value('scrollback', {}))
+ eq(42, api.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.nvim_get_option_value('scrollback', {}))
+ eq(42, api.nvim_get_option_value('scrollback', {}))
command('terminal')
- eq(42, meths.nvim_get_option_value('scrollback', {})) -- inherits global default
+ eq(42, api.nvim_get_option_value('scrollback', {})) -- inherits global default
command('setlocal scrollback=99')
- eq(99, meths.nvim_get_option_value('scrollback', {}))
+ eq(99, api.nvim_get_option_value('scrollback', {}))
command('set scrollback<') -- reset to global default
- eq(42, meths.nvim_get_option_value('scrollback', {}))
+ eq(42, api.nvim_get_option_value('scrollback', {}))
command('setglobal scrollback=734') -- new global default
- eq(42, meths.nvim_get_option_value('scrollback', {})) -- local value did not change
+ eq(42, api.nvim_get_option_value('scrollback', {})) -- local value did not change
command('terminal')
- eq(734, meths.nvim_get_option_value('scrollback', {}))
+ eq(734, api.nvim_get_option_value('scrollback', {}))
end)
end)
diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua
index bd122ee848..54fbfd191a 100644
--- a/test/functional/terminal/tui_spec.lua
+++ b/test/functional/terminal/tui_spec.lua
@@ -20,8 +20,8 @@ local nvim_prog = helpers.nvim_prog
local nvim_set = helpers.nvim_set
local ok = helpers.ok
local read_file = helpers.read_file
-local funcs = helpers.funcs
-local meths = helpers.meths
+local fn = helpers.fn
+local api = helpers.api
local is_ci = helpers.is_ci
local is_os = helpers.is_os
local new_pipename = helpers.new_pipename
@@ -375,7 +375,7 @@ describe('TUI', function()
if esc then
feed_data('\027[<65;8;1M')
else
- meths.nvim_input_mouse('wheel', 'down', '', 0, 0, 7)
+ api.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.nvim_input_mouse('wheel', 'down', '', 0, 0, 47)
+ api.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.nvim_input_mouse('wheel', 'right', '', 0, 0, 7)
+ api.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.nvim_input_mouse('wheel', 'right', '', 0, 0, 47)
+ api.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.nvim_input_mouse('wheel', 'down', 'S', 0, 0, 7)
+ api.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.nvim_input_mouse('wheel', 'down', 'S', 0, 0, 47)
+ api.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.nvim_input_mouse('wheel', 'right', 'S', 0, 0, 7)
+ api.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.nvim_input_mouse('wheel', 'right', 'S', 0, 0, 47)
+ api.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.nvim_input_mouse('wheel', 'up', '', 0, 0, 7)
+ api.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.nvim_input_mouse('wheel', 'up', '', 0, 0, 47)
+ api.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.nvim_input_mouse('wheel', 'left', '', 0, 0, 7)
+ api.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.nvim_input_mouse('wheel', 'left', '', 0, 0, 47)
+ api.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.nvim_input_mouse('wheel', 'up', 'S', 0, 0, 7)
+ api.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.nvim_input_mouse('wheel', 'up', 'S', 0, 0, 47)
+ api.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.nvim_input_mouse('wheel', 'left', 'S', 0, 0, 7)
+ api.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.nvim_input_mouse('wheel', 'left', 'S', 0, 0, 47)
+ api.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.nvim_input_mouse('right', 'press', '', 0, 0, 4)
+ api.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.nvim_input_mouse('right', 'release', '', 0, 0, 4)
+ api.nvim_input_mouse('right', 'release', '', 0, 0, 4)
end
screen:expect_unchanged()
if esc then
feed_data('\027[<35;7;4M')
else
- meths.nvim_input_mouse('move', '', '', 0, 3, 6)
+ api.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.nvim_input_mouse('left', 'press', '', 0, 2, 6)
+ api.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.nvim_input_mouse('left', 'release', '', 0, 2, 6)
+ api.nvim_input_mouse('left', 'release', '', 0, 2, 6)
end
screen:expect_unchanged()
if esc then
feed_data('\027[<2;45;3M')
else
- meths.nvim_input_mouse('right', 'press', '', 0, 2, 44)
+ api.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.nvim_input_mouse('right', 'drag', '', 0, 5, 47)
+ api.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.nvim_input_mouse('right', 'release', '', 0, 5, 47)
+ api.nvim_input_mouse('right', 'release', '', 0, 5, 47)
end
screen:expect([[
{1:p}opup menu test |
@@ -743,23 +743,23 @@ describe('TUI', function()
it('accepts keypad keys from kitty keyboard protocol #19180', function()
feed_data('i')
- feed_data(funcs.nr2char(57399)) -- KP_0
- feed_data(funcs.nr2char(57400)) -- KP_1
- feed_data(funcs.nr2char(57401)) -- KP_2
- feed_data(funcs.nr2char(57402)) -- KP_3
- feed_data(funcs.nr2char(57403)) -- KP_4
- feed_data(funcs.nr2char(57404)) -- KP_5
- feed_data(funcs.nr2char(57405)) -- KP_6
- feed_data(funcs.nr2char(57406)) -- KP_7
- feed_data(funcs.nr2char(57407)) -- KP_8
- feed_data(funcs.nr2char(57408)) -- KP_9
- feed_data(funcs.nr2char(57409)) -- KP_DECIMAL
- feed_data(funcs.nr2char(57410)) -- KP_DIVIDE
- feed_data(funcs.nr2char(57411)) -- KP_MULTIPLY
- feed_data(funcs.nr2char(57412)) -- KP_SUBTRACT
- feed_data(funcs.nr2char(57413)) -- KP_ADD
- feed_data(funcs.nr2char(57414)) -- KP_ENTER
- feed_data(funcs.nr2char(57415)) -- KP_EQUAL
+ feed_data(fn.nr2char(57399)) -- KP_0
+ feed_data(fn.nr2char(57400)) -- KP_1
+ feed_data(fn.nr2char(57401)) -- KP_2
+ feed_data(fn.nr2char(57402)) -- KP_3
+ feed_data(fn.nr2char(57403)) -- KP_4
+ feed_data(fn.nr2char(57404)) -- KP_5
+ feed_data(fn.nr2char(57405)) -- KP_6
+ feed_data(fn.nr2char(57406)) -- KP_7
+ feed_data(fn.nr2char(57407)) -- KP_8
+ feed_data(fn.nr2char(57408)) -- KP_9
+ feed_data(fn.nr2char(57409)) -- KP_DECIMAL
+ feed_data(fn.nr2char(57410)) -- KP_DIVIDE
+ feed_data(fn.nr2char(57411)) -- KP_MULTIPLY
+ feed_data(fn.nr2char(57412)) -- KP_SUBTRACT
+ feed_data(fn.nr2char(57413)) -- KP_ADD
+ feed_data(fn.nr2char(57414)) -- KP_ENTER
+ feed_data(fn.nr2char(57415)) -- KP_EQUAL
screen:expect([[
0123456789./*-+ |
={1: } |
@@ -768,7 +768,7 @@ describe('TUI', function()
{3:-- INSERT --} |
{3:-- TERMINAL --} |
]])
- feed_data(funcs.nr2char(57417)) -- KP_LEFT
+ feed_data(fn.nr2char(57417)) -- KP_LEFT
screen:expect([[
0123456789./*-+ |
{1:=} |
@@ -777,7 +777,7 @@ describe('TUI', function()
{3:-- INSERT --} |
{3:-- TERMINAL --} |
]])
- feed_data(funcs.nr2char(57418)) -- KP_RIGHT
+ feed_data(fn.nr2char(57418)) -- KP_RIGHT
screen:expect([[
0123456789./*-+ |
={1: } |
@@ -786,7 +786,7 @@ describe('TUI', function()
{3:-- INSERT --} |
{3:-- TERMINAL --} |
]])
- feed_data(funcs.nr2char(57419)) -- KP_UP
+ feed_data(fn.nr2char(57419)) -- KP_UP
screen:expect([[
0{1:1}23456789./*-+ |
= |
@@ -795,7 +795,7 @@ describe('TUI', function()
{3:-- INSERT --} |
{3:-- TERMINAL --} |
]])
- feed_data(funcs.nr2char(57420)) -- KP_DOWN
+ feed_data(fn.nr2char(57420)) -- KP_DOWN
screen:expect([[
0123456789./*-+ |
={1: } |
@@ -804,7 +804,7 @@ describe('TUI', function()
{3:-- INSERT --} |
{3:-- TERMINAL --} |
]])
- feed_data(funcs.nr2char(57425)) -- KP_INSERT
+ feed_data(fn.nr2char(57425)) -- KP_INSERT
screen:expect([[
0123456789./*-+ |
={1: } |
@@ -840,7 +840,7 @@ describe('TUI', function()
|
{3:-- TERMINAL --} |
]])
- feed_data(funcs.nr2char(57426)) -- KP_DELETE
+ feed_data(fn.nr2char(57426)) -- KP_DELETE
screen:expect([[
0123456789{1:/}*-+ |
= |
@@ -849,7 +849,7 @@ describe('TUI', function()
|
{3:-- TERMINAL --} |
]])
- feed_data(funcs.nr2char(57423)) -- KP_HOME
+ feed_data(fn.nr2char(57423)) -- KP_HOME
screen:expect([[
{1:0}123456789/*-+ |
= |
@@ -858,7 +858,7 @@ describe('TUI', function()
|
{3:-- TERMINAL --} |
]])
- feed_data(funcs.nr2char(57424)) -- KP_END
+ feed_data(fn.nr2char(57424)) -- KP_END
screen:expect([[
0123456789/*-{1:+} |
= |
@@ -1903,7 +1903,7 @@ describe('TUI', function()
[5] = { bold = true, reverse = true },
})
screen:attach()
- funcs.termopen({
+ fn.termopen({
nvim_prog,
'--clean',
'--cmd',
@@ -2989,7 +2989,7 @@ describe('TUI as a client', function()
local client_super = spawn_argv(true)
set_session(server)
- local server_pipe = meths.nvim_get_vvar('servername')
+ local server_pipe = api.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.nvim_get_vvar('shell_error'))
+ eq(0, api.nvim_get_vvar('shell_error'))
-- exits on input eof #22244
- funcs.system({ nvim_prog, '--server', server_pipe, '--remote-ui' })
- eq(1, meths.nvim_get_vvar('shell_error'))
+ fn.system({ nvim_prog, '--server', server_pipe, '--remote-ui' })
+ eq(1, api.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 5cfff301a2..17411e2724 100644
--- a/test/functional/terminal/window_split_tab_spec.lua
+++ b/test/functional/terminal/window_split_tab_spec.lua
@@ -7,7 +7,7 @@ local feed_command = helpers.feed_command
local command = helpers.command
local eq = helpers.eq
local eval = helpers.eval
-local meths = helpers.meths
+local api = helpers.api
local sleep = vim.uv.sleep
local retry = helpers.retry
local is_os = helpers.is_os
@@ -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.nvim_set_option_value('statusline', '==========', {})
+ api.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.nvim_get_option_value('channel', {})
+ local channel = api.nvim_get_option_value('channel', {})
command('enew')
sleep(100)
- meths.nvim_chan_send(channel, 'foo')
+ api.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 d91dff096c..f4f7bc691c 100644
--- a/test/functional/treesitter/highlight_spec.lua
+++ b/test/functional/treesitter/highlight_spec.lua
@@ -6,7 +6,7 @@ local insert = helpers.insert
local exec_lua = helpers.exec_lua
local feed = helpers.feed
local command = helpers.command
-local meths = helpers.meths
+local api = helpers.api
local eq = helpers.eq
before_each(clear)
@@ -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.nvim_get_hl_by_name(name, 1).foreground
+ return api.nvim_get_hl_by_name(name, 1).foreground
end
- 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 })
+ api.nvim_set_hl(0, '@foo', { fg = 1 })
+ api.nvim_set_hl(0, '@foo.bar', { fg = 2 })
+ api.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.nvim_set_hl(0, '@foo.missing.exists', { fg = 3 })
+ api.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')
@@ -772,7 +772,7 @@ describe('treesitter highlighting (help)', function()
]],
}
- helpers.meths.nvim_buf_set_text(0, 0, 1, 0, 5, { 'lua' })
+ helpers.api.nvim_buf_set_text(0, 0, 1, 0, 5, { 'lua' })
screen:expect {
grid = [[
@@ -785,7 +785,7 @@ describe('treesitter highlighting (help)', function()
]],
}
- helpers.meths.nvim_buf_set_text(0, 0, 1, 0, 4, { 'ruby' })
+ helpers.api.nvim_buf_set_text(0, 0, 1, 0, 4, { 'ruby' })
screen:expect {
grid = [[
diff --git a/test/functional/ui/bufhl_spec.lua b/test/functional/ui/bufhl_spec.lua
index 2cde0a8688..417a19f92c 100644
--- a/test/functional/ui/bufhl_spec.lua
+++ b/test/functional/ui/bufhl_spec.lua
@@ -3,10 +3,10 @@ local Screen = require('test.functional.ui.screen')
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local command, neq = helpers.command, helpers.neq
-local meths = helpers.meths
+local api = helpers.api
local eq = helpers.eq
local pcall_err = helpers.pcall_err
-local set_virtual_text = meths.nvim_buf_set_virtual_text
+local set_virtual_text = api.nvim_buf_set_virtual_text
describe('Buffer highlighting', function()
local screen
@@ -40,8 +40,8 @@ describe('Buffer highlighting', function()
})
end)
- local add_highlight = meths.nvim_buf_add_highlight
- local clear_namespace = meths.nvim_buf_clear_namespace
+ local add_highlight = api.nvim_buf_add_highlight
+ local clear_namespace = api.nvim_buf_clear_namespace
it('works', function()
insert([[
@@ -134,7 +134,7 @@ describe('Buffer highlighting', function()
end)
it('and clearing using deprecated name', function()
- meths.nvim_buf_clear_highlight(0, id1, 0, -1)
+ api.nvim_buf_clear_highlight(0, id1, 0, -1)
screen:expect([[
a {4:longer} example |
in {6:order} to de{4:monstr}ate |
@@ -494,16 +494,16 @@ describe('Buffer highlighting', function()
end)
it('respects priority', function()
- local id = meths.nvim_create_namespace('')
+ local id = api.nvim_create_namespace('')
insert [[foobar]]
- meths.nvim_buf_set_extmark(0, id, 0, 0, {
+ api.nvim_buf_set_extmark(0, id, 0, 0, {
end_line = 0,
end_col = 5,
hl_group = 'Statement',
priority = 100,
})
- meths.nvim_buf_set_extmark(0, id, 0, 0, {
+ api.nvim_buf_set_extmark(0, id, 0, 0, {
end_line = 0,
end_col = 6,
hl_group = 'String',
@@ -525,13 +525,13 @@ describe('Buffer highlighting', function()
]],
}
- meths.nvim_buf_set_extmark(0, id, 0, 0, {
+ api.nvim_buf_set_extmark(0, id, 0, 0, {
end_line = 0,
end_col = 6,
hl_group = 'String',
priority = 1,
})
- meths.nvim_buf_set_extmark(0, id, 0, 0, {
+ api.nvim_buf_set_extmark(0, id, 0, 0, {
end_line = 0,
end_col = 5,
hl_group = 'Statement',
@@ -696,8 +696,8 @@ describe('Buffer highlighting', function()
end)
it('can be retrieved', function()
- local get_extmarks = meths.nvim_buf_get_extmarks
- local line_count = meths.nvim_buf_line_count
+ local get_extmarks = api.nvim_buf_get_extmarks
+ local line_count = api.nvim_buf_line_count
local s1 = { { 'Köttbullar', 'Comment' }, { 'Kräuterbutter' } }
local s2 = { { 'こんにちは', 'Comment' } }
@@ -900,9 +900,9 @@ describe('Buffer highlighting', function()
it('and virtual text use the same namespace counter', function()
eq(1, add_highlight(0, 0, 'String', 0, 0, -1))
eq(2, set_virtual_text(0, 0, 0, { { '= text', 'Comment' } }, {}))
- eq(3, meths.nvim_create_namespace('my-ns'))
+ eq(3, api.nvim_create_namespace('my-ns'))
eq(4, add_highlight(0, 0, 'String', 0, 0, -1))
eq(5, set_virtual_text(0, 0, 0, { { '= text', 'Comment' } }, {}))
- eq(6, meths.nvim_create_namespace('other-ns'))
+ eq(6, api.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 a26c529396..6c4000ba41 100644
--- a/test/functional/ui/cmdline_highlight_spec.lua
+++ b/test/functional/ui/cmdline_highlight_spec.lua
@@ -4,8 +4,8 @@ local Screen = require('test.functional.ui.screen')
local eq = helpers.eq
local feed = helpers.feed
local clear = helpers.clear
-local meths = helpers.meths
-local funcs = helpers.funcs
+local api = helpers.api
+local fn = helpers.fn
local source = helpers.source
local exec_capture = helpers.exec_capture
local dedent = helpers.dedent
@@ -156,16 +156,16 @@ before_each(function()
end)
local function set_color_cb(funcname, callback_return, id)
- meths.nvim_set_var('id', id or '')
- if id and id ~= '' and funcs.exists('*' .. funcname .. 'N') then
+ api.nvim_set_var('id', id or '')
+ if id and id ~= '' and fn.exists('*' .. funcname .. 'N') then
command(('let g:Nvim_color_input%s = {cmdline -> %sN(%s, cmdline)}'):format(id, funcname, id))
if callback_return then
- meths.nvim_set_var('callback_return' .. id, callback_return)
+ api.nvim_set_var('callback_return' .. id, callback_return)
end
else
- meths.nvim_set_var('Nvim_color_input', funcname)
+ api.nvim_set_var('Nvim_color_input', funcname)
if callback_return then
- meths.nvim_set_var('callback_return', callback_return)
+ api.nvim_set_var('callback_return', callback_return)
end
end
end
@@ -176,7 +176,7 @@ end
describe('Command-line coloring', function()
it('works', function()
set_color_cb('RainBowParens')
- meths.nvim_set_option_value('more', false, {})
+ api.nvim_set_option_value('more', false, {})
start_prompt()
screen:expect([[
|
@@ -361,9 +361,9 @@ describe('Command-line coloring', function()
|
]])
feed('\n')
- eq('let x = "«»«»«»«»«»"', meths.nvim_get_var('out'))
+ eq('let x = "«»«»«»«»«»"', api.nvim_get_var('out'))
local msg = '\nE5405: Chunk 0 start 10 splits multibyte character'
- eq(msg:rep(1), funcs.execute('messages'))
+ eq(msg:rep(1), fn.execute('messages'))
end)
it('allows interrupting callback with <C-c>', function()
set_color_cb('Halting')
@@ -397,7 +397,7 @@ describe('Command-line coloring', function()
:echo 42 |
]])
feed('\n')
- eq('echo 42', meths.nvim_get_var('out'))
+ eq('echo 42', api.nvim_get_var('out'))
feed('<C-c>')
screen:expect([[
^ |
@@ -502,9 +502,9 @@ describe('Command-line coloring', function()
]]))
eq(
{ '', ':', 'E888 detected for \\ze*', ':', 'E888 detected for \\zs*' },
- meths.nvim_buf_get_lines(0, 0, -1, false)
+ api.nvim_buf_get_lines(0, 0, -1, false)
)
- eq('', funcs.execute('messages'))
+ eq('', fn.execute('messages'))
end)
it('allows nesting input()s', function()
set_color_cb('ReturningGlobal', { { 0, 1, 'RBP1' } }, '')
@@ -563,16 +563,16 @@ describe('Command-line coloring', function()
{EOB:~ }|*6
|
]])
- 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'))
+ eq('1234', api.nvim_get_var('out'))
+ eq('234', api.nvim_get_var('out1'))
+ eq('34', api.nvim_get_var('out2'))
+ eq('4', api.nvim_get_var('out3'))
+ eq(0, fn.exists('g:out4'))
end)
it('runs callback with the same data only once', function()
local function new_recording_calls(...)
- eq({ ... }, meths.nvim_get_var('recording_calls'))
- meths.nvim_set_var('recording_calls', {})
+ eq({ ... }, api.nvim_get_var('recording_calls'))
+ api.nvim_set_var('recording_calls', {})
end
set_color_cb('Recording')
start_prompt('')
@@ -593,7 +593,7 @@ describe('Command-line coloring', function()
feed('<BS>')
new_recording_calls() -- ('a')
feed('<CR><CR>')
- eq('', meths.nvim_get_var('out'))
+ eq('', api.nvim_get_var('out'))
end)
it('does not crash when callback has caught not-a-editor-command exception', function()
source([[
@@ -608,12 +608,12 @@ describe('Command-line coloring', function()
]])
set_color_cb('CaughtExc')
start_prompt('1')
- eq(1, meths.nvim_eval('1'))
+ eq(1, api.nvim_eval('1'))
end)
end)
describe('Ex commands coloring', function()
it('works', function()
- meths.nvim_set_var('Nvim_color_cmdline', 'RainBowParens')
+ api.nvim_set_var('Nvim_color_cmdline', 'RainBowParens')
feed(':echo (((1)))')
screen:expect([[
|
@@ -622,11 +622,11 @@ describe('Ex commands coloring', function()
]])
end)
it('still executes command-line even if errored out', function()
- meths.nvim_set_var('Nvim_color_cmdline', 'SplitMultibyteStart')
+ api.nvim_set_var('Nvim_color_cmdline', 'SplitMultibyteStart')
feed(':let x = "«"\n')
- eq('«', meths.nvim_get_var('x'))
+ eq('«', api.nvim_get_var('x'))
local msg = 'E5405: Chunk 0 start 10 splits multibyte character'
- eq('\n' .. msg, funcs.execute('messages'))
+ eq('\n' .. msg, fn.execute('messages'))
end)
it('does not error out when called from a errorred out cycle', function()
-- Apparently when there is a cycle in which one of the commands errors out
@@ -645,9 +645,9 @@ describe('Ex commands coloring', function()
]]))
eq(
{ '', 'E888 detected for \\ze*', 'E888 detected for \\zs*' },
- meths.nvim_buf_get_lines(0, 0, -1, false)
+ api.nvim_buf_get_lines(0, 0, -1, false)
)
- eq('', funcs.execute('messages'))
+ eq('', fn.execute('messages'))
end)
it('does not crash when using `n` in debug mode', function()
feed(':debug execute "echo 1"\n')
@@ -708,7 +708,7 @@ describe('Ex commands coloring', function()
)
end)
it('errors out when failing to get callback', function()
- meths.nvim_set_var('Nvim_color_cmdline', 42)
+ api.nvim_set_var('Nvim_color_cmdline', 42)
feed(':#')
screen:expect([[
|
@@ -736,7 +736,7 @@ describe('Expressions coloring support', function()
]])
end)
it('does not use Nvim_color_expr', function()
- meths.nvim_set_var('Nvim_color_expr', 42)
+ api.nvim_set_var('Nvim_color_expr', 42)
-- Used to error out due to failing to get callback.
command('hi clear NvimNumber')
command('hi NvimNumber guifg=Blue2')
@@ -786,7 +786,7 @@ describe('Expressions coloring support', function()
{EOB:~ }|*6
:^ |
]])
- funcs.setreg('a', { '\192' })
+ fn.setreg('a', { '\192' })
feed('<C-r>="<C-r><C-r>a"<C-r><C-r>a"foo"')
screen:expect([[
|
diff --git a/test/functional/ui/cmdline_spec.lua b/test/functional/ui/cmdline_spec.lua
index 2670288cbb..40221269a8 100644
--- a/test/functional/ui/cmdline_spec.lua
+++ b/test/functional/ui/cmdline_spec.lua
@@ -9,7 +9,7 @@ local exec = helpers.exec
local eval = helpers.eval
local eq = helpers.eq
local is_os = helpers.is_os
-local meths = helpers.meths
+local api = helpers.api
local function new_screen(opt)
local screen = Screen.new(25, 5)
@@ -922,7 +922,7 @@ describe('cmdline redraw', function()
it('with rightleftcmd', function()
command('set rightleft rightleftcmd=search shortmess+=s')
- meths.nvim_buf_set_lines(0, 0, -1, true, { "let's rock!" })
+ api.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.nvim_buf_set_lines(0, 0, -1, true, { 'p' })
+ api.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.nvim_input_mouse('left', 'press', '', 0, 6, 10)
+ api.nvim_input_mouse('left', 'press', '', 0, 6, 10)
poke_eventloop()
- meths.nvim_input_mouse('left', 'drag', '', 0, 5, 10)
+ api.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 601d242de0..8d58c11302 100644
--- a/test/functional/ui/cursor_spec.lua
+++ b/test/functional/ui/cursor_spec.lua
@@ -1,6 +1,6 @@
local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
-local clear, meths = helpers.clear, helpers.meths
+local clear, api = helpers.clear, helpers.api
local eq = helpers.eq
local command = helpers.command
@@ -299,7 +299,7 @@ describe('ui/cursor', function()
}
-- Another cursor style.
- meths.nvim_set_option_value(
+ api.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.nvim_set_option_value(
+ api.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.nvim_set_option_value('guicursor', '', {})
+ api.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 42c9c706d1..186bf19214 100644
--- a/test/functional/ui/decorations_spec.lua
+++ b/test/functional/ui/decorations_spec.lua
@@ -7,8 +7,8 @@ local insert = helpers.insert
local exec_lua = helpers.exec_lua
local exec = helpers.exec
local expect_events = helpers.expect_events
-local meths = helpers.meths
-local funcs = helpers.funcs
+local api = helpers.api
+local fn = helpers.fn
local command = helpers.command
local eq = helpers.eq
local assert_alive = helpers.assert_alive
@@ -242,8 +242,8 @@ describe('decorations providers', function()
]]}
-- spell=false with higher priority does disable spell
- local ns = meths.nvim_create_namespace "spell"
- local id = meths.nvim_buf_set_extmark(0, ns, 0, 0, { priority = 30, end_row = 2, end_col = 23, spell = false })
+ local ns = api.nvim_create_namespace "spell"
+ local id = api.nvim_buf_set_extmark(0, ns, 0, 0, { priority = 30, end_row = 2, end_col = 23, spell = false })
screen:expect{grid=[[
I am well written text. |
@@ -266,7 +266,7 @@ describe('decorations providers', function()
command('echo ""')
-- spell=false with lower priority doesn't disable spell
- meths.nvim_buf_set_extmark(0, ns, 0, 0, { id = id, priority = 10, end_row = 2, end_col = 23, spell = false })
+ api.nvim_buf_set_extmark(0, ns, 0, 0, { id = id, priority = 10, end_row = 2, end_col = 23, spell = false })
screen:expect{grid=[[
I am well written text. |
@@ -305,7 +305,7 @@ describe('decorations providers', function()
LineNr = {italic=true, bg="Magenta"};
Comment = {fg="#FF0000", bg = 80*256+40};
CursorLine = {link="ErrorMsg"};
- } do meths.nvim_set_hl(ns1, k, v) end
+ } do api.nvim_set_hl(ns1, k, v) end
screen:expect{grid=[[
{3: 1 }{4:// just to see if there was an accid}|
@@ -326,7 +326,7 @@ describe('decorations providers', function()
|
]]}
- meths.nvim_set_hl_ns(ns1)
+ api.nvim_set_hl_ns(ns1)
screen:expect{grid=[[
{10: 1 }{11:// just to see if there was an accid}|
{10: }{11:ent} |
@@ -386,7 +386,7 @@ describe('decorations providers', function()
highlight link LinkGroup OriginalGroup
]]
- meths.nvim_buf_set_virtual_text(0, 0, 2, {{'- not red', 'LinkGroup'}}, {})
+ api.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 |
@@ -398,8 +398,8 @@ describe('decorations providers', function()
|
]]}
- meths.nvim_set_hl(ns1, 'LinkGroup', {fg = 'Blue'})
- meths.nvim_set_hl_ns(ns1)
+ api.nvim_set_hl(ns1, 'LinkGroup', {fg = 'Blue'})
+ api.nvim_set_hl_ns(ns1)
screen:expect{grid=[[
// just to see if there was an accident |
@@ -422,7 +422,7 @@ describe('decorations providers', function()
highlight link LinkGroup OriginalGroup
]]
- meths.nvim_buf_set_virtual_text(0, 0, 2, {{'- not red', 'LinkGroup'}}, {})
+ api.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 |
@@ -434,8 +434,8 @@ describe('decorations providers', function()
|
]]}
- meths.nvim_set_hl(ns1, 'LinkGroup', {fg = 'Blue', default=true})
- meths.nvim_set_hl_ns(ns1)
+ api.nvim_set_hl(ns1, 'LinkGroup', {fg = 'Blue', default=true})
+ api.nvim_set_hl_ns(ns1)
feed 'k'
screen:expect{grid=[[
@@ -625,7 +625,7 @@ describe('decorations providers', function()
end
]])
command([[autocmd CursorMoved * call line('w$')]])
- meths.nvim_win_set_cursor(0, {100, 0})
+ api.nvim_win_set_cursor(0, {100, 0})
screen:expect([[
{14: }hello97 |
{14: }hello98 |
@@ -636,7 +636,7 @@ describe('decorations providers', function()
{14: }hello103 |
|
]])
- meths.nvim_win_set_cursor(0, {1, 0})
+ api.nvim_win_set_cursor(0, {1, 0})
screen:expect([[
^hello1 |
hello2 |
@@ -765,7 +765,7 @@ describe('extmark decorations', function()
[43] = {background = Screen.colors.Yellow, undercurl = true, special = Screen.colors.Red};
}
- ns = meths.nvim_create_namespace 'test'
+ ns = api.nvim_create_namespace 'test'
end)
it('empty virtual text at eol should not break colorcolumn #17860', function()
@@ -788,7 +788,7 @@ describe('extmark decorations', function()
{1:~ }|*2
|
]])
- meths.nvim_buf_set_extmark(0, ns, 4, 0, { virt_text={{''}}, virt_text_pos='eol'})
+ api.nvim_buf_set_extmark(0, ns, 4, 0, { virt_text={{''}}, virt_text_pos='eol'})
screen:expect_unchanged()
end)
@@ -797,19 +797,19 @@ describe('extmark decorations', function()
feed 'gg'
for i = 1,9 do
- meths.nvim_buf_set_extmark(0, ns, i, 0, { virt_text={{'|', 'LineNr'}}, virt_text_pos='overlay'})
+ api.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.nvim_buf_set_extmark(0, ns, i, 4, { virt_text={{'|', 'NonText'}}, virt_text_pos='overlay'})
+ api.nvim_buf_set_extmark(0, ns, i, 4, { virt_text={{'|', 'NonText'}}, virt_text_pos='overlay'})
end
end
- meths.nvim_buf_set_extmark(0, ns, 9, 10, { virt_text={{'foo'}, {'bar', 'MoreMsg'}, {'!!', 'ErrorMsg'}}, virt_text_pos='overlay'})
+ api.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.nvim_buf_set_extmark(0, ns, 5, 28, { virt_text={{'loopy', 'ErrorMsg'}}, virt_text_pos='overlay'})
+ api.nvim_buf_set_extmark(0, ns, 5, 28, { virt_text={{'loopy', 'ErrorMsg'}}, virt_text_pos='overlay'})
-- bound check: right edge of window
- meths.nvim_buf_set_extmark(0, ns, 2, 26, { virt_text={{'bork bork bork'}, {(' bork'):rep(10), 'ErrorMsg'}}, virt_text_pos='overlay'})
+ api.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.nvim_buf_set_extmark(0, ns, 6, 16, { virt_text={{''}}, virt_text_pos='overlay'})
+ api.nvim_buf_set_extmark(0, ns, 6, 16, { virt_text={{''}}, virt_text_pos='overlay'})
screen:expect{grid=[[
^for _,item in ipairs(items) do |
@@ -858,12 +858,12 @@ describe('extmark decorations', function()
]]}
-- truncating in the middle of a char leaves a space
- 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'})
+ api.nvim_buf_set_lines(0, 0, 1, true, {'for _,item in ipairs(items) do -- 古古古'})
+ api.nvim_buf_set_lines(0, 10, 12, true, {' end -- ??????????', 'end -- ?古古古古?古古'})
+ api.nvim_buf_set_extmark(0, ns, 0, 35, { virt_text={{'A', 'ErrorMsg'}, {'AA'}}, virt_text_pos='overlay'})
+ api.nvim_buf_set_extmark(0, ns, 10, 19, { virt_text={{'口口口', 'ErrorMsg'}}, virt_text_pos='overlay'})
+ api.nvim_buf_set_extmark(0, ns, 11, 21, { virt_text={{'口口口', 'ErrorMsg'}}, virt_text_pos='overlay'})
+ api.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 古 |
@@ -908,7 +908,7 @@ describe('extmark decorations', function()
|
]]}
- meths.nvim_buf_clear_namespace(0, ns, 0, -1)
+ api.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) |
@@ -930,8 +930,8 @@ describe('extmark decorations', function()
screen:try_resize(50, 6)
insert(('ab'):rep(100))
for i = 0, 9 do
- 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})
+ api.nvim_buf_set_extmark(0, ns, 0, 42 + i, { virt_text={{tostring(i), 'ErrorMsg'}}, virt_text_pos='overlay'})
+ api.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}|
@@ -1027,9 +1027,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.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})
+ api.nvim_buf_set_lines(0, 0, -1, true, {'-- ' .. ('…'):rep(57)})
+ api.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text={{'?????', 'ErrorMsg'}}, virt_text_pos='overlay', virt_text_hide=true})
+ api.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:~ }|
@@ -1082,10 +1082,10 @@ describe('extmark decorations', function()
it('overlay virtual text works on and after a TAB #24022', function()
screen:try_resize(40, 3)
- 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' })
+ api.nvim_buf_set_lines(0, 0, -1, true, {'\t\tline 1'})
+ api.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = {{'AA', 'Search'}}, virt_text_pos = 'overlay', hl_mode = 'combine' })
+ api.nvim_buf_set_extmark(0, ns, 0, 1, { virt_text = {{'BB', 'Search'}}, virt_text_pos = 'overlay', hl_mode = 'combine' })
+ api.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:~ }|
@@ -1124,13 +1124,13 @@ describe('extmark decorations', function()
]]}
command 'hi Blendy guibg=Red blend=30'
- 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'})
+ api.nvim_buf_set_extmark(0, ns, 1, 5, { virt_text={{'blendy text - here', 'Blendy'}}, virt_text_pos='overlay', hl_mode='blend'})
+ api.nvim_buf_set_extmark(0, ns, 2, 5, { virt_text={{'combining color', 'Blendy'}}, virt_text_pos='overlay', hl_mode='combine'})
+ api.nvim_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, 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})
+ api.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})
+ api.nvim_buf_set_extmark(0, ns, 5, 5, { virt_text={{'combining color', 'Blendy'}}, virt_text_pos='overlay', hl_mode='combine', virt_text_hide=true})
+ api.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} |
@@ -1189,17 +1189,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.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'})
+ api.nvim_buf_set_extmark(0, ns, 1, 0, { virt_text={{'Very', 'ErrorMsg'}}, virt_text_win_col=31, hl_mode='blend'})
+ api.nvim_buf_set_extmark(0, ns, 1, 0, { virt_text={{'VERY', 'ErrorMsg'}}, virt_text_pos='right_align', hl_mode='blend'})
+ api.nvim_buf_set_extmark(0, ns, 2, 10, { virt_text={{'Much', 'ErrorMsg'}}, virt_text_win_col=31, hl_mode='blend'})
+ api.nvim_buf_set_extmark(0, ns, 2, 10, { virt_text={{'MUCH', 'ErrorMsg'}}, virt_text_pos='right_align', hl_mode='blend'})
+ api.nvim_buf_set_extmark(0, ns, 3, 14, { virt_text={{'Error', 'ErrorMsg'}}, virt_text_win_col=31, hl_mode='blend'})
+ api.nvim_buf_set_extmark(0, ns, 3, 14, { virt_text={{'ERROR', 'ErrorMsg'}}, virt_text_pos='right_align', hl_mode='blend'})
+ api.nvim_buf_set_extmark(0, ns, 7, 21, { virt_text={{'-', 'NonText'}}, virt_text_win_col=4, hl_mode='blend'})
+ api.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.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'})
+ api.nvim_buf_set_extmark(0, ns, 8, 0, { virt_text={{''}}, virt_text_win_col=14, hl_mode='blend'})
+ api.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 |
@@ -1293,7 +1293,7 @@ describe('extmark decorations', function()
|
]]}
- meths.nvim_buf_set_extmark(0, ns, 4, 50, { virt_text={{'EOL', 'NonText'}} })
+ api.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}|
@@ -1449,7 +1449,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.nvim_buf_set_lines(0, 0, -1, false, { string.rep('a', 50) })
+ api.nvim_buf_set_lines(0, 0, -1, false, { string.rep('a', 50) })
screen:expect{grid=[[
^aaaaaaaaaaaaaaaaaaaaaaaaa│ |
aaaaaaaaaaaaaaaaaaaaaaaaa│{1:~ }|
@@ -1458,7 +1458,7 @@ describe('extmark decorations', function()
|
]]}
local extmark_opts = { virt_text_win_col = 35, virt_text = { { ' ', 'Comment' } } }
- meths.nvim_buf_set_extmark(0, ns, 0, 0, extmark_opts)
+ api.nvim_buf_set_extmark(0, ns, 0, 0, extmark_opts)
screen:expect_unchanged()
assert_alive()
end)
@@ -1474,9 +1474,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.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' })
+ api.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = {{'AA', 'Underlined'}}, hl_mode = 'combine', virt_text_pos = 'overlay' })
+ api.nvim_buf_set_extmark(0, ns, 0, 5, { virt_text = {{'BB', 'Underlined'}}, hl_mode = 'combine', virt_text_win_col = 10 })
+ api.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 |
@@ -1519,9 +1519,9 @@ describe('extmark decorations', function()
ddddd
eeeee]])
command('windo diffthis')
- 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' })
+ api.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = {{'AA', 'Underlined'}}, virt_text_pos = 'overlay' })
+ api.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = {{'BB', 'Underlined'}}, virt_text_win_col = 10 })
+ api.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}|
@@ -1564,10 +1564,10 @@ describe('extmark decorations', function()
{'d', {'BgTwo', 'FgZwei'}};
{'X', {'BgTwo', 'FgZwei', 'VeryBold'}};
}
- 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 } })
+ api.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = vt, virt_text_pos = 'eol' })
+ api.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = vt, virt_text_pos = 'right_align' })
+ api.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = vt, virt_text_pos = 'inline' })
+ api.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
@@ -1602,7 +1602,7 @@ describe('extmark decorations', function()
it('conceal with conceal char #19007', function()
screen:try_resize(50, 5)
insert('foo\n')
- meths.nvim_buf_set_extmark(0, ns, 0, 0, {end_col=0, end_row=2, conceal='X'})
+ api.nvim_buf_set_extmark(0, ns, 0, 0, {end_col=0, end_row=2, conceal='X'})
command('set conceallevel=2')
screen:expect([[
{26:X} |
@@ -1613,13 +1613,13 @@ describe('extmark decorations', function()
command('set conceallevel=1')
screen:expect_unchanged()
- 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'}))
+ eq("conceal char has to be printable", pcall_err(api.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.nvim_buf_set_extmark(0, ns, 0, 0, {end_col=0, end_row=2, conceal='ẍ̲'})
+ api.nvim_buf_set_extmark(0, ns, 0, 0, {end_col=0, end_row=2, conceal='ẍ̲'})
command('set conceallevel=2')
screen:expect([[
{26:ẍ̲} |
@@ -1631,7 +1631,7 @@ describe('extmark decorations', function()
screen:expect_unchanged()
-- this is rare, but could happen. Save at least the first codepoint
- meths.nvim__invalidate_glyph_cache()
+ api.nvim__invalidate_glyph_cache()
screen:expect{grid=[[
{26:x} |
^ |
@@ -1643,7 +1643,7 @@ describe('extmark decorations', function()
it('conceal without conceal char #24782', function()
screen:try_resize(50, 5)
insert('foobar\n')
- meths.nvim_buf_set_extmark(0, ns, 0, 0, {end_col=3, conceal=''})
+ api.nvim_buf_set_extmark(0, ns, 0, 0, {end_col=3, conceal=''})
command('set listchars=conceal:?')
command('let &conceallevel=1')
screen:expect([[
@@ -1663,8 +1663,8 @@ describe('extmark decorations', function()
it('conceal works just before truncated double-width char #21486', function()
screen:try_resize(40, 4)
- 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=''})
+ api.nvim_buf_set_lines(0, 0, -1, true, {'', ('a'):rep(37) .. '<>古'})
+ api.nvim_buf_set_extmark(0, ns, 1, 37, {end_col=39, conceal=''})
command('setlocal conceallevel=2')
screen:expect{grid=[[
^ |
@@ -1738,32 +1738,32 @@ describe('extmark decorations', function()
[6] = {bold = true, undercurl = true, special = Screen.colors.Red};
})
- 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 })
+ api.nvim_buf_set_extmark(0, ns, 0, 0, { end_col = 9, hl_group = 'TestUL', priority = 20 })
+ api.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.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 })
+ api.nvim_buf_clear_namespace(0, ns, 0, -1)
+ api.nvim_buf_set_extmark(0, ns, 0, 0, { end_col = 9, hl_group = 'TestUC', priority = 20 })
+ api.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.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 })
+ api.nvim_buf_clear_namespace(0, ns, 0, -1)
+ api.nvim_buf_set_extmark(0, ns, 0, 0, { end_col = 9, hl_group = 'TestUL', priority = 30 })
+ api.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.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 })
+ api.nvim_buf_clear_namespace(0, ns, 0, -1)
+ api.nvim_buf_set_extmark(0, ns, 0, 0, { end_col = 9, hl_group = 'TestUC', priority = 30 })
+ api.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:~ }|
@@ -1772,14 +1772,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.nvim_buf_clear_namespace(0, ns, 0, -1)
+ api.nvim_buf_clear_namespace(0, ns, 0, -1)
screen:expect([[
aaabbbaa^a |
{0:~ }|
|
]])
- 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 })
+ api.nvim_buf_set_extmark(0, ns, 0, 0, { end_col = 9, hl_group = 'TestUL', priority = 25 + d })
+ api.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:~ }|
@@ -1787,14 +1787,14 @@ describe('extmark decorations', function()
]])
end
for _, d in ipairs({-5, 5}) do
- meths.nvim_buf_clear_namespace(0, ns, 0, -1)
+ api.nvim_buf_clear_namespace(0, ns, 0, -1)
screen:expect([[
aaabbbaa^a |
{0:~ }|
|
]])
- 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 })
+ api.nvim_buf_set_extmark(0, ns, 0, 0, { end_col = 9, hl_group = 'TestUC', priority = 25 + d })
+ api.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:~ }|
@@ -1811,10 +1811,10 @@ describe('extmark decorations', function()
feed('gg')
command('set ft=lua')
command('syntax on')
- meths.nvim_buf_set_extmark(0, ns, 0, 0, { end_col = 3, hl_mode = 'combine', hl_group = 'Visual' })
+ api.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 })
+ fn.sign_place(6, 'Test', 'CurrentLine', '', { lnum = 1 })
screen:expect{grid=[[
{30:^fun}{31:ction}{32: Func() }|
{6:end} |
@@ -1825,8 +1825,8 @@ describe('extmark decorations', function()
it('highlight works after TAB with sidescroll #14201', function()
screen:try_resize(50, 3)
command('set nowrap')
- 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' })
+ api.nvim_buf_set_lines(0, 0, -1, true, {'\tword word word word'})
+ api.nvim_buf_set_extmark(0, ns, 0, 1, { end_col = 3, hl_group = 'ErrorMsg' })
screen:expect{grid=[[
^ {4:wo}rd word word word |
{1:~ }|
@@ -1854,16 +1854,16 @@ describe('extmark decorations', function()
it('highlights the beginning of a TAB char correctly #23734', function()
screen:try_resize(50, 3)
- 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' })
+ api.nvim_buf_set_lines(0, 0, -1, true, {'this is the\ttab'})
+ api.nvim_buf_set_extmark(0, ns, 0, 11, { end_col = 15, hl_group = 'ErrorMsg' })
screen:expect{grid=[[
^this is the{4: tab} |
{1:~ }|
|
]]}
- meths.nvim_buf_clear_namespace(0, ns, 0, -1)
- meths.nvim_buf_set_extmark(0, ns, 0, 12, { end_col = 15, hl_group = 'ErrorMsg' })
+ api.nvim_buf_clear_namespace(0, ns, 0, -1)
+ api.nvim_buf_set_extmark(0, ns, 0, 12, { end_col = 15, hl_group = 'ErrorMsg' })
screen:expect{grid=[[
^this is the {4:tab} |
{1:~ }|
@@ -1873,10 +1873,10 @@ describe('extmark decorations', function()
it('highlight applies to a full TAB on line with matches #20885', function()
screen:try_resize(50, 3)
- meths.nvim_buf_set_lines(0, 0, -1, true, {'\t-- match1', ' -- match2'})
- funcs.matchadd('Underlined', 'match')
- 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' })
+ api.nvim_buf_set_lines(0, 0, -1, true, {'\t-- match1', ' -- match2'})
+ fn.matchadd('Underlined', 'match')
+ api.nvim_buf_set_extmark(0, ns, 0, 0, { end_row = 1, end_col = 0, hl_group = 'Visual' })
+ api.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} |
@@ -1886,8 +1886,8 @@ describe('extmark decorations', function()
pending('highlight applies to a full TAB in visual block mode', function()
screen:try_resize(50, 8)
- 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'})
+ api.nvim_buf_set_lines(0, 0, -1, true, {'asdf', '\tasdf', '\tasdf', '\tasdf', 'asdf'})
+ api.nvim_buf_set_extmark(0, ns, 0, 0, {end_row = 5, end_col = 0, hl_group = 'Underlined'})
screen:expect([[
{28:^asdf} |
{28: asdf} |*3
@@ -1908,7 +1908,7 @@ describe('extmark decorations', function()
it('highlight works properly with multibyte text and spell #26771', function()
insert('口口\n')
screen:try_resize(50, 3)
- meths.nvim_buf_set_extmark(0, ns, 0, 0, { end_col = 3, hl_group = 'Search' })
+ api.nvim_buf_set_extmark(0, ns, 0, 0, { end_col = 3, hl_group = 'Search' })
screen:expect([[
{34:口}口 |
^ |
@@ -1927,7 +1927,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.nvim_buf_set_extmark(0, ns, i, j, { end_col=j+2, hl_group = 'NonText'})
+ api.nvim_buf_set_extmark(0, ns, i, j, { end_col=j+2, hl_group = 'NonText'})
end
end
screen:expect{grid=[[
@@ -1959,7 +1959,7 @@ describe('extmark decorations', function()
|
]]}
- meths.nvim_buf_set_extmark(0, ns, 1, 0, { end_line=8, end_col=10, hl_group = 'ErrorMsg'})
+ api.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]} |
@@ -1977,7 +1977,7 @@ describe('extmark decorations', function()
screen:try_resize(50, 5)
insert(example_text)
feed'gg'
- meths.nvim_buf_set_extmark(0, ns, 0, 6, { end_col=13, hl_group = 'NonText', undo_restore=val})
+ api.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) |
@@ -1986,7 +1986,7 @@ describe('extmark decorations', function()
|
]]}
- meths.nvim_buf_set_text(0, 0, 4, 0, 8, {''})
+ api.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) |
@@ -2024,7 +2024,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.nvim_buf_get_extmarks(0, ns, {0,0}, {0, -1}, {details=true}))
+ api.nvim_buf_get_extmarks(0, ns, {0,0}, {0, -1}, {details=true}))
end)
it('virtual text works with rightleft', function()
@@ -2032,10 +2032,10 @@ describe('extmark decorations', function()
insert('abcdefghijklmn')
feed('0')
command('set rightleft')
- 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' })
+ api.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = {{'EOL', 'Underlined'}}})
+ api.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = {{'right_align', 'Underlined'}}, virt_text_pos = 'right_align' })
+ api.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = {{'win_col', 'Underlined'}}, virt_text_win_col = 20 })
+ api.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: ~}|
@@ -2085,7 +2085,7 @@ describe('extmark decorations', function()
screen:try_resize(50, 3)
insert('abcdefghij口klmnopqrstu口vwx口yz')
feed('0')
- meths.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = {{'!!!!!', 'Underlined'}}, virt_text_win_col = 11 })
+ api.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:~ }|
@@ -2116,7 +2116,7 @@ describe('extmark decorations', function()
insert('abcdefghij口klmnopqrstu口vwx口yz')
feed('0')
command('hi Blendy guibg=Red blend=30')
- meths.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = {{' ! ! ', 'Blendy'}}, virt_text_win_col = 8, hl_mode = 'blend' })
+ api.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:~ }|
@@ -2158,10 +2158,10 @@ describe('extmark decorations', function()
{1: ~}|
|
]]}
- 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' })
+ api.nvim_buf_set_extmark(0, ns, 0, 2, { virt_text = {{'overlayed', 'Underlined'}}, virt_text_pos = 'overlay' })
+ api.nvim_buf_set_extmark(0, ns, 0, 14, { virt_text = {{'古', 'Underlined'}}, virt_text_pos = 'overlay' })
+ api.nvim_buf_set_extmark(0, ns, 0, 20, { virt_text = {{'\t', 'Underlined'}}, virt_text_pos = 'overlay' })
+ api.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: ~}|
@@ -2172,7 +2172,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.nvim_buf_set_extmark(0, ns, 0, 0, {sign_text='S', sign_hl_group='NonText', hl_group='Error', end_col=14})
+ api.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:~ }|
@@ -2182,10 +2182,10 @@ describe('extmark decorations', function()
it('virt_text_repeat_linebreak repeats virtual text on wrapped lines', function()
screen:try_resize(40, 5)
- meths.nvim_set_option_value('breakindent', true, {})
+ api.nvim_set_option_value('breakindent', true, {})
insert(example_text)
- 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 })
+ api.nvim_buf_set_extmark(0, ns, 1, 0, { virt_text = {{'│', 'NonText'}}, virt_text_pos = 'overlay', virt_text_repeat_linebreak = true })
+ api.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 |
@@ -2194,9 +2194,9 @@ describe('extmark decorations', function()
if hl_id_cell ~= nil then |
|
]]}
- 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 })
+ api.nvim_buf_clear_namespace(0, ns, 0, -1)
+ api.nvim_buf_set_extmark(0, ns, 1, 0, { virt_text = {{'│', 'NonText'}}, virt_text_repeat_linebreak = true, virt_text_win_col = 0 })
+ api.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|
@@ -2237,7 +2237,7 @@ describe('decorations: inline virtual text', function()
[21] = {reverse = true, foreground = Screen.colors.SlateBlue}
}
- ns = meths.nvim_create_namespace 'test'
+ ns = api.nvim_create_namespace 'test'
end)
@@ -2258,7 +2258,7 @@ describe('decorations: inline virtual text', function()
|
]]}
- meths.nvim_buf_set_extmark(0, ns, 1, 14, {virt_text={{': ', 'Special'}, {'string', 'Type'}}, virt_text_pos='inline'})
+ api.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|
@@ -2318,9 +2318,9 @@ describe('decorations: inline virtual text', function()
|
]]}
- 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'})
+ api.nvim_buf_set_extmark(0, ns, 0, 5, {virt_text={{''}, {''}}, virt_text_pos='inline'})
+ api.nvim_buf_set_extmark(0, ns, 1, 14, {virt_text={{''}, {': ', 'Special'}}, virt_text_pos='inline'})
+ api.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)|
@@ -2334,7 +2334,7 @@ describe('decorations: inline virtual text', function()
|
]]}
- meths.nvim_buf_set_extmark(0, ns, 1, 14, {virt_text={{''}, {'string', 'Type'}}, virt_text_pos='inline'})
+ api.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} |
@@ -2366,8 +2366,8 @@ describe('decorations: inline virtual text', function()
it('Normal mode "gM" command works properly', function()
command([[call setline(1, '123456789')]])
- 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' })
+ api.nvim_buf_set_extmark(0, ns, 0, 2, { virt_text = { { 'bbb', 'Special' } }, virt_text_pos = 'inline' })
+ api.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 |
@@ -2379,8 +2379,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.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' })
+ api.nvim_buf_set_extmark(0, ns, 0, 40, { virt_text = { { ('b'):rep(10), 'Special' } }, virt_text_pos = 'inline' })
+ api.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 |
@@ -2458,8 +2458,8 @@ describe('decorations: inline virtual text', function()
it('cursor positions are correct with multiple inline virtual text', function()
insert('12345678')
- 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' })
+ api.nvim_buf_set_extmark(0, ns, 0, 4, { virt_text = { { ' virtual text ', 'Special' } }, virt_text_pos = 'inline' })
+ api.nvim_buf_set_extmark(0, ns, 0, 4, { virt_text = { { ' virtual text ', 'Special' } }, virt_text_pos = 'inline' })
feed '^'
feed '4l'
screen:expect{grid=[[
@@ -2472,7 +2472,7 @@ describe('decorations: inline virtual text', function()
it('adjusts cursor location correctly when inserting around inline virtual text', function()
insert('12345678')
feed '$'
- meths.nvim_buf_set_extmark(0, ns, 0, 4, { virt_text = { { ' virtual text ', 'Special' } }, virt_text_pos = 'inline' })
+ api.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 |
@@ -2483,7 +2483,7 @@ describe('decorations: inline virtual text', function()
it('has correct highlighting with multi-byte characters', function()
insert('12345678')
- meths.nvim_buf_set_extmark(0, ns, 0, 4, { virt_text = { { 'múlti-byté chñröcters 修补', 'Special' } }, virt_text_pos = 'inline' })
+ api.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 |
@@ -2494,7 +2494,7 @@ describe('decorations: inline virtual text', function()
it('has correct cursor position when inserting around virtual text', function()
insert('12345678')
- meths.nvim_buf_set_extmark(0, ns, 0, 4, { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' })
+ api.nvim_buf_set_extmark(0, ns, 0, 4, { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' })
feed '^'
feed '3l'
feed 'a'
@@ -2520,7 +2520,7 @@ describe('decorations: inline virtual text', function()
end)
it('has correct cursor position with virtual text on an empty line', function()
- meths.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' })
+ api.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' })
screen:expect{grid=[[
{10:^virtual text} |
{1:~ }|
@@ -2534,8 +2534,8 @@ describe('decorations: inline virtual text', function()
call setline(1, ['', 'aaa', '', 'bbbbbb'])
normal gg0
]])
- 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' })
+ api.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = { { string.rep('X', 60), 'Special' } }, virt_text_pos = 'inline' })
+ api.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}|
@@ -2625,7 +2625,7 @@ describe('decorations: inline virtual text', function()
feed('<TAB>')
feed('test')
feed('<ESC>')
- meths.nvim_buf_set_extmark(0, ns, 0, 1, { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' })
+ api.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 |
@@ -2666,7 +2666,7 @@ describe('decorations: inline virtual text', function()
command('set linebreak')
insert('one twoword')
feed('0')
- meths.nvim_buf_set_extmark(0, ns, 0, 3, { virt_text = { { ': virtual text', 'Special' } }, virt_text_pos = 'inline' })
+ api.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:~ }|
@@ -2677,10 +2677,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.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' })
+ api.nvim_buf_set_extmark(0, ns, 0, 9, { virt_text = { { 'AAA', 'Special' } }, virt_text_pos = 'inline' })
+ api.nvim_buf_set_extmark(0, ns, 0, 9, { virt_text = { { 'BBB', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' })
+ api.nvim_buf_set_extmark(0, ns, 1, 9, { virt_text = { { 'CCC', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' })
+ api.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 |
@@ -2694,7 +2694,7 @@ describe('decorations: inline virtual text', function()
/foo^ |
]]}
- meths.nvim_buf_set_extmark(0, ns, 0, 13, { virt_text = { { 'EEE', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' })
+ api.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 |
@@ -2706,10 +2706,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.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' })
+ api.nvim_buf_set_extmark(0, ns, 0, 8, { virt_text = { { 'AAA', 'Special' } }, virt_text_pos = 'inline' })
+ api.nvim_buf_set_extmark(0, ns, 0, 8, { virt_text = { { 'BBB', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' })
+ api.nvim_buf_set_extmark(0, ns, 1, 8, { virt_text = { { 'CCC', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' })
+ api.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 |
@@ -2725,7 +2725,7 @@ describe('decorations: inline virtual text', function()
{8:-- VISUAL BLOCK --} |
]]}
- meths.nvim_buf_set_extmark(0, ns, 0, 10, { virt_text = { { 'EEE', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' })
+ api.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 |
@@ -2735,12 +2735,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.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' })
+ api.nvim_buf_set_extmark(0, ns, 0, 8, { virt_text = { { 'AAA', 'Special' } }, virt_text_pos = 'inline' })
+ api.nvim_buf_set_extmark(0, ns, 0, 8, { virt_text = { { 'BBB', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' })
+ api.nvim_buf_set_extmark(0, ns, 1, 8, { virt_text = { { 'CCC', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' })
+ api.nvim_buf_set_extmark(0, ns, 1, 8, { virt_text = { { 'DDD', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'replace' })
+ api.nvim_buf_set_extmark(0, ns, 0, 4, { end_col = 11, hl_group = 'Search' })
+ api.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 |
@@ -2750,10 +2750,10 @@ describe('decorations: inline virtual text', function()
it('inside highlight range of syntax', function()
insert('foo foo foo bar\nfoo foo foo bar')
- 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' })
+ api.nvim_buf_set_extmark(0, ns, 0, 8, { virt_text = { { 'AAA', 'Special' } }, virt_text_pos = 'inline' })
+ api.nvim_buf_set_extmark(0, ns, 0, 8, { virt_text = { { 'BBB', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' })
+ api.nvim_buf_set_extmark(0, ns, 1, 8, { virt_text = { { 'CCC', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' })
+ api.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 |
@@ -2765,7 +2765,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.nvim_buf_set_extmark(0, ns, 0, 8, { virt_text = { { ('>'):rep(43), 'Special' } }, virt_text_pos = 'inline', right_gravity = false })
+ api.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=[[
@@ -2836,8 +2836,8 @@ describe('decorations: inline virtual text', function()
screen:try_resize(30, 4)
command('setlocal showbreak=+ breakindent breakindentopt=shift:2')
insert(('a'):rep(15))
- 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 })
+ api.nvim_buf_set_extmark(0, ns, 0, 8, { virt_text = {{ ('>'):rep(32), 'Special' }}, virt_text_pos = 'inline', right_gravity = false })
+ api.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:>>>>>>>>>>>>>>>>>>>>>>}|
@@ -2934,8 +2934,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.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' })
+ api.nvim_buf_set_extmark(0, ns, 0, 50, { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' })
+ api.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|
@@ -2947,7 +2947,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.nvim_buf_set_extmark(0, ns, 0, 2, { virt_text = { { string.rep('X', 55), 'Special' } }, virt_text_pos = 'inline' })
+ api.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|
@@ -2959,7 +2959,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.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = { { string.rep('a', 55), 'Special' } }, virt_text_pos = 'inline' })
+ api.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 |
@@ -2971,7 +2971,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.nvim_buf_set_extmark(0, ns, 0, 3, { virt_text = { { string.rep('X', 50), 'Special' } }, virt_text_pos = 'inline' })
+ api.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|
@@ -2983,7 +2983,7 @@ describe('decorations: inline virtual text', function()
it('hidden virtual text does not interfere with Visual highlight', function()
insert('abcdef')
command('set nowrap')
- meths.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = { { 'XXX', 'Special' } }, virt_text_pos = 'inline' })
+ api.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 |
@@ -3010,7 +3010,7 @@ describe('decorations: inline virtual text', function()
test
test]])
command('set number')
- meths.nvim_buf_set_extmark(0, ns, 0, 1, { virt_text = { { string.rep('X', 55), 'Special' } }, virt_text_pos = 'inline' })
+ api.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}|
@@ -3023,7 +3023,7 @@ describe('decorations: inline virtual text', function()
it('highlighting is correct when virtual text is proceeded with a match', function()
insert([[test]])
- meths.nvim_buf_set_extmark(0, ns, 0, 2, { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' })
+ api.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=[[
@@ -3041,7 +3041,7 @@ describe('decorations: inline virtual text', function()
it('smoothscroll works correctly when virtual text wraps', function()
insert('foobar')
- meths.nvim_buf_set_extmark(0, ns, 0, 3, { virt_text = { { string.rep('X', 55), 'Special' } }, virt_text_pos = 'inline' })
+ api.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}|
@@ -3067,9 +3067,9 @@ describe('decorations: inline virtual text', function()
]])
insert('aaa\tbbb')
command("set diff")
- 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' })
+ api.nvim_buf_set_extmark(0, ns, 0, 1, { virt_text = { { 'test', 'Special' } }, virt_text_pos = 'inline', right_gravity = false })
+ api.nvim_buf_set_extmark(0, ns, 5, 0, { virt_text = { { '!', 'Special' } }, virt_text_pos = 'inline' })
+ api.nvim_buf_set_extmark(0, ns, 5, 3, { virt_text = { { '' } }, virt_text_pos = 'inline' })
command("vnew")
insert([[
000
@@ -3108,8 +3108,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.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' })
+ api.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = { { string.rep('a', 55), 'Special' } }, virt_text_pos = 'inline' })
+ api.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 |
@@ -3121,7 +3121,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.nvim_buf_set_extmark( 0, ns, 0, 0, { virt_text = { { string.rep('a', 60), 'Special' } }, virt_text_pos = 'inline' })
+ api.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 |
@@ -3139,8 +3139,8 @@ describe('decorations: inline virtual text', function()
bbbbb
ccccc]])
- 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' })
+ api.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = {{'foo'}}, virt_text_pos = 'inline' })
+ api.nvim_buf_set_extmark(0, ns, 2, 0, { virt_text = {{'bar'}}, virt_text_pos = 'inline' })
screen:expect{grid=[[
fooaaaaa |
bbbbb |
@@ -3182,7 +3182,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.nvim_buf_set_extmark(0, ns, 0, 0, {virt_text = {{('a'):rep(82)}, {'b'}}, virt_text_pos = 'inline'})
+ api.nvim_buf_set_extmark(0, ns, 0, 0, {virt_text = {{('a'):rep(82)}, {'b'}}, virt_text_pos = 'inline'})
screen:expect{grid=[[
^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
b |
@@ -3216,7 +3216,7 @@ describe('decorations: inline virtual text', function()
setlocal nowrap list listchars=extends:!
call setline(1, repeat('a', 51))
]])
- meths.nvim_buf_set_extmark(0, ns, 0, 50, { virt_text = { { 'bbb', 'Special' } }, virt_text_pos = 'inline' })
+ api.nvim_buf_set_extmark(0, ns, 0, 50, { virt_text = { { 'bbb', 'Special' } }, virt_text_pos = 'inline' })
feed('20l')
screen:expect{grid=[[
aaaaaaaaaaaaaaaaaaaa^aaaaaaaaaaaaaaaaaaaaaaaaaaaaa{1:!}|
@@ -3253,7 +3253,7 @@ describe('decorations: inline virtual text', function()
command('set nowrap')
command('set list')
command('set listchars+=extends:c')
- meths.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = { { 'test', 'Special' } }, virt_text_pos = 'inline' })
+ api.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=[[
@@ -3266,8 +3266,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.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' })
+ api.nvim_buf_set_extmark(0, ns, 1, 1, { virt_text = { { '-口-', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'replace' })
+ api.nvim_buf_set_extmark(0, ns, 2, 2, { virt_text = { { '口', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'replace' })
feed('gg0')
screen:expect{grid=[[
^123456789 |
@@ -3336,8 +3336,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.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' })
+ api.nvim_buf_set_extmark(0, ns, 1, 1, { virt_text = { { '-口-', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' })
+ api.nvim_buf_set_extmark(0, ns, 2, 2, { virt_text = { { '口', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' })
feed('gg0')
screen:expect{grid=[[
^123456789 |
@@ -3412,7 +3412,7 @@ describe('decorations: inline virtual text', function()
call setline(1, repeat('a', 28))
normal! $
]])
- meths.nvim_buf_set_extmark(0, ns, 0, 27, { virt_text = { { ('123'):rep(23) } }, virt_text_pos = 'inline' })
+ api.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|
@@ -3625,7 +3625,7 @@ describe('decorations: inline virtual text', function()
call setline(1, repeat("\t", 4) .. 'a')
normal! $
]])
- meths.nvim_buf_set_extmark(0, ns, 0, 3, { virt_text = { { ('12'):rep(32) } }, virt_text_pos = 'inline' })
+ api.nvim_buf_set_extmark(0, ns, 0, 3, { virt_text = { { ('12'):rep(32) } }, virt_text_pos = 'inline' })
screen:expect{grid=[[
{1:<------><------><------>}121212|
121212121212121212121212121212|
@@ -3721,7 +3721,7 @@ describe('decorations: inline virtual text', function()
call setline(1, repeat('a', 50) .. ' ' .. repeat('c', 45))
normal! $
]])
- meths.nvim_buf_set_extmark(0, ns, 0, 50, { virt_text = { { ('b'):rep(10) } }, virt_text_pos = 'inline' })
+ api.nvim_buf_set_extmark(0, ns, 0, 50, { virt_text = { { ('b'):rep(10) } }, virt_text_pos = 'inline' })
screen:expect{grid=[[
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{1:+}bbbbbbbbbb |
@@ -3744,7 +3744,7 @@ describe('decorations: inline virtual text', function()
call setline(1, repeat('a', 40) .. '口' .. '12345')
normal! $
]])
- meths.nvim_buf_set_extmark(0, ns, 0, 40, { virt_text = { { ('b'):rep(9) } }, virt_text_pos = 'inline' })
+ api.nvim_buf_set_extmark(0, ns, 0, 40, { virt_text = { { ('b'):rep(9) } }, virt_text_pos = 'inline' })
screen:expect{grid=[[
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbb{1:>}|
口1234^5 |
@@ -3771,7 +3771,7 @@ describe('decorations: virtual lines', function()
[9] = {foreground = Screen.colors.Brown};
}
- ns = meths.nvim_create_namespace 'test'
+ ns = api.nvim_create_namespace 'test'
end)
local example_text2 = [[
@@ -3787,7 +3787,7 @@ if (h->n_buckets < new_n_buckets) { // expand
it('works with one line', function()
insert(example_text2)
feed 'gg'
- meths.nvim_buf_set_extmark(0, ns, 1, 33, {
+ api.nvim_buf_set_extmark(0, ns, 1, 33, {
virt_lines={ {{">> ", "NonText"}, {"krealloc", "Identifier"}, {": change the size of an allocation"}}};
virt_lines_above=true;
})
@@ -3856,7 +3856,7 @@ if (h->n_buckets < new_n_buckets) { // expand
|
]]}
- meths.nvim_buf_set_extmark(0, ns, 5, 0, {
+ api.nvim_buf_set_extmark(0, ns, 5, 0, {
virt_lines = { {{"^^ REVIEW:", "Todo"}, {" new_vals variable seems unnecessary?", "Comment"}} };
})
-- TODO: what about the cursor??
@@ -3875,7 +3875,7 @@ if (h->n_buckets < new_n_buckets) { // expand
|
]]}
- meths.nvim_buf_clear_namespace(0, ns, 0, -1)
+ api.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 |
@@ -3912,7 +3912,7 @@ if (h->n_buckets < new_n_buckets) { // expand
|
]]}
- meths.nvim_buf_set_extmark(0, ns, 0, 0, {
+ api.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"}};
@@ -3973,7 +3973,7 @@ if (h->n_buckets < new_n_buckets) { // expand
|
]]}
- local id = meths.nvim_buf_set_extmark(0, ns, 7, 0, {
+ local id = api.nvim_buf_set_extmark(0, ns, 7, 0, {
virt_lines={{{"Grugg"}}};
right_gravity=false;
})
@@ -4056,7 +4056,7 @@ if (h->n_buckets < new_n_buckets) { // expand
|
]]}
- meths.nvim_buf_del_extmark(0, ns, id)
+ api.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 *)|
@@ -4092,7 +4092,7 @@ if (h->n_buckets < new_n_buckets) { // expand
|
]]}
- local id = meths.nvim_buf_set_extmark(0, ns, 8, 0, {
+ local id = api.nvim_buf_set_extmark(0, ns, 8, 0, {
virt_lines={{{"Grugg"}}};
virt_lines_above = true,
})
@@ -4150,7 +4150,7 @@ if (h->n_buckets < new_n_buckets) { // expand
--No lines in buffer-- |
]]}
- meths.nvim_buf_del_extmark(0, ns, id)
+ api.nvim_buf_del_extmark(0, ns, id)
screen:expect{grid=[[
^ |
{1:~ }|*10
@@ -4162,7 +4162,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.nvim_buf_set_extmark(0, ns, 0, 0, {virt_lines = {{{'bar', 'Comment'}}}})
+ api.nvim_buf_set_extmark(0, ns, 0, 0, {virt_lines = {{{'bar', 'Comment'}}}})
screen:expect([[
fo^o |
{6:bar} |
@@ -4176,7 +4176,7 @@ if (h->n_buckets < new_n_buckets) { // expand
insert("aa\nbb\ncc\ndd\nee\nff\ngg\nhh")
feed 'gg'
- meths.nvim_buf_set_extmark(0, ns, 6, 0, {
+ api.nvim_buf_set_extmark(0, ns, 6, 0, {
virt_lines={
{{"they see me"}};
{{"scrolling", "Special"}};
@@ -4326,7 +4326,7 @@ if (h->n_buckets < new_n_buckets) { // expand
|
]]}
- local markid = meths.nvim_buf_set_extmark(0, ns, 2, 0, {
+ local markid = api.nvim_buf_set_extmark(0, ns, 2, 0, {
virt_lines={
{{"Some special", "Special"}};
{{"remark about codes", "Comment"}};
@@ -4348,7 +4348,7 @@ if (h->n_buckets < new_n_buckets) { // expand
|
]]}
- meths.nvim_buf_set_extmark(0, ns, 2, 0, {
+ api.nvim_buf_set_extmark(0, ns, 2, 0, {
virt_lines={
{{"Some special", "Special"}};
{{"remark about codes", "Comment"}};
@@ -4376,7 +4376,7 @@ if (h->n_buckets < new_n_buckets) { // expand
it('works with hard TABs', function()
insert(example_text2)
feed 'gg'
- meths.nvim_buf_set_extmark(0, ns, 1, 0, {
+ api.nvim_buf_set_extmark(0, ns, 1, 0, {
virt_lines={ {{">>", "NonText"}, {"\tvery\ttabby", "Identifier"}, {"text\twith\ttabs"}}};
})
screen:expect{grid=[[
@@ -4450,8 +4450,8 @@ if (h->n_buckets < new_n_buckets) { // expand
bbb
ccc
ddd]])
- 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'}}}})
+ api.nvim_buf_set_extmark(0, ns, 0, 0, {end_row = 2, virt_lines = {{{'VIRT LINE 1', 'NonText'}}}})
+ api.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} |
@@ -4472,8 +4472,8 @@ if (h->n_buckets < new_n_buckets) { // expand
ccc
ddd]])
command('set number rightleft')
- 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'}}}})
+ api.nvim_buf_set_extmark(0, ns, 0, 0, {virt_lines = {{{'VIRT LINE 1', 'NonText'}}}, virt_lines_leftcol = true})
+ api.nvim_buf_set_extmark(0, ns, 3, 0, {virt_lines = {{{'VIRT LINE 2', 'NonText'}}}})
screen:expect{grid=[[
aaa{9: 1 }|
{1:1 ENIL TRIV}|
@@ -4493,7 +4493,7 @@ if (h->n_buckets < new_n_buckets) { // expand
line3
line4
line5]])
- meths.nvim_buf_set_extmark(0, ns, 0, 0, {virt_lines={{{"foo"}}, {{"bar"}}, {{"baz"}}}})
+ api.nvim_buf_set_extmark(0, ns, 0, 0, {virt_lines={{{"foo"}}, {{"bar"}}, {{"baz"}}}})
screen:expect{grid=[[
line1 |
foo |
@@ -4550,8 +4550,8 @@ describe('decorations: signs', function()
[3] = {background = Screen.colors.Yellow1, foreground = Screen.colors.Blue1};
}
- ns = meths.nvim_create_namespace 'test'
- meths.nvim_set_option_value('signcolumn', 'auto:9', {})
+ ns = api.nvim_create_namespace 'test'
+ api.nvim_set_option_value('signcolumn', 'auto:9', {})
end)
local example_test3 = [[
@@ -4566,7 +4566,7 @@ l5
insert(example_test3)
feed 'gg'
- meths.nvim_buf_set_extmark(0, ns, 1, -1, {sign_text='S'})
+ api.nvim_buf_set_extmark(0, ns, 1, -1, {sign_text='S'})
screen:expect{grid=[[
{1: }^l1 |
@@ -4584,7 +4584,7 @@ l5
insert(example_test3)
feed 'gg'
- meths.nvim_buf_set_extmark(0, ns, 1, -1, {sign_text='S', end_row=1})
+ api.nvim_buf_set_extmark(0, ns, 1, -1, {sign_text='S', end_row=1})
screen:expect{grid=[[
{1: }^l1 |
@@ -4602,7 +4602,7 @@ l5
insert(example_test3)
feed 'gg'
- meths.nvim_buf_set_extmark(0, ns, 1, 0, {sign_text='S', hl_group='Todo', end_col=1})
+ api.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 |
@@ -4614,14 +4614,14 @@ l5
|
]]}
- meths.nvim_buf_clear_namespace(0, ns, 0, -1)
+ api.nvim_buf_clear_namespace(0, ns, 0, -1)
end)
it('can add multiple signs (single extmark)', function()
insert(example_test3)
feed 'gg'
- meths.nvim_buf_set_extmark(0, ns, 1, -1, {sign_text='S', end_row = 2})
+ api.nvim_buf_set_extmark(0, ns, 1, -1, {sign_text='S', end_row = 2})
screen:expect{grid=[[
{1: }^l1 |
@@ -4639,8 +4639,8 @@ l5
insert(example_test3)
feed'gg'
- 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})
+ api.nvim_buf_set_extmark(0, ns, 1, -1, {sign_text='S1'})
+ api.nvim_buf_set_extmark(0, ns, 3, -1, {sign_text='S2', end_row = 4})
screen:expect{grid=[[
{1: }^l1 |
@@ -4658,8 +4658,8 @@ l5
insert(example_test3)
feed 'gg'
- 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})
+ api.nvim_buf_set_extmark(0, ns, 3, -1, {sign_text='S1'})
+ api.nvim_buf_set_extmark(0, ns, 1, -1, {sign_text='S2', end_row = 3})
screen:expect{grid=[[
{1: }^l1 |
S2{1: }l2 |
@@ -4677,8 +4677,8 @@ l5
insert(example_test3)
feed 'gg'
- 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})
+ api.nvim_buf_set_extmark(0, ns, 1, -1, {sign_text='S1', end_row=2})
+ api.nvim_buf_set_extmark(0, ns, 2, -1, {sign_text='S2', end_row=3})
screen:expect{grid=[[
{1: }^l1 |
@@ -4696,8 +4696,8 @@ l5
insert(example_test3)
feed 'gg'
- 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})
+ api.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S1', end_row=0})
+ api.nvim_buf_set_extmark(0, ns, 1, -1, {sign_text='S2', end_row=1})
screen:expect{grid=[[
S1^l1 |
@@ -4718,10 +4718,10 @@ l5
helpers.command('sign define Oldsign text=x')
helpers.command([[exe 'sign place 42 line=2 name=Oldsign buffer=' . bufnr('')]])
- 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'})
+ api.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S1'})
+ api.nvim_buf_set_extmark(0, ns, 1, -1, {sign_text='S2'})
+ api.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S4'})
+ api.nvim_buf_set_extmark(0, ns, 2, -1, {sign_text='S5'})
screen:expect{grid=[[
S1S4^l1 |
@@ -4742,11 +4742,11 @@ l5
helpers.command('sign define Oldsign text=x')
helpers.command([[exe 'sign place 42 line=2 name=Oldsign buffer=' . bufnr('')]])
- 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'})
+ api.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S1'})
+ api.nvim_buf_set_extmark(0, ns, 1, -1, {sign_text='S2'})
+ api.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S3', end_row = 4})
+ api.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S4'})
+ api.nvim_buf_set_extmark(0, ns, 2, -1, {sign_text='S5'})
screen:expect{grid=[[
S1S3S4^l1 |
@@ -4766,7 +4766,7 @@ l5
feed 'gg'
feed '2<C-e>'
- meths.nvim_buf_set_extmark(0, ns, 1, -1, {sign_text='X', end_row=3})
+ api.nvim_buf_set_extmark(0, ns, 1, -1, {sign_text='X', end_row=3})
screen:expect{grid=[[
X {1: }^l3 |
@@ -4783,18 +4783,18 @@ l5
command 'normal 10oa b c d e f g h'
for i = 1, 10 do
- 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' })
+ api.nvim_buf_set_extmark(0, ns, i, 0, { end_col = 1, hl_group='Todo' })
+ api.nvim_buf_set_extmark(0, ns, i, 2, { end_col = 3, hl_group='Todo' })
+ api.nvim_buf_set_extmark(0, ns, i, 4, { end_col = 5, hl_group='Todo' })
+ api.nvim_buf_set_extmark(0, ns, i, 6, { end_col = 7, hl_group='Todo' })
+ api.nvim_buf_set_extmark(0, ns, i, 8, { end_col = 9, hl_group='Todo' })
+ api.nvim_buf_set_extmark(0, ns, i, 10, { end_col = 11, hl_group='Todo' })
+ api.nvim_buf_set_extmark(0, ns, i, 12, { end_col = 13, hl_group='Todo' })
+ api.nvim_buf_set_extmark(0, ns, i, 14, { end_col = 15, hl_group='Todo' })
+ api.nvim_buf_set_extmark(0, ns, i, -1, { sign_text='W' })
+ api.nvim_buf_set_extmark(0, ns, i, -1, { sign_text='X' })
+ api.nvim_buf_set_extmark(0, ns, i, -1, { sign_text='Y' })
+ api.nvim_buf_set_extmark(0, ns, i, -1, { sign_text='Z' })
end
screen:expect{grid=[[
@@ -4812,10 +4812,10 @@ l5
command('sign define Oldsign text=O3')
command([[exe 'sign place 42 line=1 name=Oldsign priority=10 buffer=' . bufnr('')]])
- 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})
+ api.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S4', priority=100})
+ api.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S2', priority=5})
+ api.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S5', priority=200})
+ api.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S1', priority=1})
screen:expect{grid=[[
S1S2O3S4S5^l1 |
@@ -4824,7 +4824,7 @@ l5
]]}
-- Check truncation works too
- meths.nvim_set_option_value('signcolumn', 'auto', {})
+ api.nvim_set_option_value('signcolumn', 'auto', {})
screen:expect{grid=[[
S5^l1 |
@@ -4853,10 +4853,10 @@ l5
|
]]}
- meths.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S1', priority=1})
+ api.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S1', priority=1})
screen:expect_unchanged()
- meths.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S5', priority=200})
+ api.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S5', priority=200})
screen:expect{grid=[[
O3O3O3O3O3O3O3O3S5^ |
{2:~ }|
@@ -4868,10 +4868,10 @@ l5
it('does not set signcolumn for signs without text', function()
screen:try_resize(20, 3)
- meths.nvim_set_option_value('signcolumn', 'auto', {})
+ api.nvim_set_option_value('signcolumn', 'auto', {})
insert(example_test3)
feed 'gg'
- meths.nvim_buf_set_extmark(0, ns, 0, -1, {number_hl_group='Error'})
+ api.nvim_buf_set_extmark(0, ns, 0, -1, {number_hl_group='Error'})
screen:expect{grid=[[
^l1 |
l2 |
@@ -4882,9 +4882,9 @@ l5
it('correct width when removing multiple signs from sentinel line', function()
screen:try_resize(20, 4)
insert(example_test3)
- 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'})
+ api.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S1', end_row=3})
+ api.nvim_buf_set_extmark(0, ns, 1, -1, {invalidate = true, sign_text='S2'})
+ api.nvim_buf_set_extmark(0, ns, 1, -1, {invalidate = true, sign_text='S3'})
feed('2Gdd')
screen:expect{grid=[[
@@ -4898,8 +4898,8 @@ l5
it('correct width with multiple overlapping signs', function()
screen:try_resize(20, 4)
insert(example_test3)
- 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})
+ api.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S1', end_row=2})
+ api.nvim_buf_set_extmark(0, ns, 1, -1, {sign_text='S2', end_row=2})
feed('gg')
screen:expect{grid=[[
@@ -4934,9 +4934,9 @@ describe('decorations: virt_text', function()
command 'normal 4ohello'
command 'normal aVIRTUAL'
- local ns = meths.nvim_create_namespace('test')
+ local ns = api.nvim_create_namespace('test')
- meths.nvim_buf_set_extmark(0, ns, 2, 0, {
+ api.nvim_buf_set_extmark(0, ns, 2, 0, {
virt_text = {{"hello", "String"}},
virt_text_win_col = 20,
})
@@ -4976,9 +4976,9 @@ describe('decorations: virt_text', function()
|
]]}
- local ns = meths.nvim_create_namespace('ns')
+ local ns = api.nvim_create_namespace('ns')
for row = 1, 5 do
- meths.nvim_buf_set_extmark(0, ns, row, 0, { id = 1, virt_text = {{'world', 'Normal'}} })
+ api.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 0c9ca6199b..cbb6ee466b 100644
--- a/test/functional/ui/diff_spec.lua
+++ b/test/functional/ui/diff_spec.lua
@@ -9,7 +9,7 @@ local write_file = helpers.write_file
local dedent = helpers.dedent
local exec = helpers.exec
local eq = helpers.eq
-local meths = helpers.meths
+local api = helpers.api
before_each(clear)
@@ -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.nvim_get_current_buf()
+ local buf = api.nvim_get_current_buf()
command('botright new')
screen:expect {
grid = [[
@@ -1071,7 +1071,7 @@ AAAB]]
]],
}
- meths.nvim_buf_set_lines(buf, 1, 2, true, { 'BBB' })
+ api.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.nvim_get_current_buf()
+ local buf = api.nvim_get_current_buf()
command('botright split | diffoff')
screen:expect {
grid = [[
@@ -1115,7 +1115,7 @@ AAAB]]
]],
}
- meths.nvim_buf_set_lines(buf, 1, 2, true, { 'BBB' })
+ api.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.nvim_get_option_value('foldcolumn', {}))
+ eq('0', api.nvim_get_option_value('foldcolumn', {}))
command('diffsplit | bd')
screen:expect([[
^ |
{0:~ }|*4
|
]])
- eq('0', meths.nvim_get_option_value('foldcolumn', {}))
+ eq('0', api.nvim_get_option_value('foldcolumn', {}))
end)
-- oldtest: Test_diff_binary()
diff --git a/test/functional/ui/embed_spec.lua b/test/functional/ui/embed_spec.lua
index a9506f2b38..9e08f7748e 100644
--- a/test/functional/ui/embed_spec.lua
+++ b/test/functional/ui/embed_spec.lua
@@ -8,7 +8,7 @@ local eq = helpers.eq
local neq = helpers.neq
local clear = helpers.clear
local ok = helpers.ok
-local funcs = helpers.funcs
+local fn = helpers.fn
local nvim_prog = helpers.nvim_prog
local retry = helpers.retry
@@ -178,7 +178,7 @@ describe('--embed --listen UI', function()
helpers.skip(helpers.is_os('win'))
clear()
local child_server = assert(helpers.new_pipename())
- funcs.jobstart({
+ fn.jobstart({
nvim_prog,
'--embed',
'--listen',
diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua
index 944e40876f..d08e346fc2 100644
--- a/test/functional/ui/float_spec.lua
+++ b/test/functional/ui/float_spec.lua
@@ -11,14 +11,14 @@ local expect = helpers.expect
local exec = helpers.exec
local exec_lua = helpers.exec_lua
local insert = helpers.insert
-local meths = helpers.meths
-local funcs = helpers.funcs
+local api = helpers.api
+local fn = helpers.fn
local run = helpers.run
local pcall_err = helpers.pcall_err
local tbl_contains = vim.tbl_contains
-local curbuf = helpers.meths.nvim_get_current_buf
-local curwin = helpers.meths.nvim_get_current_win
-local curtab = helpers.meths.nvim_get_current_tabpage
+local curbuf = helpers.api.nvim_get_current_buf
+local curwin = helpers.api.nvim_get_current_win
+local curtab = helpers.api.nvim_get_current_tabpage
local NIL = vim.NIL
describe('float window', function()
@@ -31,36 +31,36 @@ 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.nvim_open_win(0, true, {width=10, height=10, relative='editor', row=0, col=0})
- eq(1002, funcs.win_getid())
- eq('editor', meths.nvim_win_get_config(1002).relative)
+ api.nvim_open_win(0, true, {width=10, height=10, relative='editor', row=0, col=0})
+ eq(1002, fn.win_getid())
+ eq('editor', api.nvim_win_get_config(1002).relative)
command([[
call nvim_win_close(1001, v:false)
wincmd j
]])
- eq(1000, funcs.win_getid())
+ eq(1000, fn.win_getid())
end)
it('win_execute() should work' , function()
- 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)')
+ local buf = api.nvim_create_buf(false, false)
+ api.nvim_buf_set_lines(buf, 0, -1, true, {'the floatwin', 'abc', 'def'})
+ local win = api.nvim_open_win(buf, false, {relative='win', width=16, height=1, row=0, col=10})
+ local line = fn.win_execute(win, 'echo getline(1)')
eq('\nthe floatwin', line)
- eq('\n1', funcs.win_execute(win, 'echo line(".",'..win.id..')'))
- eq('\n3', funcs.win_execute(win, 'echo line("$",'..win.id..')'))
- eq('\n0', funcs.win_execute(win, 'echo line("$", 123456)'))
- funcs.win_execute(win, 'bwipe!')
+ eq('\n1', fn.win_execute(win, 'echo line(".",'..win.id..')'))
+ eq('\n3', fn.win_execute(win, 'echo line("$",'..win.id..')'))
+ eq('\n0', fn.win_execute(win, 'echo line("$", 123456)'))
+ fn.win_execute(win, 'bwipe!')
end)
it("win_execute() call commands that are not allowed when 'hidden' is not set" , function()
command('set nohidden')
- 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!')
+ local buf = api.nvim_create_buf(false, false)
+ api.nvim_buf_set_lines(buf, 0, -1, true, {'the floatwin'})
+ local win = api.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(fn.win_execute, win, 'close'))
+ eq('Vim(bdelete):E89: No write since last change for buffer 2 (add ! to override)', pcall_err(fn.win_execute, win, 'bdelete'))
+ fn.win_execute(win, 'bwipe!')
end)
it('closed immediately by autocmd #11383', function()
@@ -193,7 +193,7 @@ describe('float window', function()
end)
it('opened with correct position relative to the mouse', function()
- meths.nvim_input_mouse('left', 'press', '', 0, 10, 10)
+ api.nvim_input_mouse('left', 'press', '', 0, 10, 10)
local pos = exec_lua([[
local bufnr = vim.api.nvim_create_buf(false, true)
@@ -480,67 +480,67 @@ describe('float window', function()
it('no crash with bufpos and non-existent window', function()
command('new')
- local closed_win = meths.nvim_get_current_win().id
+ local closed_win = api.nvim_get_current_win().id
command('close')
- 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}})
+ local buf = api.nvim_create_buf(false,false)
+ api.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.nvim_open_win(0, true, float_opts)
- meths.nvim_set_option_value('fillchars', NIL, {win=float_win.id})
+ local float_win = api.nvim_open_win(0, true, float_opts)
+ api.nvim_set_option_value('fillchars', NIL, {win=float_win.id})
float_opts.style = 'minimal'
- meths.nvim_win_set_config(float_win, float_opts)
+ api.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.nvim_open_win(0, true, float_opts)
- meths.nvim_set_option_value('number', true, { win = float_win })
+ local float_win = api.nvim_open_win(0, true, float_opts)
+ api.nvim_set_option_value('number', true, { win = float_win })
float_opts.row = 2
- meths.nvim_win_set_config(float_win, float_opts)
- eq(false, meths.nvim_get_option_value('number', { win = float_win }))
+ api.nvim_win_set_config(float_win, float_opts)
+ eq(false, api.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.nvim_open_win(0, true, float_opts)
- meths.nvim_set_option_value('number', true, { win = float_win })
+ local float_win = api.nvim_open_win(0, true, float_opts)
+ api.nvim_set_option_value('number', true, { win = float_win })
float_opts.row = 2
float_opts.style = nil
- meths.nvim_win_set_config(float_win, float_opts)
- eq(true, meths.nvim_get_option_value('number', { win = float_win }))
+ api.nvim_win_set_config(float_win, float_opts)
+ eq(true, api.nvim_get_option_value('number', { win = float_win }))
end)
it("'scroll' is computed correctly when opening float with splitkeep=screen #20684", function()
- meths.nvim_set_option_value('splitkeep', 'screen', {})
+ api.nvim_set_option_value('splitkeep', 'screen', {})
local float_opts = {relative = 'editor', row = 1, col = 1, width = 10, height = 10}
- local float_win = meths.nvim_open_win(0, true, float_opts)
- eq(5, meths.nvim_get_option_value('scroll', {win=float_win.id}))
+ local float_win = api.nvim_open_win(0, true, float_opts)
+ eq(5, api.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.nvim_open_win(0, false, float_opts)
- meths.nvim_open_win(0, false, float_opts)
- eq(3, #meths.nvim_list_wins())
+ api.nvim_open_win(0, false, float_opts)
+ api.nvim_open_win(0, false, float_opts)
+ eq(3, #api.nvim_list_wins())
command('unhide')
- eq({ w0 }, meths.nvim_list_wins())
+ eq({ w0 }, api.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.nvim_open_win(0, false, float_opts)
- meths.nvim_open_win(0, false, float_opts)
- eq(3, #meths.nvim_list_wins())
+ api.nvim_open_win(0, false, float_opts)
+ api.nvim_open_win(0, false, float_opts)
+ eq(3, #api.nvim_list_wins())
command('all')
- eq({ w0 }, meths.nvim_list_wins())
+ eq({ w0 }, api.nvim_list_wins())
end)
describe('with only one tabpage,', function()
@@ -553,37 +553,37 @@ describe('float window', function()
end)
describe('closing the last non-floating window gives E444', function()
before_each(function()
- meths.nvim_open_win(old_buf, true, float_opts)
+ api.nvim_open_win(old_buf, true, float_opts)
end)
it('if called from non-floating window', function()
- meths.nvim_set_current_win(old_win)
+ api.nvim_set_current_win(old_win)
eq('Vim:E444: Cannot close last window',
- pcall_err(meths.nvim_win_close, old_win, false))
+ pcall_err(api.nvim_win_close, old_win, false))
end)
it('if called from floating window', function()
eq('Vim:E444: Cannot close last window',
- pcall_err(meths.nvim_win_close, old_win, false))
+ pcall_err(api.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.nvim_open_win(old_buf, false, float_opts).id
+ same_buf_float = api.nvim_open_win(old_buf, false, float_opts).id
end)
after_each(function()
eq(old_win, curwin().id)
expect('')
- eq(1, #meths.nvim_list_wins())
+ eq(1, #api.nvim_list_wins())
end)
it('if called from non-floating window', function()
- meths.nvim_buf_delete(old_buf, {force = true})
+ api.nvim_buf_delete(old_buf, {force = true})
end)
it('if called from floating window', function()
- meths.nvim_set_current_win(same_buf_float)
+ api.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.nvim_buf_delete(old_buf, {force = true})
+ api.nvim_buf_delete(old_buf, {force = true})
eq(same_buf_float, eval('g:win_leave'))
eq(old_win, eval('g:win_enter'))
end)
@@ -591,67 +591,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.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
+ same_buf_float = api.nvim_open_win(old_buf, false, float_opts).id
+ other_buf = api.nvim_create_buf(true, false).id
+ other_buf_float = api.nvim_open_win(other_buf, true, float_opts).id
insert('bar')
- meths.nvim_set_current_win(old_win)
+ api.nvim_set_current_win(old_win)
end)
after_each(function()
eq(other_buf, curbuf().id)
expect('bar')
- eq(2, #meths.nvim_list_wins())
+ eq(2, #api.nvim_list_wins())
end)
it('if called from non-floating window', function()
- meths.nvim_buf_delete(old_buf, {force = true})
+ api.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.nvim_set_current_win(same_buf_float)
+ api.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.nvim_buf_delete(old_buf, {force = true})
+ api.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.nvim_set_current_win(other_buf_float)
- meths.nvim_buf_delete(old_buf, {force = true})
+ api.nvim_set_current_win(other_buf_float)
+ api.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.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
+ same_buf_float = api.nvim_open_win(old_buf, false, float_opts).id
+ local unlisted_buf = api.nvim_create_buf(true, false).id
+ unlisted_buf_float = api.nvim_open_win(unlisted_buf, true, float_opts).id
insert('unlisted')
command('set nobuflisted')
- meths.nvim_set_current_win(old_win)
+ api.nvim_set_current_win(old_win)
end)
after_each(function()
expect('')
- eq(2, #meths.nvim_list_wins())
+ eq(2, #api.nvim_list_wins())
end)
it('if called from non-floating window', function()
- meths.nvim_buf_delete(old_buf, {force = true})
+ api.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.nvim_set_current_win(same_buf_float)
+ api.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.nvim_buf_delete(old_buf, {force = true})
+ api.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.nvim_set_current_win(unlisted_buf_float)
- meths.nvim_buf_delete(old_buf, {force = true})
+ api.nvim_set_current_win(unlisted_buf_float)
+ api.nvim_buf_delete(old_buf, {force = true})
end)
end)
end)
@@ -662,20 +662,20 @@ describe('float window', function()
command('botright vnew')
insert('unlisted')
command('set nobuflisted')
- meths.nvim_set_current_win(old_win)
- same_buf_float = meths.nvim_open_win(old_buf, false, float_opts).id
+ api.nvim_set_current_win(old_win)
+ same_buf_float = api.nvim_open_win(old_buf, false, float_opts).id
end)
after_each(function()
expect('')
- eq(2, #meths.nvim_list_wins())
+ eq(2, #api.nvim_list_wins())
end)
it('if called from non-floating window with the deleted buffer', function()
- meths.nvim_buf_delete(old_buf, {force = true})
+ api.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.nvim_set_current_win(same_buf_float)
- meths.nvim_buf_delete(old_buf, {force = true})
+ api.nvim_set_current_win(same_buf_float)
+ api.nvim_buf_delete(old_buf, {force = true})
eq(same_buf_float, curwin().id)
end)
end)
@@ -697,28 +697,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.nvim_set_current_win(old_win)
- same_buf_float = meths.nvim_open_win(old_buf, false, float_opts).id
+ api.nvim_set_current_win(old_win)
+ same_buf_float = api.nvim_open_win(old_buf, false, float_opts).id
end)
after_each(function()
expect('')
- eq(2, #meths.nvim_list_wins())
- eq(2, #meths.nvim_list_tabpages())
+ eq(2, #api.nvim_list_wins())
+ eq(2, #api.nvim_list_tabpages())
end)
it('if called from non-floating window', function()
- meths.nvim_buf_delete(old_buf, {force = true})
+ api.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.nvim_list_tabpages())
- meths.nvim_buf_delete(old_buf, {force = true})
+ eq(3, #api.nvim_list_tabpages())
+ api.nvim_buf_delete(old_buf, {force = true})
end)
it('if called from floating window with the same buffer', function()
- meths.nvim_set_current_win(same_buf_float)
+ api.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.nvim_buf_delete(old_buf, {force = true})
+ api.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)
@@ -728,22 +728,22 @@ describe('float window', function()
local same_buf_float
before_each(function()
command('botright vsplit')
- 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
+ api.nvim_set_current_buf(unlisted_buf)
+ api.nvim_set_current_win(old_win)
+ same_buf_float = api.nvim_open_win(old_buf, false, float_opts).id
end)
after_each(function()
expect('')
- eq(3, #meths.nvim_list_wins())
- eq(2, #meths.nvim_list_tabpages())
+ eq(3, #api.nvim_list_wins())
+ eq(2, #api.nvim_list_tabpages())
end)
it('if called from non-floating window with the deleted buffer', function()
- meths.nvim_buf_delete(old_buf, {force = true})
+ api.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.nvim_set_current_win(same_buf_float)
- meths.nvim_buf_delete(old_buf, {force = true})
+ api.nvim_set_current_win(same_buf_float)
+ api.nvim_buf_delete(old_buf, {force = true})
eq(same_buf_float, curwin().id)
end)
end)
@@ -763,38 +763,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.nvim_open_win(old_buf, false, float_opts).id
+ same_buf_float = api.nvim_open_win(old_buf, false, float_opts).id
end)
after_each(function()
eq(old_tabpage, curtab().id)
expect('oldtab')
- eq(1, #meths.nvim_list_tabpages())
+ eq(1, #api.nvim_list_tabpages())
end)
it('if called from non-floating window', function()
- meths.nvim_win_close(old_win, false)
+ api.nvim_win_close(old_win, false)
end)
it('if called from floating window', function()
- meths.nvim_set_current_win(same_buf_float)
- meths.nvim_win_close(old_win, false)
+ api.nvim_set_current_win(same_buf_float)
+ api.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.nvim_create_buf(true, false).id
- other_buf_float = meths.nvim_open_win(other_buf, true, float_opts).id
+ local other_buf = api.nvim_create_buf(true, false).id
+ other_buf_float = api.nvim_open_win(other_buf, true, float_opts).id
insert('foo')
- meths.nvim_set_current_win(old_win)
+ api.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.nvim_win_close, old_win, false))
+ pcall_err(api.nvim_win_close, old_win, false))
end)
it('if called from floating window', function()
- meths.nvim_set_current_win(other_buf_float)
+ api.nvim_set_current_win(other_buf_float)
eq('Vim:E5601: Cannot close window, only floating window would remain',
- pcall_err(meths.nvim_win_close, old_win, false))
+ pcall_err(api.nvim_win_close, old_win, false))
end)
end)
end)
@@ -802,27 +802,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.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)
+ same_buf_float = api.nvim_open_win(old_buf, false, float_opts).id
+ other_buf = api.nvim_create_buf(true, false).id
+ other_buf_float = api.nvim_open_win(other_buf, true, float_opts).id
+ api.nvim_set_current_win(old_win)
end)
after_each(function()
eq(old_tabpage, curtab().id)
expect('oldtab')
- eq(1, #meths.nvim_list_tabpages())
+ eq(1, #api.nvim_list_tabpages())
end)
it('if called from non-floating window', function()
- meths.nvim_buf_delete(old_buf, {force = false})
+ api.nvim_buf_delete(old_buf, {force = false})
end)
it('if called from floating window with the same buffer', function()
- meths.nvim_set_current_win(same_buf_float)
- meths.nvim_buf_delete(old_buf, {force = false})
+ api.nvim_set_current_win(same_buf_float)
+ api.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.nvim_set_current_win(other_buf_float)
- meths.nvim_buf_delete(old_buf, {force = false})
+ api.nvim_set_current_win(other_buf_float)
+ api.nvim_buf_delete(old_buf, {force = false})
end)
end)
-- TODO: what to do when there are non-closeable floating windows?
@@ -869,8 +869,8 @@ describe('float window', function()
end)
it('can be created and reconfigured', function()
- 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 buf = api.nvim_create_buf(false,false)
+ local win = api.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},
}
@@ -901,7 +901,7 @@ describe('float window', function()
end
- meths.nvim_win_set_config(win, {relative='editor', row=0, col=10})
+ api.nvim_win_set_config(win, {relative='editor', row=0, col=10})
expected_pos[4][4] = 0
expected_pos[4][5] = 10
if multigrid then
@@ -927,7 +927,7 @@ describe('float window', function()
]])
end
- meths.nvim_win_close(win, false)
+ api.nvim_win_close(win, false)
if multigrid then
screen:expect([[
## grid 1
@@ -950,8 +950,8 @@ describe('float window', function()
it('window position fixed', function()
command('rightbelow 20vsplit')
- local buf = meths.nvim_create_buf(false,false)
- local win = meths.nvim_open_win(buf, false, {
+ local buf = api.nvim_create_buf(false,false)
+ local win = api.nvim_open_win(buf, false, {
relative='win', width=15, height=2, row=2, col=10, anchor='NW', fixed=true})
if multigrid then
@@ -986,7 +986,7 @@ describe('float window', function()
]])
end
- meths.nvim_win_set_config(win, {fixed=false})
+ api.nvim_win_set_config(win, {fixed=false})
if multigrid then
screen:expect_unchanged()
@@ -1010,8 +1010,8 @@ describe('float window', function()
-- or something.
command("set redrawdebug=compositor")
command("set wd=1")
- 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 buf = api.nvim_create_buf(false,false)
+ local win = api.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},
}
@@ -1042,7 +1042,7 @@ describe('float window', function()
end
- meths.nvim_win_set_config(win, {relative='editor', row=0, col=10})
+ api.nvim_win_set_config(win, {relative='editor', row=0, col=10})
expected_pos[4][4] = 0
expected_pos[4][5] = 10
if multigrid then
@@ -1068,7 +1068,7 @@ describe('float window', function()
]])
end
- meths.nvim_win_close(win, false)
+ api.nvim_win_close(win, false)
if multigrid then
screen:expect([[
## grid 1
@@ -1090,16 +1090,16 @@ describe('float window', function()
end)
it('return their configuration', function()
- 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 buf = api.nvim_create_buf(false, false)
+ local win = api.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.nvim_win_get_config(win))
+ eq(expected, api.nvim_win_get_config(win))
- eq({relative='', external=false, focusable=true, hide=false}, meths.nvim_win_get_config(0))
+ eq({relative='', external=false, focusable=true, hide=false}, api.nvim_win_get_config(0))
if multigrid then
- 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))
+ api.nvim_win_set_config(win, {external=true, width=10, height=1})
+ eq({external=true,focusable=true,width=10,height=1,relative='',hide=false}, api.nvim_win_get_config(win))
end
end)
@@ -1107,7 +1107,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.nvim_open_win(0, false, {relative='editor', width=20, height=4, row=4, col=10})
+ local win = api.nvim_open_win(0, false, {relative='editor', width=20, height=4, row=4, col=10})
if multigrid then
screen:expect{grid=[[
## grid 1
@@ -1138,8 +1138,8 @@ describe('float window', function()
]])
end
- local buf = meths.nvim_create_buf(false, true)
- meths.nvim_win_set_buf(win, buf)
+ local buf = api.nvim_create_buf(false, true)
+ api.nvim_win_set_buf(win, buf)
if multigrid then
screen:expect{grid=[[
## grid 1
@@ -1175,7 +1175,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.nvim_open_win(0, false, {relative='editor', width=20, height=4, row=4, col=10, style='minimal'})
+ local win = api.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
@@ -1239,8 +1239,8 @@ describe('float window', function()
end
command('sign unplace 1 buffer=1')
- local buf = meths.nvim_create_buf(false, true)
- meths.nvim_win_set_buf(win, buf)
+ local buf = api.nvim_create_buf(false, true)
+ api.nvim_win_set_buf(win, buf)
if multigrid then
screen:expect{grid=[[
## grid 1
@@ -1275,7 +1275,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.nvim_open_win(0, false, {relative='editor', width=20, height=4, row=4, col=10, style='minimal'})
+ local win = api.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
@@ -1339,8 +1339,8 @@ describe('float window', function()
end
command('sign unplace 1 buffer=1')
- local buf = meths.nvim_create_buf(false, true)
- meths.nvim_win_set_buf(win, buf)
+ local buf = api.nvim_create_buf(false, true)
+ api.nvim_win_set_buf(win, buf)
if multigrid then
screen:expect{grid=[[
## grid 1
@@ -1376,7 +1376,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.nvim_open_win(0, false, {relative='editor', width=20, height=4, row=4, col=10, style='minimal'})
+ api.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
@@ -1407,10 +1407,10 @@ describe('float window', function()
end)
it('can have border', function()
- local buf = meths.nvim_create_buf(false, false)
- meths.nvim_buf_set_lines(buf, 0, -1, true, {' halloj! ',
+ local buf = api.nvim_create_buf(false, false)
+ api.nvim_buf_set_lines(buf, 0, -1, true, {' halloj! ',
' BORDAA '})
- local win = meths.nvim_open_win(buf, false, {relative='editor', width=9, height=2, row=2, col=5, border="double"})
+ local win = api.nvim_open_win(buf, false, {relative='editor', width=9, height=2, row=2, col=5, border="double"})
if multigrid then
screen:expect{grid=[[
@@ -1445,7 +1445,7 @@ describe('float window', function()
]]}
end
- meths.nvim_win_set_config(win, {border="single"})
+ api.nvim_win_set_config(win, {border="single"})
if multigrid then
screen:expect{grid=[[
## grid 1
@@ -1479,7 +1479,7 @@ describe('float window', function()
]]}
end
- meths.nvim_win_set_config(win, {border="rounded"})
+ api.nvim_win_set_config(win, {border="rounded"})
if multigrid then
screen:expect{grid=[[
## grid 1
@@ -1513,7 +1513,7 @@ describe('float window', function()
]]}
end
- meths.nvim_win_set_config(win, {border="solid"})
+ api.nvim_win_set_config(win, {border="solid"})
if multigrid then
screen:expect{grid=[[
## grid 1
@@ -1548,7 +1548,7 @@ describe('float window', function()
end
-- support: ascii char, UTF-8 char, composed char, highlight per char
- meths.nvim_win_set_config(win, {border={"x", {"å", "ErrorMsg"}, {"\\"}, {"n̈̊", "Search"}}})
+ api.nvim_win_set_config(win, {border={"x", {"å", "ErrorMsg"}, {"\\"}, {"n̈̊", "Search"}}})
if multigrid then
screen:expect{grid=[[
## grid 1
@@ -1582,7 +1582,7 @@ describe('float window', function()
]]}
end
- meths.nvim_win_set_config(win, {border="none"})
+ api.nvim_win_set_config(win, {border="none"})
if multigrid then
screen:expect{grid=[[
## grid 1
@@ -1613,7 +1613,7 @@ describe('float window', function()
]]}
end
- meths.nvim_win_set_config(win, {border={"", "", "", ">", "", "", "", "<"}})
+ api.nvim_win_set_config(win, {border={"", "", "", ">", "", "", "", "<"}})
if multigrid then
screen:expect{grid=[[
## grid 1
@@ -1644,7 +1644,7 @@ describe('float window', function()
]]}
end
- meths.nvim_win_set_config(win, {border={"", "_", "", "", "", "-", "", ""}})
+ api.nvim_win_set_config(win, {border={"", "_", "", "", "", "-", "", ""}})
if multigrid then
screen:expect{grid=[[
## grid 1
@@ -1686,7 +1686,7 @@ describe('float window', function()
of border shadow
]]
- meths.nvim_win_set_config(win, {border="shadow"})
+ api.nvim_win_set_config(win, {border="shadow"})
if multigrid then
screen:expect{grid=[[
## grid 1
@@ -1725,13 +1725,13 @@ describe('float window', function()
end)
it('validates title title_pos', function()
- local buf = meths.nvim_create_buf(false,false)
+ local buf = api.nvim_create_buf(false,false)
eq("title requires border to be set",
- pcall_err(meths.nvim_open_win,buf, false, {
+ pcall_err(api.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.nvim_open_win,buf, false, {
+ pcall_err(api.nvim_open_win,buf, false, {
relative='editor', width=9, height=2, row=2, col=5,
border='single', title_pos='left',
}))
@@ -1759,13 +1759,13 @@ describe('float window', function()
end)
it('validates footer footer_pos', function()
- local buf = meths.nvim_create_buf(false,false)
+ local buf = api.nvim_create_buf(false,false)
eq("footer requires border to be set",
- pcall_err(meths.nvim_open_win,buf, false, {
+ pcall_err(api.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.nvim_open_win,buf, false, {
+ pcall_err(api.nvim_open_win,buf, false, {
relative='editor', width=9, height=2, row=2, col=5,
border='single', footer_pos='left',
}))
@@ -1793,10 +1793,10 @@ describe('float window', function()
end)
it('center aligned title longer than window width #25746', function()
- local buf = meths.nvim_create_buf(false, false)
- meths.nvim_buf_set_lines(buf, 0, -1, true, {' halloj! ',
+ local buf = api.nvim_create_buf(false, false)
+ api.nvim_buf_set_lines(buf, 0, -1, true, {' halloj! ',
' BORDAA '})
- local win = meths.nvim_open_win(buf, false, {
+ local win = api.nvim_open_win(buf, false, {
relative='editor', width=9, height=2, row=2, col=5, border="double",
title = "abcdefghijklmnopqrstuvwxyz",title_pos = "center",
})
@@ -1834,15 +1834,15 @@ describe('float window', function()
]]}
end
- meths.nvim_win_close(win, false)
+ api.nvim_win_close(win, false)
assert_alive()
end)
it('border with title', function()
- local buf = meths.nvim_create_buf(false, false)
- meths.nvim_buf_set_lines(buf, 0, -1, true, {' halloj! ',
+ local buf = api.nvim_create_buf(false, false)
+ api.nvim_buf_set_lines(buf, 0, -1, true, {' halloj! ',
' BORDAA '})
- local win = meths.nvim_open_win(buf, false, {
+ local win = api.nvim_open_win(buf, false, {
relative='editor', width=9, height=2, row=2, col=5, border="double",
title = "Left",title_pos = "left",
})
@@ -1880,7 +1880,7 @@ describe('float window', function()
]]}
end
- meths.nvim_win_set_config(win, {title= "Center",title_pos="center"})
+ api.nvim_win_set_config(win, {title= "Center",title_pos="center"})
if multigrid then
screen:expect{grid=[[
## grid 1
@@ -1914,7 +1914,7 @@ describe('float window', function()
]]}
end
- meths.nvim_win_set_config(win, {title= "Right",title_pos="right"})
+ api.nvim_win_set_config(win, {title= "Right",title_pos="right"})
if multigrid then
screen:expect{grid=[[
## grid 1
@@ -1948,7 +1948,7 @@ describe('float window', function()
]]}
end
- meths.nvim_win_set_config(win, {title= { {"🦄"},{"BB"}},title_pos="right"})
+ api.nvim_win_set_config(win, {title= { {"🦄"},{"BB"}},title_pos="right"})
if multigrid then
screen:expect{grid=[[
## grid 1
@@ -1984,10 +1984,10 @@ describe('float window', function()
end)
it('border with footer', function()
- local buf = meths.nvim_create_buf(false, false)
- meths.nvim_buf_set_lines(buf, 0, -1, true, {' halloj! ',
+ local buf = api.nvim_create_buf(false, false)
+ api.nvim_buf_set_lines(buf, 0, -1, true, {' halloj! ',
' BORDAA '})
- local win = meths.nvim_open_win(buf, false, {
+ local win = api.nvim_open_win(buf, false, {
relative='editor', width=9, height=2, row=2, col=5, border="double",
footer = "Left",footer_pos = "left",
})
@@ -2025,7 +2025,7 @@ describe('float window', function()
]]}
end
- meths.nvim_win_set_config(win, {footer= "Center",footer_pos="center"})
+ api.nvim_win_set_config(win, {footer= "Center",footer_pos="center"})
if multigrid then
screen:expect{grid=[[
## grid 1
@@ -2059,7 +2059,7 @@ describe('float window', function()
]]}
end
- meths.nvim_win_set_config(win, {footer= "Right",footer_pos="right"})
+ api.nvim_win_set_config(win, {footer= "Right",footer_pos="right"})
if multigrid then
screen:expect{grid=[[
## grid 1
@@ -2093,7 +2093,7 @@ describe('float window', function()
]]}
end
- meths.nvim_win_set_config(win, {footer= { {"🦄"},{"BB"}},footer_pos="right"})
+ api.nvim_win_set_config(win, {footer= { {"🦄"},{"BB"}},footer_pos="right"})
if multigrid then
screen:expect{grid=[[
## grid 1
@@ -2129,10 +2129,10 @@ describe('float window', function()
end)
it('border with title and footer', function()
- local buf = meths.nvim_create_buf(false, false)
- meths.nvim_buf_set_lines(buf, 0, -1, true, {' halloj! ',
+ local buf = api.nvim_create_buf(false, false)
+ api.nvim_buf_set_lines(buf, 0, -1, true, {' halloj! ',
' BORDAA '})
- local win = meths.nvim_open_win(buf, false, {
+ local win = api.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",
})
@@ -2170,7 +2170,7 @@ describe('float window', function()
]]}
end
- meths.nvim_win_set_config(win, {title= "Center",title_pos="center",footer= "Center",footer_pos="center"})
+ api.nvim_win_set_config(win, {title= "Center",title_pos="center",footer= "Center",footer_pos="center"})
if multigrid then
screen:expect{grid=[[
## grid 1
@@ -2204,7 +2204,7 @@ describe('float window', function()
]]}
end
- meths.nvim_win_set_config(win, {title= "Right",title_pos="right",footer= "Left",footer_pos="left"})
+ api.nvim_win_set_config(win, {title= "Right",title_pos="right",footer= "Left",footer_pos="left"})
if multigrid then
screen:expect{grid=[[
## grid 1
@@ -2240,7 +2240,7 @@ describe('float window', function()
command('hi B0 guibg=Red guifg=Black')
command('hi B1 guifg=White')
- meths.nvim_win_set_config(win, {
+ api.nvim_win_set_config(win, {
title = {{"🦄"}, {"BB", {"B0", "B1"}}}, title_pos = "right",
footer= {{"🦄"}, {"BB", {"B0", "B1"}}}, footer_pos = "right",
})
@@ -2279,8 +2279,8 @@ describe('float window', function()
end)
it('terminates border on edge of viewport when window extends past viewport', function()
- 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})
+ local buf = api.nvim_create_buf(false, false)
+ api.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
@@ -2314,10 +2314,10 @@ describe('float window', function()
it('with border show popupmenu', function()
screen:try_resize(40,10)
- local buf = meths.nvim_create_buf(false, false)
- meths.nvim_buf_set_lines(buf, 0, -1, true, {'aaa aab ',
+ local buf = api.nvim_create_buf(false, false)
+ api.nvim_buf_set_lines(buf, 0, -1, true, {'aaa aab ',
'abb acc ', ''})
- meths.nvim_open_win(buf, true, {relative='editor', width=9, height=3, row=0, col=5, border="double"})
+ api.nvim_open_win(buf, true, {relative='editor', width=9, height=3, row=0, col=5, border="double"})
feed 'G'
if multigrid then
@@ -2483,10 +2483,10 @@ describe('float window', function()
it('show ruler of current floating window', function()
command 'set ruler'
- local buf = meths.nvim_create_buf(false, false)
- meths.nvim_buf_set_lines(buf, 0, -1, true, {'aaa aab ',
+ local buf = api.nvim_create_buf(false, false)
+ api.nvim_buf_set_lines(buf, 0, -1, true, {'aaa aab ',
'abb acc '})
- meths.nvim_open_win(buf, true, {relative='editor', width=9, height=3, row=0, col=5})
+ api.nvim_open_win(buf, true, {relative='editor', width=9, height=3, row=0, col=5})
feed 'gg'
if multigrid then
@@ -2553,7 +2553,7 @@ describe('float window', function()
it("correct ruler position in current float with 'rulerformat' set", function()
command 'set ruler rulerformat=fish:<><'
- meths.nvim_open_win(0, true, {relative='editor', width=9, height=3, row=0, col=5})
+ api.nvim_open_win(0, true, {relative='editor', width=9, height=3, row=0, col=5})
if multigrid then
screen:expect{grid=[[
## grid 1
@@ -2586,11 +2586,11 @@ 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.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})
+ api.nvim_open_win(0, false, {relative='editor', width=3, height=3, row=0, col=0})
+ api.nvim_open_win(0, false, {relative='editor', width=3, height=3, row=0, col=5})
feed '<c-w>w'
- neq('', meths.nvim_win_get_config(0).relative)
- neq(funcs.winnr '$', funcs.winnr())
+ neq('', api.nvim_win_get_config(0).relative)
+ neq(fn.winnr '$', fn.winnr())
if multigrid then
screen:expect{grid=[[
## grid 1
@@ -2660,9 +2660,9 @@ describe('float window', function()
it('can have minimum size', function()
insert("the background text")
- 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})
+ local buf = api.nvim_create_buf(false, true)
+ api.nvim_buf_set_lines(buf, 0, -1, true, {'x'})
+ local win = api.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
@@ -2686,7 +2686,7 @@ describe('float window', function()
]])
end
- meths.nvim_win_set_config(win, {relative='win', row=0, col=15})
+ api.nvim_win_set_config(win, {relative='win', row=0, col=15})
if multigrid then
screen:expect{grid=[[
## grid 1
@@ -2710,7 +2710,7 @@ describe('float window', function()
]])
end
- meths.nvim_win_close(win,false)
+ api.nvim_win_close(win,false)
if multigrid then
screen:expect([[
## grid 1
@@ -2746,8 +2746,8 @@ describe('float window', function()
command('sargument 6')
local float_opts = { relative = 'editor', row = 6, col = 0, width = 40, height = 1 }
- meths.nvim_win_set_config(w3, float_opts)
- meths.nvim_win_set_config(w4, float_opts)
+ api.nvim_win_set_config(w3, float_opts)
+ api.nvim_win_set_config(w4, float_opts)
command('wincmd =')
if multigrid then
screen:expect{grid=[[
@@ -2876,36 +2876,36 @@ describe('float window', function()
end)
it('API has proper error messages', function()
- local buf = meths.nvim_create_buf(false,false)
+ local buf = api.nvim_create_buf(false,false)
eq("Invalid key: 'bork'",
- pcall_err(meths.nvim_open_win,buf, false, {width=20,height=2,bork=true}))
+ pcall_err(api.nvim_open_win,buf, false, {width=20,height=2,bork=true}))
eq("'win' key is only valid with relative='win'",
- pcall_err(meths.nvim_open_win,buf, false, {width=20,height=2,relative='editor',row=0,col=0,win=0}))
+ pcall_err(api.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.nvim_open_win,buf, false, {width=20,height=2,relative='editor',row=0,col=0,external=true}))
+ pcall_err(api.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.nvim_open_win,buf, false, {width=20,height=2,relative='shell',row=0,col=0}))
+ pcall_err(api.nvim_open_win,buf, false, {width=20,height=2,relative='shell',row=0,col=0}))
eq("Invalid value of 'anchor' key",
- pcall_err(meths.nvim_open_win,buf, false, {width=20,height=2,relative='editor',row=0,col=0,anchor='bottom'}))
+ pcall_err(api.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.nvim_open_win,buf, false, {width=20,height=2,relative='editor'}))
+ pcall_err(api.nvim_open_win,buf, false, {width=20,height=2,relative='editor'}))
eq("'width' key must be a positive Integer",
- pcall_err(meths.nvim_open_win,buf, false, {width=-1,height=2,relative='editor', row=0, col=0}))
+ pcall_err(api.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.nvim_open_win,buf, false, {width=20,height=-1,relative='editor', row=0, col=0}))
+ pcall_err(api.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.nvim_open_win,buf, false, {width=20,height=0,relative='editor', row=0, col=0}))
+ pcall_err(api.nvim_open_win,buf, false, {width=20,height=0,relative='editor', row=0, col=0}))
eq("Must specify 'width'",
- pcall_err(meths.nvim_open_win,buf, false, {relative='editor', row=0, col=0}))
+ pcall_err(api.nvim_open_win,buf, false, {relative='editor', row=0, col=0}))
eq("Must specify 'height'",
- pcall_err(meths.nvim_open_win,buf, false, {relative='editor', row=0, col=0, width=2}))
+ pcall_err(api.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.nvim_buf_set_lines(0, 0, -1, true, {'just some', 'example text'})
+ api.nvim_buf_set_lines(0, 0, -1, true, {'just some', 'example text'})
feed('gge')
- local oldwin = meths.nvim_get_current_win()
+ local oldwin = api.nvim_get_current_win()
command('below split')
if multigrid then
screen:expect([[
@@ -2940,9 +2940,9 @@ describe('float window', function()
]])
end
- local buf = meths.nvim_create_buf(false,false)
+ local buf = api.nvim_create_buf(false,false)
-- no 'win' arg, relative default window
- local win = meths.nvim_open_win(buf, false, {relative='win', width=20, height=2, row=0, col=10})
+ local win = api.nvim_open_win(buf, false, {relative='win', width=20, height=2, row=0, col=10})
if multigrid then
screen:expect{grid=[[
## grid 1
@@ -2981,7 +2981,7 @@ describe('float window', function()
]])
end
- meths.nvim_win_set_config(win, {relative='cursor', row=1, col=-2})
+ api.nvim_win_set_config(win, {relative='cursor', row=1, col=-2})
if multigrid then
screen:expect{grid=[[
## grid 1
@@ -3020,7 +3020,7 @@ describe('float window', function()
]])
end
- meths.nvim_win_set_config(win, {relative='cursor', row=0, col=0, anchor='SW'})
+ api.nvim_win_set_config(win, {relative='cursor', row=0, col=0, anchor='SW'})
if multigrid then
screen:expect{grid=[[
## grid 1
@@ -3059,7 +3059,7 @@ describe('float window', function()
]])
end
- meths.nvim_win_set_config(win, {relative='win', win=oldwin, row=1, col=10, anchor='NW'})
+ api.nvim_win_set_config(win, {relative='win', win=oldwin, row=1, col=10, anchor='NW'})
if multigrid then
screen:expect{grid=[[
## grid 1
@@ -3098,7 +3098,7 @@ describe('float window', function()
]])
end
- meths.nvim_win_set_config(win, {relative='win', win=oldwin, row=3, col=39, anchor='SE'})
+ api.nvim_win_set_config(win, {relative='win', win=oldwin, row=3, col=39, anchor='SE'})
if multigrid then
screen:expect{grid=[[
## grid 1
@@ -3137,7 +3137,7 @@ describe('float window', function()
]])
end
- meths.nvim_win_set_config(win, {relative='win', win=0, row=0, col=50, anchor='NE'})
+ api.nvim_win_set_config(win, {relative='win', win=0, row=0, col=50, anchor='NE'})
if multigrid then
screen:expect{grid=[[
## grid 1
@@ -3207,7 +3207,7 @@ describe('float window', function()
it('always anchor to corner including border', function()
screen:try_resize(40,13)
- meths.nvim_buf_set_lines(0, 0, -1, true, {'just some example text', 'some more example text'})
+ api.nvim_buf_set_lines(0, 0, -1, true, {'just some example text', 'some more example text'})
feed('ggeee')
command('below split')
if multigrid then
@@ -3243,10 +3243,10 @@ describe('float window', function()
]])
end
- local buf = meths.nvim_create_buf(false, false)
- meths.nvim_buf_set_lines(buf, 0, -1, true, {' halloj! ',
+ local buf = api.nvim_create_buf(false, false)
+ api.nvim_buf_set_lines(buf, 0, -1, true, {' halloj! ',
' BORDAA '})
- local win = meths.nvim_open_win(buf, false, {relative='cursor', width=9, height=2, row=1, col=-2, border="double"})
+ local win = api.nvim_open_win(buf, false, {relative='cursor', width=9, height=2, row=1, col=-2, border="double"})
if multigrid then
screen:expect{grid=[[
@@ -3290,7 +3290,7 @@ describe('float window', function()
]])
end
- meths.nvim_win_set_config(win, {relative='cursor', row=0, col=-2, anchor='NE'})
+ api.nvim_win_set_config(win, {relative='cursor', row=0, col=-2, anchor='NE'})
if multigrid then
screen:expect{grid=[[
## grid 1
@@ -3333,7 +3333,7 @@ describe('float window', function()
]])
end
- meths.nvim_win_set_config(win, {relative='cursor', row=1, col=-2, anchor='SE'})
+ api.nvim_win_set_config(win, {relative='cursor', row=1, col=-2, anchor='SE'})
if multigrid then
screen:expect{grid=[[
## grid 1
@@ -3376,7 +3376,7 @@ describe('float window', function()
]])
end
- meths.nvim_win_set_config(win, {relative='cursor', row=0, col=-2, anchor='SW'})
+ api.nvim_win_set_config(win, {relative='cursor', row=0, col=-2, anchor='SW'})
if multigrid then
screen:expect{grid=[[
## grid 1
@@ -3596,8 +3596,8 @@ describe('float window', function()
it('can be placed relative text in a window', function()
screen:try_resize(30,5)
- 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'})
+ local firstwin = api.nvim_get_current_win().id
+ api.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
@@ -3620,10 +3620,10 @@ describe('float window', function()
]]}
end
- local buf = meths.nvim_create_buf(false,false)
- meths.nvim_buf_set_lines(buf, 0, -1, true, {'some info!'})
+ local buf = api.nvim_create_buf(false,false)
+ api.nvim_buf_set_lines(buf, 0, -1, true, {'some info!'})
- local win = meths.nvim_open_win(buf, false, {relative='win', width=12, height=1, bufpos={1,32}})
+ local win = api.nvim_open_win(buf, false, {relative='win', width=12, height=1, bufpos={1,32}})
if multigrid then
screen:expect{grid=[[
## grid 1
@@ -3651,7 +3651,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.nvim_win_get_config(win))
+ external=false, col=0, row=1, win=firstwin, focusable=true, zindex=50}, api.nvim_win_get_config(win))
feed('<c-e>')
if multigrid then
@@ -3739,7 +3739,7 @@ describe('float window', function()
]]}
end
- meths.nvim_win_set_config(win, {relative='win', bufpos={1,32}, anchor='SW'})
+ api.nvim_win_set_config(win, {relative='win', bufpos={1,32}, anchor='SW'})
if multigrid then
screen:expect{grid=[[
## grid 1
@@ -3812,7 +3812,7 @@ describe('float window', function()
end
command('close')
- meths.nvim_win_set_config(win, {relative='win', bufpos={1,32}, anchor='NW', col=-2})
+ api.nvim_win_set_config(win, {relative='win', bufpos={1,32}, anchor='NW', col=-2})
if multigrid then
screen:expect{grid=[[
## grid 1
@@ -3843,7 +3843,7 @@ describe('float window', function()
]]}
end
- meths.nvim_win_set_config(win, {relative='win', bufpos={1,32}, row=2})
+ api.nvim_win_set_config(win, {relative='win', bufpos={1,32}, row=2})
if multigrid then
screen:expect{grid=[[
## grid 1
@@ -3924,9 +3924,9 @@ describe('float window', function()
]])
end
- 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})
+ local buf = api.nvim_create_buf(false,true)
+ api.nvim_buf_set_lines(buf, 0, -1, true, {'some floaty text'})
+ api.nvim_open_win(buf, false, {relative='editor', width=20, height=1, row=3, col=1})
if multigrid then
screen:expect{grid=[[
## grid 1
@@ -3959,8 +3959,8 @@ describe('float window', function()
local screen2 = Screen.new(40,7)
screen2:attach(nil, session2)
screen2:set_default_attr_ids(attrs)
- 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 buf = api.nvim_create_buf(false,false)
+ api.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}
}
@@ -3986,9 +3986,9 @@ describe('float window', function()
it('handles resized screen', function()
- 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 buf = api.nvim_create_buf(false,false)
+ api.nvim_buf_set_lines(buf, 0, -1, true, {'such', 'very', 'float'})
+ local win = api.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},
}
@@ -4151,7 +4151,7 @@ describe('float window', function()
]])
end
- meths.nvim_win_set_config(win, {height=3})
+ api.nvim_win_set_config(win, {height=3})
feed('gg')
if multigrid then
screen:expect{grid=[[
@@ -4436,8 +4436,8 @@ describe('float window', function()
command("set inccommand=split")
command("set laststatus=2")
- local buf = meths.nvim_create_buf(false,false)
- meths.nvim_open_win(buf, true, {relative='editor', width=30, height=3, row=2, col=0})
+ local buf = api.nvim_create_buf(false,false)
+ api.nvim_open_win(buf, true, {relative='editor', width=30, height=3, row=2, col=0})
insert([[
foo
@@ -4533,17 +4533,17 @@ describe('float window', function()
end)
it('does not crash when set cmdheight #9680', function()
- local buf = meths.nvim_create_buf(false,false)
- meths.nvim_open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5})
+ local buf = api.nvim_create_buf(false,false)
+ api.nvim_open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5})
command("set cmdheight=2")
- eq(1, meths.nvim_eval('1'))
+ eq(1, api.nvim_eval('1'))
end)
describe('and completion', function()
before_each(function()
- 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})
+ local buf = api.nvim_create_buf(false,false)
+ local win = api.nvim_open_win(buf, true, {relative='editor', width=12, height=4, row=2, col=5}).id
+ api.nvim_set_option_value('winhl', 'Normal:ErrorMsg', {win=win})
if multigrid then
screen:expect{grid=[[
## grid 1
@@ -4573,7 +4573,7 @@ describe('float window', function()
it('with builtin popupmenu', function()
feed('ix ')
- funcs.complete(3, {'aa', 'word', 'longtext'})
+ fn.complete(3, {'aa', 'word', 'longtext'})
if multigrid then
screen:expect{grid=[[
## grid 1
@@ -4636,7 +4636,7 @@ describe('float window', function()
end
feed('<c-w>wi')
- funcs.complete(1, {'xx', 'yy', 'zz'})
+ fn.complete(1, {'xx', 'yy', 'zz'})
if multigrid then
screen:expect{grid=[[
## grid 1
@@ -4736,7 +4736,7 @@ describe('float window', function()
it('with ext_popupmenu', function()
screen:set_option('ext_popupmenu', true)
feed('ix ')
- funcs.complete(3, {'aa', 'word', 'longtext'})
+ fn.complete(3, {'aa', 'word', 'longtext'})
local items = {{"aa", "", "", ""}, {"word", "", "", ""}, {"longtext", "", "", ""}}
if multigrid then
screen:expect{grid=[[
@@ -4796,7 +4796,7 @@ describe('float window', function()
end
feed('<c-w>wi')
- funcs.complete(1, {'xx', 'yy', 'zz'})
+ fn.complete(1, {'xx', 'yy', 'zz'})
items = {{"xx", "", "", ""}, {"yy", "", "", ""}, {"zz", "", "", ""}}
if multigrid then
screen:expect{grid=[[
@@ -4862,7 +4862,7 @@ describe('float window', function()
before_each(function()
command('hi NormalFloat guibg=#333333 guifg=NONE')
feed('i')
- funcs.complete(1, {'aa', 'word', 'longtext'})
+ fn.complete(1, {'aa', 'word', 'longtext'})
if multigrid then
screen:expect{grid=[[
## grid 1
@@ -4891,9 +4891,9 @@ describe('float window', function()
]])
end
- 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})
+ local buf = api.nvim_create_buf(false,true)
+ api.nvim_buf_set_lines(buf,0,-1,true,{"some info", "about item"})
+ win = api.nvim_open_win(buf, false, {relative='cursor', width=12, height=2, row=1, col=10})
if multigrid then
screen:expect{grid=[[
## grid 1
@@ -4955,7 +4955,7 @@ describe('float window', function()
]])
end
- meths.nvim_win_close(win, false)
+ api.nvim_win_close(win, false)
if multigrid then
screen:expect([[
## grid 1
@@ -4977,7 +4977,7 @@ describe('float window', function()
end)
it('and close float first', function()
- meths.nvim_win_close(win, false)
+ api.nvim_win_close(win, false)
if multigrid then
screen:expect{grid=[[
## grid 1
@@ -5029,10 +5029,10 @@ describe('float window', function()
end)
it("can use Normal as background", function()
- 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})
+ local buf = api.nvim_create_buf(false,false)
+ api.nvim_buf_set_lines(buf,0,-1,true,{"here", "float"})
+ local win = api.nvim_open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5})
+ api.nvim_set_option_value('winhl', 'Normal:Normal', {win=win})
if multigrid then
screen:expect{grid=[[
@@ -5072,10 +5072,10 @@ describe('float window', function()
-- the default, but be explicit:
command("set laststatus=1")
command("set hidden")
- 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"})
+ api.nvim_buf_set_lines(0,0,-1,true,{"x"})
+ local buf = api.nvim_create_buf(false,false)
+ win = api.nvim_open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5})
+ api.nvim_buf_set_lines(buf,0,-1,true,{"y"})
expected_pos = {
[4]={{id=1001}, 'NW', 1, 2, 5, true}
}
@@ -5160,7 +5160,7 @@ describe('float window', function()
end)
it("w with focusable=false", function()
- meths.nvim_win_set_config(win, {focusable=false})
+ api.nvim_win_set_config(win, {focusable=false})
expected_pos[4][6] = false
feed("<c-w>wi") -- i to provoke redraw
if multigrid then
@@ -5271,7 +5271,7 @@ describe('float window', function()
it("focus by mouse", function()
if multigrid then
- meths.nvim_input_mouse('left', 'press', '', 4, 0, 0)
+ api.nvim_input_mouse('left', 'press', '', 4, 0, 0)
screen:expect{grid=[[
## grid 1
[2:----------------------------------------]|*6
@@ -5286,7 +5286,7 @@ describe('float window', function()
{2:~ }|
]], float_pos=expected_pos}
else
- meths.nvim_input_mouse('left', 'press', '', 0, 2, 5)
+ api.nvim_input_mouse('left', 'press', '', 0, 2, 5)
screen:expect([[
x |
{0:~ }|
@@ -5298,7 +5298,7 @@ describe('float window', function()
end
if multigrid then
- meths.nvim_input_mouse('left', 'press', '', 2, 0, 0)
+ api.nvim_input_mouse('left', 'press', '', 2, 0, 0)
screen:expect{grid=[[
## grid 1
[2:----------------------------------------]|*6
@@ -5313,7 +5313,7 @@ describe('float window', function()
{2:~ }|
]], float_pos=expected_pos}
else
- meths.nvim_input_mouse('left', 'press', '', 0, 0, 0)
+ api.nvim_input_mouse('left', 'press', '', 0, 0, 0)
screen:expect([[
^x |
{0:~ }|
@@ -5326,11 +5326,11 @@ describe('float window', function()
end)
it("focus by mouse (focusable=false)", function()
- meths.nvim_win_set_config(win, {focusable=false})
- meths.nvim_buf_set_lines(0, -1, -1, true, {"a"})
+ api.nvim_win_set_config(win, {focusable=false})
+ api.nvim_buf_set_lines(0, -1, -1, true, {"a"})
expected_pos[4][6] = false
if multigrid then
- meths.nvim_input_mouse('left', 'press', '', 4, 0, 0)
+ api.nvim_input_mouse('left', 'press', '', 4, 0, 0)
screen:expect{grid=[[
## grid 1
[2:----------------------------------------]|*6
@@ -5346,7 +5346,7 @@ describe('float window', function()
{2:~ }|
]], float_pos=expected_pos}
else
- meths.nvim_input_mouse('left', 'press', '', 0, 2, 5)
+ api.nvim_input_mouse('left', 'press', '', 0, 2, 5)
screen:expect([[
x |
^a |
@@ -5358,7 +5358,7 @@ describe('float window', function()
end
if multigrid then
- meths.nvim_input_mouse('left', 'press', '', 2, 0, 0)
+ api.nvim_input_mouse('left', 'press', '', 2, 0, 0)
screen:expect{grid=[[
## grid 1
[2:----------------------------------------]|*6
@@ -5374,7 +5374,7 @@ describe('float window', function()
{2:~ }|
]], float_pos=expected_pos, unchanged=true}
else
- meths.nvim_input_mouse('left', 'press', '', 0, 0, 0)
+ api.nvim_input_mouse('left', 'press', '', 0, 0, 0)
screen:expect([[
^x |
a |
@@ -6156,7 +6156,7 @@ describe('float window', function()
-- enter first float
feed('<c-w><c-w>')
-- enter second float
- meths.nvim_open_win(0, true, {relative='editor', width=20, height=2, row=4, col=8})
+ api.nvim_open_win(0, true, {relative='editor', width=20, height=2, row=4, col=8})
if multigrid then
screen:expect{grid=[[
## grid 1
@@ -6476,7 +6476,7 @@ describe('float window', function()
end
if multigrid then
- meths.nvim_win_set_config(0, {external=true, width=30, height=2})
+ api.nvim_win_set_config(0, {external=true, width=30, height=2})
expected_pos = {[4]={external=true}}
screen:expect{grid=[[
## grid 1
@@ -6494,7 +6494,7 @@ describe('float window', function()
]], float_pos=expected_pos}
else
eq("UI doesn't support external windows",
- pcall_err(meths.nvim_win_set_config, 0, {external=true, width=30, height=2}))
+ pcall_err(api.nvim_win_set_config, 0, {external=true, width=30, height=2}))
return
end
@@ -6520,7 +6520,7 @@ describe('float window', function()
end)
it('J (float with border)', function()
- meths.nvim_win_set_config(win, {relative='editor', width=20, height=2, row=2, col=5, border='single'})
+ api.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
@@ -6625,7 +6625,7 @@ describe('float window', function()
for i = 1,5 do
feed(i.."<c-w>w")
feed_command("enew")
- meths.nvim_buf_set_lines(0, 0,-1,true,{tostring(i)})
+ api.nvim_buf_set_lines(0, 0,-1,true,{tostring(i)})
end
if multigrid then
@@ -6681,7 +6681,7 @@ describe('float window', function()
for i = 1,5 do
feed(i.."<c-w>w")
feed('<c-w>'..k)
- local nr = funcs.winnr()
+ local nr = fn.winnr()
eq(v[i],nr, "when using <c-w>"..k.." from window "..i)
end
end
@@ -6692,7 +6692,7 @@ describe('float window', function()
if j ~= i then
feed(j.."<c-w>w")
feed('<c-w>p')
- local nr = funcs.winnr()
+ local nr = fn.winnr()
eq(i,nr, "when using <c-w>p to window "..i.." from window "..j)
end
end
@@ -6792,7 +6792,7 @@ describe('float window', function()
it(":tabnew and :tabnext (external)", function()
if multigrid then
-- also test external window wider than main screen
- meths.nvim_win_set_config(win, {external=true, width=65, height=4})
+ api.nvim_win_set_config(win, {external=true, width=65, height=4})
expected_pos = {[4]={external=true}}
feed(":tabnew<cr>")
screen:expect{grid=[[
@@ -6814,7 +6814,7 @@ describe('float window', function()
]], float_pos=expected_pos}
else
eq("UI doesn't support external windows",
- pcall_err(meths.nvim_win_set_config, 0, {external=true, width=65, height=4}))
+ pcall_err(api.nvim_win_set_config, 0, {external=true, width=65, height=4}))
end
feed(":tabnext<cr>")
@@ -6862,9 +6862,9 @@ describe('float window', function()
end)
it("left drag changes visual selection in float window", function()
- 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})
+ local buf = api.nvim_create_buf(false,false)
+ api.nvim_buf_set_lines(buf, 0, -1, true, {'foo', 'bar', 'baz'})
+ api.nvim_open_win(buf, false, {relative='editor', width=20, height=3, row=2, col=5})
if multigrid then
screen:expect{grid=[[
## grid 1
@@ -6886,7 +6886,7 @@ describe('float window', function()
[4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3, sum_scroll_delta = 0};
}}
- meths.nvim_input_mouse('left', 'press', '', 4, 0, 0)
+ api.nvim_input_mouse('left', 'press', '', 4, 0, 0)
screen:expect{grid=[[
## grid 1
[2:----------------------------------------]|*6
@@ -6907,7 +6907,7 @@ describe('float window', function()
[4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3, sum_scroll_delta = 0};
}}
- meths.nvim_input_mouse('left', 'drag', '', 4, 1, 2)
+ api.nvim_input_mouse('left', 'drag', '', 4, 1, 2)
screen:expect{grid=[[
## grid 1
[2:----------------------------------------]|*6
@@ -6938,7 +6938,7 @@ describe('float window', function()
|
]]}
- meths.nvim_input_mouse('left', 'press', '', 0, 2, 5)
+ api.nvim_input_mouse('left', 'press', '', 0, 2, 5)
screen:expect{grid=[[
|
{0:~ }|
@@ -6949,7 +6949,7 @@ describe('float window', function()
|
]]}
- meths.nvim_input_mouse('left', 'drag', '', 0, 3, 7)
+ api.nvim_input_mouse('left', 'drag', '', 0, 3, 7)
screen:expect{grid=[[
|
{0:~ }|
@@ -6963,9 +6963,9 @@ describe('float window', function()
end)
it("left drag changes visual selection in float window with border", function()
- 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'})
+ local buf = api.nvim_create_buf(false,false)
+ api.nvim_buf_set_lines(buf, 0, -1, true, {'foo', 'bar', 'baz'})
+ api.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
@@ -6989,7 +6989,7 @@ describe('float window', function()
[4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3, sum_scroll_delta = 0};
}}
- meths.nvim_input_mouse('left', 'press', '', 4, 1, 1)
+ api.nvim_input_mouse('left', 'press', '', 4, 1, 1)
screen:expect{grid=[[
## grid 1
[2:----------------------------------------]|*6
@@ -7012,7 +7012,7 @@ describe('float window', function()
[4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3, sum_scroll_delta = 0};
}}
- meths.nvim_input_mouse('left', 'drag', '', 4, 2, 3)
+ api.nvim_input_mouse('left', 'drag', '', 4, 2, 3)
screen:expect{grid=[[
## grid 1
[2:----------------------------------------]|*6
@@ -7045,7 +7045,7 @@ describe('float window', function()
|
]]}
- meths.nvim_input_mouse('left', 'press', '', 0, 1, 6)
+ api.nvim_input_mouse('left', 'press', '', 0, 1, 6)
screen:expect{grid=[[
{5:┌────────────────────┐} |
{0:~ }{5:│}{1:^foo }{5:│}{0: }|
@@ -7056,7 +7056,7 @@ describe('float window', function()
|
]]}
- meths.nvim_input_mouse('left', 'drag', '', 0, 2, 8)
+ api.nvim_input_mouse('left', 'drag', '', 0, 2, 8)
screen:expect{grid=[[
{5:┌────────────────────┐} |
{0:~ }{5:│}{27:foo}{1: }{5:│}{0: }|
@@ -7070,10 +7070,10 @@ describe('float window', function()
end)
it("left drag changes visual selection in float window with winbar", function()
- 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})
+ local buf = api.nvim_create_buf(false,false)
+ api.nvim_buf_set_lines(buf, 0, -1, true, {'foo', 'bar', 'baz'})
+ local float_win = api.nvim_open_win(buf, false, {relative='editor', width=20, height=4, row=1, col=5})
+ api.nvim_set_option_value('winbar', 'floaty bar', {win=float_win.id})
if multigrid then
screen:expect{grid=[[
## grid 1
@@ -7096,7 +7096,7 @@ describe('float window', function()
[4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3, sum_scroll_delta = 0};
}}
- meths.nvim_input_mouse('left', 'press', '', 4, 1, 0)
+ api.nvim_input_mouse('left', 'press', '', 4, 1, 0)
screen:expect{grid=[[
## grid 1
[2:----------------------------------------]|*6
@@ -7118,7 +7118,7 @@ describe('float window', function()
[4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3, sum_scroll_delta = 0};
}}
- meths.nvim_input_mouse('left', 'drag', '', 4, 2, 2)
+ api.nvim_input_mouse('left', 'drag', '', 4, 2, 2)
screen:expect{grid=[[
## grid 1
[2:----------------------------------------]|*6
@@ -7150,7 +7150,7 @@ describe('float window', function()
|
]]}
- meths.nvim_input_mouse('left', 'press', '', 0, 2, 5)
+ api.nvim_input_mouse('left', 'press', '', 0, 2, 5)
screen:expect{grid=[[
|
{0:~ }{3:floaty bar }{0: }|
@@ -7161,7 +7161,7 @@ describe('float window', function()
|
]]}
- meths.nvim_input_mouse('left', 'drag', '', 0, 3, 7)
+ api.nvim_input_mouse('left', 'drag', '', 0, 3, 7)
screen:expect{grid=[[
|
{0:~ }{3:floaty bar }{0: }|
@@ -7175,9 +7175,9 @@ describe('float window', function()
end)
it('left drag changes visual selection if float window is turned into a split', function()
- 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})
+ local buf = api.nvim_create_buf(false,false)
+ api.nvim_buf_set_lines(buf, 0, -1, true, {'foo', 'bar', 'baz'})
+ api.nvim_open_win(buf, true, {relative='editor', width=20, height=3, row=2, col=5})
command('wincmd L')
if multigrid then
screen:expect([[
@@ -7197,7 +7197,7 @@ describe('float window', function()
{0:~ }|*2
]])
- meths.nvim_input_mouse('left', 'press', '', 4, 2, 2)
+ api.nvim_input_mouse('left', 'press', '', 4, 2, 2)
screen:expect([[
## grid 1
[2:-------------------]{5:│}[4:--------------------]|*5
@@ -7215,7 +7215,7 @@ describe('float window', function()
{0:~ }|*2
]])
- meths.nvim_input_mouse('left', 'drag', '', 4, 1, 1)
+ api.nvim_input_mouse('left', 'drag', '', 4, 1, 1)
screen:expect([[
## grid 1
[2:-------------------]{5:│}[4:--------------------]|*5
@@ -7242,7 +7242,7 @@ describe('float window', function()
|
]])
- meths.nvim_input_mouse('left', 'press', '', 0, 2, 22)
+ api.nvim_input_mouse('left', 'press', '', 0, 2, 22)
screen:expect([[
{5:│}foo |
{0:~ }{5:│}bar |
@@ -7252,7 +7252,7 @@ describe('float window', function()
|
]])
- meths.nvim_input_mouse('left', 'drag', '', 0, 1, 21)
+ api.nvim_input_mouse('left', 'drag', '', 0, 1, 21)
screen:expect([[
{5:│}foo |
{0:~ }{5:│}b^a{27:r} |
@@ -7265,9 +7265,9 @@ describe('float window', function()
end)
it('left click sets correct curswant in float window with border', function()
- 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'})
+ local buf = api.nvim_create_buf(false,false)
+ api.nvim_buf_set_lines(buf, 0, -1, true, {'', '', ''})
+ api.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
@@ -7299,25 +7299,25 @@ describe('float window', function()
end
if multigrid then
- meths.nvim_input_mouse('left', 'press', '', 4, 3, 1)
+ api.nvim_input_mouse('left', 'press', '', 4, 3, 1)
else
- meths.nvim_input_mouse('left', 'press', '', 0, 3, 6)
+ api.nvim_input_mouse('left', 'press', '', 0, 3, 6)
end
- eq({0, 3, 1, 0, 1}, funcs.getcurpos())
+ eq({0, 3, 1, 0, 1}, fn.getcurpos())
if multigrid then
- meths.nvim_input_mouse('left', 'press', '', 4, 3, 2)
+ api.nvim_input_mouse('left', 'press', '', 4, 3, 2)
else
- meths.nvim_input_mouse('left', 'press', '', 0, 3, 7)
+ api.nvim_input_mouse('left', 'press', '', 0, 3, 7)
end
- eq({0, 3, 1, 0, 2}, funcs.getcurpos())
+ eq({0, 3, 1, 0, 2}, fn.getcurpos())
if multigrid then
- meths.nvim_input_mouse('left', 'press', '', 4, 3, 10)
+ api.nvim_input_mouse('left', 'press', '', 4, 3, 10)
else
- meths.nvim_input_mouse('left', 'press', '', 0, 3, 15)
+ api.nvim_input_mouse('left', 'press', '', 0, 3, 15)
end
- eq({0, 3, 1, 0, 10}, funcs.getcurpos())
+ eq({0, 3, 1, 0, 10}, fn.getcurpos())
command('setlocal foldcolumn=1')
feed('zfkgg')
@@ -7356,7 +7356,7 @@ describe('float window', function()
end
if multigrid then
- meths.nvim_input_mouse('left', 'press', '', 4, 2, 1)
+ api.nvim_input_mouse('left', 'press', '', 4, 2, 1)
screen:expect{grid=[[
## grid 1
[2:----------------------------------------]|*6
@@ -7379,7 +7379,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.nvim_input_mouse('left', 'press', '', 0, 2, 6)
+ api.nvim_input_mouse('left', 'press', '', 0, 2, 6)
screen:expect{grid=[[
{5:┌────────────────────┐} |
{0:~ }{5:│}{19: }{1:^ }{5:│}{0: }|
@@ -7392,25 +7392,25 @@ describe('float window', function()
end
if multigrid then
- meths.nvim_input_mouse('left', 'press', '', 4, 2, 2)
+ api.nvim_input_mouse('left', 'press', '', 4, 2, 2)
else
- meths.nvim_input_mouse('left', 'press', '', 0, 2, 7)
+ api.nvim_input_mouse('left', 'press', '', 0, 2, 7)
end
- eq({0, 2, 1, 0, 1}, funcs.getcurpos())
+ eq({0, 2, 1, 0, 1}, fn.getcurpos())
if multigrid then
- meths.nvim_input_mouse('left', 'press', '', 4, 2, 3)
+ api.nvim_input_mouse('left', 'press', '', 4, 2, 3)
else
- meths.nvim_input_mouse('left', 'press', '', 0, 2, 8)
+ api.nvim_input_mouse('left', 'press', '', 0, 2, 8)
end
- eq({0, 2, 1, 0, 2}, funcs.getcurpos())
+ eq({0, 2, 1, 0, 2}, fn.getcurpos())
if multigrid then
- meths.nvim_input_mouse('left', 'press', '', 4, 2, 11)
+ api.nvim_input_mouse('left', 'press', '', 4, 2, 11)
else
- meths.nvim_input_mouse('left', 'press', '', 0, 2, 16)
+ api.nvim_input_mouse('left', 'press', '', 0, 2, 16)
end
- eq({0, 2, 1, 0, 10}, funcs.getcurpos())
+ eq({0, 2, 1, 0, 10}, fn.getcurpos())
end)
it("'winblend' option", function()
@@ -7454,9 +7454,9 @@ describe('float window', function()
occaecat cupidatat non proident, sunt in culpa
qui officia deserunt mollit anim id est
laborum.]])
- 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})
+ local buf = api.nvim_create_buf(false,false)
+ api.nvim_buf_set_lines(buf, 0, -1, true, {"test", "", "popup text"})
+ local win = api.nvim_open_win(buf, false, {relative='editor', width=15, height=3, row=2, col=5})
if multigrid then
screen:expect{grid=[[
## grid 1
@@ -7492,7 +7492,7 @@ describe('float window', function()
]])
end
- meths.nvim_set_option_value("winblend", 30, {win=win.id})
+ api.nvim_set_option_value("winblend", 30, {win=win.id})
if multigrid then
screen:expect{grid=[[
## grid 1
@@ -7529,7 +7529,7 @@ describe('float window', function()
end
-- Check that 'winblend' works with NormalNC highlight
- meths.nvim_set_option_value('winhighlight', 'NormalNC:Visual', {win = win})
+ api.nvim_set_option_value('winhighlight', 'NormalNC:Visual', {win = win})
if multigrid then
screen:expect{grid=[[
## grid 1
@@ -7574,7 +7574,7 @@ describe('float window', function()
command('hi clear NormalNC')
command('hi SpecialRegion guifg=Red blend=0')
- meths.nvim_buf_add_highlight(buf, -1, "SpecialRegion", 2, 0, -1)
+ api.nvim_buf_add_highlight(buf, -1, "SpecialRegion", 2, 0, -1)
if multigrid then
screen:expect{grid=[[
## grid 1
@@ -7648,7 +7648,7 @@ describe('float window', function()
-- Test scrolling by mouse
if multigrid then
- meths.nvim_input_mouse('wheel', 'down', '', 4, 2, 2)
+ api.nvim_input_mouse('wheel', 'down', '', 4, 2, 2)
screen:expect{grid=[[
## grid 1
[2:--------------------------------------------------]|*8
@@ -7669,7 +7669,7 @@ describe('float window', function()
{12:~ }|*2
]], float_pos={[4] = {{id = 1001}, "NW", 1, 2, 5, true}}}
else
- meths.nvim_input_mouse('wheel', 'down', '', 0, 4, 7)
+ api.nvim_input_mouse('wheel', 'down', '', 0, 4, 7)
screen:expect([[
Ut enim ad minim veniam, quis nostrud |
exercitation ullamco laboris nisi ut aliquip ex |
@@ -7684,9 +7684,9 @@ describe('float window', function()
end
-- Check that 'winblend' applies to border/title/footer
- 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})
+ api.nvim_win_set_config(win, {border='single', title='Title', footer='Footer'})
+ api.nvim_set_option_value('winblend', 100, {win=win.id})
+ api.nvim_set_option_value("cursorline", true, {win=0})
command('hi clear VertSplit')
feed('k0')
if multigrid then
@@ -7730,9 +7730,9 @@ describe('float window', function()
insert([[
# TODO: 测试字典信息的准确性
# FIXME: 测试字典信息的准确性]])
- 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'})
+ local buf = api.nvim_create_buf(false,false)
+ api.nvim_buf_set_lines(buf, 0, -1, true, {'口', '口'})
+ local win = api.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
@@ -7758,7 +7758,7 @@ describe('float window', function()
]])
end
- meths.nvim_win_close(win, false)
+ api.nvim_win_close(win, false)
if multigrid then
screen:expect([[
## grid 1
@@ -7783,9 +7783,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.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})
+ api.nvim_buf_set_lines(buf, 0, -1, true, {" x x x xx", " x x x x"})
+ win = api.nvim_open_win(buf, false, {relative='editor', width=12, height=3, row=0, col=11, style='minimal'})
+ api.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')},
@@ -7821,7 +7821,7 @@ describe('float window', function()
]])
end
- meths.nvim_win_set_config(win, {relative='editor', row=0, col=12})
+ api.nvim_win_set_config(win, {relative='editor', row=0, col=12})
if multigrid then
screen:expect{grid=[[
## grid 1
@@ -7975,9 +7975,9 @@ describe('float window', function()
end)
it("correctly orders multiple opened floats (current last)", function()
- 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})
+ local buf = api.nvim_create_buf(false,false)
+ local win = api.nvim_open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5})
+ api.nvim_set_option_value("winhl", "Normal:ErrorMsg,EndOfBuffer:ErrorMsg", {win=win.id})
if multigrid then
screen:expect{grid=[[
@@ -8061,9 +8061,9 @@ describe('float window', function()
end)
it("correctly orders multiple opened floats (non-current last)", function()
- 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})
+ local buf = api.nvim_create_buf(false,false)
+ local win = api.nvim_open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5})
+ api.nvim_set_option_value("winhl", "Normal:ErrorMsg,EndOfBuffer:ErrorMsg", {win=win.id})
if multigrid then
screen:expect{grid=[[
@@ -8147,13 +8147,13 @@ describe('float window', function()
end)
it('can use z-index', function()
- 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})
+ local buf = api.nvim_create_buf(false,false)
+ local win1 = api.nvim_open_win(buf, false, {relative='editor', width=20, height=3, row=1, col=5, zindex=30})
+ api.nvim_set_option_value("winhl", "Normal:ErrorMsg,EndOfBuffer:ErrorMsg", {win=win1.id})
+ local win2 = api.nvim_open_win(buf, false, {relative='editor', width=20, height=3, row=2, col=6, zindex=50})
+ api.nvim_set_option_value("winhl", "Normal:Search,EndOfBuffer:Search", {win=win2.id})
+ local win3 = api.nvim_open_win(buf, false, {relative='editor', width=20, height=3, row=3, col=7, zindex=40})
+ api.nvim_set_option_value("winhl", "Normal:Question,EndOfBuffer:Question", {win=win3.id})
if multigrid then
screen:expect{grid=[[
@@ -8198,9 +8198,9 @@ describe('float window', function()
end)
it('can use winbar', function()
- 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})
+ local buf = api.nvim_create_buf(false,false)
+ local win1 = api.nvim_open_win(buf, false, {relative='editor', width=15, height=3, row=1, col=5})
+ api.nvim_set_option_value('winbar', 'floaty bar', {win=win1.id})
if multigrid then
screen:expect{grid=[[
@@ -8234,7 +8234,7 @@ describe('float window', function()
end
-- resize and add a border
- meths.nvim_win_set_config(win1, {relative='editor', width=15, height=4, row=0, col=4, border = 'single'})
+ api.nvim_win_set_config(win1, {relative='editor', width=15, height=4, row=0, col=4, border = 'single'})
if multigrid then
screen:expect{grid=[[
@@ -8273,8 +8273,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.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})
+ local buf = api.nvim_create_buf(false,true)
+ local win = api.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=[[
@@ -8339,7 +8339,7 @@ describe('float window', function()
end
- meths.nvim_win_close(win, true)
+ api.nvim_win_close(win, true)
if multigrid then
screen:expect{grid=[[
## grid 1
@@ -8361,8 +8361,8 @@ describe('float window', function()
it('it can be resized with messages and cmdheight=1', function()
screen:try_resize(40,9)
- 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})
+ local buf = api.nvim_create_buf(false,true)
+ local win = api.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=[[
@@ -8469,7 +8469,7 @@ describe('float window', function()
]]}
end
- meths.nvim_win_close(win, true)
+ api.nvim_win_close(win, true)
if multigrid then
screen:expect{grid=[[
## grid 1
@@ -8495,7 +8495,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.nvim_open_win(meths.nvim_create_buf(false, false), true, float_opts)
+ api.nvim_open_win(api.nvim_create_buf(false, false), true, float_opts)
if multigrid then
screen:expect({float_pos = {[4] = {{id = 1001}, 'NW', 1, 1, 1, true}}})
end
@@ -8522,7 +8522,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.nvim_open_win(meths.nvim_create_buf(false, false), true, float_opts)
+ local win = api.nvim_open_win(api.nvim_create_buf(false, false), true, float_opts)
feed('iab<CR>cd<Esc>')
feed(':sleep 100')
if multigrid then
@@ -8590,7 +8590,7 @@ describe('float window', function()
feed('<C-C>')
screen:expect_unchanged()
- meths.nvim_win_set_config(win, {border = 'single'})
+ api.nvim_win_set_config(win, {border = 'single'})
feed(':sleep 100')
if multigrid then
screen:expect{grid=[[
@@ -8739,7 +8739,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.nvim_open_win(meths.nvim_create_buf(false, false), true, float_opts)
+ api.nvim_open_win(api.nvim_create_buf(false, false), true, float_opts)
command('setlocal rightleft')
feed('iabc<CR>def<Esc>')
if multigrid then
@@ -8778,8 +8778,8 @@ describe('float window', function()
end)
it('float window with hide option', function()
- 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 buf = api.nvim_create_buf(false,false)
+ local win = api.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},
}
@@ -8807,7 +8807,7 @@ describe('float window', function()
]])
end
- meths.nvim_win_set_config(win, {hide = false})
+ api.nvim_win_set_config(win, {hide = false})
if multigrid then
screen:expect{grid=[[
## grid 1
@@ -8834,7 +8834,7 @@ describe('float window', function()
]])
end
- meths.nvim_win_set_config(win, {hide=true})
+ api.nvim_win_set_config(win, {hide=true})
if multigrid then
screen:expect{grid=[[
## grid 1
@@ -8860,18 +8860,18 @@ describe('float window', function()
end)
it(':fclose command #9663', function()
- 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 buf_a = api.nvim_create_buf(false,false)
+ local buf_b = api.nvim_create_buf(false,false)
+ local buf_c = api.nvim_create_buf(false,false)
+ local buf_d = api.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.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)
+ api.nvim_open_win(buf_a, false, config_a)
+ api.nvim_open_win(buf_b, false, config_b)
+ api.nvim_open_win(buf_c, false, config_c)
+ api.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 08dcd18aa0..833e3833d5 100644
--- a/test/functional/ui/fold_spec.lua
+++ b/test/functional/ui/fold_spec.lua
@@ -4,8 +4,8 @@ local clear, feed, eq = helpers.clear, helpers.feed, helpers.eq
local command = helpers.command
local feed_command = helpers.feed_command
local insert = helpers.insert
-local funcs = helpers.funcs
-local meths = helpers.meths
+local fn = helpers.fn
+local api = helpers.api
local exec = helpers.exec
local assert_alive = helpers.assert_alive
@@ -317,7 +317,7 @@ describe('folded lines', function()
feed_command('set norightleft')
if multigrid then
- meths.nvim_input_mouse('left', 'press', '', 2, 0, 1)
+ api.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.nvim_input_mouse('left', 'press', '', 0, 0, 1)
+ api.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.nvim_input_mouse('left', 'press', '', 2, 0, 0)
+ api.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.nvim_input_mouse('left', 'press', '', 0, 0, 0)
+ api.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.nvim_input_mouse('left', 'press', '', 2, 1, 0)
+ api.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.nvim_input_mouse('left', 'press', '', 0, 1, 0)
+ api.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.nvim_input_mouse('left', 'press', '', 2, 1, 1)
+ api.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.nvim_input_mouse('left', 'press', '', 0, 1, 1)
+ api.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.nvim_input_mouse('left', 'press', '', 4, 0, 0)
+ api.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.nvim_input_mouse('left', 'press', '', 0, 3, 0)
+ api.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.nvim_input_mouse('left', 'press', '', 4, 1, 0)
+ api.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.nvim_input_mouse('left', 'press', '', 0, 4, 0)
+ api.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.nvim_input_mouse('left', 'press', '', 2, 1, 0)
+ api.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.nvim_input_mouse('left', 'press', '', 0, 1, 0)
+ api.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.nvim_input_mouse('left', 'press', '', 2, 0, 0)
+ api.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.nvim_input_mouse('left', 'press', '', 0, 0, 0)
+ api.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.nvim_input_mouse('left', 'press', '', 4, 0, 0)
+ api.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.nvim_input_mouse('left', 'press', '', 0, 0, 23)
+ api.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.nvim_input_mouse('left', 'press', '', 4, 1, 0)
+ api.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.nvim_input_mouse('left', 'press', '', 0, 1, 23)
+ api.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.nvim_input_mouse('left', 'press', '', 2, 1, 0)
+ api.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.nvim_input_mouse('left', 'press', '', 0, 1, 0)
+ api.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.nvim_input_mouse('left', 'press', '', 2, 0, 0)
+ api.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.nvim_input_mouse('left', 'press', '', 0, 0, 0)
+ api.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.nvim_input_mouse('left', 'press', '', 4, 1, 1)
+ api.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.nvim_input_mouse('left', 'press', '', 0, 2, 1)
+ api.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.nvim_input_mouse('left', 'press', '', 4, 0, 0)
+ api.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.nvim_input_mouse('left', 'press', '', 0, 1, 0)
+ api.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.nvim_input_mouse('left', 'press', '', 2, 1, 1)
+ api.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.nvim_input_mouse('left', 'press', '', 0, 2, 1)
+ api.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.nvim_input_mouse('left', 'press', '', 2, 0, 0)
+ api.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.nvim_input_mouse('left', 'press', '', 0, 1, 0)
+ api.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.nvim_get_option_value('arabicshape', {}))
+ eq(true, api.nvim_get_option_value('arabicshape', {}))
insert([[
å 语 x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢͟ العَرَبِيَّة
möre text]])
@@ -1232,10 +1232,10 @@ describe('folded lines', function()
end)
it('work with autoresize', function()
- funcs.setline(1, 'line 1')
- funcs.setline(2, 'line 2')
- funcs.setline(3, 'line 3')
- funcs.setline(4, 'line 4')
+ fn.setline(1, 'line 1')
+ fn.setline(2, 'line 2')
+ fn.setline(3, 'line 3')
+ fn.setline(4, 'line 4')
feed('zfj')
command('set foldcolumn=0')
@@ -1526,34 +1526,34 @@ describe('folded lines', function()
end)
it('fold attached virtual lines are drawn and scrolled correctly #21837', function()
- funcs.setline(1, 'line 1')
- funcs.setline(2, 'line 2')
- funcs.setline(3, 'line 3')
- funcs.setline(4, 'line 4')
+ fn.setline(1, 'line 1')
+ fn.setline(2, 'line 2')
+ fn.setline(3, 'line 3')
+ fn.setline(4, 'line 4')
feed('zfj')
- local ns = meths.nvim_create_namespace('ns')
- meths.nvim_buf_set_extmark(
+ local ns = api.nvim_create_namespace('ns')
+ api.nvim_buf_set_extmark(
0,
ns,
0,
0,
{ virt_lines_above = true, virt_lines = { { { 'virt_line above line 1', '' } } } }
)
- meths.nvim_buf_set_extmark(
+ api.nvim_buf_set_extmark(
0,
ns,
1,
0,
{ virt_lines = { { { 'virt_line below line 2', '' } } } }
)
- meths.nvim_buf_set_extmark(
+ api.nvim_buf_set_extmark(
0,
ns,
2,
0,
{ virt_lines_above = true, virt_lines = { { { 'virt_line above line 3', '' } } } }
)
- meths.nvim_buf_set_extmark(
+ api.nvim_buf_set_extmark(
0,
ns,
3,
@@ -1636,7 +1636,7 @@ describe('folded lines', function()
end
feed('kzo<C-Y>')
- funcs.setline(5, 'line 5')
+ fn.setline(5, 'line 5')
if multigrid then
screen:expect {
grid = [[
@@ -1679,7 +1679,7 @@ describe('folded lines', function()
]])
end
- meths.nvim_input_mouse('left', 'press', '', multigrid and 2 or 0, 4, 0)
+ api.nvim_input_mouse('left', 'press', '', multigrid and 2 or 0, 4, 0)
eq({
screencol = 1,
screenrow = 5,
@@ -1689,9 +1689,9 @@ describe('folded lines', function()
line = 3,
column = 1,
coladd = 0,
- }, funcs.getmousepos())
+ }, fn.getmousepos())
- meths.nvim_buf_set_extmark(
+ api.nvim_buf_set_extmark(
0,
ns,
1,
@@ -1965,7 +1965,7 @@ describe('folded lines', function()
]])
end
- meths.nvim_input_mouse('left', 'press', '3', multigrid and 2 or 0, 3, 0)
+ api.nvim_input_mouse('left', 'press', '3', multigrid and 2 or 0, 3, 0)
if multigrid then
screen:expect {
grid = [[
@@ -2004,7 +2004,7 @@ describe('folded lines', function()
]])
end
- meths.nvim_input_mouse('left', 'drag', '3', multigrid and 2 or 0, 7, 0)
+ api.nvim_input_mouse('left', 'drag', '3', multigrid and 2 or 0, 7, 0)
if multigrid then
screen:expect {
grid = [[
@@ -2041,7 +2041,7 @@ describe('folded lines', function()
]])
end
- meths.nvim_input_mouse('left', 'drag', '3', multigrid and 2 or 0, 7, 5)
+ api.nvim_input_mouse('left', 'drag', '3', multigrid and 2 or 0, 7, 5)
if multigrid then
screen:expect {
grid = [[
@@ -2400,7 +2400,7 @@ describe('folded lines', function()
]])
end
feed('<Esc>')
- funcs.matchadd('Search', 'line')
+ fn.matchadd('Search', 'line')
if multigrid then
screen:expect([[
## grid 1
@@ -2431,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.nvim_set_option_value('cursorline', true, {})
- meths.nvim_set_option_value('foldcolumn', '4', {})
- meths.nvim_set_option_value(
+ api.nvim_set_option_value('cursorline', true, {})
+ api.nvim_set_option_value('foldcolumn', '4', {})
+ api.nvim_set_option_value(
'foldtext',
'['
.. '["▶", ["F0", "F1"]], '
@@ -2466,7 +2466,7 @@ describe('folded lines', function()
|
]])
end
- eq('▶-\tvalid English', funcs.foldtextresult(2))
+ eq('▶-\tvalid English', fn.foldtextresult(2))
feed('zo')
if multigrid then
@@ -2493,8 +2493,8 @@ describe('folded lines', function()
|
]])
end
- eq('▶--\tsentence composed by', funcs.foldtextresult(3))
- eq('▶--\tin his cave.', funcs.foldtextresult(5))
+ eq('▶--\tsentence composed by', fn.foldtextresult(3))
+ eq('▶--\tin his cave.', fn.foldtextresult(5))
command('hi! Visual guibg=Red')
feed('V2k')
@@ -2523,7 +2523,7 @@ describe('folded lines', function()
]])
end
- meths.nvim_set_option_value('rightleft', true, {})
+ api.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 c2a7317da0..fc692f47bb 100644
--- a/test/functional/ui/highlight_spec.lua
+++ b/test/functional/ui/highlight_spec.lua
@@ -5,8 +5,8 @@ local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local command, exec = helpers.command, helpers.exec
local eval = helpers.eval
local feed_command, eq = helpers.feed_command, helpers.eq
-local funcs = helpers.funcs
-local meths = helpers.meths
+local fn = helpers.fn
+local api = helpers.api
local exec_lua = helpers.exec_lua
describe('colorscheme compatibility', function()
@@ -15,8 +15,8 @@ describe('colorscheme compatibility', function()
end)
it('&t_Co exists and is set to 256 by default', function()
- eq(1, funcs.exists('&t_Co'))
- eq(1, funcs.exists('+t_Co'))
+ eq(1, fn.exists('&t_Co'))
+ eq(1, fn.exists('+t_Co'))
eq('256', eval('&t_Co'))
end)
end)
@@ -2087,7 +2087,7 @@ describe("'winhighlight' highlight", function()
end)
it('can override NonText, Conceal and EndOfBuffer', function()
- meths.nvim_buf_set_lines(0, 0, -1, true, { 'raa\000' })
+ api.nvim_buf_set_lines(0, 0, -1, true, { 'raa\000' })
command('call matchaddpos("Conceal", [[1,2]], 0, -1, {"conceal": "#"})')
command('set cole=2 cocu=nvic')
command('split')
@@ -2402,13 +2402,13 @@ describe('highlight namespaces', function()
[10] = { bold = true, foreground = Screen.colors.SeaGreen },
}
- ns1 = meths.nvim_create_namespace 'grungy'
- ns2 = meths.nvim_create_namespace 'ultrared'
+ ns1 = api.nvim_create_namespace 'grungy'
+ ns2 = api.nvim_create_namespace 'ultrared'
- 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' })
+ api.nvim_set_hl(ns1, 'Normal', { bg = 'DarkGrey' })
+ api.nvim_set_hl(ns1, 'NonText', { bg = 'DarkOrange4', fg = 'DarkCyan', italic = true })
+ api.nvim_set_hl(ns2, 'Normal', { bg = 'DarkMagenta' })
+ api.nvim_set_hl(ns2, 'NonText', { fg = 'Crimson' })
end)
it('can be used globally', function()
@@ -2420,7 +2420,7 @@ describe('highlight namespaces', function()
]],
}
- meths.nvim_set_hl_ns(ns1)
+ api.nvim_set_hl_ns(ns1)
screen:expect {
grid = [[
{2:^ }|
@@ -2429,7 +2429,7 @@ describe('highlight namespaces', function()
]],
}
- meths.nvim_set_hl_ns(ns2)
+ api.nvim_set_hl_ns(ns2)
screen:expect {
grid = [[
{4:^ }|
@@ -2438,7 +2438,7 @@ describe('highlight namespaces', function()
]],
}
- meths.nvim_set_hl_ns(0)
+ api.nvim_set_hl_ns(0)
screen:expect {
grid = [[
^ |
@@ -2449,13 +2449,13 @@ describe('highlight namespaces', function()
end)
it('can be used per window', function()
- local win1 = meths.nvim_get_current_win()
+ local win1 = api.nvim_get_current_win()
command 'split'
- local win2 = meths.nvim_get_current_win()
+ local win2 = api.nvim_get_current_win()
command 'split'
- meths.nvim_win_set_hl_ns(win1, ns1)
- meths.nvim_win_set_hl_ns(win2, ns2)
+ api.nvim_win_set_hl_ns(win1, ns1)
+ api.nvim_win_set_hl_ns(win2, ns2)
screen:expect {
grid = [[
@@ -2482,7 +2482,7 @@ describe('highlight namespaces', function()
]],
}
- meths.nvim_set_hl(0, 'EndOfBuffer', { fg = '#333333' })
+ api.nvim_set_hl(0, 'EndOfBuffer', { fg = '#333333' })
screen:expect {
grid = [[
^ |
@@ -2507,7 +2507,7 @@ describe('highlight namespaces', function()
it('Normal in set_hl #25474', function()
command('highlight Ignore guifg=bg ctermfg=White')
- meths.nvim_set_hl(0, 'Normal', { bg = '#333333' })
+ api.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 d6fd864536..278e6e5272 100644
--- a/test/functional/ui/hlstate_spec.lua
+++ b/test/functional/ui/hlstate_spec.lua
@@ -3,7 +3,7 @@ local Screen = require('test.functional.ui.screen')
local clear, insert = helpers.clear, helpers.insert
local command = helpers.command
-local meths = helpers.meths
+local api = helpers.api
local testprg = helpers.testprg
local thelpers = require('test.functional.terminal.helpers')
local skip = helpers.skip
@@ -28,8 +28,8 @@ describe('ext_hlstate detailed highlights', function()
insert([[
these are some lines
with colorful text]])
- meths.nvim_buf_add_highlight(0, -1, 'String', 0, 10, 14)
- meths.nvim_buf_add_highlight(0, -1, 'Statement', 1, 5, -1)
+ api.nvim_buf_add_highlight(0, -1, 'String', 0, 10, 14)
+ api.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 e82f889553..f4347a460e 100644
--- a/test/functional/ui/inccommand_spec.lua
+++ b/test/functional/ui/inccommand_spec.lua
@@ -7,8 +7,8 @@ local eval = helpers.eval
local expect = helpers.expect
local feed = helpers.feed
local insert = helpers.insert
-local funcs = helpers.funcs
-local meths = helpers.meths
+local fn = helpers.fn
+local api = helpers.api
local neq = helpers.neq
local ok = helpers.ok
local retry = helpers.retry
@@ -157,19 +157,19 @@ describe(":substitute, 'inccommand' preserves", function()
common_setup(screen, 'nosplit', ('abc\ndef\n'):rep(50))
feed('ggyG')
- local X = meths.nvim_get_vvar('maxcol')
- eq({ 0, 1, 1, 0 }, funcs.getpos("'["))
- eq({ 0, 101, X, 0 }, funcs.getpos("']"))
+ local X = api.nvim_get_vvar('maxcol')
+ eq({ 0, 1, 1, 0 }, fn.getpos("'["))
+ eq({ 0, 101, X, 0 }, fn.getpos("']"))
feed(":'[,']s/def/")
poke_eventloop()
- eq({ 0, 1, 1, 0 }, funcs.getpos("'["))
- eq({ 0, 101, X, 0 }, funcs.getpos("']"))
+ eq({ 0, 1, 1, 0 }, fn.getpos("'["))
+ eq({ 0, 101, X, 0 }, fn.getpos("']"))
feed('DEF/g')
poke_eventloop()
- eq({ 0, 1, 1, 0 }, funcs.getpos("'["))
- eq({ 0, 101, X, 0 }, funcs.getpos("']"))
+ eq({ 0, 1, 1, 0 }, fn.getpos("'["))
+ eq({ 0, 101, X, 0 }, fn.getpos("']"))
feed('<CR>')
expect(('abc\nDEF\n'):rep(50))
@@ -204,8 +204,8 @@ describe(":substitute, 'inccommand' preserves", function()
feed(':%s/as/glork/')
poke_eventloop()
feed('<enter>')
- eq(meths.nvim_get_option_value('undolevels', { scope = 'global' }), 139)
- eq(meths.nvim_get_option_value('undolevels', { buf = 0 }), 34)
+ eq(api.nvim_get_option_value('undolevels', { scope = 'global' }), 139)
+ eq(api.nvim_get_option_value('undolevels', { buf = 0 }), 34)
end)
end
@@ -1098,7 +1098,7 @@ describe(':substitute, inccommand=split', function()
feed('<CR>')
poke_eventloop()
feed(':vs tmp<enter>')
- eq(3, funcs.bufnr('$'))
+ eq(3, fn.bufnr('$'))
end)
it('works with the n flag', function()
@@ -1118,7 +1118,7 @@ describe(':substitute, inccommand=split', function()
it("deactivates if 'redrawtime' is exceeded #5602", function()
-- prevent redraws from 'incsearch'
- meths.nvim_set_option_value('incsearch', false, {})
+ api.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.
@@ -1751,7 +1751,7 @@ describe("'inccommand' autocommands", function()
end
local function register_autocmd(event)
- meths.nvim_set_var(event .. '_fired', {})
+ api.nvim_set_var(event .. '_fired', {})
command('autocmd ' .. event .. ' * call add(g:' .. event .. "_fired, expand('<abuf>'))")
end
@@ -1767,14 +1767,14 @@ describe("'inccommand' autocommands", function()
feed(':%s/tw')
for event, _ in pairs(eventsExpected) do
- eventsObserved[event].open = meths.nvim_get_var(event .. '_fired')
- meths.nvim_set_var(event .. '_fired', {})
+ eventsObserved[event].open = api.nvim_get_var(event .. '_fired')
+ api.nvim_set_var(event .. '_fired', {})
end
feed('/<enter>')
for event, _ in pairs(eventsExpected) do
- eventsObserved[event].close = meths.nvim_get_var(event .. '_fired')
+ eventsObserved[event].close = api.nvim_get_var(event .. '_fired')
end
for event, _ in pairs(eventsExpected) do
@@ -1897,20 +1897,20 @@ describe("'inccommand' with 'gdefault'", function()
common_setup(nil, 'nosplit', '{')
command('set gdefault')
feed(':s/{\\n')
- eq({ mode = 'c', blocking = false }, meths.nvim_get_mode())
+ eq({ mode = 'c', blocking = false }, api.nvim_get_mode())
feed('/A<Enter>')
expect('A')
- eq({ mode = 'n', blocking = false }, meths.nvim_get_mode())
+ eq({ mode = 'n', blocking = false }, api.nvim_get_mode())
end)
it('with multiline text and range, does not lock up #7244', function()
common_setup(nil, 'nosplit', '{\n\n{')
command('set gdefault')
feed(':%s/{\\n')
- eq({ mode = 'c', blocking = false }, meths.nvim_get_mode())
+ eq({ mode = 'c', blocking = false }, api.nvim_get_mode())
feed('/A<Enter>')
expect('A\nA')
- eq({ mode = 'n', blocking = false }, meths.nvim_get_mode())
+ eq({ mode = 'n', blocking = false }, api.nvim_get_mode())
end)
it('does not crash on zero-width matches #7485', function()
@@ -1919,9 +1919,9 @@ describe("'inccommand' with 'gdefault'", function()
feed('gg')
feed('Vj')
feed(':s/\\%V')
- eq({ mode = 'c', blocking = false }, meths.nvim_get_mode())
+ eq({ mode = 'c', blocking = false }, api.nvim_get_mode())
feed('<Esc>')
- eq({ mode = 'n', blocking = false }, meths.nvim_get_mode())
+ eq({ mode = 'n', blocking = false }, api.nvim_get_mode())
end)
it('removes highlights after abort for a zero-width match', function()
@@ -2613,8 +2613,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.nvim_create_buf(false, true)
- meths.nvim_open_win(float_buf, false, {
+ local float_buf = api.nvim_create_buf(false, true)
+ api.nvim_open_win(float_buf, false, {
relative = 'editor',
height = 1,
width = 5,
@@ -2640,7 +2640,7 @@ it(':substitute with inccommand, allows :redraw before first separator is typed
{15:~ }|
:%s^ |
]])
- meths.nvim_buf_set_lines(float_buf, 0, -1, true, { 'foo' })
+ api.nvim_buf_set_lines(float_buf, 0, -1, true, { 'foo' })
command('redraw')
screen:expect([[
foo bar baz |
@@ -2744,7 +2744,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.nvim_set_keymap('x', '<F2>', '<Esc>`<Oaaaaa asdf<Esc>`>obbbbb asdf<Esc>V`<k:s/asdf/', {})
+ api.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 8a08d459c4..80862b668f 100644
--- a/test/functional/ui/input_spec.lua
+++ b/test/functional/ui/input_spec.lua
@@ -4,10 +4,10 @@ local feed, next_msg, eq = helpers.feed, helpers.next_msg, helpers.eq
local command = helpers.command
local expect = helpers.expect
local curbuf_contents = helpers.curbuf_contents
-local meths = helpers.meths
+local api = helpers.api
local exec_lua = helpers.exec_lua
local write_file = helpers.write_file
-local funcs = helpers.funcs
+local fn = helpers.fn
local eval = helpers.eval
local Screen = require('test.functional.ui.screen')
@@ -244,7 +244,7 @@ it('Ctrl-6 is Ctrl-^ vim-patch:8.1.2333', function()
command('split aaa')
command('edit bbb')
feed('<C-6>')
- eq('aaa', funcs.bufname())
+ eq('aaa', fn.bufname())
end)
it('c_CTRL-R_CTRL-R, i_CTRL-R_CTRL-R, i_CTRL-G_CTRL-K work properly vim-patch:8.1.2346', function()
@@ -303,7 +303,7 @@ it('unsimplified mapping works when there was a partial match vim-patch:8.2.4504
command('nnoremap <C-J> a')
command('nnoremap <NL> x')
command('nnoremap <C-J>x <Nop>')
- funcs.setline(1, 'x')
+ fn.setline(1, 'x')
-- CTRL-J b should have trigger the <C-J> mapping and then insert "b"
feed('<C-J>b<Esc>')
expect('xb')
@@ -392,7 +392,7 @@ end)
describe('event processing and input', function()
it('not blocked by event bursts', function()
- meths.nvim_set_keymap(
+ api.nvim_set_keymap(
'',
'<f2>',
"<cmd>lua vim.rpcnotify(1, 'stop') winning = true <cr>",
diff --git a/test/functional/ui/linematch_spec.lua b/test/functional/ui/linematch_spec.lua
index 98ada8f6c4..40df5cadf1 100644
--- a/test/functional/ui/linematch_spec.lua
+++ b/test/functional/ui/linematch_spec.lua
@@ -1118,9 +1118,9 @@ describe('regressions', function()
screen = Screen.new(100, 20)
screen:attach()
-- line must be greater than MATCH_CHAR_MAX_LEN
- helpers.meths.nvim_buf_set_lines(0, 0, -1, false, { string.rep('a', 1000) .. 'hello' })
+ helpers.api.nvim_buf_set_lines(0, 0, -1, false, { string.rep('a', 1000) .. 'hello' })
helpers.exec 'vnew'
- helpers.meths.nvim_buf_set_lines(0, 0, -1, false, { string.rep('a', 1010) .. 'world' })
+ helpers.api.nvim_buf_set_lines(0, 0, -1, false, { string.rep('a', 1010) .. 'world' })
helpers.exec 'windo diffthis'
end)
@@ -1133,9 +1133,9 @@ describe('regressions', function()
for i = 0, 29 do
lines[#lines + 1] = tostring(i)
end
- helpers.meths.nvim_buf_set_lines(0, 0, -1, false, lines)
+ helpers.api.nvim_buf_set_lines(0, 0, -1, false, lines)
helpers.exec 'vnew'
- helpers.meths.nvim_buf_set_lines(0, 0, -1, false, { '00', '29' })
+ helpers.api.nvim_buf_set_lines(0, 0, -1, false, { '00', '29' })
helpers.exec 'windo diffthis'
feed('<C-e>')
screen:expect {
diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua
index 25ae74daf1..4f95cd909c 100644
--- a/test/functional/ui/messages_spec.lua
+++ b/test/functional/ui/messages_spec.lua
@@ -5,7 +5,7 @@ local eval = helpers.eval
local eq = helpers.eq
local command = helpers.command
local set_method_error = helpers.set_method_error
-local meths = helpers.meths
+local api = helpers.api
local async_meths = helpers.async_meths
local test_build_dir = helpers.test_build_dir
local nvim_prog = helpers.nvim_prog
@@ -17,7 +17,7 @@ local poke_eventloop = helpers.poke_eventloop
local assert_alive = helpers.assert_alive
local is_os = helpers.is_os
local is_ci = helpers.is_ci
-local funcs = helpers.funcs
+local fn = helpers.fn
local skip = helpers.skip
describe('ui/ext_messages', function()
@@ -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.nvim_buf_set_lines(0, 0, 0, true, { 'aaa', 'bbb', 'ccc' })
+ api.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.nvim_get_option_value('cmdheight', {}))
+ eq(1, api.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.nvim_get_mode())
+ eq({ mode = 'n', blocking = false }, api.nvim_get_mode())
end)
end)
@@ -1675,9 +1675,9 @@ describe('ui/ext_messages', function()
})
feed(':set mouse=a<cr>')
- meths.nvim_input_mouse('left', 'press', '', 0, 12, 10)
+ api.nvim_input_mouse('left', 'press', '', 0, 12, 10)
poke_eventloop()
- meths.nvim_input_mouse('left', 'drag', '', 0, 11, 10)
+ api.nvim_input_mouse('left', 'drag', '', 0, 11, 10)
feed('<c-l>')
feed(':set cmdheight<cr>')
screen:expect({
@@ -2183,7 +2183,7 @@ aliquip ex ea commodo consequat.]]
end)
it('with :!cmd does not crash on resize', function()
- skip(funcs.executable('sleep') == 0, 'missing "sleep" command')
+ skip(fn.executable('sleep') == 0, 'missing "sleep" command')
feed(':!sleep 1<cr>')
screen:expect {
grid = [[
diff --git a/test/functional/ui/mouse_spec.lua b/test/functional/ui/mouse_spec.lua
index f3025c0d53..a7710ab584 100644
--- a/test/functional/ui/mouse_spec.lua
+++ b/test/functional/ui/mouse_spec.lua
@@ -1,8 +1,8 @@
local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
-local clear, feed, meths = helpers.clear, helpers.feed, helpers.meths
+local clear, feed, api = helpers.clear, helpers.feed, helpers.api
local insert, feed_command = helpers.insert, helpers.feed_command
-local eq, funcs = helpers.eq, helpers.funcs
+local eq, fn = helpers.eq, helpers.fn
local poke_eventloop = helpers.poke_eventloop
local command = helpers.command
local exec = helpers.exec
@@ -12,8 +12,8 @@ describe('ui/mouse/input', function()
before_each(function()
clear()
- meths.nvim_set_option_value('mouse', 'a', {})
- meths.nvim_set_option_value('list', true, {})
+ api.nvim_set_option_value('mouse', 'a', {})
+ api.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.nvim_set_option_value('mouse', '', {})
+ api.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.nvim_set_option_value('hidden', true, {})
+ api.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.nvim_set_option_value('hidden', true, {})
+ api.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.nvim_set_option_value('tabline', '%@Test@test%X-%5@Test2@test2', {})
- meths.nvim_set_option_value('showtabline', 2, {})
+ api.nvim_set_option_value('tabline', '%@Test@test%X-%5@Test2@test2', {})
+ api.nvim_set_option_value('showtabline', 2, {})
screen:expect([[
{fill:test-test2 }|
testing |
@@ -441,17 +441,17 @@ describe('ui/mouse/input', function()
support and selectio^n |
|
]])
- meths.nvim_set_var('reply', {})
+ api.nvim_set_var('reply', {})
end)
local check_reply = function(expected)
- eq(expected, meths.nvim_get_var('reply'))
- meths.nvim_set_var('reply', {})
+ eq(expected, api.nvim_get_var('reply'))
+ api.nvim_set_var('reply', {})
end
local test_click = function(name, click_str, click_num, mouse_button, modifiers)
local function doit(do_click)
- eq(1, funcs.has('tablineat'))
+ eq(1, fn.has('tablineat'))
do_click(0, 3)
check_reply({ 0, click_num, mouse_button, modifiers })
do_click(0, 4)
@@ -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.nvim_input_mouse(buttons[mouse_button], 'press', modstr, 0, row, col)
+ api.nvim_input_mouse(buttons[mouse_button], 'press', modstr, 0, row, col)
end)
end)
end
@@ -609,7 +609,7 @@ describe('ui/mouse/input', function()
]],
}
- meths.nvim_input_mouse('left', 'press', '', 0, 6, 27)
+ api.nvim_input_mouse('left', 'press', '', 0, 6, 27)
screen:expect {
grid = [[
testing │testing |
@@ -624,7 +624,7 @@ describe('ui/mouse/input', function()
|
]],
}
- meths.nvim_input_mouse('left', 'drag', '', 0, 7, 30)
+ api.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.nvim_set_option_value('tags', './non-existent-tags-file', {})
+ api.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.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)
+ api.nvim_set_var('x1_pressed', 0)
+ api.nvim_set_var('x1_released', 0)
+ api.nvim_set_var('x2_pressed', 0)
+ api.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.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')
+ api.nvim_input_mouse('x1', 'press', '', 0, 0, 0)
+ api.nvim_input_mouse('x1', 'release', '', 0, 0, 0)
+ api.nvim_input_mouse('x2', 'press', '', 0, 0, 0)
+ api.nvim_input_mouse('x2', 'release', '', 0, 0, 0)
+ eq(1, api.nvim_get_var('x1_pressed'), 'x1 pressed once')
+ eq(1, api.nvim_get_var('x1_released'), 'x1 released once')
+ eq(1, api.nvim_get_var('x2_pressed'), 'x2 pressed once')
+ eq(1, api.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.nvim_get_current_win().id
+ local oldwin = api.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.nvim_input_mouse('left', 'press', '', 0, 0, 22)
+ api.nvim_input_mouse('left', 'press', '', 0, 0, 22)
poke_eventloop()
- meths.nvim_input_mouse('left', 'drag', '', 0, 1, 12)
+ api.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.nvim_input_mouse('left', 'drag', '', 0, 2, 2)
+ api.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.nvim_input_mouse('left', 'release', '', 0, 2, 2)
- meths.nvim_set_option_value('statuscolumn', 'foobar', { win = oldwin })
+ api.nvim_input_mouse('left', 'release', '', 0, 2, 2)
+ api.nvim_set_option_value('statuscolumn', 'foobar', { win = oldwin })
screen:expect([[
{8:fo}│{0:^$} |
{8:fo}│{0:~ }|*2
{4:< }{5:[No Name] }|
|
]])
- meths.nvim_input_mouse('left', 'press', '', 0, 0, 2)
+ api.nvim_input_mouse('left', 'press', '', 0, 0, 2)
poke_eventloop()
- meths.nvim_input_mouse('left', 'drag', '', 0, 1, 12)
+ api.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.nvim_input_mouse('left', 'drag', '', 0, 2, 22)
+ api.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.nvim_input_mouse('left', 'release', '', 0, 2, 22)
+ api.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.nvim_input_mouse('wheel', 'down', '', 0, 0, 0)
+ api.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.nvim_input_mouse('wheel', 'up', '', 0, 0, 27)
+ api.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.nvim_input_mouse('wheel', 'up', '', 0, 7, 27)
- meths.nvim_input_mouse('wheel', 'up', '', 0, 7, 27)
+ api.nvim_input_mouse('wheel', 'up', '', 0, 7, 27)
+ api.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.nvim_input_mouse('wheel', 'left', '', 0, 0, 27)
+ api.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.nvim_input_mouse('wheel', 'right', '', 0, 0, 0)
+ api.nvim_input_mouse('wheel', 'right', '', 0, 0, 0)
screen:expect([[
g |
|
@@ -1048,7 +1048,7 @@ describe('ui/mouse/input', function()
|
]])
- meths.nvim_input_mouse('wheel', 'right', '', 0, 0, 27)
+ api.nvim_input_mouse('wheel', 'right', '', 0, 0, 27)
screen:expect([[
g |
|
@@ -1068,7 +1068,7 @@ describe('ui/mouse/input', function()
|
]])
- meths.nvim_input_mouse('wheel', 'right', '', 0, 0, 27)
+ api.nvim_input_mouse('wheel', 'right', '', 0, 0, 27)
screen:expect([[
g |
|
@@ -1605,39 +1605,39 @@ describe('ui/mouse/input', function()
describe('(matchadd())', function()
before_each(function()
- funcs.matchadd('Conceal', [[\*]])
- funcs.matchadd('Conceal', [[cats]], 10, -1, { conceal = 'X' })
- funcs.matchadd('Conceal', [[\n\@<=x]], 10, -1, { conceal = '>' })
+ fn.matchadd('Conceal', [[\*]])
+ fn.matchadd('Conceal', [[cats]], 10, -1, { conceal = 'X' })
+ fn.matchadd('Conceal', [[\n\@<=x]], 10, -1, { conceal = '>' })
end)
test_mouse_click_conceal()
end)
describe('(extmarks)', function()
before_each(function()
- 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 = '>' })
+ local ns = api.nvim_create_namespace('conceal')
+ api.nvim_buf_set_extmark(0, ns, 0, 11, { end_col = 12, conceal = '' })
+ api.nvim_buf_set_extmark(0, ns, 0, 14, { end_col = 15, conceal = '' })
+ api.nvim_buf_set_extmark(0, ns, 1, 5, { end_col = 6, conceal = '' })
+ api.nvim_buf_set_extmark(0, ns, 1, 8, { end_col = 9, conceal = '' })
+ api.nvim_buf_set_extmark(0, ns, 1, 10, { end_col = 11, conceal = '' })
+ api.nvim_buf_set_extmark(0, ns, 1, 13, { end_col = 14, conceal = '' })
+ api.nvim_buf_set_extmark(0, ns, 1, 15, { end_col = 16, conceal = '' })
+ api.nvim_buf_set_extmark(0, ns, 1, 18, { end_col = 19, conceal = '' })
+ api.nvim_buf_set_extmark(0, ns, 2, 24, { end_col = 25, conceal = '' })
+ api.nvim_buf_set_extmark(0, ns, 2, 29, { end_col = 30, conceal = '' })
+ api.nvim_buf_set_extmark(0, ns, 2, 25, { end_col = 29, conceal = 'X' })
+ api.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.nvim_get_option_value('winwidth', {})
+ local winwidth = api.nvim_get_option_value('winwidth', {})
-- Set winwidth=1 so that window sizes don't change.
- meths.nvim_set_option_value('winwidth', 1, {})
+ api.nvim_set_option_value('winwidth', 1, {})
command('tabedit')
- local tabpage = meths.nvim_get_current_tabpage()
+ local tabpage = api.nvim_get_current_tabpage()
insert('hello')
command('vsplit')
local opts = {
@@ -1651,19 +1651,19 @@ describe('ui/mouse/input', function()
border = 'single',
focusable = 1,
}
- local float = meths.nvim_open_win(meths.nvim_get_current_buf(), false, opts)
+ local float = api.nvim_open_win(api.nvim_get_current_buf(), false, opts)
command('redraw')
- local lines = meths.nvim_get_option_value('lines', {})
- local columns = meths.nvim_get_option_value('columns', {})
+ local lines = api.nvim_get_option_value('lines', {})
+ local columns = api.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.nvim_input_mouse('left', 'press', '', 0, row, col)
- meths.nvim_set_current_tabpage(tabpage)
- local mousepos = funcs.getmousepos()
+ api.nvim_input_mouse('left', 'press', '', 0, row, col)
+ api.nvim_set_current_tabpage(tabpage)
+ local mousepos = fn.getmousepos()
eq(row + 1, mousepos.screenrow)
eq(col + 1, mousepos.screencol)
-- All other values should be 0 when clicking on the command line.
@@ -1686,8 +1686,8 @@ 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.nvim_input_mouse('left', 'press', '', 0, row, col)
- local mousepos = funcs.getmousepos()
+ api.nvim_input_mouse('left', 'press', '', 0, row, col)
+ local mousepos = fn.getmousepos()
eq(float.id, mousepos.winid)
eq(win_row + 1, mousepos.winrow)
eq(win_col + 1, mousepos.wincol)
@@ -1702,8 +1702,8 @@ describe('ui/mouse/input', function()
then
-- Because of border, win_row and win_col don't need to be
-- incremented by 1.
- line = math.min(win_row, funcs.line('$'))
- column = math.min(win_col, #funcs.getline(line) + 1)
+ line = math.min(win_row, fn.line('$'))
+ column = math.min(win_col, #fn.getline(line) + 1)
coladd = win_col - column
end
eq(line, mousepos.line)
@@ -1715,19 +1715,19 @@ 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.nvim_win_set_config(float, opts)
+ api.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.nvim_input_mouse('left', 'press', '', 0, row, col)
- local mousepos = funcs.getmousepos()
+ api.nvim_input_mouse('left', 'press', '', 0, row, col)
+ local mousepos = fn.getmousepos()
eq(float.id, mousepos.winid)
eq(win_row + 1, mousepos.winrow)
eq(win_col + 1, mousepos.wincol)
- local line = math.min(win_row + 1, funcs.line('$'))
- local column = math.min(win_col + 1, #funcs.getline(line) + 1)
+ local line = math.min(win_row + 1, fn.line('$'))
+ local column = math.min(win_col + 1, #fn.getline(line) + 1)
local coladd = win_col + 1 - column
eq(line, mousepos.line)
eq(column, mousepos.column)
@@ -1740,20 +1740,20 @@ describe('ui/mouse/input', function()
-- that getmousepos() does not consider unfocusable floats. (see discussion
-- in PR #14937 for details).
opts.focusable = false
- meths.nvim_win_set_config(float, opts)
+ api.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.nvim_input_mouse('left', 'press', '', 0, row, col)
- local mousepos = funcs.getmousepos()
- eq(funcs.win_getid(nr), mousepos.winid)
+ for win_row = 0, fn.winheight(nr) - 1 do
+ for win_col = 0, fn.winwidth(nr) - 1 do
+ local row = win_row + fn.win_screenpos(nr)[1] - 1
+ local col = win_col + fn.win_screenpos(nr)[2] - 1
+ api.nvim_input_mouse('left', 'press', '', 0, row, col)
+ local mousepos = fn.getmousepos()
+ eq(fn.win_getid(nr), mousepos.winid)
eq(win_row + 1, mousepos.winrow)
eq(win_col + 1, mousepos.wincol)
- local line = math.min(win_row + 1, funcs.line('$'))
- local column = math.min(win_col + 1, #funcs.getline(line) + 1)
+ local line = math.min(win_row + 1, fn.line('$'))
+ local column = math.min(win_col + 1, #fn.getline(line) + 1)
local coladd = win_col + 1 - column
eq(line, mousepos.line)
eq(column, mousepos.column)
@@ -1764,34 +1764,34 @@ describe('ui/mouse/input', function()
-- Restore state and release mouse.
command('tabclose!')
- meths.nvim_set_option_value('winwidth', winwidth, {})
- meths.nvim_input_mouse('left', 'release', '', 0, 0, 0)
+ api.nvim_set_option_value('winwidth', winwidth, {})
+ api.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.nvim_set_var('mouse_up', 0)
- meths.nvim_set_var('mouse_up2', 0)
+ api.nvim_set_var('mouse_up', 0)
+ api.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.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'))
+ api.nvim_input_mouse('wheel', 'up', '', 0, 0, 0)
+ api.nvim_input_mouse('wheel', 'up', '', 0, 0, 0)
+ eq(4, api.nvim_get_var('mouse_up'))
+ eq(0, api.nvim_get_var('mouse_up2'))
end)
it('<MouseMove> is not translated into multiclicks and can be mapped', function()
- meths.nvim_set_var('mouse_move', 0)
- meths.nvim_set_var('mouse_move2', 0)
+ api.nvim_set_var('mouse_move', 0)
+ api.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.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'))
+ api.nvim_input_mouse('move', '', '', 0, 0, 0)
+ api.nvim_input_mouse('move', '', '', 0, 0, 0)
+ eq(4, api.nvim_get_var('mouse_move'))
+ eq(0, api.nvim_get_var('mouse_move2'))
end)
it('feeding <MouseMove> in Normal mode does not use uninitialized memory #19480', function()
@@ -1818,127 +1818,127 @@ describe('ui/mouse/input', function()
vmenu PopUp.baz y:<C-U>let g:menustr = 'baz'<CR>
]])
- 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)
+ api.nvim_win_set_cursor(0, { 1, 0 })
+ api.nvim_input_mouse('right', 'press', '', 0, 0, 4)
+ api.nvim_input_mouse('right', 'release', '', 0, 0, 4)
feed('<Down><Down><CR>')
- eq('bar', meths.nvim_get_var('menustr'))
- eq({ 1, 4 }, meths.nvim_win_get_cursor(0))
+ eq('bar', api.nvim_get_var('menustr'))
+ eq({ 1, 4 }, api.nvim_win_get_cursor(0))
-- Test for right click in visual mode inside the selection
- funcs.setreg('"', '')
- meths.nvim_win_set_cursor(0, { 1, 9 })
+ fn.setreg('"', '')
+ api.nvim_win_set_cursor(0, { 1, 9 })
feed('vee')
- meths.nvim_input_mouse('right', 'press', '', 0, 0, 11)
- meths.nvim_input_mouse('right', 'release', '', 0, 0, 11)
+ api.nvim_input_mouse('right', 'press', '', 0, 0, 11)
+ api.nvim_input_mouse('right', 'release', '', 0, 0, 11)
feed('<Down><CR>')
- eq({ 1, 9 }, meths.nvim_win_get_cursor(0))
- eq('ran away', funcs.getreg('"'))
+ eq({ 1, 9 }, api.nvim_win_get_cursor(0))
+ eq('ran away', fn.getreg('"'))
-- Test for right click in visual mode right before the selection
- funcs.setreg('"', '')
- meths.nvim_win_set_cursor(0, { 1, 9 })
+ fn.setreg('"', '')
+ api.nvim_win_set_cursor(0, { 1, 9 })
feed('vee')
- meths.nvim_input_mouse('right', 'press', '', 0, 0, 8)
- meths.nvim_input_mouse('right', 'release', '', 0, 0, 8)
+ api.nvim_input_mouse('right', 'press', '', 0, 0, 8)
+ api.nvim_input_mouse('right', 'release', '', 0, 0, 8)
feed('<Down><CR>')
- eq({ 1, 8 }, meths.nvim_win_get_cursor(0))
- eq('', funcs.getreg('"'))
+ eq({ 1, 8 }, api.nvim_win_get_cursor(0))
+ eq('', fn.getreg('"'))
-- Test for right click in visual mode right after the selection
- funcs.setreg('"', '')
- meths.nvim_win_set_cursor(0, { 1, 9 })
+ fn.setreg('"', '')
+ api.nvim_win_set_cursor(0, { 1, 9 })
feed('vee')
- meths.nvim_input_mouse('right', 'press', '', 0, 0, 17)
- meths.nvim_input_mouse('right', 'release', '', 0, 0, 17)
+ api.nvim_input_mouse('right', 'press', '', 0, 0, 17)
+ api.nvim_input_mouse('right', 'release', '', 0, 0, 17)
feed('<Down><CR>')
- eq({ 1, 17 }, meths.nvim_win_get_cursor(0))
- eq('', funcs.getreg('"'))
+ eq({ 1, 17 }, api.nvim_win_get_cursor(0))
+ eq('', fn.getreg('"'))
-- Test for right click in block-wise visual mode inside the selection
- funcs.setreg('"', '')
- meths.nvim_win_set_cursor(0, { 1, 15 })
+ fn.setreg('"', '')
+ api.nvim_win_set_cursor(0, { 1, 15 })
feed('<C-V>j3l')
- meths.nvim_input_mouse('right', 'press', '', 0, 1, 16)
- meths.nvim_input_mouse('right', 'release', '', 0, 1, 16)
+ api.nvim_input_mouse('right', 'press', '', 0, 1, 16)
+ api.nvim_input_mouse('right', 'release', '', 0, 1, 16)
feed('<Down><CR>')
- eq({ 1, 15 }, meths.nvim_win_get_cursor(0))
- eq('\0224', funcs.getregtype('"'))
+ eq({ 1, 15 }, api.nvim_win_get_cursor(0))
+ eq('\0224', fn.getregtype('"'))
-- Test for right click in block-wise visual mode outside the selection
- funcs.setreg('"', '')
- meths.nvim_win_set_cursor(0, { 1, 15 })
+ fn.setreg('"', '')
+ api.nvim_win_set_cursor(0, { 1, 15 })
feed('<C-V>j3l')
- meths.nvim_input_mouse('right', 'press', '', 0, 1, 1)
- meths.nvim_input_mouse('right', 'release', '', 0, 1, 1)
+ api.nvim_input_mouse('right', 'press', '', 0, 1, 1)
+ api.nvim_input_mouse('right', 'release', '', 0, 1, 1)
feed('<Down><CR>')
- eq({ 2, 1 }, meths.nvim_win_get_cursor(0))
- eq('v', funcs.getregtype('"'))
- eq('', funcs.getreg('"'))
+ eq({ 2, 1 }, api.nvim_win_get_cursor(0))
+ eq('v', fn.getregtype('"'))
+ eq('', fn.getreg('"'))
-- Test for right click in line-wise visual mode inside the selection
- funcs.setreg('"', '')
- meths.nvim_win_set_cursor(0, { 1, 15 })
+ fn.setreg('"', '')
+ api.nvim_win_set_cursor(0, { 1, 15 })
feed('V')
- meths.nvim_input_mouse('right', 'press', '', 0, 0, 9)
- meths.nvim_input_mouse('right', 'release', '', 0, 0, 9)
+ api.nvim_input_mouse('right', 'press', '', 0, 0, 9)
+ api.nvim_input_mouse('right', 'release', '', 0, 0, 9)
feed('<Down><CR>')
- 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))
+ eq({ 1, 0 }, api.nvim_win_get_cursor(0)) -- After yanking, the cursor goes to 1,1
+ eq('V', fn.getregtype('"'))
+ eq(1, #fn.getreg('"', 1, true))
-- Test for right click in multi-line line-wise visual mode inside the selection
- funcs.setreg('"', '')
- meths.nvim_win_set_cursor(0, { 1, 15 })
+ fn.setreg('"', '')
+ api.nvim_win_set_cursor(0, { 1, 15 })
feed('Vj')
- meths.nvim_input_mouse('right', 'press', '', 0, 1, 19)
- meths.nvim_input_mouse('right', 'release', '', 0, 1, 19)
+ api.nvim_input_mouse('right', 'press', '', 0, 1, 19)
+ api.nvim_input_mouse('right', 'release', '', 0, 1, 19)
feed('<Down><CR>')
- 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))
+ eq({ 1, 0 }, api.nvim_win_get_cursor(0)) -- After yanking, the cursor goes to 1,1
+ eq('V', fn.getregtype('"'))
+ eq(2, #fn.getreg('"', 1, true))
-- Test for right click in line-wise visual mode outside the selection
- funcs.setreg('"', '')
- meths.nvim_win_set_cursor(0, { 1, 15 })
+ fn.setreg('"', '')
+ api.nvim_win_set_cursor(0, { 1, 15 })
feed('V')
- meths.nvim_input_mouse('right', 'press', '', 0, 1, 9)
- meths.nvim_input_mouse('right', 'release', '', 0, 1, 9)
+ api.nvim_input_mouse('right', 'press', '', 0, 1, 9)
+ api.nvim_input_mouse('right', 'release', '', 0, 1, 9)
feed('<Down><CR>')
- eq({ 2, 9 }, meths.nvim_win_get_cursor(0))
- eq('', funcs.getreg('"'))
+ eq({ 2, 9 }, api.nvim_win_get_cursor(0))
+ eq('', fn.getreg('"'))
-- Try clicking outside the window
- funcs.setreg('"', '')
- meths.nvim_win_set_cursor(0, { 2, 1 })
+ fn.setreg('"', '')
+ api.nvim_win_set_cursor(0, { 2, 1 })
feed('vee')
- meths.nvim_input_mouse('right', 'press', '', 0, 6, 1)
- meths.nvim_input_mouse('right', 'release', '', 0, 6, 1)
+ api.nvim_input_mouse('right', 'press', '', 0, 6, 1)
+ api.nvim_input_mouse('right', 'release', '', 0, 6, 1)
feed('<Down><CR>')
- eq(2, funcs.winnr())
- eq('', funcs.getreg('"'))
+ eq(2, fn.winnr())
+ eq('', fn.getreg('"'))
-- Test for right click in visual mode inside the selection with vertical splits
command('wincmd t')
command('rightbelow vsplit')
- funcs.setreg('"', '')
- meths.nvim_win_set_cursor(0, { 1, 9 })
+ fn.setreg('"', '')
+ api.nvim_win_set_cursor(0, { 1, 9 })
feed('vee')
- meths.nvim_input_mouse('right', 'press', '', 0, 0, 52)
- meths.nvim_input_mouse('right', 'release', '', 0, 0, 52)
+ api.nvim_input_mouse('right', 'press', '', 0, 0, 52)
+ api.nvim_input_mouse('right', 'release', '', 0, 0, 52)
feed('<Down><CR>')
- eq({ 1, 9 }, meths.nvim_win_get_cursor(0))
- eq('ran away', funcs.getreg('"'))
+ eq({ 1, 9 }, api.nvim_win_get_cursor(0))
+ eq('ran away', fn.getreg('"'))
-- Test for right click inside visual selection at bottom of window with winbar
command('setlocal winbar=WINBAR')
feed('2yyP')
- funcs.setreg('"', '')
+ fn.setreg('"', '')
feed('G$vbb')
- meths.nvim_input_mouse('right', 'press', '', 0, 4, 61)
- meths.nvim_input_mouse('right', 'release', '', 0, 4, 61)
+ api.nvim_input_mouse('right', 'press', '', 0, 4, 61)
+ api.nvim_input_mouse('right', 'release', '', 0, 4, 61)
feed('<Down><CR>')
- eq({ 4, 20 }, meths.nvim_win_get_cursor(0))
- eq('the moon', funcs.getreg('"'))
+ eq({ 4, 20 }, api.nvim_win_get_cursor(0))
+ eq('the moon', fn.getreg('"'))
end)
end)
diff --git a/test/functional/ui/multibyte_spec.lua b/test/functional/ui/multibyte_spec.lua
index 72bb0b0174..d38bc27a51 100644
--- a/test/functional/ui/multibyte_spec.lua
+++ b/test/functional/ui/multibyte_spec.lua
@@ -5,8 +5,8 @@ local command = helpers.command
local feed = helpers.feed
local feed_command = helpers.feed_command
local insert = helpers.insert
-local funcs = helpers.funcs
-local meths = helpers.meths
+local fn = helpers.fn
+local api = helpers.api
local split = vim.split
local dedent = helpers.dedent
@@ -85,7 +85,7 @@ describe('multibyte rendering', function()
]])
-- check double-with char is temporarily hidden when overlapped
- funcs.complete(4, { 'xx', 'yy' })
+ fn.complete(4, { 'xx', 'yy' })
screen:expect([[
ab xx^ |
- {2: xx } |
@@ -118,7 +118,7 @@ describe('multibyte rendering', function()
it('works with a lot of unicode (zalgo) text', function()
screen:try_resize(65, 10)
- meths.nvim_buf_set_lines(
+ api.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.nvim__invalidate_glyph_cache()
+ api.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.nvim_buf_set_lines(0, 0, -1, true, { 'سلام့̀́̂̃̄̅̆̇̈̉̊̋̌' })
+ api.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 600b08744f..c77363e584 100644
--- a/test/functional/ui/multigrid_spec.lua
+++ b/test/functional/ui/multigrid_spec.lua
@@ -3,9 +3,9 @@ local Screen = require('test.functional.ui.screen')
local clear = helpers.clear
local feed, command, insert = helpers.feed, helpers.command, helpers.insert
local eq = helpers.eq
-local funcs = helpers.funcs
-local meths = helpers.meths
-local curwin = helpers.meths.nvim_get_current_win
+local fn = helpers.fn
+local api = helpers.api
+local curwin = helpers.api.nvim_get_current_win
local poke_eventloop = helpers.poke_eventloop
@@ -454,17 +454,17 @@ describe('ext_multigrid', function()
end)
it('winwidth() winheight() getwininfo() return inner width and height #19743', function()
- eq(60, funcs.winwidth(0))
- eq(20, funcs.winheight(0))
- local win_info = funcs.getwininfo(curwin().id)[1]
+ eq(60, fn.winwidth(0))
+ eq(20, fn.winheight(0))
+ local win_info = fn.getwininfo(curwin().id)[1]
eq(60, win_info.width)
eq(20, win_info.height)
end)
it("'scroll' option works properly", function()
- 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 }))
+ eq(10, api.nvim_get_option_value('scroll', { win = 0 }))
+ api.nvim_set_option_value('scroll', 15, { win = 0 })
+ eq(15, api.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.nvim_create_buf(false, false)
- meths.nvim_open_win(float_buf, false, {
+ local float_buf = api.nvim_create_buf(false, false)
+ api.nvim_open_win(float_buf, false, {
relative = 'win',
win = curwin(),
bufpos = {0, 1018},
@@ -984,7 +984,7 @@ describe('ext_multigrid', function()
|
]]}
- meths.nvim_input_mouse('left', 'press', '', 2, 0, 5)
+ api.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.nvim_input_mouse('left', 'press', '', 2, 1, 6)
+ api.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.nvim_input_mouse('left', 'press', '', 4, 1, 4)
+ api.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.nvim_input_mouse('left', 'press', '', 4, 0, 64)
+ api.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.nvim_input_mouse('left', 'press', '', 1, 6, 20)
+ api.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.nvim_input_mouse('left', 'drag', '', 1, 4, 20)
+ api.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.nvim_input_mouse('left', 'press', '', 1, 8, 26)
+ api.nvim_input_mouse('left', 'press', '', 1, 8, 26)
poke_eventloop()
- meths.nvim_input_mouse('left', 'drag', '', 1, 6, 30)
+ api.nvim_input_mouse('left', 'drag', '', 1, 6, 30)
screen:expect{grid=[[
## grid 1
[4:-----------------------------------------------------]|*4
@@ -1173,8 +1173,8 @@ describe('ext_multigrid', function()
command('aunmenu PopUp | vmenu PopUp.Copy y')
- funcs.setreg('"', '')
- meths.nvim_input_mouse('left', 'press', '2', 2, 1, 6)
+ fn.setreg('"', '')
+ api.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.nvim_input_mouse('right', 'press', '', 2, 1, 6)
- meths.nvim_input_mouse('right', 'release', '', 2, 1, 6)
+ api.nvim_input_mouse('right', 'press', '', 2, 1, 6)
+ api.nvim_input_mouse('right', 'release', '', 2, 1, 6)
screen:expect{grid=[[
## grid 1
[4:-----------------------------------------------------]|*4
@@ -1245,10 +1245,10 @@ describe('ext_multigrid', function()
to be clicked |
{1:~ }|*5
]]}
- eq('clicked', funcs.getreg('"'))
+ eq('clicked', fn.getreg('"'))
- funcs.setreg('"', '')
- meths.nvim_input_mouse('left', 'press', '2', 4, 0, 64)
+ fn.setreg('"', '')
+ api.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.nvim_input_mouse('right', 'press', '', 4, 0, 64)
- meths.nvim_input_mouse('right', 'release', '', 4, 0, 64)
+ api.nvim_input_mouse('right', 'press', '', 4, 0, 64)
+ api.nvim_input_mouse('right', 'release', '', 4, 0, 64)
screen:expect{grid=[[
## grid 1
[4:-----------------------------------------------------]|*4
@@ -1319,7 +1319,7 @@ describe('ext_multigrid', function()
to be clicked |
{1:~ }|*5
]]}
- eq('eiusmo', funcs.getreg('"'))
+ eq('eiusmo', fn.getreg('"'))
command('wincmd J')
screen:try_resize_grid(4, 7, 10)
@@ -1353,8 +1353,8 @@ describe('ext_multigrid', function()
{1:~ }|*3
]]}
- funcs.setreg('"', '')
- meths.nvim_input_mouse('left', 'press', '2', 4, 9, 1)
+ fn.setreg('"', '')
+ api.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.nvim_input_mouse('right', 'press', '', 4, 9, 1)
- meths.nvim_input_mouse('right', 'release', '', 4, 9, 1)
+ api.nvim_input_mouse('right', 'press', '', 4, 9, 1)
+ api.nvim_input_mouse('right', 'release', '', 4, 9, 1)
screen:expect{grid=[[
## grid 1
[5:------------------------------]│[2:----------------------]|*5
@@ -1449,7 +1449,7 @@ describe('ext_multigrid', function()
to be clicked |
{1:~ }|*3
]]}
- eq('eiusmo', funcs.getreg('"'))
+ eq('eiusmo', fn.getreg('"'))
screen:try_resize_grid(4, 7, 11)
screen:expect{grid=[[
@@ -1483,8 +1483,8 @@ describe('ext_multigrid', function()
{1:~ }|*3
]]}
- funcs.setreg('"', '')
- meths.nvim_input_mouse('left', 'press', '2', 4, 9, 1)
+ fn.setreg('"', '')
+ api.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.nvim_input_mouse('right', 'press', '', 4, 9, 1)
- meths.nvim_input_mouse('right', 'release', '', 4, 9, 1)
+ api.nvim_input_mouse('right', 'press', '', 4, 9, 1)
+ api.nvim_input_mouse('right', 'release', '', 4, 9, 1)
screen:expect{grid=[[
## grid 1
[5:------------------------------]│[2:----------------------]|*5
@@ -1582,7 +1582,7 @@ describe('ext_multigrid', function()
to be clicked |
{1:~ }|*3
]]}
- eq('eiusmo', funcs.getreg('"'))
+ eq('eiusmo', fn.getreg('"'))
end)
it('supports mouse drag with mouse=a', function()
@@ -1593,9 +1593,9 @@ describe('ext_multigrid', function()
command('enew')
feed('ifoo\nbar<esc>')
- meths.nvim_input_mouse('left', 'press', '', 5, 0, 0)
+ api.nvim_input_mouse('left', 'press', '', 5, 0, 0)
poke_eventloop()
- meths.nvim_input_mouse('left', 'drag', '', 5, 1, 2)
+ api.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.nvim_win_set_cursor(1000, {1, 10})
+ api.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.nvim_input_mouse('left', 'press', '', 1,5, 1)
+ api.nvim_input_mouse('left', 'press', '', 1,5, 1)
poke_eventloop()
- meths.nvim_input_mouse('left', 'drag', '', 1, 6, 1)
+ api.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.nvim_set_option_value('winbar', 'Set Up The Bars', {})
+ api.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.nvim_input_mouse('left', 'press', '', 1, 6, 20)
+ api.nvim_input_mouse('left', 'press', '', 1, 6, 20)
poke_eventloop()
- meths.nvim_input_mouse('left', 'drag', '', 1, 7, 20)
+ api.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.nvim_input_mouse('left', 'drag', '', 1, 4, 20)
+ api.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.nvim_input_mouse('left', 'press', '', 1, 12, 10)
+ api.nvim_input_mouse('left', 'press', '', 1, 12, 10)
poke_eventloop()
- meths.nvim_input_mouse('left', 'drag', '', 1, 10, 10)
+ api.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.nvim_get_option_value('cmdheight', {}))
+ eq(3, api.nvim_get_option_value('cmdheight', {}))
- meths.nvim_input_mouse('left', 'drag', '', 1, 12, 10)
+ api.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.nvim_get_option_value('cmdheight', {}))
+ eq(1, api.nvim_get_option_value('cmdheight', {}))
end)
end)
diff --git a/test/functional/ui/popupmenu_spec.lua b/test/functional/ui/popupmenu_spec.lua
index b4cfe39bc3..941b8b69bf 100644
--- a/test/functional/ui/popupmenu_spec.lua
+++ b/test/functional/ui/popupmenu_spec.lua
@@ -4,10 +4,10 @@ local assert_alive = helpers.assert_alive
local clear, feed = helpers.clear, helpers.feed
local source = helpers.source
local insert = helpers.insert
-local meths = helpers.meths
+local api = helpers.api
local async_meths = helpers.async_meths
local command = helpers.command
-local funcs = helpers.funcs
+local fn = helpers.fn
local eq = helpers.eq
local pcall_err = helpers.pcall_err
local exec_lua = helpers.exec_lua
@@ -117,7 +117,7 @@ describe('ui/ext_popupmenu', function()
},
}
- meths.nvim_select_popupmenu_item(1, false, false, {})
+ api.nvim_select_popupmenu_item(1, false, false, {})
screen:expect {
grid = [[
|
@@ -132,7 +132,7 @@ describe('ui/ext_popupmenu', function()
},
}
- meths.nvim_select_popupmenu_item(2, true, false, {})
+ api.nvim_select_popupmenu_item(2, true, false, {})
screen:expect {
grid = [[
|
@@ -147,7 +147,7 @@ describe('ui/ext_popupmenu', function()
},
}
- meths.nvim_select_popupmenu_item(0, true, true, {})
+ api.nvim_select_popupmenu_item(0, true, true, {})
screen:expect([[
|
foo^ |
@@ -170,7 +170,7 @@ describe('ui/ext_popupmenu', function()
},
}
- meths.nvim_select_popupmenu_item(-1, false, false, {})
+ api.nvim_select_popupmenu_item(-1, false, false, {})
screen:expect {
grid = [[
|
@@ -185,7 +185,7 @@ describe('ui/ext_popupmenu', function()
},
}
- meths.nvim_select_popupmenu_item(1, true, false, {})
+ api.nvim_select_popupmenu_item(1, true, false, {})
screen:expect {
grid = [[
|
@@ -200,7 +200,7 @@ describe('ui/ext_popupmenu', function()
},
}
- meths.nvim_select_popupmenu_item(-1, true, false, {})
+ api.nvim_select_popupmenu_item(-1, true, false, {})
screen:expect {
grid = [[
|
@@ -215,7 +215,7 @@ describe('ui/ext_popupmenu', function()
},
}
- meths.nvim_select_popupmenu_item(0, true, false, {})
+ api.nvim_select_popupmenu_item(0, true, false, {})
screen:expect {
grid = [[
|
@@ -230,7 +230,7 @@ describe('ui/ext_popupmenu', function()
},
}
- meths.nvim_select_popupmenu_item(-1, true, true, {})
+ api.nvim_select_popupmenu_item(-1, true, true, {})
screen:expect([[
|
^ |
@@ -262,7 +262,7 @@ describe('ui/ext_popupmenu', function()
},
})
- meths.nvim_select_popupmenu_item(-1, true, false, {})
+ api.nvim_select_popupmenu_item(-1, true, false, {})
screen:expect({
grid = [[
|*2
@@ -276,7 +276,7 @@ describe('ui/ext_popupmenu', function()
},
})
- meths.nvim_select_popupmenu_item(5, true, false, {})
+ api.nvim_select_popupmenu_item(5, true, false, {})
screen:expect({
grid = [[
|*2
@@ -290,7 +290,7 @@ describe('ui/ext_popupmenu', function()
},
})
- meths.nvim_select_popupmenu_item(-1, true, true, {})
+ api.nvim_select_popupmenu_item(-1, true, true, {})
screen:expect({
grid = [[
|*2
@@ -313,7 +313,7 @@ describe('ui/ext_popupmenu', function()
},
})
- meths.nvim_select_popupmenu_item(5, true, true, {})
+ api.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.nvim_ui_pum_set_height(pum_height)
+ api.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.nvim_ui_pum_set_height(1)
- eq('Expected pum height > 0', pcall_err(meths.nvim_ui_pum_set_height, 0))
+ api.nvim_ui_pum_set_height(1)
+ eq('Expected pum height > 0', pcall_err(api.nvim_ui_pum_set_height, 0))
end)
it('an error occurs when ext_popupmenu is false', function()
- meths.nvim_ui_pum_set_height(1)
+ api.nvim_ui_pum_set_height(1)
screen:set_option('ext_popupmenu', false)
- eq('It must support the ext_popupmenu option', pcall_err(meths.nvim_ui_pum_set_height, 1))
+ eq('It must support the ext_popupmenu option', pcall_err(api.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.nvim_ui_pum_set_height(pum_height)
+ api.nvim_ui_pum_set_height(pum_height)
-- set bounds w h r c
- meths.nvim_ui_pum_set_bounds(10.5, 5.2, 6.3, 7.4)
+ api.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.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)
+ api.nvim_ui_pum_set_bounds(1.0, 1.0, 0.0, 1.5)
+ api.nvim_ui_pum_set_bounds(1.0, 1.0, -1.0, 0.0)
+ api.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.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))
+ api.nvim_ui_pum_set_bounds(1.0, 1.0, 0.0, 1.5)
+ eq('Expected width > 0', pcall_err(api.nvim_ui_pum_set_bounds, 0.0, 1.0, 1.0, 0.0))
+ eq('Expected height > 0', pcall_err(api.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.nvim_ui_pum_set_bounds(1.0, 1.0, 0.0, 1.5)
+ api.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.nvim_ui_pum_set_bounds, 1.0, 1.0, 0.0, 1.5)
+ pcall_err(api.nvim_ui_pum_set_bounds, 1.0, 1.0, 0.0, 1.5)
)
end)
end)
@@ -768,7 +768,7 @@ describe('ui/ext_popupmenu', function()
{1:~ }|*8
:sign ^ |
]])
- eq(0, funcs.wildmenumode())
+ eq(0, fn.wildmenumode())
feed('<tab>')
screen:expect {
@@ -779,7 +779,7 @@ describe('ui/ext_popupmenu', function()
]],
popupmenu = { items = wild_expected, pos = 0, anchor = { 1, 9, 6 } },
}
- eq(1, funcs.wildmenumode())
+ eq(1, fn.wildmenumode())
feed('<left>')
screen:expect {
@@ -820,7 +820,7 @@ describe('ui/ext_popupmenu', function()
popupmenu = { items = wild_expected, pos = 5, anchor = { 1, 9, 6 } },
}
feed('<esc>')
- eq(0, funcs.wildmenumode())
+ eq(0, fn.wildmenumode())
-- check positioning with multibyte char in pattern
command('e långfile1')
@@ -1055,7 +1055,7 @@ describe("builtin popupmenu 'pumblend'", function()
{20:-- Keyword Local completion (^N^P) }{21:match 1 of 65} |
]])
- meths.nvim_input_mouse('wheel', 'down', '', 0, 9, 40)
+ api.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.nvim_input_mouse('wheel', 'down', '', 0, 9, 40)
+ api.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.nvim_input_mouse('wheel', 'up', '', 0, 9, 40)
+ api.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.nvim_input_mouse('wheel', 'down', '', 0, 9, 40)
+ api.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.nvim_input_mouse('wheel', 'down', '', 0, 9, 40)
+ api.nvim_input_mouse('wheel', 'down', '', 0, 9, 40)
screen:expect([[
Est eu^ |
L{n: elit } sit amet, consectetur |
@@ -2158,10 +2158,7 @@ describe('builtin popupmenu', function()
{2:-- Keyword Local completion (^N^P) }{5:match 22 of 65} |
]])
- funcs.complete(
- 4,
- { 'ea', 'eeeeeeeeeeeeeeeeee', 'ei', 'eo', 'eu', 'ey', 'eå', 'eä', 'eö' }
- )
+ fn.complete(4, { 'ea', 'eeeeeeeeeeeeeeeeee', 'ei', 'eo', 'eu', 'ey', 'eå', 'eä', 'eö' })
screen:expect([[
Est eu^ |
{s: ea }t amet, consectetur |
@@ -2179,7 +2176,7 @@ describe('builtin popupmenu', function()
{2:-- Keyword Local completion (^N^P) }{5:match 1 of 9} |
]])
- funcs.complete(4, { 'ea', 'eee', 'ei', 'eo', 'eu', 'ey', 'eå', 'eä', 'eö' })
+ fn.complete(4, { 'ea', 'eee', 'ei', 'eo', 'eu', 'ey', 'eå', 'eä', 'eö' })
screen:expect([[
Est eu^ |
{s: ea }r sit amet, consectetur |
@@ -2215,7 +2212,7 @@ describe('builtin popupmenu', function()
{2:-- INSERT --} |
]])
- funcs.complete(6, { 'foo', 'bar' })
+ fn.complete(6, { 'foo', 'bar' })
screen:expect([[
Esteee^ |
Lo{s: foo }sit amet, consectetur |
@@ -2256,7 +2253,7 @@ describe('builtin popupmenu', function()
feed('isome long prefix before the ')
command('set completeopt+=noinsert,noselect')
command('set linebreak')
- funcs.complete(29, { 'word', 'choice', 'text', 'thing' })
+ fn.complete(29, { 'word', 'choice', 'text', 'thing' })
screen:expect([[
some long prefix before the ^ |
{1:~ }{n: word }|
@@ -2360,7 +2357,7 @@ describe('builtin popupmenu', function()
command('set completeopt+=noinsert,noselect')
command('autocmd VimResized * redraw!')
command('set linebreak')
- funcs.complete(29, { 'word', 'choice', 'text', 'thing' })
+ fn.complete(29, { 'word', 'choice', 'text', 'thing' })
screen:expect([[
some long prefix before the ^ |
{1:~ }{n: word }|
@@ -2395,7 +2392,7 @@ describe('builtin popupmenu', function()
]])
command('set completeopt+=noinsert,noselect')
- funcs.complete(16, { 'word', 'choice', 'text', 'thing' })
+ fn.complete(16, { 'word', 'choice', 'text', 'thing' })
screen:expect([[
^ tfelthgir emos|
{1: }{n: drow }{1: ~}|
@@ -2458,7 +2455,7 @@ describe('builtin popupmenu', function()
command('set completeopt+=noinsert,noselect')
command('set pumheight=2')
feed('isome rightleft ')
- funcs.complete(16, { 'word', 'choice', 'text', 'thing' })
+ fn.complete(16, { 'word', 'choice', 'text', 'thing' })
if multigrid then
screen:expect {
grid = [[
@@ -2493,7 +2490,7 @@ describe('builtin popupmenu', function()
]])
end
feed('<C-E><CR>')
- funcs.complete(1, { 'word', 'choice', 'text', 'thing' })
+ fn.complete(1, { 'word', 'choice', 'text', 'thing' })
if multigrid then
screen:expect {
grid = [[
@@ -2603,7 +2600,7 @@ describe('builtin popupmenu', function()
screen:try_resize(40, 8)
feed('ixx<cr>')
command('imap <f2> <cmd>echoerr "very"\\|echoerr "much"\\|echoerr "error"<cr>')
- funcs.complete(1, { 'word', 'choice', 'text', 'thing' })
+ fn.complete(1, { 'word', 'choice', 'text', 'thing' })
screen:expect([[
xx |
word^ |
@@ -2663,7 +2660,7 @@ describe('builtin popupmenu', function()
{2:-- INSERT --} |
]])
- meths.nvim_input_mouse('wheel', 'down', '', 0, 6, 15)
+ api.nvim_input_mouse('wheel', 'down', '', 0, 6, 15)
screen:expect {
grid = [[
xx |
@@ -2682,7 +2679,7 @@ describe('builtin popupmenu', function()
it('with kind, menu and abbr attributes', function()
screen:try_resize(40, 8)
feed('ixx ')
- funcs.complete(4, {
+ fn.complete(4, {
{ word = 'wordey', kind = 'x', menu = 'extrainfo' },
'thing',
{ word = 'secret', abbr = 'sneaky', menu = 'bar' },
@@ -3317,7 +3314,7 @@ describe('builtin popupmenu', function()
:sign un^ |
]],
}
- eq(0, funcs.wildmenumode())
+ eq(0, fn.wildmenumode())
-- pressing <Tab> should display the wildmenu
feed('<Tab>')
@@ -3330,7 +3327,7 @@ describe('builtin popupmenu', function()
:sign undefine^ |
]],
}
- eq(1, funcs.wildmenumode())
+ eq(1, fn.wildmenumode())
-- pressing <Tab> second time should select the next entry in the menu
feed('<Tab>')
@@ -3347,7 +3344,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.nvim_buf_set_lines(0, 0, -1, true, { ('a'):rep(100) })
+ api.nvim_buf_set_lines(0, 0, -1, true, { ('a'):rep(100) })
command('set wildoptions+=pum')
feed('$')
feed(':sign <Tab>')
@@ -3461,7 +3458,7 @@ describe('builtin popupmenu', function()
command('set completeopt+=noinsert,noselect')
command('set linebreak')
command('set pumheight=2')
- funcs.complete(29, { 'word', 'choice', 'text', 'thing' })
+ fn.complete(29, { 'word', 'choice', 'text', 'thing' })
if multigrid then
screen:expect {
grid = [[
@@ -3498,7 +3495,7 @@ describe('builtin popupmenu', function()
command('set completeopt+=noinsert,noselect')
command('set linebreak')
command('set pumwidth=8')
- funcs.complete(29, { 'word', 'choice', 'text', 'thing' })
+ fn.complete(29, { 'word', 'choice', 'text', 'thing' })
if multigrid then
screen:expect {
grid = [[
@@ -3544,7 +3541,7 @@ describe('builtin popupmenu', function()
command('set rightleft')
command('call setline(1, repeat(" ", &columns - ' .. max_len .. '))')
feed('$i')
- funcs.complete(col - max_len, items)
+ fn.complete(col - max_len, items)
feed('<c-y>')
assert_alive()
end)
@@ -3553,7 +3550,7 @@ describe('builtin popupmenu', function()
screen:try_resize(32, 8)
command('set completeopt+=menuone,noselect')
feed('i' .. string.rep(' ', 13))
- funcs.complete(14, { '哦哦哦哦哦哦哦哦哦哦' })
+ fn.complete(14, { '哦哦哦哦哦哦哦哦哦哦' })
if multigrid then
screen:expect({
grid = [[
@@ -3589,7 +3586,7 @@ describe('builtin popupmenu', function()
for _ = 1, 8 do
table.insert(items, { word = '哦哦哦哦哦哦哦哦哦哦', equal = 1, dup = 1 })
end
- funcs.complete(13, items)
+ fn.complete(13, items)
if multigrid then
screen:expect({
grid = [[
@@ -3631,7 +3628,7 @@ describe('builtin popupmenu', function()
]])
if multigrid then
- meths.nvim_input_mouse('right', 'press', '', 2, 0, 4)
+ api.nvim_input_mouse('right', 'press', '', 2, 0, 4)
screen:expect({
grid = [[
## grid 1
@@ -3739,10 +3736,10 @@ describe('builtin popupmenu', function()
:let g:menustr = 'bar' |
]])
end
- eq('bar', meths.nvim_get_var('menustr'))
+ eq('bar', api.nvim_get_var('menustr'))
if multigrid then
- meths.nvim_input_mouse('right', 'press', '', 2, 2, 20)
+ api.nvim_input_mouse('right', 'press', '', 2, 2, 20)
screen:expect({
grid = [[
## grid 1
@@ -3771,7 +3768,7 @@ describe('builtin popupmenu', function()
]])
end
if multigrid then
- meths.nvim_input_mouse('right', 'press', '', 2, 0, 18)
+ api.nvim_input_mouse('right', 'press', '', 2, 0, 18)
screen:expect {
grid = [[
## grid 1
@@ -3803,7 +3800,7 @@ describe('builtin popupmenu', function()
]])
end
if multigrid then
- meths.nvim_input_mouse('right', 'press', '', 4, 1, 3)
+ api.nvim_input_mouse('right', 'press', '', 4, 1, 3)
screen:expect({
grid = [[
## grid 1
@@ -3832,7 +3829,7 @@ describe('builtin popupmenu', function()
]])
end
if multigrid then
- meths.nvim_input_mouse('left', 'press', '', 4, 2, 2)
+ api.nvim_input_mouse('left', 'press', '', 4, 2, 2)
screen:expect({
grid = [[
## grid 1
@@ -3853,10 +3850,10 @@ describe('builtin popupmenu', function()
:let g:menustr = 'baz' |
]])
end
- eq('baz', meths.nvim_get_var('menustr'))
+ eq('baz', api.nvim_get_var('menustr'))
if multigrid then
- meths.nvim_input_mouse('right', 'press', '', 2, 0, 4)
+ api.nvim_input_mouse('right', 'press', '', 2, 0, 4)
screen:expect({
grid = [[
## grid 1
@@ -3886,7 +3883,7 @@ describe('builtin popupmenu', function()
]])
end
if multigrid then
- meths.nvim_input_mouse('right', 'drag', '', 2, 3, 6)
+ api.nvim_input_mouse('right', 'drag', '', 2, 3, 6)
screen:expect({
grid = [[
## grid 1
@@ -3916,7 +3913,7 @@ describe('builtin popupmenu', function()
]])
end
if multigrid then
- meths.nvim_input_mouse('right', 'release', '', 2, 1, 6)
+ api.nvim_input_mouse('right', 'release', '', 2, 1, 6)
screen:expect({
grid = [[
## grid 1
@@ -3937,11 +3934,11 @@ describe('builtin popupmenu', function()
:let g:menustr = 'foo' |
]])
end
- eq('foo', meths.nvim_get_var('menustr'))
+ eq('foo', api.nvim_get_var('menustr'))
eq(false, screen.options.mousemoveevent)
if multigrid then
- meths.nvim_input_mouse('right', 'press', '', 2, 0, 4)
+ api.nvim_input_mouse('right', 'press', '', 2, 0, 4)
screen:expect({
grid = [[
## grid 1
@@ -3972,7 +3969,7 @@ describe('builtin popupmenu', function()
end
eq(true, screen.options.mousemoveevent)
if multigrid then
- meths.nvim_input_mouse('move', '', '', 2, 3, 6)
+ api.nvim_input_mouse('move', '', '', 2, 3, 6)
screen:expect({
grid = [[
## grid 1
@@ -4003,7 +4000,7 @@ describe('builtin popupmenu', function()
end
eq(true, screen.options.mousemoveevent)
if multigrid then
- meths.nvim_input_mouse('left', 'press', '', 2, 2, 6)
+ api.nvim_input_mouse('left', 'press', '', 2, 2, 6)
screen:expect({
grid = [[
## grid 1
@@ -4025,11 +4022,11 @@ describe('builtin popupmenu', function()
]])
end
eq(false, screen.options.mousemoveevent)
- eq('bar', meths.nvim_get_var('menustr'))
+ eq('bar', api.nvim_get_var('menustr'))
command('set laststatus=0 | botright split')
if multigrid then
- meths.nvim_input_mouse('right', 'press', '', 5, 1, 20)
+ api.nvim_input_mouse('right', 'press', '', 5, 1, 20)
screen:expect({
grid = [[
## grid 1
@@ -4064,7 +4061,7 @@ describe('builtin popupmenu', function()
]])
end
if multigrid then
- meths.nvim_input_mouse('left', 'press', '', 4, 2, 2)
+ api.nvim_input_mouse('left', 'press', '', 4, 2, 2)
screen:expect({
grid = [[
## grid 1
@@ -4093,11 +4090,11 @@ describe('builtin popupmenu', function()
:let g:menustr = 'baz' |
]])
end
- eq('baz', meths.nvim_get_var('menustr'))
+ eq('baz', api.nvim_get_var('menustr'))
command('set winwidth=1 | rightbelow vsplit')
if multigrid then
- meths.nvim_input_mouse('right', 'press', '', 6, 1, 14)
+ api.nvim_input_mouse('right', 'press', '', 6, 1, 14)
screen:expect({
grid = [[
## grid 1
@@ -4135,7 +4132,7 @@ describe('builtin popupmenu', function()
]])
end
if multigrid then
- meths.nvim_input_mouse('left', 'press', '', 4, 0, 2)
+ api.nvim_input_mouse('left', 'press', '', 4, 0, 2)
screen:expect({
grid = [[
## grid 1
@@ -4167,11 +4164,11 @@ describe('builtin popupmenu', function()
:let g:menustr = 'foo' |
]])
end
- eq('foo', meths.nvim_get_var('menustr'))
+ eq('foo', api.nvim_get_var('menustr'))
command('setlocal winbar=WINBAR')
if multigrid then
- meths.nvim_input_mouse('right', 'press', '', 6, 1, 14)
+ api.nvim_input_mouse('right', 'press', '', 6, 1, 14)
screen:expect({
grid = [[
## grid 1
@@ -4209,7 +4206,7 @@ describe('builtin popupmenu', function()
]])
end
if multigrid then
- meths.nvim_input_mouse('left', 'press', '', 4, 1, 2)
+ api.nvim_input_mouse('left', 'press', '', 4, 1, 2)
screen:expect({
grid = [[
## grid 1
@@ -4241,7 +4238,7 @@ describe('builtin popupmenu', function()
:let g:menustr = 'bar' |
]])
end
- eq('bar', meths.nvim_get_var('menustr'))
+ eq('bar', api.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 f8475acb68..40f8ef353a 100644
--- a/test/functional/ui/quickfix_spec.lua
+++ b/test/functional/ui/quickfix_spec.lua
@@ -1,6 +1,6 @@
local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
-local clear, feed, meths = helpers.clear, helpers.feed, helpers.meths
+local clear, feed, api = helpers.clear, helpers.feed, helpers.api
local insert, command = helpers.insert, helpers.command
describe('quickfix selection highlight', function()
@@ -26,7 +26,7 @@ describe('quickfix selection highlight', function()
[12] = { foreground = Screen.colors.Brown, background = Screen.colors.Fuchsia },
})
- meths.nvim_set_option_value('errorformat', '%m %l', {})
+ api.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 3089690f0a..42e2b4d4b5 100644
--- a/test/functional/ui/screen_basic_spec.lua
+++ b/test/functional/ui/screen_basic_spec.lua
@@ -4,7 +4,7 @@ local spawn, set_session, clear = helpers.spawn, helpers.set_session, helpers.cl
local feed, command = helpers.feed, helpers.command
local insert = helpers.insert
local eq = helpers.eq
-local funcs, meths = helpers.funcs, helpers.meths
+local fn, api = helpers.fn, helpers.api
describe('screen', function()
local screen
@@ -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.nvim_set_option_value('showtabline', 2, {})
+ api.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.nvim_get_var('echospace'))
+ eq(29, api.nvim_get_var('echospace'))
end)
it('messages from the same Ex command as resize are visible #22225', function()
@@ -779,33 +779,33 @@ 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.nvim_get_option_value('lines', {}))
- eq(99, meths.nvim_get_option_value('window', {}))
- eq(99, meths.nvim_win_get_height(0))
+ eq(100, api.nvim_get_option_value('lines', {}))
+ eq(99, api.nvim_get_option_value('window', {}))
+ eq(99, api.nvim_win_get_height(0))
feed('1000o<Esc>')
- eq(903, funcs.line('w0'))
+ eq(903, fn.line('w0'))
feed('<C-B>')
- eq(806, funcs.line('w0'))
+ eq(806, fn.line('w0'))
feed('<C-B>')
- eq(709, funcs.line('w0'))
+ eq(709, fn.line('w0'))
feed('<C-F>')
- eq(806, funcs.line('w0'))
+ eq(806, fn.line('w0'))
feed('<C-F>')
- eq(903, funcs.line('w0'))
+ eq(903, fn.line('w0'))
feed('G')
screen:try_resize(50, 50)
- 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'))
+ eq(50, api.nvim_get_option_value('lines', {}))
+ eq(49, api.nvim_get_option_value('window', {}))
+ eq(49, api.nvim_win_get_height(0))
+ eq(953, fn.line('w0'))
feed('<C-B>')
- eq(906, funcs.line('w0'))
+ eq(906, fn.line('w0'))
feed('<C-B>')
- eq(859, funcs.line('w0'))
+ eq(859, fn.line('w0'))
feed('<C-F>')
- eq(906, funcs.line('w0'))
+ eq(906, fn.line('w0'))
feed('<C-F>')
- eq(953, funcs.line('w0'))
+ eq(953, fn.line('w0'))
end)
it("showcmd doesn't cause empty grid_line with redrawdebug=compositor #22593", function()
diff --git a/test/functional/ui/searchhl_spec.lua b/test/functional/ui/searchhl_spec.lua
index 68596f27ad..f745cdb97b 100644
--- a/test/functional/ui/searchhl_spec.lua
+++ b/test/functional/ui/searchhl_spec.lua
@@ -5,7 +5,7 @@ local command = helpers.command
local feed_command = helpers.feed_command
local eq = helpers.eq
local eval = helpers.eval
-local funcs = helpers.funcs
+local fn = helpers.fn
local testprg = helpers.testprg
describe('search highlighting', function()
@@ -458,13 +458,13 @@ describe('search highlighting', function()
command([[let @/ = 'i']])
-- moves to next match of previous search pattern, just like /<cr>
feed('/<c-g><cr>')
- eq({ 0, 1, 6, 0 }, funcs.getpos('.'))
+ eq({ 0, 1, 6, 0 }, fn.getpos('.'))
-- moves to next match of previous search pattern, just like /<cr>
feed('/<cr>')
- eq({ 0, 1, 12, 0 }, funcs.getpos('.'))
+ eq({ 0, 1, 12, 0 }, fn.getpos('.'))
-- moves to next match of previous search pattern, just like /<cr>
feed('/<c-t><cr>')
- eq({ 0, 2, 1, 0 }, funcs.getpos('.'))
+ eq({ 0, 2, 1, 0 }, fn.getpos('.'))
-- 8.0.1304, test that C-g and C-t works with incsearch and empty pattern
feed('<esc>/fi<CR>')
diff --git a/test/functional/ui/sign_spec.lua b/test/functional/ui/sign_spec.lua
index cade21a3e4..5e45c3113b 100644
--- a/test/functional/ui/sign_spec.lua
+++ b/test/functional/ui/sign_spec.lua
@@ -1,6 +1,6 @@
local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
-local clear, feed, exec, meths = helpers.clear, helpers.feed, helpers.exec, helpers.meths
+local clear, feed, exec, api = helpers.clear, helpers.feed, helpers.exec, helpers.api
describe('Signs', function()
local screen
@@ -423,7 +423,7 @@ describe('Signs', function()
{0:~ }|*7
|
]])
- meths.nvim_buf_set_extmark(0, meths.nvim_create_namespace('test'), 0, 0, {
+ api.nvim_buf_set_extmark(0, api.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.nvim_buf_set_lines(0, 0, 1, true, { 'a', 'b', 'c', 'd', 'e' })
+ api.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.nvim_buf_set_lines(0, 0, 1, true, { 'a', 'b', 'c', 'd', 'e' })
+ api.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 f52ae29562..8b5644ee42 100644
--- a/test/functional/ui/spell_spec.lua
+++ b/test/functional/ui/spell_spec.lua
@@ -6,7 +6,7 @@ local clear = helpers.clear
local exec = helpers.exec
local feed = helpers.feed
local insert = helpers.insert
-local meths = helpers.meths
+local api = helpers.api
local is_os = helpers.is_os
describe("'spell'", function()
@@ -259,9 +259,9 @@ describe("'spell'", function()
{6:search hit BOTTOM, continuing at TOP} |
]])
exec('echo ""')
- local ns = meths.nvim_create_namespace('spell')
+ local ns = api.nvim_create_namespace('spell')
-- extmark with spell=true enables spell
- local id = meths.nvim_buf_set_extmark(0, ns, 1, 4, { end_row = 1, end_col = 10, spell = true })
+ local id = api.nvim_buf_set_extmark(0, ns, 1, 4, { end_row = 1, end_col = 10, spell = true })
screen:expect([[
{3:#include }{4:<stdbool.h>} |
{5:bool} {1:func}({5:void}); |
@@ -277,9 +277,9 @@ describe("'spell'", function()
{0:~ }|*4
|
]])
- meths.nvim_buf_del_extmark(0, ns, id)
+ api.nvim_buf_del_extmark(0, ns, id)
-- extmark with spell=false disables spell
- id = meths.nvim_buf_set_extmark(0, ns, 2, 18, { end_row = 2, end_col = 26, spell = false })
+ id = api.nvim_buf_set_extmark(0, ns, 2, 18, { end_row = 2, end_col = 26, spell = false })
screen:expect([[
{3:#include }{4:<stdbool.h>} |
{5:bool} ^func({5:void}); |
@@ -296,7 +296,7 @@ describe("'spell'", function()
{6:search hit TOP, continuing at BOTTOM} |
]])
exec('echo ""')
- meths.nvim_buf_del_extmark(0, ns, id)
+ api.nvim_buf_del_extmark(0, ns, id)
screen:expect([[
{3:#include }{4:<stdbool.h>} |
{5:bool} func({5:void}); |
@@ -367,8 +367,8 @@ describe("'spell'", function()
syntax match Constant "^.*$"
call setline(1, "This is some text without any spell errors.")
]])
- local ns = meths.nvim_create_namespace('spell')
- meths.nvim_buf_set_extmark(0, ns, 0, 0, { hl_group = 'WarningMsg', end_col = 43 })
+ local ns = api.nvim_create_namespace('spell')
+ api.nvim_buf_set_extmark(0, ns, 0, 0, { hl_group = 'WarningMsg', end_col = 43 })
screen:expect([[
{6:^This is some text without any spell errors.}|
{0:~ }|
diff --git a/test/functional/ui/statuscolumn_spec.lua b/test/functional/ui/statuscolumn_spec.lua
index 7e0ba85500..dec696d3c3 100644
--- a/test/functional/ui/statuscolumn_spec.lua
+++ b/test/functional/ui/statuscolumn_spec.lua
@@ -7,7 +7,7 @@ local exec = helpers.exec
local eval = helpers.eval
local exec_lua = helpers.exec_lua
local feed = helpers.feed
-local meths = helpers.meths
+local api = helpers.api
local pcall_err = helpers.pcall_err
local assert_alive = helpers.assert_alive
@@ -543,60 +543,56 @@ describe('statuscolumn', function()
end)
it('clicks work with mousemodel=' .. model, function()
- meths.nvim_set_option_value('statuscolumn', '%0@MyClickFunc@%=%l%T', {})
- meths.nvim_input_mouse('left', 'press', '', 0, 0, 0)
+ api.nvim_set_option_value('statuscolumn', '%0@MyClickFunc@%=%l%T', {})
+ api.nvim_input_mouse('left', 'press', '', 0, 0, 0)
eq('0 1 l 4', eval('g:testvar'))
- meths.nvim_input_mouse('left', 'press', '', 0, 0, 0)
+ api.nvim_input_mouse('left', 'press', '', 0, 0, 0)
eq('0 2 l 4', eval('g:testvar'))
- meths.nvim_input_mouse('left', 'press', '', 0, 0, 0)
+ api.nvim_input_mouse('left', 'press', '', 0, 0, 0)
eq('0 3 l 4', eval('g:testvar'))
- meths.nvim_input_mouse('left', 'press', '', 0, 0, 0)
+ api.nvim_input_mouse('left', 'press', '', 0, 0, 0)
eq('0 4 l 4', eval('g:testvar'))
- meths.nvim_input_mouse('right', 'press', '', 0, 3, 0)
+ api.nvim_input_mouse('right', 'press', '', 0, 3, 0)
eq('0 1 r 7', eval('g:testvar'))
- meths.nvim_input_mouse('right', 'press', '', 0, 3, 0)
+ api.nvim_input_mouse('right', 'press', '', 0, 3, 0)
eq('0 2 r 7', eval('g:testvar'))
- meths.nvim_input_mouse('right', 'press', '', 0, 3, 0)
+ api.nvim_input_mouse('right', 'press', '', 0, 3, 0)
eq('0 3 r 7', eval('g:testvar'))
- meths.nvim_input_mouse('right', 'press', '', 0, 3, 0)
+ api.nvim_input_mouse('right', 'press', '', 0, 3, 0)
eq('0 4 r 7', eval('g:testvar'))
command('rightbelow vsplit')
- meths.nvim_input_mouse('left', 'press', '', 0, 0, 27)
+ api.nvim_input_mouse('left', 'press', '', 0, 0, 27)
eq('0 1 l 4', eval('g:testvar'))
- meths.nvim_input_mouse('right', 'press', '', 0, 3, 27)
+ api.nvim_input_mouse('right', 'press', '', 0, 3, 27)
eq('0 1 r 7', eval('g:testvar'))
command('setlocal rightleft')
- meths.nvim_input_mouse('left', 'press', '', 0, 0, 52)
+ api.nvim_input_mouse('left', 'press', '', 0, 0, 52)
eq('0 1 l 4', eval('g:testvar'))
- meths.nvim_input_mouse('right', 'press', '', 0, 3, 52)
+ api.nvim_input_mouse('right', 'press', '', 0, 3, 52)
eq('0 1 r 7', eval('g:testvar'))
command('wincmd H')
- meths.nvim_input_mouse('left', 'press', '', 0, 0, 25)
+ api.nvim_input_mouse('left', 'press', '', 0, 0, 25)
eq('0 1 l 4', eval('g:testvar'))
- meths.nvim_input_mouse('right', 'press', '', 0, 3, 25)
+ api.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.nvim_input_mouse('right', 'press', '', 0, 0, 0)
+ api.nvim_input_mouse('right', 'press', '', 0, 0, 0)
eq('', eval('g:testvar'))
-- Check that statusline click doesn't register as statuscolumn click
- meths.nvim_input_mouse('right', 'press', '', 0, 12, 0)
+ api.nvim_input_mouse('right', 'press', '', 0, 12, 0)
eq('', eval('g:testvar'))
-- Check that cmdline click doesn't register as statuscolumn click
- meths.nvim_input_mouse('right', 'press', '', 0, 13, 0)
+ api.nvim_input_mouse('right', 'press', '', 0, 13, 0)
eq('', eval('g:testvar'))
end)
it('clicks and highlights work with control characters', function()
- meths.nvim_set_option_value(
- 'statuscolumn',
- '\t%#NonText#\1%0@MyClickFunc@\t\1%T\t%##\1',
- {}
- )
+ api.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
@@ -609,13 +605,13 @@ describe('statuscolumn', function()
[1] = { foreground = Screen.colors.Brown }, -- LineNr
},
}
- meths.nvim_input_mouse('right', 'press', '', 0, 4, 3)
+ api.nvim_input_mouse('right', 'press', '', 0, 4, 3)
eq('', eval('g:testvar'))
- meths.nvim_input_mouse('left', 'press', '', 0, 5, 8)
+ api.nvim_input_mouse('left', 'press', '', 0, 5, 8)
eq('', eval('g:testvar'))
- meths.nvim_input_mouse('right', 'press', '', 0, 6, 4)
+ api.nvim_input_mouse('right', 'press', '', 0, 6, 4)
eq('0 1 r 10', eval('g:testvar'))
- meths.nvim_input_mouse('left', 'press', '', 0, 7, 7)
+ api.nvim_input_mouse('left', 'press', '', 0, 7, 7)
eq('0 1 l 11', eval('g:testvar'))
end)
@@ -625,7 +621,7 @@ describe('statuscolumn', function()
[0] = { foreground = Screen.colors.Brown },
[1] = { background = Screen.colors.Plum1 },
})
- meths.nvim_set_option_value('statuscolumn', '%0@MyClickFunc@%l%T', {})
+ api.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)
@@ -634,26 +630,26 @@ describe('statuscolumn', function()
endfunction
]])
-- clicking an item does not drag mouse
- meths.nvim_input_mouse('left', 'press', '', 0, 0, 0)
+ api.nvim_input_mouse('left', 'press', '', 0, 0, 0)
screen:expect([[
{0:8 }^aaaaa |
{1: Echo } |
]])
- meths.nvim_input_mouse('left', 'press', '', 0, 1, 5)
- meths.nvim_input_mouse('left', 'release', '', 0, 1, 5)
+ api.nvim_input_mouse('left', 'press', '', 0, 1, 5)
+ api.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.nvim_input_mouse('left', 'press', '', 0, 0, 0)
+ api.nvim_input_mouse('left', 'press', '', 0, 0, 0)
screen:expect([[
{0:8 }^aaaaa |
{1: Echo } |
]])
- meths.nvim_input_mouse('left', 'press', '', 0, 0, 10)
- meths.nvim_input_mouse('left', 'release', '', 0, 0, 10)
+ api.nvim_input_mouse('left', 'press', '', 0, 0, 10)
+ api.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 2d39312ea2..d1bf163ab8 100644
--- a/test/functional/ui/statusline_spec.lua
+++ b/test/functional/ui/statusline_spec.lua
@@ -5,8 +5,8 @@ local clear = helpers.clear
local command = helpers.command
local feed = helpers.feed
local eq = helpers.eq
-local funcs = helpers.funcs
-local meths = helpers.meths
+local fn = helpers.fn
+local api = helpers.api
local exec = helpers.exec
local exec_lua = helpers.exec_lua
local eval = helpers.eval
@@ -39,35 +39,31 @@ for _, model in ipairs(mousemodels) do
end)
it('works', function()
- meths.nvim_set_option_value(
- 'statusline',
- 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T',
- {}
- )
- meths.nvim_input_mouse('left', 'press', '', 0, 6, 16)
+ api.nvim_set_option_value('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {})
+ api.nvim_input_mouse('left', 'press', '', 0, 6, 16)
eq('', eval('g:testvar'))
- meths.nvim_input_mouse('right', 'press', '', 0, 6, 29)
+ api.nvim_input_mouse('right', 'press', '', 0, 6, 29)
eq('', eval('g:testvar'))
- meths.nvim_input_mouse('left', 'press', '', 0, 6, 17)
+ api.nvim_input_mouse('left', 'press', '', 0, 6, 17)
eq('0 1 l', eval('g:testvar'))
- meths.nvim_input_mouse('left', 'press', '', 0, 6, 17)
+ api.nvim_input_mouse('left', 'press', '', 0, 6, 17)
eq('0 2 l', eval('g:testvar'))
- meths.nvim_input_mouse('left', 'press', '', 0, 6, 17)
+ api.nvim_input_mouse('left', 'press', '', 0, 6, 17)
eq('0 3 l', eval('g:testvar'))
- meths.nvim_input_mouse('left', 'press', '', 0, 6, 17)
+ api.nvim_input_mouse('left', 'press', '', 0, 6, 17)
eq('0 4 l', eval('g:testvar'))
- meths.nvim_input_mouse('right', 'press', '', 0, 6, 28)
+ api.nvim_input_mouse('right', 'press', '', 0, 6, 28)
eq('0 1 r', eval('g:testvar'))
- meths.nvim_input_mouse('right', 'press', '', 0, 6, 28)
+ api.nvim_input_mouse('right', 'press', '', 0, 6, 28)
eq('0 2 r', eval('g:testvar'))
- meths.nvim_input_mouse('right', 'press', '', 0, 6, 28)
+ api.nvim_input_mouse('right', 'press', '', 0, 6, 28)
eq('0 3 r', eval('g:testvar'))
- meths.nvim_input_mouse('right', 'press', '', 0, 6, 28)
+ api.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.nvim_set_option_value('statusline', '\t%#NonText#\1%0@MyClickFunc@\t\1%T\t%##\1', {})
+ api.nvim_set_option_value('statusline', '\t%#NonText#\1%0@MyClickFunc@\t\1%T\t%##\1', {})
screen:expect {
grid = [[
^ |
@@ -76,54 +72,50 @@ for _, model in ipairs(mousemodels) do
|
]],
}
- meths.nvim_input_mouse('right', 'press', '', 0, 6, 3)
+ api.nvim_input_mouse('right', 'press', '', 0, 6, 3)
eq('', eval('g:testvar'))
- meths.nvim_input_mouse('left', 'press', '', 0, 6, 8)
+ api.nvim_input_mouse('left', 'press', '', 0, 6, 8)
eq('', eval('g:testvar'))
- meths.nvim_input_mouse('right', 'press', '', 0, 6, 4)
+ api.nvim_input_mouse('right', 'press', '', 0, 6, 4)
eq('0 1 r', eval('g:testvar'))
- meths.nvim_input_mouse('left', 'press', '', 0, 6, 7)
+ api.nvim_input_mouse('left', 'press', '', 0, 6, 7)
eq('0 1 l', eval('g:testvar'))
end)
it('works for winbar', function()
- meths.nvim_set_option_value('winbar', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {})
- meths.nvim_input_mouse('left', 'press', '', 0, 0, 17)
+ api.nvim_set_option_value('winbar', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {})
+ api.nvim_input_mouse('left', 'press', '', 0, 0, 17)
eq('0 1 l', eval('g:testvar'))
- meths.nvim_input_mouse('right', 'press', '', 0, 0, 17)
+ api.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.nvim_open_win(
+ api.nvim_open_win(
0,
true,
{ width = 30, height = 4, relative = 'editor', row = 1, col = 5, border = 'single' }
)
- meths.nvim_set_option_value(
+ api.nvim_set_option_value(
'winbar',
'Not clicky stuff %0@MyClickFunc@Clicky stuff%T',
{ scope = 'local' }
)
- meths.nvim_input_mouse('left', 'press', '', 0, 2, 23)
+ api.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.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)
+ api.nvim_set_option_value('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {})
+ api.nvim_set_option_value('winbar', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {})
+ api.nvim_input_mouse('left', 'press', '', 0, 0, 17)
eq('0 1 l', eval('g:testvar'))
- meths.nvim_input_mouse('right', 'press', '', 0, 4, 17)
+ api.nvim_input_mouse('right', 'press', '', 0, 4, 17)
eq('0 1 r', eval('g:testvar'))
- meths.nvim_input_mouse('middle', 'press', '', 0, 3, 17)
+ api.nvim_input_mouse('middle', 'press', '', 0, 3, 17)
eq('0 1 m', eval('g:testvar'))
- meths.nvim_input_mouse('left', 'press', '', 0, 6, 17)
+ api.nvim_input_mouse('left', 'press', '', 0, 6, 17)
eq('0 1 l', eval('g:testvar'))
end)
@@ -133,72 +125,64 @@ for _, model in ipairs(mousemodels) do
vim.g.testvar = string.format("%d %d %s", minwid, clicks, button)
end
]])
- meths.nvim_set_option_value(
+ api.nvim_set_option_value(
'statusline',
'Not clicky stuff %0@v:lua.clicky_func@Clicky stuff%T',
{}
)
- meths.nvim_input_mouse('left', 'press', '', 0, 6, 17)
+ api.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.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())
+ api.nvim_set_option_value('statusline', '%2TNot clicky stuff%T', {})
+ api.nvim_input_mouse('left', 'press', '', 0, 6, 0)
+ eq(1, api.nvim_get_current_tabpage().id)
+ api.nvim_set_option_value('statusline', '%2XNot clicky stuff%X', {})
+ api.nvim_input_mouse('left', 'press', '', 0, 6, 0)
+ eq(2, #api.nvim_list_tabpages())
end)
it("right click works when statusline isn't focused #18994", function()
- meths.nvim_set_option_value(
- 'statusline',
- 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T',
- {}
- )
- meths.nvim_input_mouse('right', 'press', '', 0, 6, 17)
+ api.nvim_set_option_value('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {})
+ api.nvim_input_mouse('right', 'press', '', 0, 6, 17)
eq('0 1 r', eval('g:testvar'))
- meths.nvim_input_mouse('right', 'press', '', 0, 6, 17)
+ api.nvim_input_mouse('right', 'press', '', 0, 6, 17)
eq('0 2 r', eval('g:testvar'))
end)
it('works with modifiers #18994', function()
- meths.nvim_set_option_value(
- 'statusline',
- 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T',
- {}
- )
+ api.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.nvim_input_mouse('left', 'press', 'S', 0, 6, 17)
+ api.nvim_input_mouse('left', 'press', 'S', 0, 6, 17)
eq('0 1 l(s )', eval('g:testvar'))
- meths.nvim_input_mouse('right', 'press', 'S', 0, 6, 17)
+ api.nvim_input_mouse('right', 'press', 'S', 0, 6, 17)
eq('0 1 r(s )', eval('g:testvar'))
- meths.nvim_input_mouse('left', 'press', 'A', 0, 6, 17)
+ api.nvim_input_mouse('left', 'press', 'A', 0, 6, 17)
eq('0 1 l( a )', eval('g:testvar'))
- meths.nvim_input_mouse('right', 'press', 'A', 0, 6, 17)
+ api.nvim_input_mouse('right', 'press', 'A', 0, 6, 17)
eq('0 1 r( a )', eval('g:testvar'))
- meths.nvim_input_mouse('left', 'press', 'AS', 0, 6, 17)
+ api.nvim_input_mouse('left', 'press', 'AS', 0, 6, 17)
eq('0 1 l(s a )', eval('g:testvar'))
- meths.nvim_input_mouse('right', 'press', 'AS', 0, 6, 17)
+ api.nvim_input_mouse('right', 'press', 'AS', 0, 6, 17)
eq('0 1 r(s a )', eval('g:testvar'))
- meths.nvim_input_mouse('left', 'press', 'T', 0, 6, 17)
+ api.nvim_input_mouse('left', 'press', 'T', 0, 6, 17)
eq('0 1 l( m)', eval('g:testvar'))
- meths.nvim_input_mouse('right', 'press', 'T', 0, 6, 17)
+ api.nvim_input_mouse('right', 'press', 'T', 0, 6, 17)
eq('0 1 r( m)', eval('g:testvar'))
- meths.nvim_input_mouse('left', 'press', 'TS', 0, 6, 17)
+ api.nvim_input_mouse('left', 'press', 'TS', 0, 6, 17)
eq('0 1 l(s m)', eval('g:testvar'))
- meths.nvim_input_mouse('right', 'press', 'TS', 0, 6, 17)
+ api.nvim_input_mouse('right', 'press', 'TS', 0, 6, 17)
eq('0 1 r(s m)', eval('g:testvar'))
- meths.nvim_input_mouse('left', 'press', 'C', 0, 6, 17)
+ api.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.nvim_set_option_value(
+ api.nvim_set_option_value(
'statusline',
'%0@MyClickFunc@Clicky stuff%T %= %0@MyClickFunc@Clicky stuff%T',
{}
@@ -214,15 +198,15 @@ for _, model in ipairs(mousemodels) do
}
-- clickable area on the right
- meths.nvim_input_mouse('left', 'press', '', 0, 6, 35)
+ api.nvim_input_mouse('left', 'press', '', 0, 6, 35)
eq('0 1 l', eval('g:testvar'))
- meths.nvim_input_mouse('right', 'press', '', 0, 6, 35)
+ api.nvim_input_mouse('right', 'press', '', 0, 6, 35)
eq('0 1 r', eval('g:testvar'))
-- clickable area on the left
- meths.nvim_input_mouse('left', 'press', '', 0, 6, 5)
+ api.nvim_input_mouse('left', 'press', '', 0, 6, 5)
eq('0 1 l', eval('g:testvar'))
- meths.nvim_input_mouse('right', 'press', '', 0, 6, 5)
+ api.nvim_input_mouse('right', 'press', '', 0, 6, 5)
eq('0 1 r', eval('g:testvar'))
end)
@@ -230,9 +214,9 @@ for _, model in ipairs(mousemodels) do
command([[
let &stl = '%@Test@%T%@MyClickFunc@%=%T%@Test@'
]])
- meths.nvim_input_mouse('left', 'press', '', 0, 6, 0)
+ api.nvim_input_mouse('left', 'press', '', 0, 6, 0)
eq('0 1 l', eval('g:testvar'))
- meths.nvim_input_mouse('right', 'press', '', 0, 6, 39)
+ api.nvim_input_mouse('right', 'press', '', 0, 6, 39)
eq('0 1 r', eval('g:testvar'))
end)
@@ -240,7 +224,7 @@ for _, model in ipairs(mousemodels) do
command([[
let &stl = '%@MyClickFunc@foo%X' .. repeat('a', 40) .. '%<t%@Test@bar%X%@Test@baz'
]])
- meths.nvim_input_mouse('left', 'press', '', 0, 6, 2)
+ api.nvim_input_mouse('left', 'press', '', 0, 6, 2)
eq('0 1 l', eval('g:testvar'))
end)
end)
@@ -382,38 +366,38 @@ describe('global statusline', function()
end)
it('win_move_statusline() can reduce cmdheight to 1', function()
- eq(1, meths.nvim_get_option_value('cmdheight', {}))
- funcs.win_move_statusline(0, -1)
- eq(2, meths.nvim_get_option_value('cmdheight', {}))
- funcs.win_move_statusline(0, -1)
- eq(3, meths.nvim_get_option_value('cmdheight', {}))
- funcs.win_move_statusline(0, 1)
- eq(2, meths.nvim_get_option_value('cmdheight', {}))
- funcs.win_move_statusline(0, 1)
- eq(1, meths.nvim_get_option_value('cmdheight', {}))
+ eq(1, api.nvim_get_option_value('cmdheight', {}))
+ fn.win_move_statusline(0, -1)
+ eq(2, api.nvim_get_option_value('cmdheight', {}))
+ fn.win_move_statusline(0, -1)
+ eq(3, api.nvim_get_option_value('cmdheight', {}))
+ fn.win_move_statusline(0, 1)
+ eq(2, api.nvim_get_option_value('cmdheight', {}))
+ fn.win_move_statusline(0, 1)
+ eq(1, api.nvim_get_option_value('cmdheight', {}))
end)
it('mouse dragging can reduce cmdheight to 1', function()
command('set mouse=a')
- 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', {}))
+ api.nvim_input_mouse('left', 'press', '', 0, 14, 10)
+ eq(1, api.nvim_get_option_value('cmdheight', {}))
+ api.nvim_input_mouse('left', 'drag', '', 0, 13, 10)
+ eq(2, api.nvim_get_option_value('cmdheight', {}))
+ api.nvim_input_mouse('left', 'drag', '', 0, 12, 10)
+ eq(3, api.nvim_get_option_value('cmdheight', {}))
+ api.nvim_input_mouse('left', 'drag', '', 0, 13, 10)
+ eq(2, api.nvim_get_option_value('cmdheight', {}))
+ api.nvim_input_mouse('left', 'drag', '', 0, 14, 10)
+ eq(1, api.nvim_get_option_value('cmdheight', {}))
+ api.nvim_input_mouse('left', 'drag', '', 0, 15, 10)
+ eq(1, api.nvim_get_option_value('cmdheight', {}))
+ api.nvim_input_mouse('left', 'drag', '', 0, 14, 10)
+ eq(1, api.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.nvim_set_option_value('cmdheight', 1, {})
+ api.nvim_set_option_value('cmdheight', 1, {})
feed('L')
screen:expect([[
|
@@ -444,7 +428,7 @@ describe('global statusline', function()
{2:test/functional/fixtures/bigfile.txt 8,1 0%}|
|
]])
- meths.nvim_set_option_value('showtabline', 2, {})
+ api.nvim_set_option_value('showtabline', 2, {})
screen:expect([[
{3: }{5:2}{3: t/f/f/bigfile.txt }{4: }|
|
@@ -459,7 +443,7 @@ describe('global statusline', function()
{2:test/functional/fixtures/bigfile.txt 8,1 0%}|
|
]])
- meths.nvim_set_option_value('cmdheight', 0, {})
+ api.nvim_set_option_value('cmdheight', 0, {})
screen:expect([[
{3: }{5:2}{3: t/f/f/bigfile.txt }{4: }|
|
@@ -474,7 +458,7 @@ describe('global statusline', function()
^0007;<control>;Cc;0;BN;;;;;N;BELL;;;; |
{2:test/functional/fixtures/bigfile.txt 8,1 0%}|
]])
- meths.nvim_set_option_value('cmdheight', 1, {})
+ api.nvim_set_option_value('cmdheight', 1, {})
screen:expect([[
{3: }{5:2}{3: t/f/f/bigfile.txt }{4: }|
|
@@ -494,8 +478,8 @@ end)
it('statusline does not crash if it has Arabic characters #19447', function()
clear()
- meths.nvim_set_option_value('statusline', 'غً', {})
- meths.nvim_set_option_value('laststatus', 2, {})
+ api.nvim_set_option_value('statusline', 'غً', {})
+ api.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 9a75e6333b..d58155ef0c 100644
--- a/test/functional/ui/tabline_spec.lua
+++ b/test/functional/ui/tabline_spec.lua
@@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local clear, command, eq = helpers.clear, helpers.command, helpers.eq
local insert = helpers.insert
-local meths = helpers.meths
+local api = helpers.api
local assert_alive = helpers.assert_alive
describe('ui/ext_tabline', function()
@@ -138,7 +138,7 @@ describe('tabline', function()
command('tabnew')
insert('tab2')
command('tabprev')
- meths.nvim_set_option_value('tabline', '%1T口口%2Ta' .. ('b'):rep(38) .. '%999Xc', {})
+ api.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.nvim_input_mouse('left', 'press', '', 0, 0, 1)
+ api.nvim_input_mouse('left', 'press', '', 0, 0, 1)
screen:expect {
grid = [[
{1:<abbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbc }|
@@ -157,7 +157,7 @@ describe('tabline', function()
|
]],
}
- meths.nvim_input_mouse('left', 'press', '', 0, 0, 0)
+ api.nvim_input_mouse('left', 'press', '', 0, 0, 0)
screen:expect {
grid = [[
{1:<abbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbc }|
@@ -166,7 +166,7 @@ describe('tabline', function()
|
]],
}
- meths.nvim_input_mouse('left', 'press', '', 0, 0, 39)
+ api.nvim_input_mouse('left', 'press', '', 0, 0, 39)
screen:expect {
grid = [[
{1:<abbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbc }|
@@ -175,7 +175,7 @@ describe('tabline', function()
|
]],
}
- meths.nvim_input_mouse('left', 'press', '', 0, 0, 40)
+ api.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 598952404d..c77e836d21 100644
--- a/test/functional/ui/title_spec.lua
+++ b/test/functional/ui/title_spec.lua
@@ -2,12 +2,12 @@ local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local clear = helpers.clear
local command = helpers.command
-local curwin = helpers.meths.nvim_get_current_win
+local curwin = helpers.api.nvim_get_current_win
local eq = helpers.eq
local exec_lua = helpers.exec_lua
local feed = helpers.feed
-local funcs = helpers.funcs
-local meths = helpers.meths
+local fn = helpers.fn
+local api = helpers.api
local is_os = helpers.is_os
describe('title', function()
@@ -44,7 +44,7 @@ describe('title', function()
before_each(function()
command('edit ' .. file1)
- buf2 = funcs.bufadd(file2)
+ buf2 = fn.bufadd(file2)
command('set title')
end)
@@ -58,7 +58,7 @@ describe('title', function()
end)
it('an RPC call to nvim_set_option_value in a hidden buffer', function()
- meths.nvim_set_option_value('autoindent', true, { buf = buf2 })
+ api.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.nvim_win_set_buf(oldwin, buf2)
+ api.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.nvim_open_win(buf2, false, {
+ api.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 45eb9222c2..4ad0326851 100644
--- a/test/functional/ui/wildmode_spec.lua
+++ b/test/functional/ui/wildmode_spec.lua
@@ -1,8 +1,8 @@
local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local clear, feed, command = helpers.clear, helpers.feed, helpers.command
-local funcs = helpers.funcs
-local meths = helpers.meths
+local fn = helpers.fn
+local api = helpers.api
local eq = helpers.eq
local eval = helpers.eval
local retry = helpers.retry
@@ -413,12 +413,12 @@ describe("'wildmenu'", function()
}
-- Wildcharm? where we are going we aint't no need no wildcharm.
- eq(0, meths.nvim_get_option_value('wildcharm', {}))
+ eq(0, api.nvim_get_option_value('wildcharm', {}))
-- Don't mess the defaults yet (neovim is about backwards compatibility)
- eq(9, meths.nvim_get_option_value('wildchar', {}))
+ eq(9, api.nvim_get_option_value('wildchar', {}))
-- Lol what is cnoremap? Some say it can define mappings.
command 'set wildchar=0'
- eq(0, meths.nvim_get_option_value('wildchar', {}))
+ eq(0, api.nvim_get_option_value('wildchar', {}))
command 'cnoremap <f2> <c-z>'
feed(':syntax <f2>')
@@ -483,7 +483,7 @@ describe('command line completion', function()
end)
it('lists directories with empty PATH', function()
- local tmp = funcs.tempname()
+ local tmp = fn.tempname()
command('e ' .. tmp)
command('cd %:h')
command("call mkdir('Xtest-functional-viml-compl-dir')")
@@ -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.nvim_set_option_value('wildmenu', true, {})
- meths.nvim_set_option_value('wildmode', 'full', {})
- meths.nvim_set_option_value('wildoptions', 'pum', {})
+ api.nvim_set_option_value('wildmenu', true, {})
+ api.nvim_set_option_value('wildmode', 'full', {})
+ api.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.nvim_set_option_value('wildmenu', false, {})
- meths.nvim_set_option_value('wildmode', 'full', {})
+ api.nvim_set_option_value('wildmenu', false, {})
+ api.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.nvim_set_option_value('wildmenu', false, {})
- meths.nvim_set_option_value('wildmode', 'list', {})
+ api.nvim_set_option_value('wildmenu', false, {})
+ api.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 5e914952e3..858a537d3a 100644
--- a/test/functional/ui/winbar_spec.lua
+++ b/test/functional/ui/winbar_spec.lua
@@ -3,11 +3,11 @@ local Screen = require('test.functional.ui.screen')
local clear = helpers.clear
local command = helpers.command
local insert = helpers.insert
-local meths = helpers.meths
+local api = helpers.api
local eq = helpers.eq
local poke_eventloop = helpers.poke_eventloop
local feed = helpers.feed
-local funcs = helpers.funcs
+local fn = helpers.fn
local pcall_err = helpers.pcall_err
describe('winbar', function()
@@ -39,7 +39,7 @@ describe('winbar', function()
foreground = Screen.colors.Magenta,
},
})
- meths.nvim_set_option_value('winbar', 'Set Up The Bars', {})
+ api.nvim_set_option_value('winbar', 'Set Up The Bars', {})
end)
it('works', function()
@@ -50,8 +50,8 @@ describe('winbar', function()
|
]])
-- winbar is excluded from the heights returned by winheight() and getwininfo()
- eq(11, funcs.winheight(0))
- local win_info = funcs.getwininfo(meths.nvim_get_current_win().id)[1]
+ eq(11, fn.winheight(0))
+ local win_info = fn.getwininfo(api.nvim_get_current_win().id)[1]
eq(11, win_info.height)
eq(1, win_info.winbar)
end)
@@ -184,7 +184,7 @@ describe('winbar', function()
insert [[
just some
random text]]
- meths.nvim_set_option_value('winbar', 'Hello, I am a ruler: %l,%c', {})
+ api.nvim_set_option_value('winbar', 'Hello, I am a ruler: %l,%c', {})
screen:expect {
grid = [[
{1:Hello, I am a ruler: 2,11 }|
@@ -264,7 +264,7 @@ describe('winbar', function()
line sin(theta)
line 8]])
- meths.nvim_input_mouse('left', 'press', '', 0, 5, 1)
+ api.nvim_input_mouse('left', 'press', '', 0, 5, 1)
screen:expect([[
{1:Set Up The Bars }|
line 1 |
@@ -278,9 +278,9 @@ describe('winbar', function()
{3:~ }|*3
|
]])
- eq({ 5, 1 }, meths.nvim_win_get_cursor(0))
+ eq({ 5, 1 }, api.nvim_win_get_cursor(0))
- meths.nvim_input_mouse('left', 'drag', '', 0, 6, 2)
+ api.nvim_input_mouse('left', 'drag', '', 0, 6, 2)
screen:expect([[
{1:Set Up The Bars }|
line 1 |
@@ -294,9 +294,9 @@ describe('winbar', function()
{3:~ }|*3
{1:-- VISUAL --} |
]])
- eq({ 6, 2 }, meths.nvim_win_get_cursor(0))
+ eq({ 6, 2 }, api.nvim_win_get_cursor(0))
- meths.nvim_input_mouse('left', 'drag', '', 0, 1, 2)
+ api.nvim_input_mouse('left', 'drag', '', 0, 1, 2)
screen:expect([[
{1:Set Up The Bars }|
li^n{7:e 1} |
@@ -310,11 +310,11 @@ describe('winbar', function()
{3:~ }|*3
{1:-- VISUAL --} |
]])
- eq({ 1, 2 }, meths.nvim_win_get_cursor(0))
+ eq({ 1, 2 }, api.nvim_win_get_cursor(0))
- meths.nvim_input_mouse('left', 'drag', '', 0, 0, 2)
+ api.nvim_input_mouse('left', 'drag', '', 0, 0, 2)
screen:expect_unchanged()
- eq({ 1, 2 }, meths.nvim_win_get_cursor(0))
+ eq({ 1, 2 }, api.nvim_win_get_cursor(0))
end)
it('dragging statusline with mouse works correctly', function()
@@ -331,9 +331,9 @@ describe('winbar', function()
|
]])
- meths.nvim_input_mouse('left', 'press', '', 1, 5, 10)
+ api.nvim_input_mouse('left', 'press', '', 1, 5, 10)
poke_eventloop()
- meths.nvim_input_mouse('left', 'drag', '', 1, 6, 10)
+ api.nvim_input_mouse('left', 'drag', '', 1, 6, 10)
screen:expect([[
{1:Set Up The Bars }|
^ |
@@ -346,7 +346,7 @@ describe('winbar', function()
|
]])
- meths.nvim_input_mouse('left', 'drag', '', 1, 4, 10)
+ api.nvim_input_mouse('left', 'drag', '', 1, 4, 10)
screen:expect([[
{1:Set Up The Bars }|
^ |
@@ -359,9 +359,9 @@ describe('winbar', function()
|
]])
- meths.nvim_input_mouse('left', 'press', '', 1, 11, 10)
+ api.nvim_input_mouse('left', 'press', '', 1, 11, 10)
poke_eventloop()
- meths.nvim_input_mouse('left', 'drag', '', 1, 9, 10)
+ api.nvim_input_mouse('left', 'drag', '', 1, 9, 10)
screen:expect([[
{1:Set Up The Bars }|
^ |
@@ -373,9 +373,9 @@ describe('winbar', function()
{2:[No Name] }|
|*3
]])
- eq(3, meths.nvim_get_option_value('cmdheight', {}))
+ eq(3, api.nvim_get_option_value('cmdheight', {}))
- meths.nvim_input_mouse('left', 'drag', '', 1, 11, 10)
+ api.nvim_input_mouse('left', 'drag', '', 1, 11, 10)
screen:expect([[
{1:Set Up The Bars }|
^ |
@@ -387,7 +387,7 @@ describe('winbar', function()
{2:[No Name] }|
|
]])
- eq(1, meths.nvim_get_option_value('cmdheight', {}))
+ eq(1, api.nvim_get_option_value('cmdheight', {}))
end)
it('properly equalizes window height for window-local value', function()
@@ -412,12 +412,12 @@ describe('winbar', function()
end)
it('requires window-local value for floating windows', function()
- local win = meths.nvim_open_win(
+ local win = api.nvim_open_win(
0,
false,
{ relative = 'editor', row = 2, col = 10, height = 7, width = 30 }
)
- meths.nvim_set_option_value('winbar', 'bar', {})
+ api.nvim_set_option_value('winbar', 'bar', {})
screen:expect {
grid = [[
{1:bar }|
@@ -428,7 +428,7 @@ describe('winbar', function()
|
]],
}
- meths.nvim_set_option_value('winbar', 'floaty bar', { scope = 'local', win = win.id })
+ api.nvim_set_option_value('winbar', 'floaty bar', { scope = 'local', win = win.id })
screen:expect {
grid = [[
{1:bar }|
@@ -531,7 +531,7 @@ describe('local winbar with tabs', function()
[3] = { bold = true, foreground = Screen.colors.Blue },
[4] = { underline = true, background = Screen.colors.LightGray },
})
- meths.nvim_set_option_value('winbar', 'foo', { scope = 'local', win = 0 })
+ api.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 29841d052a..200ad40c3a 100644
--- a/test/functional/vimscript/api_functions_spec.lua
+++ b/test/functional/vimscript/api_functions_spec.lua
@@ -5,7 +5,7 @@ local clear = helpers.clear
local exc_exec, expect, eval = helpers.exc_exec, helpers.expect, helpers.eval
local insert, pcall_err = helpers.insert, helpers.pcall_err
local matches = helpers.matches
-local meths = helpers.meths
+local api = helpers.api
local feed = helpers.feed
describe('eval-API', function()
@@ -80,36 +80,36 @@ 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.nvim_set_vvar('errmsg', '')
+ api.nvim_set_vvar('errmsg', '')
feed('i<f2><esc>')
eq(
'E5555: API call: E565: Not allowed to change text or change window',
- meths.nvim_get_vvar('errmsg')
+ api.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.nvim_get_current_win()
+ local old_win = api.nvim_get_current_win()
feed('q:')
eq(
'E11: Invalid in command-line window; <CR> executes, CTRL-C quits',
- pcall_err(meths.nvim_set_current_win, old_win)
+ pcall_err(api.nvim_set_current_win, old_win)
)
-- But others, like nvim_buf_set_lines(), which just changes text, is OK.
- meths.nvim_buf_set_lines(0, 0, -1, 1, { 'wow!' })
- eq({ 'wow!' }, meths.nvim_buf_get_lines(0, 0, -1, 1))
+ api.nvim_buf_set_lines(0, 0, -1, 1, { 'wow!' })
+ eq({ 'wow!' }, api.nvim_buf_get_lines(0, 0, -1, 1))
-- 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.nvim_open_term, 0, {})
+ pcall_err(api.nvim_open_term, 0, {})
)
-- But turning a different buffer into a terminal from the cmdwin is OK.
- 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 }))
+ local term_buf = api.nvim_create_buf(false, true)
+ api.nvim_open_term(term_buf, {})
+ eq('terminal', api.nvim_get_option_value('buftype', { buf = term_buf }))
end)
it('use buffer numbers and windows ids as handles', function()
@@ -143,11 +143,11 @@ describe('eval-API', function()
end)
it('get_lines and set_lines use NL to represent NUL', function()
- meths.nvim_buf_set_lines(0, 0, -1, true, { 'aa\0', 'b\0b' })
+ api.nvim_buf_set_lines(0, 0, -1, true, { 'aa\0', 'b\0b' })
eq({ 'aa\n', 'b\nb' }, eval('nvim_buf_get_lines(0, 0, -1, 1)'))
command('call nvim_buf_set_lines(0, 1, 2, v:true, ["xx", "\\nyy"])')
- eq({ 'aa\0', 'xx', '\0yy' }, meths.nvim_buf_get_lines(0, 0, -1, 1))
+ eq({ 'aa\0', 'xx', '\0yy' }, api.nvim_buf_get_lines(0, 0, -1, 1))
end)
it('that are FUNC_ATTR_NOEVAL cannot be called', 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.nvim_buf_get_lines(0, 0, -1, true))
+ eq({ '' }, api.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 34206b15ae..5557ce6788 100644
--- a/test/functional/vimscript/buf_functions_spec.lua
+++ b/test/functional/vimscript/buf_functions_spec.lua
@@ -2,8 +2,8 @@ local helpers = require('test.functional.helpers')(after_each)
local eq = helpers.eq
local clear = helpers.clear
-local funcs = helpers.funcs
-local meths = helpers.meths
+local fn = helpers.fn
+local api = helpers.api
local command = helpers.command
local exc_exec = helpers.exc_exec
local get_pathsep = helpers.get_pathsep
@@ -65,12 +65,12 @@ end
describe('bufname() function', function()
it('returns empty string when buffer was not found', function()
command('file ' .. fname)
- eq('', funcs.bufname(2))
- eq('', funcs.bufname('non-existent-buffer'))
- eq('', funcs.bufname('#'))
+ eq('', fn.bufname(2))
+ eq('', fn.bufname('non-existent-buffer'))
+ eq('', fn.bufname('#'))
command('edit ' .. fname2)
- eq(2, funcs.bufnr('%'))
- eq('', funcs.bufname('X'))
+ eq(2, fn.bufnr('%'))
+ eq('', fn.bufname('X'))
end)
before_each(function()
mkdir(dirname)
@@ -79,80 +79,80 @@ describe('bufname() function', function()
rmdir(dirname)
end)
it('returns expected buffer name', function()
- eq('', funcs.bufname('%')) -- Buffer has no name yet
+ eq('', fn.bufname('%')) -- Buffer has no name yet
command('file ' .. fname)
local wd = vim.uv.cwd()
local sep = get_pathsep()
- local curdirname = funcs.fnamemodify(wd, ':t')
+ local curdirname = fn.fnamemodify(wd, ':t')
for _, arg in ipairs({ '%', 1, 'X', wd }) do
- eq(fname, funcs.bufname(arg))
- meths.nvim_set_current_dir('..')
- eq(curdirname .. sep .. fname, funcs.bufname(arg))
- meths.nvim_set_current_dir(curdirname)
- meths.nvim_set_current_dir(dirname)
- eq(wd .. sep .. fname, funcs.bufname(arg))
- meths.nvim_set_current_dir('..')
- eq(fname, funcs.bufname(arg))
+ eq(fname, fn.bufname(arg))
+ api.nvim_set_current_dir('..')
+ eq(curdirname .. sep .. fname, fn.bufname(arg))
+ api.nvim_set_current_dir(curdirname)
+ api.nvim_set_current_dir(dirname)
+ eq(wd .. sep .. fname, fn.bufname(arg))
+ api.nvim_set_current_dir('..')
+ eq(fname, fn.bufname(arg))
command('enew')
end
- eq('', funcs.bufname('%'))
- eq('', funcs.bufname('$'))
- eq(2, funcs.bufnr('%'))
+ eq('', fn.bufname('%'))
+ eq('', fn.bufname('$'))
+ eq(2, fn.bufnr('%'))
end)
end)
describe('bufnr() function', function()
it('returns -1 when buffer was not found', function()
command('file ' .. fname)
- eq(-1, funcs.bufnr(2))
- eq(-1, funcs.bufnr('non-existent-buffer'))
- eq(-1, funcs.bufnr('#'))
+ eq(-1, fn.bufnr(2))
+ eq(-1, fn.bufnr('non-existent-buffer'))
+ eq(-1, fn.bufnr('#'))
command('edit ' .. fname2)
- eq(2, funcs.bufnr('%'))
- eq(-1, funcs.bufnr('X'))
+ eq(2, fn.bufnr('%'))
+ eq(-1, fn.bufnr('X'))
end)
it('returns expected buffer number', function()
- eq(1, funcs.bufnr('%'))
+ eq(1, fn.bufnr('%'))
command('file ' .. fname)
local wd = vim.uv.cwd()
- local curdirname = funcs.fnamemodify(wd, ':t')
- eq(1, funcs.bufnr(fname))
- eq(1, funcs.bufnr(wd))
- eq(1, funcs.bufnr(curdirname))
- eq(1, funcs.bufnr('X'))
+ local curdirname = fn.fnamemodify(wd, ':t')
+ eq(1, fn.bufnr(fname))
+ eq(1, fn.bufnr(wd))
+ eq(1, fn.bufnr(curdirname))
+ eq(1, fn.bufnr('X'))
end)
it('returns number of last buffer with "$"', function()
- eq(1, funcs.bufnr('$'))
+ eq(1, fn.bufnr('$'))
command('new')
- eq(2, funcs.bufnr('$'))
+ eq(2, fn.bufnr('$'))
command('new')
- eq(3, funcs.bufnr('$'))
+ eq(3, fn.bufnr('$'))
command('only')
- eq(3, funcs.bufnr('$'))
- eq(3, funcs.bufnr('%'))
+ eq(3, fn.bufnr('$'))
+ eq(3, fn.bufnr('%'))
command('buffer 1')
- eq(3, funcs.bufnr('$'))
- eq(1, funcs.bufnr('%'))
+ eq(3, fn.bufnr('$'))
+ eq(1, fn.bufnr('%'))
command('bwipeout 2')
- eq(3, funcs.bufnr('$'))
- eq(1, funcs.bufnr('%'))
+ eq(3, fn.bufnr('$'))
+ eq(1, fn.bufnr('%'))
command('bwipeout 3')
- eq(1, funcs.bufnr('$'))
- eq(1, funcs.bufnr('%'))
+ eq(1, fn.bufnr('$'))
+ eq(1, fn.bufnr('%'))
command('new')
- eq(4, funcs.bufnr('$'))
+ eq(4, fn.bufnr('$'))
end)
end)
describe('bufwinnr() function', function()
it('returns -1 when buffer was not found', function()
command('file ' .. fname)
- eq(-1, funcs.bufwinnr(2))
- eq(-1, funcs.bufwinnr('non-existent-buffer'))
- eq(-1, funcs.bufwinnr('#'))
+ eq(-1, fn.bufwinnr(2))
+ eq(-1, fn.bufwinnr('non-existent-buffer'))
+ eq(-1, fn.bufwinnr('#'))
command('split ' .. fname2) -- It would be OK if there was one window
- eq(2, funcs.bufnr('%'))
- eq(-1, funcs.bufwinnr('X'))
+ eq(2, fn.bufnr('%'))
+ eq(-1, fn.bufwinnr('X'))
end)
before_each(function()
mkdir(dirname)
@@ -161,105 +161,105 @@ describe('bufwinnr() function', function()
rmdir(dirname)
end)
it('returns expected window number', function()
- eq(1, funcs.bufwinnr('%'))
+ eq(1, fn.bufwinnr('%'))
command('file ' .. fname)
command('vsplit')
command('split ' .. fname2)
- eq(2, funcs.bufwinnr(fname))
- eq(1, funcs.bufwinnr(fname2))
- eq(-1, funcs.bufwinnr(fname:sub(1, #fname - 1)))
- 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)))
- eq(1, funcs.bufwinnr('%'))
- eq(2, funcs.bufwinnr(1))
- eq(1, funcs.bufwinnr(2))
- eq(-1, funcs.bufwinnr(3))
- eq(1, funcs.bufwinnr('$'))
+ eq(2, fn.bufwinnr(fname))
+ eq(1, fn.bufwinnr(fname2))
+ eq(-1, fn.bufwinnr(fname:sub(1, #fname - 1)))
+ api.nvim_set_current_dir(dirname)
+ eq(2, fn.bufwinnr(fname))
+ eq(1, fn.bufwinnr(fname2))
+ eq(-1, fn.bufwinnr(fname:sub(1, #fname - 1)))
+ eq(1, fn.bufwinnr('%'))
+ eq(2, fn.bufwinnr(1))
+ eq(1, fn.bufwinnr(2))
+ eq(-1, fn.bufwinnr(3))
+ eq(1, fn.bufwinnr('$'))
end)
end)
describe('getbufline() function', function()
it('returns empty list when buffer was not found', function()
command('file ' .. fname)
- eq({}, funcs.getbufline(2, 1))
- eq({}, funcs.getbufline('non-existent-buffer', 1))
- eq({}, funcs.getbufline('#', 1))
+ eq({}, fn.getbufline(2, 1))
+ eq({}, fn.getbufline('non-existent-buffer', 1))
+ eq({}, fn.getbufline('#', 1))
command('edit ' .. fname2)
- eq(2, funcs.bufnr('%'))
- eq({}, funcs.getbufline('X', 1))
+ eq(2, fn.bufnr('%'))
+ eq({}, fn.getbufline('X', 1))
end)
it('returns empty list when range is invalid', function()
- eq({}, funcs.getbufline(1, 0))
- meths.nvim_buf_set_lines(0, 0, 1, false, { 'foo', 'bar', 'baz' })
- eq({}, funcs.getbufline(1, 2, 1))
- eq({}, funcs.getbufline(1, -10, -20))
- eq({}, funcs.getbufline(1, -2, -1))
- eq({}, funcs.getbufline(1, -1, 9999))
+ eq({}, fn.getbufline(1, 0))
+ api.nvim_buf_set_lines(0, 0, 1, false, { 'foo', 'bar', 'baz' })
+ eq({}, fn.getbufline(1, 2, 1))
+ eq({}, fn.getbufline(1, -10, -20))
+ eq({}, fn.getbufline(1, -2, -1))
+ eq({}, fn.getbufline(1, -1, 9999))
end)
it('returns expected lines', function()
- meths.nvim_set_option_value('hidden', true, {})
+ api.nvim_set_option_value('hidden', true, {})
command('file ' .. fname)
- meths.nvim_buf_set_lines(0, 0, 1, false, { 'foo\0', '\0bar', 'baz' })
+ api.nvim_buf_set_lines(0, 0, 1, false, { 'foo\0', '\0bar', 'baz' })
command('edit ' .. fname2)
- meths.nvim_buf_set_lines(0, 0, 1, false, { 'abc\0', '\0def', 'ghi' })
- eq({ 'foo\n', '\nbar', 'baz' }, funcs.getbufline(1, 1, 9999))
- eq({ 'abc\n', '\ndef', 'ghi' }, funcs.getbufline(2, 1, 9999))
- eq({ 'foo\n', '\nbar', 'baz' }, funcs.getbufline(1, 1, '$'))
- eq({ 'baz' }, funcs.getbufline(1, '$', '$'))
- eq({ 'baz' }, funcs.getbufline(1, '$', 9999))
+ api.nvim_buf_set_lines(0, 0, 1, false, { 'abc\0', '\0def', 'ghi' })
+ eq({ 'foo\n', '\nbar', 'baz' }, fn.getbufline(1, 1, 9999))
+ eq({ 'abc\n', '\ndef', 'ghi' }, fn.getbufline(2, 1, 9999))
+ eq({ 'foo\n', '\nbar', 'baz' }, fn.getbufline(1, 1, '$'))
+ eq({ 'baz' }, fn.getbufline(1, '$', '$'))
+ eq({ 'baz' }, fn.getbufline(1, '$', 9999))
end)
end)
describe('getbufvar() function', function()
it('returns empty list when buffer was not found', function()
command('file ' .. fname)
- eq('', funcs.getbufvar(2, '&autoindent'))
- eq('', funcs.getbufvar('non-existent-buffer', '&autoindent'))
- eq('', funcs.getbufvar('#', '&autoindent'))
+ eq('', fn.getbufvar(2, '&autoindent'))
+ eq('', fn.getbufvar('non-existent-buffer', '&autoindent'))
+ eq('', fn.getbufvar('#', '&autoindent'))
command('edit ' .. fname2)
- eq(2, funcs.bufnr('%'))
- eq('', funcs.getbufvar('X', '&autoindent'))
+ eq(2, fn.bufnr('%'))
+ eq('', fn.getbufvar('X', '&autoindent'))
end)
it('returns empty list when variable/option/etc was not found', function()
command('file ' .. fname)
- eq('', funcs.getbufvar(1, '&autondent'))
- eq('', funcs.getbufvar(1, 'changedtic'))
+ eq('', fn.getbufvar(1, '&autondent'))
+ eq('', fn.getbufvar(1, 'changedtic'))
end)
it('returns expected option value', function()
- eq(0, funcs.getbufvar(1, '&autoindent'))
- eq(0, funcs.getbufvar(1, '&l:autoindent'))
- eq(0, funcs.getbufvar(1, '&g:autoindent'))
+ eq(0, fn.getbufvar(1, '&autoindent'))
+ eq(0, fn.getbufvar(1, '&l:autoindent'))
+ eq(0, fn.getbufvar(1, '&g:autoindent'))
-- Also works with global-only options
- eq(1, funcs.getbufvar(1, '&hidden'))
- eq(1, funcs.getbufvar(1, '&l:hidden'))
- eq(1, funcs.getbufvar(1, '&g:hidden'))
+ eq(1, fn.getbufvar(1, '&hidden'))
+ eq(1, fn.getbufvar(1, '&l:hidden'))
+ eq(1, fn.getbufvar(1, '&g:hidden'))
-- Also works with window-local options
- eq(0, funcs.getbufvar(1, '&number'))
- eq(0, funcs.getbufvar(1, '&l:number'))
- eq(0, funcs.getbufvar(1, '&g:number'))
+ eq(0, fn.getbufvar(1, '&number'))
+ eq(0, fn.getbufvar(1, '&l:number'))
+ eq(0, fn.getbufvar(1, '&g:number'))
command('new')
-- But with window-local options it probably does not what you expect
command('setl number')
-- (note that current window’s buffer is 2, but getbufvar() receives 1)
- eq({ id = 2 }, meths.nvim_win_get_buf(0))
- eq(1, funcs.getbufvar(1, '&number'))
- eq(1, funcs.getbufvar(1, '&l:number'))
+ eq({ id = 2 }, api.nvim_win_get_buf(0))
+ eq(1, fn.getbufvar(1, '&number'))
+ eq(1, fn.getbufvar(1, '&l:number'))
-- You can get global value though, if you find this useful.
- eq(0, funcs.getbufvar(1, '&g:number'))
+ eq(0, fn.getbufvar(1, '&g:number'))
end)
it('returns expected variable value', function()
- eq(2, funcs.getbufvar(1, 'changedtick'))
- meths.nvim_buf_set_lines(0, 0, 1, false, { 'abc\0', '\0def', 'ghi' })
- eq(3, funcs.getbufvar(1, 'changedtick'))
- meths.nvim_buf_set_var(0, 'test', true)
- eq(true, funcs.getbufvar(1, 'test'))
- eq({ test = true, changedtick = 3 }, funcs.getbufvar(1, ''))
+ eq(2, fn.getbufvar(1, 'changedtick'))
+ api.nvim_buf_set_lines(0, 0, 1, false, { 'abc\0', '\0def', 'ghi' })
+ eq(3, fn.getbufvar(1, 'changedtick'))
+ api.nvim_buf_set_var(0, 'test', true)
+ eq(true, fn.getbufvar(1, 'test'))
+ eq({ test = true, changedtick = 3 }, fn.getbufvar(1, ''))
command('new')
- eq(3, funcs.getbufvar(1, 'changedtick'))
- eq(true, funcs.getbufvar(1, 'test'))
- eq({ test = true, changedtick = 3 }, funcs.getbufvar(1, ''))
+ eq(3, fn.getbufvar(1, 'changedtick'))
+ eq(true, fn.getbufvar(1, 'test'))
+ eq({ test = true, changedtick = 3 }, fn.getbufvar(1, ''))
end)
end)
@@ -273,50 +273,50 @@ describe('setbufvar() function', function()
)
eq(0, exc_exec('call setbufvar("#", "&autoindent", 0)'))
command('edit ' .. fname2)
- eq(2, funcs.bufnr('%'))
+ eq(2, fn.bufnr('%'))
eq(
'Vim(call):E93: More than one match for X',
exc_exec('call setbufvar("X", "&autoindent", 0)')
)
end)
it('may set options, including window-local and global values', function()
- local buf1 = meths.nvim_get_current_buf()
- eq(false, meths.nvim_get_option_value('number', {}))
+ local buf1 = api.nvim_get_current_buf()
+ eq(false, api.nvim_get_option_value('number', {}))
command('split')
command('new')
- eq(2, meths.nvim_buf_get_number(meths.nvim_win_get_buf(0)))
- funcs.setbufvar(1, '&number', true)
- local windows = meths.nvim_tabpage_list_wins(0)
- 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(2, api.nvim_buf_get_number(api.nvim_win_get_buf(0)))
+ fn.setbufvar(1, '&number', true)
+ local windows = api.nvim_tabpage_list_wins(0)
+ eq(false, api.nvim_get_option_value('number', { win = windows[1].id }))
+ eq(true, api.nvim_get_option_value('number', { win = windows[2].id }))
+ eq(false, api.nvim_get_option_value('number', { win = windows[3].id }))
+ eq(false, api.nvim_get_option_value('number', { win = api.nvim_get_current_win().id }))
- eq(true, meths.nvim_get_option_value('hidden', {}))
- funcs.setbufvar(1, '&hidden', 0)
- eq(false, meths.nvim_get_option_value('hidden', {}))
+ eq(true, api.nvim_get_option_value('hidden', {}))
+ fn.setbufvar(1, '&hidden', 0)
+ eq(false, api.nvim_get_option_value('hidden', {}))
- eq(false, meths.nvim_get_option_value('autoindent', { buf = buf1.id }))
- funcs.setbufvar(1, '&autoindent', true)
- eq(true, meths.nvim_get_option_value('autoindent', { buf = buf1.id }))
+ eq(false, api.nvim_get_option_value('autoindent', { buf = buf1.id }))
+ fn.setbufvar(1, '&autoindent', true)
+ eq(true, api.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.nvim_get_current_buf()
+ local buf1 = api.nvim_get_current_buf()
command('split')
command('new')
- eq(2, meths.nvim_buf_get_number(0))
- funcs.setbufvar(1, 'number', true)
- eq(true, meths.nvim_buf_get_var(buf1, 'number'))
+ eq(2, api.nvim_buf_get_number(0))
+ fn.setbufvar(1, 'number', true)
+ eq(true, api.nvim_buf_get_var(buf1, 'number'))
eq('Vim(call):E461: Illegal variable name: b:', exc_exec('call setbufvar(1, "", 0)'))
- eq(true, meths.nvim_buf_get_var(buf1, 'number'))
+ eq(true, api.nvim_buf_get_var(buf1, 'number'))
eq(
'Vim:E46: Cannot change read-only variable "b:changedtick"',
- pcall_err(funcs.setbufvar, 1, 'changedtick', true)
+ pcall_err(fn.setbufvar, 1, 'changedtick', true)
)
- eq(2, funcs.getbufvar(1, 'changedtick'))
+ eq(2, fn.getbufvar(1, 'changedtick'))
end)
it('throws error when setting a string option to a boolean value vim-patch:9.0.0090', function()
- eq('Vim:E928: String required', pcall_err(funcs.setbufvar, '', '&errorformat', true))
+ eq('Vim:E928: String required', pcall_err(fn.setbufvar, '', '&errorformat', true))
end)
end)
diff --git a/test/functional/vimscript/changedtick_spec.lua b/test/functional/vimscript/changedtick_spec.lua
index 203c9a22e5..85928921c5 100644
--- a/test/functional/vimscript/changedtick_spec.lua
+++ b/test/functional/vimscript/changedtick_spec.lua
@@ -4,8 +4,8 @@ local eq = helpers.eq
local eval = helpers.eval
local feed = helpers.feed
local clear = helpers.clear
-local funcs = helpers.funcs
-local meths = helpers.meths
+local fn = helpers.fn
+local api = helpers.api
local command = helpers.command
local exc_exec = helpers.exc_exec
local pcall_err = helpers.pcall_err
@@ -14,14 +14,14 @@ local exec_capture = helpers.exec_capture
before_each(clear)
local function changedtick()
- local ct = meths.nvim_buf_get_changedtick(0)
- eq(ct, meths.nvim_buf_get_var(0, 'changedtick'))
- eq(ct, meths.nvim_buf_get_var(0, 'changedtick'))
+ local ct = api.nvim_buf_get_changedtick(0)
+ eq(ct, api.nvim_buf_get_var(0, 'changedtick'))
+ eq(ct, api.nvim_buf_get_var(0, 'changedtick'))
eq(ct, eval('b:changedtick'))
eq(ct, eval('b:["changedtick"]'))
eq(ct, eval('b:.changedtick'))
- eq(ct, funcs.getbufvar('%', 'changedtick'))
- eq(ct, funcs.getbufvar('%', '').changedtick)
+ eq(ct, fn.getbufvar('%', 'changedtick'))
+ eq(ct, fn.getbufvar('%', '').changedtick)
eq(ct, eval('b:').changedtick)
return ct
end
@@ -31,7 +31,7 @@ describe('b:changedtick', function()
it('increments', function() -- Test_changedtick_increments
-- New buffer has an empty line, tick starts at 2
eq(2, changedtick())
- funcs.setline(1, 'hello')
+ fn.setline(1, 'hello')
eq(3, changedtick())
eq(0, exc_exec('undo'))
-- Somehow undo counts as two changes
@@ -40,16 +40,16 @@ describe('b:changedtick', function()
it('is present in b: dictionary', function()
eq(2, changedtick())
command('let d = b:')
- eq(2, meths.nvim_get_var('d').changedtick)
+ eq(2, api.nvim_get_var('d').changedtick)
end)
it('increments at bdel', function()
command('new')
eq(2, changedtick())
- local bnr = meths.nvim_buf_get_number(0)
+ local bnr = api.nvim_buf_get_number(0)
eq(2, bnr)
command('bdel')
- eq(3, funcs.getbufvar(bnr, 'changedtick'))
- eq(1, meths.nvim_buf_get_number(0))
+ eq(3, fn.getbufvar(bnr, 'changedtick'))
+ eq(1, api.nvim_buf_get_number(0))
end)
it('fails to be changed by user', function()
local ct = changedtick()
@@ -71,7 +71,7 @@ describe('b:changedtick', function()
'Vim(let):E46: Cannot change read-only variable "d.changedtick"',
pcall_err(command, 'let d.changedtick = ' .. ctn)
)
- eq('Key is read-only: changedtick', pcall_err(meths.nvim_buf_set_var, 0, 'changedtick', ctn))
+ eq('Key is read-only: changedtick', pcall_err(api.nvim_buf_set_var, 0, 'changedtick', ctn))
eq(
'Vim(unlet):E795: Cannot delete variable b:changedtick',
@@ -89,7 +89,7 @@ describe('b:changedtick', function()
'Vim(unlet):E46: Cannot change read-only variable "d.changedtick"',
pcall_err(command, 'unlet d.changedtick')
)
- eq('Key is read-only: changedtick', pcall_err(meths.nvim_buf_del_var, 0, 'changedtick'))
+ eq('Key is read-only: changedtick', pcall_err(api.nvim_buf_del_var, 0, 'changedtick'))
eq(ct, changedtick())
eq(
@@ -107,7 +107,7 @@ describe('b:changedtick', function()
eq(ct, changedtick())
- funcs.setline(1, 'hello')
+ fn.setline(1, 'hello')
eq(ct + 1, changedtick())
end)
@@ -116,8 +116,8 @@ describe('b:changedtick', function()
end)
it('fails to unlock b:changedtick', function()
eq(0, exc_exec('let d = b:'))
- eq(0, funcs.islocked('b:changedtick'))
- eq(0, funcs.islocked('d.changedtick'))
+ eq(0, fn.islocked('b:changedtick'))
+ eq(0, fn.islocked('d.changedtick'))
eq(
'Vim(unlockvar):E940: Cannot lock or unlock variable b:changedtick',
pcall_err(command, 'unlockvar b:changedtick')
@@ -126,8 +126,8 @@ describe('b:changedtick', function()
'Vim(unlockvar):E46: Cannot change read-only variable "d.changedtick"',
pcall_err(command, 'unlockvar d.changedtick')
)
- eq(0, funcs.islocked('b:changedtick'))
- eq(0, funcs.islocked('d.changedtick'))
+ eq(0, fn.islocked('b:changedtick'))
+ eq(0, fn.islocked('d.changedtick'))
eq(
'Vim(lockvar):E940: Cannot lock or unlock variable b:changedtick',
pcall_err(command, 'lockvar b:changedtick')
@@ -136,12 +136,12 @@ describe('b:changedtick', function()
'Vim(lockvar):E46: Cannot change read-only variable "d.changedtick"',
pcall_err(command, 'lockvar d.changedtick')
)
- eq(0, funcs.islocked('b:changedtick'))
- eq(0, funcs.islocked('d.changedtick'))
+ eq(0, fn.islocked('b:changedtick'))
+ eq(0, fn.islocked('d.changedtick'))
end)
it('is being completed', function()
feed(':echo b:<Tab><Home>let cmdline="<End>"<CR>')
- eq('echo b:changedtick', meths.nvim_get_var('cmdline'))
+ eq('echo b:changedtick', api.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 62e6efd7c2..1b34ea0165 100644
--- a/test/functional/vimscript/container_functions_spec.lua
+++ b/test/functional/vimscript/container_functions_spec.lua
@@ -2,23 +2,23 @@ local helpers = require('test.functional.helpers')(after_each)
local eq = helpers.eq
local eval = helpers.eval
-local meths = helpers.meths
+local api = helpers.api
local clear = helpers.clear
before_each(clear)
describe('extend()', function()
it('succeeds to extend list with itself', function()
- meths.nvim_set_var('l', { 1, {} })
+ api.nvim_set_var('l', { 1, {} })
eq({ 1, {}, 1, {} }, eval('extend(l, l)'))
- eq({ 1, {}, 1, {} }, meths.nvim_get_var('l'))
+ eq({ 1, {}, 1, {} }, api.nvim_get_var('l'))
- meths.nvim_set_var('l', { 1, {} })
+ api.nvim_set_var('l', { 1, {} })
eq({ 1, {}, 1, {} }, eval('extend(l, l, 0)'))
- eq({ 1, {}, 1, {} }, meths.nvim_get_var('l'))
+ eq({ 1, {}, 1, {} }, api.nvim_get_var('l'))
- meths.nvim_set_var('l', { 1, {} })
+ api.nvim_set_var('l', { 1, {} })
eq({ 1, 1, {}, {} }, eval('extend(l, l, 1)'))
- eq({ 1, 1, {}, {} }, meths.nvim_get_var('l'))
+ eq({ 1, 1, {}, {} }, api.nvim_get_var('l'))
end)
end)
diff --git a/test/functional/vimscript/ctx_functions_spec.lua b/test/functional/vimscript/ctx_functions_spec.lua
index ced29a6b76..b8f9bbc92d 100644
--- a/test/functional/vimscript/ctx_functions_spec.lua
+++ b/test/functional/vimscript/ctx_functions_spec.lua
@@ -7,7 +7,7 @@ local eq = helpers.eq
local eval = helpers.eval
local feed = helpers.feed
local map = vim.tbl_map
-local meths = helpers.meths
+local api = helpers.api
local parse_context = helpers.parse_context
local exec_capture = helpers.exec_capture
local source = helpers.source
@@ -126,16 +126,16 @@ describe('context functions', function()
end)
it('saves and restores global variables properly', function()
- meths.nvim_set_var('one', 1)
- meths.nvim_set_var('Two', 2)
- meths.nvim_set_var('THREE', 3)
+ api.nvim_set_var('one', 1)
+ api.nvim_set_var('Two', 2)
+ api.nvim_set_var('THREE', 3)
eq({ 1, 2, 3 }, eval('[g:one, g:Two, g:THREE]'))
call('ctxpush')
call('ctxpush', { 'gvars' })
- meths.nvim_del_var('one')
- meths.nvim_del_var('Two')
- meths.nvim_del_var('THREE')
+ api.nvim_del_var('one')
+ api.nvim_del_var('Two')
+ api.nvim_del_var('THREE')
eq('Vim:E121: Undefined variable: g:one', pcall_err(eval, 'g:one'))
eq('Vim:E121: Undefined variable: g:Two', pcall_err(eval, 'g:Two'))
eq('Vim:E121: Undefined variable: g:THREE', pcall_err(eval, 'g:THREE'))
@@ -143,9 +143,9 @@ describe('context functions', function()
call('ctxpop')
eq({ 1, 2, 3 }, eval('[g:one, g:Two, g:THREE]'))
- meths.nvim_del_var('one')
- meths.nvim_del_var('Two')
- meths.nvim_del_var('THREE')
+ api.nvim_del_var('one')
+ api.nvim_del_var('Two')
+ api.nvim_del_var('THREE')
eq('Vim:E121: Undefined variable: g:one', pcall_err(eval, 'g:one'))
eq('Vim:E121: Undefined variable: g:Two', pcall_err(eval, 'g:Two'))
eq('Vim:E121: Undefined variable: g:THREE', pcall_err(eval, 'g:THREE'))
@@ -300,9 +300,9 @@ describe('context functions', function()
feed('G')
feed('gg')
command('edit ' .. fname2)
- meths.nvim_set_var('one', 1)
- meths.nvim_set_var('Two', 2)
- meths.nvim_set_var('THREE', 3)
+ api.nvim_set_var('one', 1)
+ api.nvim_set_var('Two', 2)
+ api.nvim_set_var('THREE', 3)
local with_regs = {
['regs'] = {
@@ -412,14 +412,14 @@ describe('context functions', function()
end)
it('sets context dictionary at index in context stack', function()
- meths.nvim_set_var('one', 1)
- meths.nvim_set_var('Two', 2)
- meths.nvim_set_var('THREE', 3)
+ api.nvim_set_var('one', 1)
+ api.nvim_set_var('Two', 2)
+ api.nvim_set_var('THREE', 3)
call('ctxpush')
local ctx1 = call('ctxget')
- meths.nvim_set_var('one', 'a')
- meths.nvim_set_var('Two', 'b')
- meths.nvim_set_var('THREE', 'c')
+ api.nvim_set_var('one', 'a')
+ api.nvim_set_var('Two', 'b')
+ api.nvim_set_var('THREE', 'c')
call('ctxpush')
call('ctxpush')
local ctx2 = call('ctxget')
@@ -431,7 +431,7 @@ describe('context functions', function()
eq({ 1, 2, 3 }, eval('[g:one, g:Two, g:THREE]'))
call('ctxpop')
eq({ 'a', 'b', 'c' }, eval('[g:one, g:Two, g:THREE]'))
- meths.nvim_set_var('one', 1.5)
+ api.nvim_set_var('one', 1.5)
eq({ 1.5, 'b', 'c' }, eval('[g:one, g:Two, g:THREE]'))
call('ctxpop')
eq({ 'a', 'b', 'c' }, eval('[g:one, g:Two, g:THREE]'))
diff --git a/test/functional/vimscript/environ_spec.lua b/test/functional/vimscript/environ_spec.lua
index c5821567ff..0763def84e 100644
--- a/test/functional/vimscript/environ_spec.lua
+++ b/test/functional/vimscript/environ_spec.lua
@@ -1,13 +1,13 @@
local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
local eq = helpers.eq
-local environ = helpers.funcs.environ
-local exists = helpers.funcs.exists
-local system = helpers.funcs.system
+local environ = helpers.fn.environ
+local exists = helpers.fn.exists
+local system = helpers.fn.system
local nvim_prog = helpers.nvim_prog
local command = helpers.command
local eval = helpers.eval
-local setenv = helpers.funcs.setenv
+local setenv = helpers.fn.setenv
describe('environment variables', function()
it('environ() handles empty env variable', function()
diff --git a/test/functional/vimscript/errorlist_spec.lua b/test/functional/vimscript/errorlist_spec.lua
index 2977612247..1e405e7e64 100644
--- a/test/functional/vimscript/errorlist_spec.lua
+++ b/test/functional/vimscript/errorlist_spec.lua
@@ -4,10 +4,10 @@ local clear = helpers.clear
local command = helpers.command
local eq = helpers.eq
local exc_exec = helpers.exc_exec
-local get_win_var = helpers.meths.nvim_win_get_var
+local get_win_var = helpers.api.nvim_win_get_var
describe('setqflist()', function()
- local setqflist = helpers.funcs.setqflist
+ local setqflist = helpers.fn.setqflist
before_each(clear)
@@ -46,7 +46,7 @@ describe('setqflist()', function()
end)
describe('setloclist()', function()
- local setloclist = helpers.funcs.setloclist
+ local setloclist = helpers.fn.setloclist
before_each(clear)
diff --git a/test/functional/vimscript/eval_spec.lua b/test/functional/vimscript/eval_spec.lua
index 180e6118fd..e337959810 100644
--- a/test/functional/vimscript/eval_spec.lua
+++ b/test/functional/vimscript/eval_spec.lua
@@ -22,7 +22,7 @@ local exec_capture = helpers.exec_capture
local eval = helpers.eval
local command = helpers.command
local write_file = helpers.write_file
-local meths = helpers.meths
+local api = helpers.api
local sleep = vim.uv.sleep
local matches = helpers.matches
local pcall_err = helpers.pcall_err
@@ -33,13 +33,13 @@ local expect_exit = helpers.expect_exit
describe('Up to MAX_FUNC_ARGS arguments are handled by', function()
local max_func_args = 20 -- from eval.h
- local range = helpers.funcs.range
+ local range = helpers.fn.range
before_each(clear)
it('printf()', function()
- local printf = helpers.funcs.printf
- local rep = helpers.funcs['repeat']
+ local printf = helpers.fn.printf
+ local rep = helpers.fn['repeat']
local expected = '2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,'
eq(expected, printf(rep('%d,', max_func_args - 1), unpack(range(2, max_func_args))))
local ret = exc_exec('call printf("", 2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21)')
@@ -47,7 +47,7 @@ describe('Up to MAX_FUNC_ARGS arguments are handled by', function()
end)
it('rpcnotify()', function()
- local rpcnotify = helpers.funcs.rpcnotify
+ local rpcnotify = helpers.fn.rpcnotify
local ret = rpcnotify(0, 'foo', unpack(range(3, max_func_args)))
eq(1, ret)
ret = exc_exec('call rpcnotify(0, "foo", 3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21)')
@@ -121,7 +121,7 @@ describe('List support code', function()
let bl = range(%u)
let dur = reltimestr(reltime(rt))
]]):format(len))
- dur = tonumber(meths.nvim_get_var('dur'))
+ dur = tonumber(api.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.nvim_get_var('t_dur'))
+ local t_dur = tonumber(api.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.nvim_get_var('t_dur'))
+ local t_dur = tonumber(api.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/execute_spec.lua b/test/functional/vimscript/execute_spec.lua
index 3124c02c2f..29488ed31c 100644
--- a/test/functional/vimscript/execute_spec.lua
+++ b/test/functional/vimscript/execute_spec.lua
@@ -5,7 +5,7 @@ local clear = helpers.clear
local source = helpers.source
local exc_exec = helpers.exc_exec
local pcall_err = helpers.pcall_err
-local funcs = helpers.funcs
+local fn = helpers.fn
local Screen = require('test.functional.ui.screen')
local command = helpers.command
local feed = helpers.feed
@@ -22,16 +22,16 @@ describe('execute()', function()
silent! messages
redir END
]])
- eq(eval('g:__redir_output'), funcs.execute('messages'))
+ eq(eval('g:__redir_output'), fn.execute('messages'))
end)
it('captures the concatenated outputs of a List of commands', function()
- eq('foobar', funcs.execute({ 'echon "foo"', 'echon "bar"' }))
- eq('\nfoo\nbar', funcs.execute({ 'echo "foo"', 'echo "bar"' }))
+ eq('foobar', fn.execute({ 'echon "foo"', 'echon "bar"' }))
+ eq('\nfoo\nbar', fn.execute({ 'echo "foo"', 'echo "bar"' }))
end)
it('supports nested execute("execute(...)")', function()
- eq('42', funcs.execute([[echon execute("echon execute('echon 42')")]]))
+ eq('42', fn.execute([[echon execute("echon execute('echon 42')")]]))
end)
it('supports nested :redir to a variable', function()
@@ -54,7 +54,7 @@ describe('execute()', function()
return a
endfunction
]])
- eq('top1bar1foobar2bar3', funcs.execute('echon "top1"|call g:Bar()'))
+ eq('top1bar1foobar2bar3', fn.execute('echon "top1"|call g:Bar()'))
end)
it('supports nested :redir to a register', function()
@@ -76,17 +76,17 @@ describe('execute()', function()
return @a
endfunction
]])
- eq('top1bar1foobar2bar3', funcs.execute('echon "top1"|call g:Bar()'))
+ eq('top1bar1foobar2bar3', fn.execute('echon "top1"|call g:Bar()'))
-- :redir itself doesn't nest, so the redirection ends in g:Foo
eq('bar1foo', eval('@a'))
end)
it('captures a transformed string', function()
- eq('^A', funcs.execute('echon "\\<C-a>"'))
+ eq('^A', fn.execute('echon "\\<C-a>"'))
end)
it('returns empty string if the argument list is empty', function()
- eq('', funcs.execute({}))
+ eq('', fn.execute({}))
eq(0, exc_exec('let g:ret = execute(v:_null_list)'))
eq('', eval('g:ret'))
end)
@@ -255,7 +255,7 @@ describe('execute()', function()
-- with how nvim currently displays the output.
it('captures shell-command output', function()
local win_lf = is_os('win') and '\13' or ''
- eq('\n:!echo foo\r\n\nfoo' .. win_lf .. '\n', funcs.execute('!echo foo'))
+ eq('\n:!echo foo\r\n\nfoo' .. win_lf .. '\n', fn.execute('!echo foo'))
end)
describe('{silent} argument', function()
@@ -275,11 +275,11 @@ describe('execute()', function()
command('split')
eq(
'Vim(windo):E493: Backwards range given: 2,1windo echo',
- pcall_err(funcs.execute, '2,1windo echo', '')
+ pcall_err(fn.execute, '2,1windo echo', '')
)
eq(
'Vim(windo):E493: Backwards range given: 2,1windo echo',
- pcall_err(funcs.execute, { '2,1windo echo' }, '')
+ pcall_err(fn.execute, { '2,1windo echo' }, '')
)
end)
diff --git a/test/functional/vimscript/fnamemodify_spec.lua b/test/functional/vimscript/fnamemodify_spec.lua
index 6e49bcb0c5..4a134fe23c 100644
--- a/test/functional/vimscript/fnamemodify_spec.lua
+++ b/test/functional/vimscript/fnamemodify_spec.lua
@@ -1,8 +1,8 @@
local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
local eq = helpers.eq
-local fnamemodify = helpers.funcs.fnamemodify
-local getcwd = helpers.funcs.getcwd
+local fnamemodify = helpers.fn.fnamemodify
+local getcwd = helpers.fn.getcwd
local command = helpers.command
local write_file = helpers.write_file
local alter_slashes = helpers.alter_slashes
diff --git a/test/functional/vimscript/has_spec.lua b/test/functional/vimscript/has_spec.lua
index c797a3bbf9..82b3db5b67 100644
--- a/test/functional/vimscript/has_spec.lua
+++ b/test/functional/vimscript/has_spec.lua
@@ -3,7 +3,7 @@ local Screen = require('test.functional.ui.screen')
local clear = helpers.clear
local connect = helpers.connect
local eq = helpers.eq
-local funcs = helpers.funcs
+local fn = helpers.fn
local is_os = helpers.is_os
local nvim_prog = helpers.nvim_prog
@@ -11,83 +11,83 @@ describe('has()', function()
before_each(clear)
it('"nvim-x.y.z"', function()
- eq(0, funcs.has('nvim-'))
- eq(0, funcs.has('nvim- '))
- eq(0, funcs.has('nvim- \t '))
- eq(0, funcs.has('nvim-0. 1. 1'))
- eq(0, funcs.has('nvim-0. 1.1'))
- eq(0, funcs.has('nvim-0.1. 1'))
- eq(0, funcs.has('nvim-a'))
- eq(0, funcs.has('nvim-a.b.c'))
- eq(0, funcs.has('nvim-0.b.c'))
- eq(0, funcs.has('nvim-0.0.c'))
- eq(0, funcs.has('nvim-0.b.0'))
- eq(0, funcs.has('nvim-a.b.0'))
- eq(0, funcs.has('nvim-.0.0.0'))
- eq(0, funcs.has('nvim-.0'))
- eq(0, funcs.has('nvim-0.'))
- eq(0, funcs.has('nvim-0..'))
- eq(0, funcs.has('nvim-.'))
- eq(0, funcs.has('nvim-..'))
- eq(0, funcs.has('nvim-...'))
- eq(0, funcs.has('nvim-42'))
- eq(0, funcs.has('nvim-9999'))
- eq(0, funcs.has('nvim-99.001.05'))
+ eq(0, fn.has('nvim-'))
+ eq(0, fn.has('nvim- '))
+ eq(0, fn.has('nvim- \t '))
+ eq(0, fn.has('nvim-0. 1. 1'))
+ eq(0, fn.has('nvim-0. 1.1'))
+ eq(0, fn.has('nvim-0.1. 1'))
+ eq(0, fn.has('nvim-a'))
+ eq(0, fn.has('nvim-a.b.c'))
+ eq(0, fn.has('nvim-0.b.c'))
+ eq(0, fn.has('nvim-0.0.c'))
+ eq(0, fn.has('nvim-0.b.0'))
+ eq(0, fn.has('nvim-a.b.0'))
+ eq(0, fn.has('nvim-.0.0.0'))
+ eq(0, fn.has('nvim-.0'))
+ eq(0, fn.has('nvim-0.'))
+ eq(0, fn.has('nvim-0..'))
+ eq(0, fn.has('nvim-.'))
+ eq(0, fn.has('nvim-..'))
+ eq(0, fn.has('nvim-...'))
+ eq(0, fn.has('nvim-42'))
+ eq(0, fn.has('nvim-9999'))
+ eq(0, fn.has('nvim-99.001.05'))
- eq(1, funcs.has('nvim'))
- eq(1, funcs.has('nvim-0'))
- eq(1, funcs.has('nvim-0.1'))
- eq(1, funcs.has('nvim-0.0.0'))
- eq(1, funcs.has('nvim-0.1.1.'))
- eq(1, funcs.has('nvim-0.1.1.abc'))
- eq(1, funcs.has('nvim-0.1.1..'))
- eq(1, funcs.has('nvim-0.1.1.. ..'))
- eq(1, funcs.has('nvim-0.1.1.... '))
- eq(1, funcs.has('nvim-0.0.0'))
- eq(1, funcs.has('nvim-0.0.1'))
- eq(1, funcs.has('nvim-0.1.0'))
- eq(1, funcs.has('nvim-0.1.1'))
- eq(1, funcs.has('nvim-0.1.5'))
- eq(1, funcs.has('nvim-0000.001.05'))
- eq(1, funcs.has('nvim-0.01.005'))
- eq(1, funcs.has('nvim-00.001.05'))
+ eq(1, fn.has('nvim'))
+ eq(1, fn.has('nvim-0'))
+ eq(1, fn.has('nvim-0.1'))
+ eq(1, fn.has('nvim-0.0.0'))
+ eq(1, fn.has('nvim-0.1.1.'))
+ eq(1, fn.has('nvim-0.1.1.abc'))
+ eq(1, fn.has('nvim-0.1.1..'))
+ eq(1, fn.has('nvim-0.1.1.. ..'))
+ eq(1, fn.has('nvim-0.1.1.... '))
+ eq(1, fn.has('nvim-0.0.0'))
+ eq(1, fn.has('nvim-0.0.1'))
+ eq(1, fn.has('nvim-0.1.0'))
+ eq(1, fn.has('nvim-0.1.1'))
+ eq(1, fn.has('nvim-0.1.5'))
+ eq(1, fn.has('nvim-0000.001.05'))
+ eq(1, fn.has('nvim-0.01.005'))
+ eq(1, fn.has('nvim-00.001.05'))
end)
it('"unnamedplus"', function()
- if (not is_os('win')) and funcs.has('clipboard') == 1 then
- eq(1, funcs.has('unnamedplus'))
+ if (not is_os('win')) and fn.has('clipboard') == 1 then
+ eq(1, fn.has('unnamedplus'))
else
- eq(0, funcs.has('unnamedplus'))
+ eq(0, fn.has('unnamedplus'))
end
end)
it('"wsl"', function()
local is_wsl = vim.uv.os_uname()['release']:lower():match('microsoft') and true or false
if is_wsl then
- eq(1, funcs.has('wsl'))
+ eq(1, fn.has('wsl'))
else
- eq(0, funcs.has('wsl'))
+ eq(0, fn.has('wsl'))
end
end)
it('"gui_running"', function()
- eq(0, funcs.has('gui_running'))
+ eq(0, fn.has('gui_running'))
local tui = Screen.new(50, 15)
- local gui_session = connect(funcs.serverstart())
+ local gui_session = connect(fn.serverstart())
local gui = Screen.new(50, 15)
- eq(0, funcs.has('gui_running'))
+ eq(0, fn.has('gui_running'))
tui:attach({ ext_linegrid = true, rgb = true, stdin_tty = true, stdout_tty = true })
gui:attach({ ext_multigrid = true, rgb = true }, gui_session)
- eq(1, funcs.has('gui_running'))
+ eq(1, fn.has('gui_running'))
tui:detach()
- eq(1, funcs.has('gui_running'))
+ eq(1, fn.has('gui_running'))
gui:detach()
- eq(0, funcs.has('gui_running'))
+ eq(0, fn.has('gui_running'))
end)
it('does not change v:shell_error', function()
- funcs.system({ nvim_prog, '-es', '+73cquit' })
- funcs.has('python3') -- use a call whose implementation shells out
- eq(73, funcs.eval('v:shell_error'))
+ fn.system({ nvim_prog, '-es', '+73cquit' })
+ fn.has('python3') -- use a call whose implementation shells out
+ eq(73, fn.eval('v:shell_error'))
end)
end)
diff --git a/test/functional/vimscript/input_spec.lua b/test/functional/vimscript/input_spec.lua
index 2e1d0501cf..6dd22078d6 100644
--- a/test/functional/vimscript/input_spec.lua
+++ b/test/functional/vimscript/input_spec.lua
@@ -3,7 +3,7 @@ local Screen = require('test.functional.ui.screen')
local eq = helpers.eq
local feed = helpers.feed
-local meths = helpers.meths
+local api = helpers.api
local clear = helpers.clear
local source = helpers.source
local command = helpers.command
@@ -110,7 +110,7 @@ describe('input()', function()
end)
it('allows unequal numeric values when using {opts} dictionary', function()
command('echohl Test')
- meths.nvim_set_var('opts', { prompt = 1, default = 2, cancelreturn = 3 })
+ api.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.nvim_set_var('opts', { prompt = 'Foo>', default = 'Bar' })
+ api.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.nvim_get_var('var'))
+ eq('TEST', api.nvim_get_var('var'))
feed(':let var = input({"completion": "customlist,CustomListCompl"})<CR>')
feed('<Tab><CR>')
- eq('FOO', meths.nvim_get_var('var'))
+ eq('FOO', api.nvim_get_var('var'))
end)
it('supports cancelreturn', function()
feed(':let var = input({"cancelreturn": "BAR"})<CR>')
feed('<Esc>')
- eq('BAR', meths.nvim_get_var('var'))
+ eq('BAR', api.nvim_get_var('var'))
feed(':let var = input({"cancelreturn": []})<CR>')
feed('<Esc>')
- eq({}, meths.nvim_get_var('var'))
+ eq({}, api.nvim_get_var('var'))
feed(':let var = input({"cancelreturn": v:false})<CR>')
feed('<Esc>')
- eq(false, meths.nvim_get_var('var'))
+ eq(false, api.nvim_get_var('var'))
feed(':let var = input({"cancelreturn": v:null})<CR>')
feed('<Esc>')
- eq(NIL, meths.nvim_get_var('var'))
+ eq(NIL, api.nvim_get_var('var'))
end)
it('supports default string', function()
feed(':let var = input("", "DEF1")<CR>')
feed('<CR>')
- eq('DEF1', meths.nvim_get_var('var'))
+ eq('DEF1', api.nvim_get_var('var'))
feed(':let var = input({"default": "DEF2"})<CR>')
feed('<CR>')
- eq('DEF2', meths.nvim_get_var('var'))
+ eq('DEF2', api.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.nvim_set_var('opts', { prompt = 1, default = 2, cancelreturn = 3 })
+ api.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.nvim_set_var('opts', { prompt = 'Foo>', default = 'Bar' })
+ api.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.nvim_get_var('var'))
+ eq('FOO', api.nvim_get_var('var'))
end)
it('supports cancelreturn', function()
feed(':let var = inputdialog("", "", "CR1")<CR>')
feed('<Esc>')
- eq('CR1', meths.nvim_get_var('var'))
+ eq('CR1', api.nvim_get_var('var'))
feed(':let var = inputdialog({"cancelreturn": "BAR"})<CR>')
feed('<Esc>')
- eq('BAR', meths.nvim_get_var('var'))
+ eq('BAR', api.nvim_get_var('var'))
end)
it('supports default string', function()
feed(':let var = inputdialog("", "DEF1")<CR>')
feed('<CR>')
- eq('DEF1', meths.nvim_get_var('var'))
+ eq('DEF1', api.nvim_get_var('var'))
feed(':let var = inputdialog({"default": "DEF2"})<CR>')
feed('<CR>')
- eq('DEF2', meths.nvim_get_var('var'))
+ eq('DEF2', api.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.nvim_set_option_value('more', false, {}) -- Avoid hit-enter prompt
- meths.nvim_set_option_value('laststatus', 2, {})
+ api.nvim_set_option_value('more', false, {}) -- Avoid hit-enter prompt
+ api.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.nvim_get_var('a'))
+ eq(1, api.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.nvim_get_var('a'))
+ eq(1, api.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.nvim_get_var('a'))
+ eq(2, api.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.nvim_get_var('a'))
+ eq(0, api.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.nvim_get_var('a'))
+ eq(1, api.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.nvim_get_var('a'))
+ eq(2, api.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.nvim_get_var('a'))
+ eq(0, api.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.nvim_get_var('a'))
+ eq(1, api.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 8f54cce444..ef0359263e 100644
--- a/test/functional/vimscript/json_functions_spec.lua
+++ b/test/functional/vimscript/json_functions_spec.lua
@@ -1,7 +1,7 @@
local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
-local funcs = helpers.funcs
-local meths = helpers.meths
+local fn = helpers.fn
+local api = helpers.api
local eq = helpers.eq
local eval = helpers.eval
local command = helpers.command
@@ -59,13 +59,13 @@ describe('json_decode() function', function()
before_each(restart)
local speq = function(expected, actual_expr)
- eq(1, funcs.EvalEq(expected, actual_expr))
+ eq(1, fn.EvalEq(expected, actual_expr))
end
it('accepts readfile()-style list', function()
eq(
{ Test = 1 },
- funcs.json_decode({
+ fn.json_decode({
'{',
'\t"Test": 1',
'}',
@@ -76,7 +76,7 @@ describe('json_decode() function', function()
it('accepts strings with newlines', function()
eq(
{ Test = 1 },
- funcs.json_decode([[
+ fn.json_decode([[
{
"Test": 1
}
@@ -85,9 +85,9 @@ describe('json_decode() function', function()
end)
it('parses null, true, false', function()
- eq(NIL, funcs.json_decode('null'))
- eq(true, funcs.json_decode('true'))
- eq(false, funcs.json_decode('false'))
+ eq(NIL, fn.json_decode('null'))
+ eq(true, fn.json_decode('true'))
+ eq(false, fn.json_decode('false'))
end)
it('fails to parse incomplete null, true, false', function()
@@ -109,12 +109,12 @@ describe('json_decode() function', function()
end)
it('parses integer numbers', function()
- eq(100000, funcs.json_decode('100000'))
- eq(-100000, funcs.json_decode('-100000'))
- eq(100000, funcs.json_decode(' 100000 '))
- eq(-100000, funcs.json_decode(' -100000 '))
- eq(0, funcs.json_decode('0'))
- eq(0, funcs.json_decode('-0'))
+ eq(100000, fn.json_decode('100000'))
+ eq(-100000, fn.json_decode('-100000'))
+ eq(100000, fn.json_decode(' 100000 '))
+ eq(-100000, fn.json_decode(' -100000 '))
+ eq(0, fn.json_decode('0'))
+ eq(0, fn.json_decode('-0'))
end)
it('fails to parse +numbers and .number', function()
@@ -158,35 +158,35 @@ describe('json_decode() function', function()
it('parses floating-point numbers', function()
-- Also test method call (->) syntax
eq('100000.0', eval('"100000.0"->json_decode()->string()'))
- eq(100000.5, funcs.json_decode('100000.5'))
- eq(-100000.5, funcs.json_decode('-100000.5'))
- eq(-100000.5e50, funcs.json_decode('-100000.5e50'))
- eq(100000.5e50, funcs.json_decode('100000.5e50'))
- eq(100000.5e50, funcs.json_decode('100000.5e+50'))
- eq(-100000.5e-50, funcs.json_decode('-100000.5e-50'))
- eq(100000.5e-50, funcs.json_decode('100000.5e-50'))
- eq(100000e-50, funcs.json_decode('100000e-50'))
- eq(0.5, funcs.json_decode('0.5'))
- eq(0.005, funcs.json_decode('0.005'))
- eq(0.005, funcs.json_decode('0.00500'))
- eq(0.5, funcs.json_decode('0.00500e+002'))
- eq(0.00005, funcs.json_decode('0.00500e-002'))
-
- eq(-0.0, funcs.json_decode('-0.0'))
- eq(-0.0, funcs.json_decode('-0.0e0'))
- eq(-0.0, funcs.json_decode('-0.0e+0'))
- eq(-0.0, funcs.json_decode('-0.0e-0'))
- eq(-0.0, funcs.json_decode('-0e-0'))
- eq(-0.0, funcs.json_decode('-0e-2'))
- eq(-0.0, funcs.json_decode('-0e+2'))
-
- eq(0.0, funcs.json_decode('0.0'))
- eq(0.0, funcs.json_decode('0.0e0'))
- eq(0.0, funcs.json_decode('0.0e+0'))
- eq(0.0, funcs.json_decode('0.0e-0'))
- eq(0.0, funcs.json_decode('0e-0'))
- eq(0.0, funcs.json_decode('0e-2'))
- eq(0.0, funcs.json_decode('0e+2'))
+ eq(100000.5, fn.json_decode('100000.5'))
+ eq(-100000.5, fn.json_decode('-100000.5'))
+ eq(-100000.5e50, fn.json_decode('-100000.5e50'))
+ eq(100000.5e50, fn.json_decode('100000.5e50'))
+ eq(100000.5e50, fn.json_decode('100000.5e+50'))
+ eq(-100000.5e-50, fn.json_decode('-100000.5e-50'))
+ eq(100000.5e-50, fn.json_decode('100000.5e-50'))
+ eq(100000e-50, fn.json_decode('100000e-50'))
+ eq(0.5, fn.json_decode('0.5'))
+ eq(0.005, fn.json_decode('0.005'))
+ eq(0.005, fn.json_decode('0.00500'))
+ eq(0.5, fn.json_decode('0.00500e+002'))
+ eq(0.00005, fn.json_decode('0.00500e-002'))
+
+ eq(-0.0, fn.json_decode('-0.0'))
+ eq(-0.0, fn.json_decode('-0.0e0'))
+ eq(-0.0, fn.json_decode('-0.0e+0'))
+ eq(-0.0, fn.json_decode('-0.0e-0'))
+ eq(-0.0, fn.json_decode('-0e-0'))
+ eq(-0.0, fn.json_decode('-0e-2'))
+ eq(-0.0, fn.json_decode('-0e+2'))
+
+ eq(0.0, fn.json_decode('0.0'))
+ eq(0.0, fn.json_decode('0.0e0'))
+ eq(0.0, fn.json_decode('0.0e+0'))
+ eq(0.0, fn.json_decode('0.0e-0'))
+ eq(0.0, fn.json_decode('0e-0'))
+ eq(0.0, fn.json_decode('0e-2'))
+ eq(0.0, fn.json_decode('0e+2'))
end)
it('fails to parse numbers with spaces inside', function()
@@ -210,7 +210,7 @@ describe('json_decode() function', function()
end)
it('parses empty containers', function()
- eq({}, funcs.json_decode('[]'))
+ eq({}, fn.json_decode('[]'))
eq('[]', eval('string(json_decode("[]"))'))
end)
@@ -301,12 +301,12 @@ describe('json_decode() function', function()
end)
it('parses containers', function()
- eq({ 1 }, funcs.json_decode('[1]'))
- eq({ NIL, 1 }, funcs.json_decode('[null, 1]'))
- eq({ ['1'] = 2 }, funcs.json_decode('{"1": 2}'))
+ eq({ 1 }, fn.json_decode('[1]'))
+ eq({ NIL, 1 }, fn.json_decode('[null, 1]'))
+ eq({ ['1'] = 2 }, fn.json_decode('{"1": 2}'))
eq(
{ ['1'] = 2, ['3'] = { { ['4'] = { ['5'] = { {}, 1 } } } } },
- funcs.json_decode('{"1": 2, "3": [{"4": {"5": [[], 1]}}]}')
+ fn.json_decode('{"1": 2, "3": [{"4": {"5": [[], 1]}}]}')
)
end)
@@ -363,10 +363,10 @@ describe('json_decode() function', function()
end)
it('parses strings properly', function()
- eq('\n', funcs.json_decode('"\\n"'))
- eq('', funcs.json_decode('""'))
- eq('\\/"\t\b\n\r\f', funcs.json_decode([["\\\/\"\t\b\n\r\f"]]))
- eq('/a', funcs.json_decode([["\/a"]]))
+ eq('\n', fn.json_decode('"\\n"'))
+ eq('', fn.json_decode('""'))
+ eq('\\/"\t\b\n\r\f', fn.json_decode([["\\\/\"\t\b\n\r\f"]]))
+ eq('/a', fn.json_decode([["\/a"]]))
-- Unicode characters: 2-byte, 3-byte, 4-byte
eq(
{
@@ -374,7 +374,7 @@ describe('json_decode() function', function()
'ફ',
'\240\144\128\128',
},
- funcs.json_decode({
+ fn.json_decode({
'[',
'"«",',
'"ફ",',
@@ -472,29 +472,29 @@ describe('json_decode() function', function()
end)
it('parses surrogate pairs properly', function()
- eq('\240\144\128\128', funcs.json_decode('"\\uD800\\uDC00"'))
- eq('\237\160\128a\237\176\128', funcs.json_decode('"\\uD800a\\uDC00"'))
- eq('\237\160\128\t\237\176\128', funcs.json_decode('"\\uD800\\t\\uDC00"'))
+ eq('\240\144\128\128', fn.json_decode('"\\uD800\\uDC00"'))
+ eq('\237\160\128a\237\176\128', fn.json_decode('"\\uD800a\\uDC00"'))
+ eq('\237\160\128\t\237\176\128', fn.json_decode('"\\uD800\\t\\uDC00"'))
- eq('\237\160\128', funcs.json_decode('"\\uD800"'))
- eq('\237\160\128a', funcs.json_decode('"\\uD800a"'))
- eq('\237\160\128\t', funcs.json_decode('"\\uD800\\t"'))
+ eq('\237\160\128', fn.json_decode('"\\uD800"'))
+ eq('\237\160\128a', fn.json_decode('"\\uD800a"'))
+ eq('\237\160\128\t', fn.json_decode('"\\uD800\\t"'))
- eq('\237\176\128', funcs.json_decode('"\\uDC00"'))
- eq('\237\176\128a', funcs.json_decode('"\\uDC00a"'))
- eq('\237\176\128\t', funcs.json_decode('"\\uDC00\\t"'))
+ eq('\237\176\128', fn.json_decode('"\\uDC00"'))
+ eq('\237\176\128a', fn.json_decode('"\\uDC00a"'))
+ eq('\237\176\128\t', fn.json_decode('"\\uDC00\\t"'))
- eq('\237\176\128', funcs.json_decode('"\\uDC00"'))
- eq('a\237\176\128', funcs.json_decode('"a\\uDC00"'))
- eq('\t\237\176\128', funcs.json_decode('"\\t\\uDC00"'))
+ eq('\237\176\128', fn.json_decode('"\\uDC00"'))
+ eq('a\237\176\128', fn.json_decode('"a\\uDC00"'))
+ eq('\t\237\176\128', fn.json_decode('"\\t\\uDC00"'))
- eq('\237\160\128¬', funcs.json_decode('"\\uD800\\u00AC"'))
+ eq('\237\160\128¬', fn.json_decode('"\\uD800\\u00AC"'))
- eq('\237\160\128\237\160\128', funcs.json_decode('"\\uD800\\uD800"'))
+ eq('\237\160\128\237\160\128', fn.json_decode('"\\uD800\\uD800"'))
end)
local sp_decode_eq = function(expected, json)
- meths.nvim_set_var('__json', json)
+ api.nvim_set_var('__json', json)
speq(expected, 'json_decode(g:__json)')
command('unlet! g:__json')
end
@@ -570,10 +570,10 @@ describe('json_decode() function', function()
end)
it('parses dictionaries with empty keys', function()
- eq({ [''] = 4 }, funcs.json_decode('{"": 4}'))
+ eq({ [''] = 4 }, fn.json_decode('{"": 4}'))
eq(
{ b = 3, a = 1, c = 4, d = 2, [''] = 4 },
- funcs.json_decode('{"b": 3, "a": 1, "c": 4, "d": 2, "": 4}')
+ fn.json_decode('{"b": 3, "a": 1, "c": 4, "d": 2, "": 4}')
)
end)
@@ -602,7 +602,7 @@ describe('json_decode() function', function()
end)
it('parses U+00C3 correctly', function()
- eq('\195\131', funcs.json_decode('"\195\131"'))
+ eq('\195\131', fn.json_decode('"\195\131"'))
end)
it('fails to parse empty string', function()
@@ -622,7 +622,7 @@ describe('json_decode() function', function()
local s =
' \t\n\r \t\r\n \n\t\r \n\r\t \r\t\n \r\n\t\t \n\r\t \r\n\t\n \r\t\n\r \t\r \n\t\r\n \n \t\r\n \r\t\n\t \r\n\t\r \n\r \t\n\r\t \r \t\n\r \n\t\r\t \n\r\t\n \r\n \t\r\n\t'
local str = ('%s{%s"key"%s:%s[%s"val"%s,%s"val2"%s]%s,%s"key2"%s:%s1%s}%s'):gsub('%%s', s)
- eq({ key = { 'val', 'val2' }, key2 = 1 }, funcs.json_decode(str))
+ eq({ key = { 'val', 'val2' }, key2 = 1 }, fn.json_decode(str))
end)
it('does not overflow when writing error message about decoding ["", ""]', function()
@@ -640,12 +640,12 @@ describe('json_encode() function', function()
end)
it('dumps strings', function()
- eq('"Test"', funcs.json_encode('Test'))
- eq('""', funcs.json_encode(''))
- eq('"\\t"', funcs.json_encode('\t'))
- eq('"\\n"', funcs.json_encode('\n'))
- eq('"\\u001B"', funcs.json_encode('\27'))
- eq('"þÿþ"', funcs.json_encode('þÿþ'))
+ eq('"Test"', fn.json_encode('Test'))
+ eq('""', fn.json_encode(''))
+ eq('"\\t"', fn.json_encode('\t'))
+ eq('"\\n"', fn.json_encode('\n'))
+ eq('"\\u001B"', fn.json_encode('\27'))
+ eq('"þÿþ"', fn.json_encode('þÿþ'))
end)
it('dumps blobs', function()
@@ -654,17 +654,17 @@ describe('json_encode() function', function()
end)
it('dumps numbers', function()
- eq('0', funcs.json_encode(0))
- eq('10', funcs.json_encode(10))
- eq('-10', funcs.json_encode(-10))
+ eq('0', fn.json_encode(0))
+ eq('10', fn.json_encode(10))
+ eq('-10', fn.json_encode(-10))
end)
it('dumps floats', function()
-- Also test method call (->) syntax
eq('0.0', eval('0.0->json_encode()'))
- eq('10.5', funcs.json_encode(10.5))
- eq('-10.5', funcs.json_encode(-10.5))
- eq('-1.0e-5', funcs.json_encode(-1e-5))
+ eq('10.5', fn.json_encode(10.5))
+ eq('-10.5', fn.json_encode(-10.5))
+ eq('-1.0e-5', fn.json_encode(-1e-5))
eq('1.0e50', eval('1.0e50->json_encode()'))
end)
@@ -684,17 +684,17 @@ describe('json_encode() function', function()
end)
it('dumps lists', function()
- eq('[]', funcs.json_encode({}))
- eq('[[]]', funcs.json_encode({ {} }))
- eq('[[], []]', funcs.json_encode({ {}, {} }))
+ eq('[]', fn.json_encode({}))
+ eq('[[]]', fn.json_encode({ {} }))
+ eq('[[], []]', fn.json_encode({ {}, {} }))
end)
it('dumps dictionaries', function()
eq('{}', eval('json_encode({})'))
- eq('{"d": []}', funcs.json_encode({ d = {} }))
- eq('{"d": [], "e": []}', funcs.json_encode({ d = {}, e = {} }))
+ eq('{"d": []}', fn.json_encode({ d = {} }))
+ eq('{"d": [], "e": []}', fn.json_encode({ d = {}, e = {} }))
-- Empty keys are allowed per JSON spec (and Vim dicts, and msgpack).
- eq('{"": []}', funcs.json_encode({ [''] = {} }))
+ eq('{"": []}', fn.json_encode({ [''] = {} }))
end)
it('cannot dump generic mapping with generic mapping keys and values', function()
@@ -892,9 +892,9 @@ describe('json_encode() function', function()
end)
it('ignores improper values in &isprint', function()
- meths.nvim_set_option_value('isprint', '1', {})
+ api.nvim_set_option_value('isprint', '1', {})
eq(1, eval('"\1" =~# "\\\\p"'))
- eq('"\\u0001"', funcs.json_encode('\1'))
+ eq('"\\u0001"', fn.json_encode('\1'))
end)
it('fails when using surrogate character in a UTF-8 string', function()
diff --git a/test/functional/vimscript/let_spec.lua b/test/functional/vimscript/let_spec.lua
index 7c632fc67e..15d4b189b8 100644
--- a/test/functional/vimscript/let_spec.lua
+++ b/test/functional/vimscript/let_spec.lua
@@ -4,7 +4,7 @@ local eq = helpers.eq
local clear = helpers.clear
local command = helpers.command
local eval = helpers.eval
-local meths = helpers.meths
+local api = helpers.api
local exec = helpers.exec
local exec_capture = helpers.exec_capture
local expect_exit = helpers.expect_exit
@@ -15,12 +15,12 @@ before_each(clear)
describe(':let', function()
it('correctly lists variables with curly-braces', function()
- meths.nvim_set_var('v', { 0 })
+ api.nvim_set_var('v', { 0 })
eq('v [0]', exec_capture('let {"v"}'))
end)
it('correctly lists variables with subscript', function()
- meths.nvim_set_var('v', { 0 })
+ api.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.nvim_get_option_value('equalalways', {}))
+ eq(true, api.nvim_get_option_value('equalalways', {}))
command('let &equalalways -= 1')
- eq(false, meths.nvim_get_option_value('equalalways', {}))
+ eq(false, api.nvim_get_option_value('equalalways', {}))
command('let &equalalways += 1')
- eq(true, meths.nvim_get_option_value('equalalways', {}))
+ eq(true, api.nvim_get_option_value('equalalways', {}))
command('let &equalalways *= 1')
- eq(true, meths.nvim_get_option_value('equalalways', {}))
+ eq(true, api.nvim_get_option_value('equalalways', {}))
command('let &equalalways /= 1')
- eq(true, meths.nvim_get_option_value('equalalways', {}))
+ eq(true, api.nvim_get_option_value('equalalways', {}))
command('let &equalalways %= 1')
- eq(false, meths.nvim_get_option_value('equalalways', {}))
+ eq(false, api.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 9edf54898b..59d427ca90 100644
--- a/test/functional/vimscript/map_functions_spec.lua
+++ b/test/functional/vimscript/map_functions_spec.lua
@@ -7,8 +7,8 @@ local exec = helpers.exec
local exec_lua = helpers.exec_lua
local expect = helpers.expect
local feed = helpers.feed
-local funcs = helpers.funcs
-local meths = helpers.meths
+local fn = helpers.fn
+local api = helpers.api
local source = helpers.source
local command = helpers.command
local exec_capture = helpers.exec_capture
@@ -37,32 +37,32 @@ describe('maparg()', function()
it('returns a dictionary', function()
command('nnoremap foo bar')
- eq('bar', funcs.maparg('foo'))
- eq(foo_bar_map_table, funcs.maparg('foo', 'n', false, true))
+ eq('bar', fn.maparg('foo'))
+ eq(foo_bar_map_table, fn.maparg('foo', 'n', false, true))
end)
it('returns 1 for silent when <silent> is used', function()
command('nnoremap <silent> foo bar')
- eq(1, funcs.maparg('foo', 'n', false, true)['silent'])
+ eq(1, fn.maparg('foo', 'n', false, true)['silent'])
command('nnoremap baz bat')
- eq(0, funcs.maparg('baz', 'n', false, true)['silent'])
+ eq(0, fn.maparg('baz', 'n', false, true)['silent'])
end)
it('returns an empty string when no map is present', function()
- eq('', funcs.maparg('not a mapping'))
+ eq('', fn.maparg('not a mapping'))
end)
it('returns an empty dictionary when no map is present and dict is requested', function()
- eq({}, funcs.maparg('not a mapping', 'n', false, true))
+ eq({}, fn.maparg('not a mapping', 'n', false, true))
end)
it('returns the same value for noremap and <script>', function()
command('inoremap <script> hello world')
command('inoremap this that')
eq(
- funcs.maparg('hello', 'i', false, true)['noremap'],
- funcs.maparg('this', 'i', false, true)['noremap']
+ fn.maparg('hello', 'i', false, true)['noremap'],
+ fn.maparg('this', 'i', false, true)['noremap']
)
end)
@@ -72,11 +72,11 @@ describe('maparg()', function()
command('new')
command('new')
command('cnoremap <buffer> this that')
- eq(1, funcs.maparg('this', 'c', false, true)['buffer'])
+ eq(1, fn.maparg('this', 'c', false, true)['buffer'])
-- Global will return 0 always
command('nnoremap other another')
- eq(0, funcs.maparg('other', 'n', false, true)['buffer'])
+ eq(0, fn.maparg('other', 'n', false, true)['buffer'])
end)
it('returns script numbers', function()
@@ -87,8 +87,8 @@ describe('maparg()', function()
nnoremap fizz :call <SID>maparg_test_function()<CR>
]])
- eq(1, funcs.maparg('fizz', 'n', false, true)['sid'])
- eq('testing', meths.nvim_call_function('<SNR>1_maparg_test_function', {}))
+ eq(1, fn.maparg('fizz', 'n', false, true)['sid'])
+ eq('testing', api.nvim_call_function('<SNR>1_maparg_test_function', {}))
end)
it('works with <F12> and others', function()
@@ -103,7 +103,7 @@ describe('maparg()', function()
]])
eq(1, eval('g:maparg_test_var'))
- eq(':let g:maparg_test_var = 1<CR>', funcs.maparg('<F12>', 'n', false, true)['rhs'])
+ eq(':let g:maparg_test_var = 1<CR>', fn.maparg('<F12>', 'n', false, true)['rhs'])
end)
it('works with <expr>', function()
@@ -126,7 +126,7 @@ describe('maparg()', function()
]])
eq(1, eval('g:counter'))
- local map_dict = funcs.maparg('<C-L>', 'i', false, true)
+ local map_dict = fn.maparg('<C-L>', 'i', false, true)
eq(1, map_dict['expr'])
eq('i', map_dict['mode'])
end)
@@ -143,10 +143,10 @@ describe('maparg()', function()
nnoremap c` d
nnoremap e` f`
]]))
- eq(ac('b`'), funcs.maparg(ac('a')))
- eq(ac(''), funcs.maparg(ac('c')))
- eq(ac('d'), funcs.maparg(ac('c`')))
- eq(ac('f`'), funcs.maparg(ac('e`')))
+ eq(ac('b`'), fn.maparg(ac('a')))
+ eq(ac(''), fn.maparg(ac('c')))
+ eq(ac('d'), fn.maparg(ac('c`')))
+ eq(ac('f`'), fn.maparg(ac('e`')))
local function acmap(lhs, rhs)
return {
@@ -169,10 +169,10 @@ describe('maparg()', function()
}
end
- eq({}, funcs.maparg(ac('c'), 'n', 0, 1))
- eq(acmap('a', 'b`'), funcs.maparg(ac('a'), 'n', 0, 1))
- eq(acmap('c`', 'd'), funcs.maparg(ac('c`'), 'n', 0, 1))
- eq(acmap('e`', 'f`'), funcs.maparg(ac('e`'), 'n', 0, 1))
+ eq({}, fn.maparg(ac('c'), 'n', 0, 1))
+ eq(acmap('a', 'b`'), fn.maparg(ac('a'), 'n', 0, 1))
+ eq(acmap('c`', 'd'), fn.maparg(ac('c`'), 'n', 0, 1))
+ eq(acmap('e`', 'f`'), fn.maparg(ac('e`'), 'n', 0, 1))
end)
end)
@@ -180,34 +180,34 @@ describe('mapset()', function()
before_each(clear)
it('can restore mapping with backslash in lhs', function()
- meths.nvim_set_keymap('n', '\\ab', 'a', {})
+ api.nvim_set_keymap('n', '\\ab', 'a', {})
eq('\nn \\ab a', exec_capture('nmap \\ab'))
- local mapargs = funcs.maparg('\\ab', 'n', false, true)
- meths.nvim_set_keymap('n', '\\ab', 'b', {})
+ local mapargs = fn.maparg('\\ab', 'n', false, true)
+ api.nvim_set_keymap('n', '\\ab', 'b', {})
eq('\nn \\ab b', exec_capture('nmap \\ab'))
- funcs.mapset('n', false, mapargs)
+ fn.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.nvim_set_keymap('n', 'lhs', 'rhs', { desc = 'map description' })
+ api.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.nvim_set_keymap('n', 'lhs', 'rhs', { desc = 'MAP DESCRIPTION' })
+ local mapargs = fn.maparg('lhs', 'n', false, true)
+ api.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)
+ fn.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.nvim_set_keymap('i', 'foo', [['<l' .. 't>']], { expr = true, replace_keycodes = true })
+ api.nvim_set_keymap('i', 'foo', [['<l' .. 't>']], { expr = true, replace_keycodes = true })
feed('Afoo')
expect('<')
- local mapargs = funcs.maparg('foo', 'i', false, true)
- meths.nvim_set_keymap('i', 'foo', [['<l' .. 't>']], { expr = true })
+ local mapargs = fn.maparg('foo', 'i', false, true)
+ api.nvim_set_keymap('i', 'foo', [['<l' .. 't>']], { expr = true })
feed('foo')
expect('<<lt>')
- funcs.mapset('i', false, mapargs)
+ fn.mapset('i', false, mapargs)
feed('foo')
expect('<<lt><')
end)
@@ -217,12 +217,12 @@ describe('mapset()', function()
eq('\ni foo * bar', exec_capture('iabbr foo'))
feed('ifoo ')
expect('bar ')
- local mapargs = funcs.maparg('foo', 'i', true, true)
+ local mapargs = fn.maparg('foo', 'i', true, true)
command('inoreabbr foo BAR')
eq('\ni foo * BAR', exec_capture('iabbr foo'))
feed('foo ')
expect('bar BAR ')
- funcs.mapset('i', true, mapargs)
+ fn.mapset('i', true, mapargs)
eq('\ni foo * bar', exec_capture('iabbr foo'))
feed('foo<Esc>')
expect('bar BAR bar')
diff --git a/test/functional/vimscript/match_functions_spec.lua b/test/functional/vimscript/match_functions_spec.lua
index 8092d140c8..3db612e472 100644
--- a/test/functional/vimscript/match_functions_spec.lua
+++ b/test/functional/vimscript/match_functions_spec.lua
@@ -3,7 +3,7 @@ local Screen = require('test.functional.ui.screen')
local eq = helpers.eq
local clear = helpers.clear
-local funcs = helpers.funcs
+local fn = helpers.fn
local command = helpers.command
local exc_exec = helpers.exc_exec
@@ -12,7 +12,7 @@ before_each(clear)
describe('setmatches()', function()
it('correctly handles case when both group and pattern entries are numbers', function()
command('hi def link 1 PreProc')
- eq(0, funcs.setmatches({ { group = 1, pattern = 2, id = 3, priority = 4 } }))
+ eq(0, fn.setmatches({ { group = 1, pattern = 2, id = 3, priority = 4 } }))
eq({
{
group = '1',
@@ -20,8 +20,8 @@ describe('setmatches()', function()
id = 3,
priority = 4,
},
- }, funcs.getmatches())
- eq(0, funcs.setmatches({ { group = 1, pattern = 2, id = 3, priority = 4, conceal = 5 } }))
+ }, fn.getmatches())
+ eq(0, fn.setmatches({ { group = 1, pattern = 2, id = 3, priority = 4, conceal = 5 } }))
eq({
{
group = '1',
@@ -30,10 +30,10 @@ describe('setmatches()', function()
priority = 4,
conceal = '5',
},
- }, funcs.getmatches())
+ }, fn.getmatches())
eq(
0,
- funcs.setmatches({
+ fn.setmatches({
{ group = 1, pos1 = { 2 }, pos2 = { 6 }, id = 3, priority = 4, conceal = 5 },
})
)
@@ -46,21 +46,21 @@ describe('setmatches()', function()
priority = 4,
conceal = '5',
},
- }, funcs.getmatches())
+ }, fn.getmatches())
end)
it('does not fail if highlight group is not defined', function()
- eq(0, funcs.setmatches { { group = 1, pattern = 2, id = 3, priority = 4 } })
- eq({ { group = '1', pattern = '2', id = 3, priority = 4 } }, funcs.getmatches())
+ eq(0, fn.setmatches { { group = 1, pattern = 2, id = 3, priority = 4 } })
+ eq({ { group = '1', pattern = '2', id = 3, priority = 4 } }, fn.getmatches())
eq(
0,
- funcs.setmatches {
+ fn.setmatches {
{ group = 1, pos1 = { 2 }, pos2 = { 6 }, id = 3, priority = 4, conceal = 5 },
}
)
eq(
{ { group = '1', pos1 = { 2 }, pos2 = { 6 }, id = 3, priority = 4, conceal = '5' } },
- funcs.getmatches()
+ fn.getmatches()
)
end)
end)
@@ -68,7 +68,7 @@ end)
describe('matchadd()', function()
it('correctly works when first two arguments and conceal are numbers at once', function()
command('hi def link 1 PreProc')
- eq(4, funcs.matchadd(1, 2, 3, 4, { conceal = 5 }))
+ eq(4, fn.matchadd(1, 2, 3, 4, { conceal = 5 }))
eq({
{
group = '1',
@@ -77,7 +77,7 @@ describe('matchadd()', function()
id = 4,
conceal = '5',
},
- }, funcs.getmatches())
+ }, fn.getmatches())
end)
end)
@@ -99,7 +99,7 @@ describe('matchaddpos()', function()
end)
it('works with 0 lnum', function()
command('hi clear PreProc')
- eq(4, funcs.matchaddpos('PreProc', { 1 }, 3, 4))
+ eq(4, fn.matchaddpos('PreProc', { 1 }, 3, 4))
eq({
{
group = 'PreProc',
@@ -107,9 +107,9 @@ describe('matchaddpos()', function()
priority = 3,
id = 4,
},
- }, funcs.getmatches())
- funcs.matchdelete(4)
- eq(4, funcs.matchaddpos('PreProc', { { 0 }, 1 }, 3, 4))
+ }, fn.getmatches())
+ fn.matchdelete(4)
+ eq(4, fn.matchaddpos('PreProc', { { 0 }, 1 }, 3, 4))
eq({
{
group = 'PreProc',
@@ -117,9 +117,9 @@ describe('matchaddpos()', function()
priority = 3,
id = 4,
},
- }, funcs.getmatches())
- funcs.matchdelete(4)
- eq(4, funcs.matchaddpos('PreProc', { 0, 1 }, 3, 4))
+ }, fn.getmatches())
+ fn.matchdelete(4)
+ eq(4, fn.matchaddpos('PreProc', { 0, 1 }, 3, 4))
eq({
{
group = 'PreProc',
@@ -127,11 +127,11 @@ describe('matchaddpos()', function()
priority = 3,
id = 4,
},
- }, funcs.getmatches())
+ }, fn.getmatches())
end)
it('works with negative numbers', function()
command('hi clear PreProc')
- eq(4, funcs.matchaddpos('PreProc', { -10, 1 }, 3, 4))
+ eq(4, fn.matchaddpos('PreProc', { -10, 1 }, 3, 4))
eq({
{
group = 'PreProc',
@@ -139,9 +139,9 @@ describe('matchaddpos()', function()
priority = 3,
id = 4,
},
- }, funcs.getmatches())
- funcs.matchdelete(4)
- eq(4, funcs.matchaddpos('PreProc', { { -10 }, 1 }, 3, 4))
+ }, fn.getmatches())
+ fn.matchdelete(4)
+ eq(4, fn.matchaddpos('PreProc', { { -10 }, 1 }, 3, 4))
eq({
{
group = 'PreProc',
@@ -149,9 +149,9 @@ describe('matchaddpos()', function()
priority = 3,
id = 4,
},
- }, funcs.getmatches())
- funcs.matchdelete(4)
- eq(4, funcs.matchaddpos('PreProc', { { 2, -1 }, 1 }, 3, 4))
+ }, fn.getmatches())
+ fn.matchdelete(4)
+ eq(4, fn.matchaddpos('PreProc', { { 2, -1 }, 1 }, 3, 4))
eq({
{
group = 'PreProc',
@@ -159,9 +159,9 @@ describe('matchaddpos()', function()
priority = 3,
id = 4,
},
- }, funcs.getmatches())
- funcs.matchdelete(4)
- eq(4, funcs.matchaddpos('PreProc', { { 2, 0, -1 }, 1 }, 3, 4))
+ }, fn.getmatches())
+ fn.matchdelete(4)
+ eq(4, fn.matchaddpos('PreProc', { { 2, 0, -1 }, 1 }, 3, 4))
eq({
{
group = 'PreProc',
@@ -169,14 +169,14 @@ describe('matchaddpos()', function()
priority = 3,
id = 4,
},
- }, funcs.getmatches())
+ }, fn.getmatches())
end)
it('works with zero length', function()
local screen = Screen.new(40, 5)
screen:attach()
- funcs.setline(1, 'abcdef')
+ fn.setline(1, 'abcdef')
command('hi PreProc guifg=Red')
- eq(4, funcs.matchaddpos('PreProc', { { 1, 2, 0 } }, 3, 4))
+ eq(4, fn.matchaddpos('PreProc', { { 1, 2, 0 } }, 3, 4))
eq({
{
group = 'PreProc',
@@ -184,7 +184,7 @@ describe('matchaddpos()', function()
priority = 3,
id = 4,
},
- }, funcs.getmatches())
+ }, fn.getmatches())
screen:expect(
[[
^a{1:b}cdef |
diff --git a/test/functional/vimscript/minmax_functions_spec.lua b/test/functional/vimscript/minmax_functions_spec.lua
index a618782f88..c4a986bc8c 100644
--- a/test/functional/vimscript/minmax_functions_spec.lua
+++ b/test/functional/vimscript/minmax_functions_spec.lua
@@ -4,7 +4,7 @@ local eq = helpers.eq
local eval = helpers.eval
local command = helpers.command
local clear = helpers.clear
-local funcs = helpers.funcs
+local fn = helpers.fn
local pcall_err = helpers.pcall_err
before_each(clear)
@@ -30,12 +30,12 @@ for _, func in ipairs({ 'min', 'max' }) do
end
end)
it('works with arrays/dictionaries with zero items', function()
- eq(0, funcs[func]({}))
+ eq(0, fn[func]({}))
eq(0, eval(func .. '({})'))
end)
it('works with arrays/dictionaries with one item', function()
- eq(5, funcs[func]({ 5 }))
- eq(5, funcs[func]({ test = 5 }))
+ eq(5, fn[func]({ 5 }))
+ eq(5, fn[func]({ test = 5 }))
end)
it('works with NULL arrays/dictionaries', function()
eq(0, eval(func .. '(v:_null_list)'))
diff --git a/test/functional/vimscript/msgpack_functions_spec.lua b/test/functional/vimscript/msgpack_functions_spec.lua
index b6980befd9..609a706155 100644
--- a/test/functional/vimscript/msgpack_functions_spec.lua
+++ b/test/functional/vimscript/msgpack_functions_spec.lua
@@ -1,9 +1,9 @@
local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
-local funcs = helpers.funcs
+local fn = helpers.fn
local eval, eq = helpers.eval, helpers.eq
local command = helpers.command
-local meths = helpers.meths
+local api = helpers.api
local exc_exec = helpers.exc_exec
local is_os = helpers.is_os
@@ -12,7 +12,7 @@ describe('msgpack*() functions', function()
local obj_test = function(msg, obj)
it(msg, function()
- meths.nvim_set_var('obj', obj)
+ api.nvim_set_var('obj', obj)
eq(obj, eval('msgpackparse(msgpackdump(g:obj))'))
eq(obj, eval('msgpackparse(msgpackdump(g:obj, "B"))'))
end)
@@ -406,7 +406,7 @@ local parse_eq = function(expect, list_arg)
.. blobstr(list_arg):gsub('(.)', function(c)
return ('%.2x'):format(c:byte())
end)
- eq(expect, funcs.msgpackparse(list_arg))
+ eq(expect, fn.msgpackparse(list_arg))
command('let g:parsed = msgpackparse(' .. blob_expr .. ')')
eq(expect, eval('g:parsed'))
end
diff --git a/test/functional/vimscript/null_spec.lua b/test/functional/vimscript/null_spec.lua
index 2e96ccfead..805cd13844 100644
--- a/test/functional/vimscript/null_spec.lua
+++ b/test/functional/vimscript/null_spec.lua
@@ -3,20 +3,20 @@ local helpers = require('test.functional.helpers')(after_each)
local exc_exec = helpers.exc_exec
local command = helpers.command
local clear = helpers.clear
-local meths = helpers.meths
-local funcs = helpers.funcs
+local api = helpers.api
+local fn = helpers.fn
local eq = helpers.eq
local function redir_exec(cmd)
- meths.nvim_set_var('__redir_exec_cmd', cmd)
+ api.nvim_set_var('__redir_exec_cmd', cmd)
command([[
redir => g:__redir_exec_output
silent! execute g:__redir_exec_cmd
redir END
]])
- local ret = meths.nvim_get_var('__redir_exec_output')
- meths.nvim_del_var('__redir_exec_output')
- meths.nvim_del_var('__redir_exec_cmd')
+ local ret = api.nvim_get_var('__redir_exec_output')
+ api.nvim_del_var('__redir_exec_output')
+ api.nvim_del_var('__redir_exec_cmd')
return ret
end
@@ -41,9 +41,9 @@ describe('NULL', function()
it(name, function()
eq((err == 0) and '' or ('\n' .. err), redir_exec('let g:_var = ' .. expr))
if val == nil then
- eq(0, funcs.exists('g:_var'))
+ eq(0, fn.exists('g:_var'))
else
- eq(val, meths.nvim_get_var('_var'))
+ eq(val, api.nvim_get_var('_var'))
end
if after ~= nil then
after()
@@ -71,10 +71,10 @@ describe('NULL', function()
null_expr_test('is not locked', 'islocked("v:_null_list")', 0, 0)
null_test('is accepted by :for', 'for x in L|throw x|endfor', 0)
null_expr_test('does not crash append()', 'append(0, L)', 0, 0, function()
- eq({ '' }, meths.nvim_buf_get_lines(0, 0, -1, false))
+ eq({ '' }, api.nvim_buf_get_lines(0, 0, -1, false))
end)
null_expr_test('does not crash setline()', 'setline(1, L)', 0, 0, function()
- eq({ '' }, meths.nvim_buf_get_lines(0, 0, -1, false))
+ eq({ '' }, api.nvim_buf_get_lines(0, 0, -1, false))
end)
null_expr_test('is identical to itself', 'L is L', 0, 1)
null_expr_test('can be sliced', 'L[:]', 0, {})
@@ -183,7 +183,7 @@ describe('NULL', function()
0,
'',
function()
- eq({ '' }, meths.nvim_buf_get_lines(0, 0, -1, false))
+ eq({ '' }, api.nvim_buf_get_lines(0, 0, -1, false))
end
)
null_expr_test('is accepted by setmatches()', 'setmatches(L)', 0, 0)
diff --git a/test/functional/vimscript/printf_spec.lua b/test/functional/vimscript/printf_spec.lua
index f9a7199f11..4fa4ea7f4c 100644
--- a/test/functional/vimscript/printf_spec.lua
+++ b/test/functional/vimscript/printf_spec.lua
@@ -3,56 +3,56 @@ local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
local eq = helpers.eq
local eval = helpers.eval
-local funcs = helpers.funcs
-local meths = helpers.meths
+local fn = helpers.fn
+local api = helpers.api
local exc_exec = helpers.exc_exec
describe('printf()', function()
before_each(clear)
it('works with zero and %b', function()
- eq('0', funcs.printf('%lb', 0))
- eq('0', funcs.printf('%llb', 0))
- eq('0', funcs.printf('%zb', 0))
+ eq('0', fn.printf('%lb', 0))
+ eq('0', fn.printf('%llb', 0))
+ eq('0', fn.printf('%zb', 0))
end)
it('works with one and %b', function()
- eq('1', funcs.printf('%b', 1))
- eq('1', funcs.printf('%lb', 1))
- eq('1', funcs.printf('%llb', 1))
- eq('1', funcs.printf('%zb', 1))
+ eq('1', fn.printf('%b', 1))
+ eq('1', fn.printf('%lb', 1))
+ eq('1', fn.printf('%llb', 1))
+ eq('1', fn.printf('%zb', 1))
end)
it('works with 0xff and %b', function()
- eq('11111111', funcs.printf('%b', 0xff))
- eq('11111111', funcs.printf('%lb', 0xff))
- eq('11111111', funcs.printf('%llb', 0xff))
- eq('11111111', funcs.printf('%zb', 0xff))
+ eq('11111111', fn.printf('%b', 0xff))
+ eq('11111111', fn.printf('%lb', 0xff))
+ eq('11111111', fn.printf('%llb', 0xff))
+ eq('11111111', fn.printf('%zb', 0xff))
end)
it('accepts width modifier with %b', function()
- eq(' 1', funcs.printf('%3b', 1))
+ eq(' 1', fn.printf('%3b', 1))
end)
it('accepts prefix modifier with %b', function()
- eq('0b1', funcs.printf('%#b', 1))
+ eq('0b1', fn.printf('%#b', 1))
end)
it('writes capital B with %B', function()
- eq('0B1', funcs.printf('%#B', 1))
+ eq('0B1', fn.printf('%#B', 1))
end)
it('accepts prefix, zero-fill and width modifiers with %b', function()
- eq('0b001', funcs.printf('%#05b', 1))
+ eq('0b001', fn.printf('%#05b', 1))
end)
it('accepts prefix and width modifiers with %b', function()
- eq(' 0b1', funcs.printf('%#5b', 1))
+ eq(' 0b1', fn.printf('%#5b', 1))
end)
it('does not write prefix for zero with prefix and width modifier used with %b', function()
- eq(' 0', funcs.printf('%#5b', 0))
+ eq(' 0', fn.printf('%#5b', 0))
end)
it('accepts precision modifier with %b', function()
- eq('00000', funcs.printf('%.5b', 0))
+ eq('00000', fn.printf('%.5b', 0))
end)
it('accepts all modifiers with %b at once', function()
-- zero-fill modifier is ignored when used with left-align
-- force-sign and add-blank are ignored
-- use-grouping-characters modifier is ignored always
- eq('0b00011 ', funcs.printf("% '+#0-10.5b", 3))
+ eq('0b00011 ', fn.printf("% '+#0-10.5b", 3))
end)
it('errors out when %b modifier is used for a list', function()
eq('Vim(call):E745: Using a List as a Number', exc_exec('call printf("%b", [])'))
@@ -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.nvim_set_var('__args', {})
+ api.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.nvim_get_var('__result'))
+ eq(id_ret, api.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.nvim_del_var('__result')
+ api.nvim_del_var('__result')
end
check_printf('v:_null_list', true)
check_printf('v:_null_dict', true)
diff --git a/test/functional/vimscript/reltime_spec.lua b/test/functional/vimscript/reltime_spec.lua
index 29a57ad8ff..7cdb78e4ce 100644
--- a/test/functional/vimscript/reltime_spec.lua
+++ b/test/functional/vimscript/reltime_spec.lua
@@ -1,7 +1,7 @@
local helpers = require('test.functional.helpers')(after_each)
local clear, eq, ok = helpers.clear, helpers.eq, helpers.ok
-local neq, command, funcs = helpers.neq, helpers.command, helpers.funcs
-local reltime, reltimestr, reltimefloat = funcs.reltime, funcs.reltimestr, funcs.reltimefloat
+local neq, command, fn = helpers.neq, helpers.command, helpers.fn
+local reltime, reltimestr, reltimefloat = fn.reltime, fn.reltimestr, fn.reltimefloat
describe('reltimestr(), reltimefloat()', function()
before_each(clear)
diff --git a/test/functional/vimscript/screenchar_spec.lua b/test/functional/vimscript/screenchar_spec.lua
index f24aa87ff4..48b6893865 100644
--- a/test/functional/vimscript/screenchar_spec.lua
+++ b/test/functional/vimscript/screenchar_spec.lua
@@ -1,6 +1,6 @@
local helpers = require('test.functional.helpers')(after_each)
local clear, eq, neq = helpers.clear, helpers.eq, helpers.neq
-local command, meths, funcs = helpers.command, helpers.meths, helpers.funcs
+local command, api, fn = helpers.command, helpers.api, helpers.fn
local tbl_deep_extend = vim.tbl_deep_extend
-- Set up two overlapping floating windows
@@ -14,15 +14,15 @@ local setup_floating_windows = function()
border = 'none',
}
- local bufnr_1 = meths.nvim_create_buf(false, true)
- meths.nvim_buf_set_lines(bufnr_1, 0, -1, true, { 'aa' })
+ local bufnr_1 = api.nvim_create_buf(false, true)
+ api.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.nvim_open_win(bufnr_1, false, opts_1)
+ api.nvim_open_win(bufnr_1, false, opts_1)
- local bufnr_2 = meths.nvim_create_buf(false, true)
- meths.nvim_buf_set_lines(bufnr_2, 0, -1, true, { 'bb' })
+ local bufnr_2 = api.nvim_create_buf(false, true)
+ api.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.nvim_open_win(bufnr_2, false, opts_2)
+ api.nvim_open_win(bufnr_2, false, opts_2)
command('redraw')
end
@@ -32,38 +32,38 @@ 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.nvim_buf_set_lines(0, 0, -1, true, { 'cccc' })
+ api.nvim_buf_set_lines(0, 0, -1, true, { 'cccc' })
setup_floating_windows()
end)
it('screenattr()', function()
- local attr_1 = funcs.screenattr(1, 1)
- local attr_2 = funcs.screenattr(1, 2)
- local attr_3 = funcs.screenattr(1, 3)
- local attr_4 = funcs.screenattr(1, 4)
+ local attr_1 = fn.screenattr(1, 1)
+ local attr_2 = fn.screenattr(1, 2)
+ local attr_3 = fn.screenattr(1, 3)
+ local attr_4 = fn.screenattr(1, 4)
eq(attr_1, attr_2)
eq(attr_1, attr_3)
neq(attr_1, attr_4)
end)
it('screenchar()', function()
- eq(97, funcs.screenchar(1, 1))
- eq(97, funcs.screenchar(1, 2))
- eq(98, funcs.screenchar(1, 3))
- eq(99, funcs.screenchar(1, 4))
+ eq(97, fn.screenchar(1, 1))
+ eq(97, fn.screenchar(1, 2))
+ eq(98, fn.screenchar(1, 3))
+ eq(99, fn.screenchar(1, 4))
end)
it('screenchars()', function()
- eq({ 97 }, funcs.screenchars(1, 1))
- eq({ 97 }, funcs.screenchars(1, 2))
- eq({ 98 }, funcs.screenchars(1, 3))
- eq({ 99 }, funcs.screenchars(1, 4))
+ eq({ 97 }, fn.screenchars(1, 1))
+ eq({ 97 }, fn.screenchars(1, 2))
+ eq({ 98 }, fn.screenchars(1, 3))
+ eq({ 99 }, fn.screenchars(1, 4))
end)
it('screenstring()', function()
- eq('a', funcs.screenstring(1, 1))
- eq('a', funcs.screenstring(1, 2))
- eq('b', funcs.screenstring(1, 3))
- eq('c', funcs.screenstring(1, 4))
+ eq('a', fn.screenstring(1, 1))
+ eq('a', fn.screenstring(1, 2))
+ eq('b', fn.screenstring(1, 3))
+ eq('c', fn.screenstring(1, 4))
end)
end)
diff --git a/test/functional/vimscript/screenpos_spec.lua b/test/functional/vimscript/screenpos_spec.lua
index 7edfcac28b..b951d830a6 100644
--- a/test/functional/vimscript/screenpos_spec.lua
+++ b/test/functional/vimscript/screenpos_spec.lua
@@ -1,6 +1,6 @@
local helpers = require('test.functional.helpers')(after_each)
-local clear, eq, meths = helpers.clear, helpers.eq, helpers.meths
-local command, funcs = helpers.command, helpers.funcs
+local clear, eq, api = helpers.clear, helpers.eq, helpers.api
+local command, fn = helpers.command, helpers.fn
local feed = helpers.feed
before_each(clear)
@@ -18,33 +18,33 @@ describe('screenpos() function', function()
border = 'none',
focusable = 1,
}
- local float = meths.nvim_open_win(meths.nvim_create_buf(false, true), false, opts)
+ local float = api.nvim_open_win(api.nvim_create_buf(false, true), false, opts)
command('redraw')
- eq({ row = 7, col = 9, endcol = 9, curscol = 9 }, funcs.screenpos(float, 1, 1))
+ eq({ row = 7, col = 9, endcol = 9, curscol = 9 }, fn.screenpos(float, 1, 1))
-- only left border
opts.border = { '', '', '', '', '', '', '', '|' }
- meths.nvim_win_set_config(float, opts)
+ api.nvim_win_set_config(float, opts)
command('redraw')
- eq({ row = 7, col = 10, endcol = 10, curscol = 10 }, funcs.screenpos(float, 1, 1))
+ eq({ row = 7, col = 10, endcol = 10, curscol = 10 }, fn.screenpos(float, 1, 1))
-- only top border
opts.border = { '', '_', '', '', '', '', '', '' }
- meths.nvim_win_set_config(float, opts)
+ api.nvim_win_set_config(float, opts)
command('redraw')
- eq({ row = 8, col = 9, endcol = 9, curscol = 9 }, funcs.screenpos(float, 1, 1))
+ eq({ row = 8, col = 9, endcol = 9, curscol = 9 }, fn.screenpos(float, 1, 1))
-- both left and top border
opts.border = 'single'
- meths.nvim_win_set_config(float, opts)
+ api.nvim_win_set_config(float, opts)
command('redraw')
- eq({ row = 8, col = 10, endcol = 10, curscol = 10 }, funcs.screenpos(float, 1, 1))
+ eq({ row = 8, col = 10, endcol = 10, curscol = 10 }, fn.screenpos(float, 1, 1))
end)
it('works for folded line with virt_lines attached to line above', function()
- meths.nvim_buf_set_lines(0, 0, -1, true, { 'aaa', 'bbb', 'ccc', 'ddd' })
- local ns = meths.nvim_create_namespace('')
- meths.nvim_buf_set_extmark(
+ api.nvim_buf_set_lines(0, 0, -1, true, { 'aaa', 'bbb', 'ccc', 'ddd' })
+ local ns = api.nvim_create_namespace('')
+ api.nvim_buf_set_extmark(
0,
ns,
0,
@@ -52,28 +52,28 @@ describe('screenpos() function', function()
{ virt_lines = { { { 'abb' } }, { { 'acc' } }, { { 'add' } } } }
)
command('2,3fold')
- eq({ row = 5, col = 1, endcol = 1, curscol = 1 }, funcs.screenpos(0, 2, 1))
- eq({ row = 5, col = 1, endcol = 1, curscol = 1 }, funcs.screenpos(0, 3, 1))
- eq({ row = 6, col = 1, endcol = 1, curscol = 1 }, funcs.screenpos(0, 4, 1))
+ eq({ row = 5, col = 1, endcol = 1, curscol = 1 }, fn.screenpos(0, 2, 1))
+ eq({ row = 5, col = 1, endcol = 1, curscol = 1 }, fn.screenpos(0, 3, 1))
+ eq({ row = 6, col = 1, endcol = 1, curscol = 1 }, fn.screenpos(0, 4, 1))
feed('<C-E>')
- eq({ row = 4, col = 1, endcol = 1, curscol = 1 }, funcs.screenpos(0, 2, 1))
- eq({ row = 4, col = 1, endcol = 1, curscol = 1 }, funcs.screenpos(0, 3, 1))
- eq({ row = 5, col = 1, endcol = 1, curscol = 1 }, funcs.screenpos(0, 4, 1))
+ eq({ row = 4, col = 1, endcol = 1, curscol = 1 }, fn.screenpos(0, 2, 1))
+ eq({ row = 4, col = 1, endcol = 1, curscol = 1 }, fn.screenpos(0, 3, 1))
+ eq({ row = 5, col = 1, endcol = 1, curscol = 1 }, fn.screenpos(0, 4, 1))
feed('<C-E>')
- eq({ row = 3, col = 1, endcol = 1, curscol = 1 }, funcs.screenpos(0, 2, 1))
- eq({ row = 3, col = 1, endcol = 1, curscol = 1 }, funcs.screenpos(0, 3, 1))
- eq({ row = 4, col = 1, endcol = 1, curscol = 1 }, funcs.screenpos(0, 4, 1))
+ eq({ row = 3, col = 1, endcol = 1, curscol = 1 }, fn.screenpos(0, 2, 1))
+ eq({ row = 3, col = 1, endcol = 1, curscol = 1 }, fn.screenpos(0, 3, 1))
+ eq({ row = 4, col = 1, endcol = 1, curscol = 1 }, fn.screenpos(0, 4, 1))
feed('<C-E>')
- eq({ row = 2, col = 1, endcol = 1, curscol = 1 }, funcs.screenpos(0, 2, 1))
- eq({ row = 2, col = 1, endcol = 1, curscol = 1 }, funcs.screenpos(0, 3, 1))
- eq({ row = 3, col = 1, endcol = 1, curscol = 1 }, funcs.screenpos(0, 4, 1))
+ eq({ row = 2, col = 1, endcol = 1, curscol = 1 }, fn.screenpos(0, 2, 1))
+ eq({ row = 2, col = 1, endcol = 1, curscol = 1 }, fn.screenpos(0, 3, 1))
+ eq({ row = 3, col = 1, endcol = 1, curscol = 1 }, fn.screenpos(0, 4, 1))
feed('<C-E>')
- eq({ row = 1, col = 1, endcol = 1, curscol = 1 }, funcs.screenpos(0, 2, 1))
- eq({ row = 1, col = 1, endcol = 1, curscol = 1 }, funcs.screenpos(0, 3, 1))
- eq({ row = 2, col = 1, endcol = 1, curscol = 1 }, funcs.screenpos(0, 4, 1))
+ eq({ row = 1, col = 1, endcol = 1, curscol = 1 }, fn.screenpos(0, 2, 1))
+ eq({ row = 1, col = 1, endcol = 1, curscol = 1 }, fn.screenpos(0, 3, 1))
+ eq({ row = 2, col = 1, endcol = 1, curscol = 1 }, fn.screenpos(0, 4, 1))
end)
end)
diff --git a/test/functional/vimscript/server_spec.lua b/test/functional/vimscript/server_spec.lua
index 9d2bfbafc8..360fcf0dfe 100644
--- a/test/functional/vimscript/server_spec.lua
+++ b/test/functional/vimscript/server_spec.lua
@@ -1,7 +1,7 @@
local helpers = require('test.functional.helpers')(after_each)
local assert_log = helpers.assert_log
local eq, neq, eval = helpers.eq, helpers.neq, helpers.eval
-local clear, funcs, meths = helpers.clear, helpers.funcs, helpers.meths
+local clear, fn, api = helpers.clear, helpers.fn, helpers.api
local ok = helpers.ok
local matches = helpers.matches
local pcall_err = helpers.pcall_err
@@ -11,8 +11,8 @@ local is_os = helpers.is_os
local testlog = 'Xtest-server-log'
local function clear_serverlist()
- for _, server in pairs(funcs.serverlist()) do
- funcs.serverstop(server)
+ for _, server in pairs(fn.serverlist()) do
+ fn.serverstop(server)
end
end
@@ -25,9 +25,9 @@ describe('server', function()
local dir = 'Xtest_xdg_run'
mkdir(dir)
clear({ env = { XDG_RUNTIME_DIR = dir } })
- matches(dir, funcs.stdpath('run'))
+ matches(dir, fn.stdpath('run'))
if not is_os('win') then
- matches(dir, funcs.serverstart())
+ matches(dir, fn.serverstart())
end
end)
@@ -45,37 +45,37 @@ describe('server', function()
clear({ env = { NVIM_LISTEN_ADDRESS = '.' } })
-- Cleared on startup.
eq('', eval('$NVIM_LISTEN_ADDRESS'))
- local servers = funcs.serverlist()
+ local servers = fn.serverlist()
eq(1, #servers)
ok(string.len(servers[1]) > 4) -- "~/.local/state/nvim…/…" or "\\.\pipe\…"
end)
it('sets v:servername at startup or if all servers were stopped', function()
clear()
- local initial_server = meths.nvim_get_vvar('servername')
+ local initial_server = api.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
-- does not get set again thereafter.
- local s = funcs.serverstart()
+ local s = fn.serverstart()
assert(s ~= nil and s:len() > 0, 'serverstart() returned empty')
neq(initial_server, s)
-- serverstop() does _not_ modify v:servername...
- eq(1, funcs.serverstop(s))
- eq(initial_server, meths.nvim_get_vvar('servername'))
+ eq(1, fn.serverstop(s))
+ eq(initial_server, api.nvim_get_vvar('servername'))
-- ...unless we stop _all_ servers.
- eq(1, funcs.serverstop(funcs.serverlist()[1]))
- eq('', meths.nvim_get_vvar('servername'))
+ eq(1, fn.serverstop(fn.serverlist()[1]))
+ eq('', api.nvim_get_vvar('servername'))
-- v:servername and $NVIM take the next available server.
local servername = (
is_os('win') and [[\\.\pipe\Xtest-functional-server-pipe]]
or './Xtest-functional-server-socket'
)
- funcs.serverstart(servername)
- eq(servername, meths.nvim_get_vvar('servername'))
+ fn.serverstart(servername)
+ eq(servername, api.nvim_get_vvar('servername'))
-- Not set in the current process, only in children.
eq('', eval('$NVIM'))
end)
@@ -96,50 +96,47 @@ describe('server', function()
NVIM_LISTEN_ADDRESS = '.',
} }
clear_serverlist()
- eq({}, funcs.serverlist())
+ eq({}, fn.serverlist())
- local s = funcs.serverstart('127.0.0.1:0') -- assign random port
+ local s = fn.serverstart('127.0.0.1:0') -- assign random port
if #s > 0 then
assert(string.match(s, '127.0.0.1:%d+'))
- eq(s, funcs.serverlist()[1])
+ eq(s, fn.serverlist()[1])
clear_serverlist()
end
- s = funcs.serverstart('127.0.0.1:') -- assign random port
+ s = fn.serverstart('127.0.0.1:') -- assign random port
if #s > 0 then
assert(string.match(s, '127.0.0.1:%d+'))
- eq(s, funcs.serverlist()[1])
+ eq(s, fn.serverlist()[1])
clear_serverlist()
end
local expected = {}
local v4 = '127.0.0.1:12345'
- local status, _ = pcall(funcs.serverstart, v4)
+ local status, _ = pcall(fn.serverstart, v4)
if status then
table.insert(expected, v4)
- pcall(funcs.serverstart, v4) -- exists already; ignore
+ pcall(fn.serverstart, v4) -- exists already; ignore
assert_log('Failed to start server: address already in use: 127%.0%.0%.1', testlog, 10)
end
local v6 = '::1:12345'
- status, _ = pcall(funcs.serverstart, v6)
+ status, _ = pcall(fn.serverstart, v6)
if status then
table.insert(expected, v6)
- pcall(funcs.serverstart, v6) -- exists already; ignore
+ pcall(fn.serverstart, v6) -- exists already; ignore
assert_log('Failed to start server: address already in use: ::1', testlog, 10)
end
- eq(expected, funcs.serverlist())
+ eq(expected, fn.serverlist())
clear_serverlist()
-- Address without slashes is a "name" which is appended to a generated path. #8519
- matches([[.*[/\\]xtest1%.2%.3%.4[^/\\]*]], funcs.serverstart('xtest1.2.3.4'))
+ matches([[.*[/\\]xtest1%.2%.3%.4[^/\\]*]], fn.serverstart('xtest1.2.3.4'))
clear_serverlist()
- eq(
- 'Vim:Failed to start server: invalid argument',
- pcall_err(funcs.serverstart, '127.0.0.1:65536')
- ) -- invalid port
- eq({}, funcs.serverlist())
+ eq('Vim:Failed to start server: invalid argument', pcall_err(fn.serverstart, '127.0.0.1:65536')) -- invalid port
+ eq({}, fn.serverlist())
end)
it('serverlist() returns the list of servers', function()
@@ -175,20 +172,20 @@ describe('startup --listen', function()
clear()
local cmd = { unpack(helpers.nvim_argv) }
table.insert(cmd, '--listen')
- matches('nvim.*: Argument missing after: "%-%-listen"', funcs.system(cmd))
+ matches('nvim.*: Argument missing after: "%-%-listen"', fn.system(cmd))
cmd = { unpack(helpers.nvim_argv) }
table.insert(cmd, '--listen2')
- matches('nvim.*: Garbage after option argument: "%-%-listen2"', funcs.system(cmd))
+ matches('nvim.*: Garbage after option argument: "%-%-listen2"', fn.system(cmd))
end)
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.nvim_get_vvar('servername'))
+ eq(addr, api.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.nvim_get_vvar('servername'))
+ matches([[.*[/\\]test%-name[^/\\]*]], api.nvim_get_vvar('servername'))
end)
end)
diff --git a/test/functional/vimscript/setpos_spec.lua b/test/functional/vimscript/setpos_spec.lua
index 15ab76e78e..a26e48f469 100644
--- a/test/functional/vimscript/setpos_spec.lua
+++ b/test/functional/vimscript/setpos_spec.lua
@@ -1,6 +1,6 @@
local helpers = require('test.functional.helpers')(after_each)
-local setpos = helpers.funcs.setpos
-local getpos = helpers.funcs.getpos
+local setpos = helpers.fn.setpos
+local getpos = helpers.fn.getpos
local insert = helpers.insert
local clear = helpers.clear
local command = helpers.command
diff --git a/test/functional/vimscript/sort_spec.lua b/test/functional/vimscript/sort_spec.lua
index 25242791c2..bd3d0da146 100644
--- a/test/functional/vimscript/sort_spec.lua
+++ b/test/functional/vimscript/sort_spec.lua
@@ -4,8 +4,8 @@ local eq = helpers.eq
local NIL = vim.NIL
local eval = helpers.eval
local clear = helpers.clear
-local meths = helpers.meths
-local funcs = helpers.funcs
+local api = helpers.api
+local fn = helpers.fn
local command = helpers.command
local exc_exec = helpers.exc_exec
local pcall_err = helpers.pcall_err
@@ -21,7 +21,7 @@ describe('sort()', function()
end)
it('sorts “wrong” values between -0.0001 and 0.0001, preserving order', function()
- meths.nvim_set_var('list', {
+ api.nvim_set_var('list', {
true,
false,
NIL,
@@ -32,7 +32,7 @@ describe('sort()', function()
-0.0001,
})
command('call insert(g:list, function("tr"))')
- local error_lines = funcs.split(funcs.execute('silent! call sort(g:list, "f")'), '\n')
+ local error_lines = fn.split(fn.execute('silent! call sort(g:list, "f")'), '\n')
local errors = {}
for _, err in ipairs(error_lines) do
errors[err] = true
diff --git a/test/functional/vimscript/special_vars_spec.lua b/test/functional/vimscript/special_vars_spec.lua
index a76bb78b6f..590d409141 100644
--- a/test/functional/vimscript/special_vars_spec.lua
+++ b/test/functional/vimscript/special_vars_spec.lua
@@ -1,11 +1,11 @@
local helpers = require('test.functional.helpers')(after_each)
local exc_exec = helpers.exc_exec
local command = helpers.command
-local funcs = helpers.funcs
+local fn = helpers.fn
local clear = helpers.clear
local eval = helpers.eval
local eq = helpers.eq
-local meths = helpers.meths
+local api = helpers.api
local NIL = vim.NIL
describe('Special values', function()
@@ -25,15 +25,15 @@ describe('Special values', function()
end)
it('work with empty()', function()
- eq(0, funcs.empty(true))
- eq(1, funcs.empty(false))
- eq(1, funcs.empty(NIL))
+ eq(0, fn.empty(true))
+ eq(1, fn.empty(false))
+ eq(1, fn.empty(NIL))
end)
it('can be stringified and eval’ed back', function()
- eq(true, funcs.eval(funcs.string(true)))
- eq(false, funcs.eval(funcs.string(false)))
- eq(NIL, funcs.eval(funcs.string(NIL)))
+ eq(true, fn.eval(fn.string(true)))
+ eq(false, fn.eval(fn.string(false)))
+ eq(NIL, fn.eval(fn.string(NIL)))
end)
it('work with is/isnot properly', function()
@@ -107,8 +107,8 @@ describe('Special values', function()
end)
it('does not work with +=/-=/.=', function()
- meths.nvim_set_var('true', true)
- meths.nvim_set_var('false', false)
+ api.nvim_set_var('true', true)
+ api.nvim_set_var('false', false)
command('let null = v:null')
eq('Vim(let):E734: Wrong variable type for +=', exc_exec('let true += 1'))
@@ -137,19 +137,19 @@ describe('Special values', function()
end)
it('work with type()', function()
- eq(6, funcs.type(true))
- eq(6, funcs.type(false))
- eq(7, funcs.type(NIL))
+ eq(6, fn.type(true))
+ eq(6, fn.type(false))
+ eq(7, fn.type(NIL))
end)
it('work with copy() and deepcopy()', function()
- eq(true, funcs.deepcopy(true))
- eq(false, funcs.deepcopy(false))
- eq(NIL, funcs.deepcopy(NIL))
+ eq(true, fn.deepcopy(true))
+ eq(false, fn.deepcopy(false))
+ eq(NIL, fn.deepcopy(NIL))
- eq(true, funcs.copy(true))
- eq(false, funcs.copy(false))
- eq(NIL, funcs.copy(NIL))
+ eq(true, fn.copy(true))
+ eq(false, fn.copy(false))
+ eq(NIL, fn.copy(NIL))
end)
it('fails in index', function()
@@ -159,20 +159,20 @@ describe('Special values', function()
end)
it('is accepted by assert_true and assert_false', function()
- funcs.assert_false(false)
- funcs.assert_false(true)
- funcs.assert_false(NIL)
+ fn.assert_false(false)
+ fn.assert_false(true)
+ fn.assert_false(NIL)
- funcs.assert_true(false)
- funcs.assert_true(true)
- funcs.assert_true(NIL)
+ fn.assert_true(false)
+ fn.assert_true(true)
+ fn.assert_true(NIL)
eq({
'Expected False but got v:true',
'Expected False but got v:null',
'Expected True but got v:false',
'Expected True but got v:null',
- }, meths.nvim_get_vvar('errors'))
+ }, api.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 f9a21c5881..7179806e36 100644
--- a/test/functional/vimscript/state_spec.lua
+++ b/test/functional/vimscript/state_spec.lua
@@ -4,7 +4,7 @@ local eq = helpers.eq
local exec = helpers.exec
local exec_lua = helpers.exec_lua
local feed = helpers.feed
-local meths = helpers.meths
+local api = helpers.api
local poke_eventloop = helpers.poke_eventloop
before_each(clear)
@@ -12,7 +12,7 @@ before_each(clear)
describe('state() function', function()
-- oldtest: Test_state()
it('works', function()
- meths.nvim_ui_attach(80, 24, {}) -- Allow hit-enter-prompt
+ api.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.nvim_get_mode() -- Process pending input and luv timer callback
+ api.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.nvim_get_mode() -- Process pending input and luv timer callback
+ api.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 cb63404c00..6a7fe1bad9 100644
--- a/test/functional/vimscript/string_spec.lua
+++ b/test/functional/vimscript/string_spec.lua
@@ -2,11 +2,11 @@ local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
local eq = helpers.eq
local command = helpers.command
-local meths = helpers.meths
+local api = helpers.api
local eval = helpers.eval
local exc_exec = helpers.exc_exec
local pcall_err = helpers.pcall_err
-local funcs = helpers.funcs
+local fn = helpers.fn
local NIL = vim.NIL
local source = helpers.source
@@ -24,8 +24,8 @@ describe('string() function', function()
end)
it('dumps regular values', function()
- eq('1.5', funcs.string(1.5))
- eq('1.56e-20', funcs.string(1.56000e-020))
+ eq('1.5', fn.string(1.5))
+ eq('1.56e-20', fn.string(1.56000e-020))
eq('0.0', eval('string(0.0)'))
end)
@@ -33,58 +33,58 @@ describe('string() function', function()
eq('v:true', eval('string(v:true)'))
eq('v:false', eval('string(v:false)'))
eq('v:null', eval('string(v:null)'))
- eq('v:true', funcs.string(true))
- eq('v:false', funcs.string(false))
- eq('v:null', funcs.string(NIL))
+ eq('v:true', fn.string(true))
+ eq('v:false', fn.string(false))
+ eq('v:null', fn.string(NIL))
end)
it('dumps values with at most six digits after the decimal point', function()
- eq('1.234568e-20', funcs.string(1.23456789123456789123456789e-020))
- eq('1.234568', funcs.string(1.23456789123456789123456789))
+ eq('1.234568e-20', fn.string(1.23456789123456789123456789e-020))
+ eq('1.234568', fn.string(1.23456789123456789123456789))
end)
it('dumps values with at most seven digits before the decimal point', function()
- eq('1234567.891235', funcs.string(1234567.89123456789123456789))
- eq('1.234568e7', funcs.string(12345678.9123456789123456789))
+ eq('1234567.891235', fn.string(1234567.89123456789123456789))
+ eq('1.234568e7', fn.string(12345678.9123456789123456789))
end)
it('dumps negative values', function()
- eq('-1.5', funcs.string(-1.5))
- eq('-1.56e-20', funcs.string(-1.56000e-020))
- eq('-1.234568e-20', funcs.string(-1.23456789123456789123456789e-020))
- eq('-1.234568', funcs.string(-1.23456789123456789123456789))
- eq('-1234567.891235', funcs.string(-1234567.89123456789123456789))
- eq('-1.234568e7', funcs.string(-12345678.9123456789123456789))
+ eq('-1.5', fn.string(-1.5))
+ eq('-1.56e-20', fn.string(-1.56000e-020))
+ eq('-1.234568e-20', fn.string(-1.23456789123456789123456789e-020))
+ eq('-1.234568', fn.string(-1.23456789123456789123456789))
+ eq('-1234567.891235', fn.string(-1234567.89123456789123456789))
+ eq('-1.234568e7', fn.string(-12345678.9123456789123456789))
end)
end)
describe('used to represent numbers', function()
it('dumps regular values', function()
- eq('0', funcs.string(0))
- eq('-1', funcs.string(-1))
- eq('1', funcs.string(1))
+ eq('0', fn.string(0))
+ eq('-1', fn.string(-1))
+ eq('1', fn.string(1))
end)
it('dumps large values', function()
- eq('2147483647', funcs.string(2 ^ 31 - 1))
- eq('-2147483648', funcs.string(-2 ^ 31))
+ eq('2147483647', fn.string(2 ^ 31 - 1))
+ eq('-2147483648', fn.string(-2 ^ 31))
end)
end)
describe('used to represent strings', function()
it('dumps regular strings', function()
- eq("'test'", funcs.string('test'))
+ eq("'test'", fn.string('test'))
end)
it('dumps empty strings', function()
- eq("''", funcs.string(''))
+ eq("''", fn.string(''))
end)
it("dumps strings with ' inside", function()
- eq("''''''''", funcs.string("'''"))
- eq("'a''b'''''", funcs.string("a'b''"))
- eq("'''b''''d'", funcs.string("'b''d"))
- eq("'a''b''c''d'", funcs.string("a'b'c'd"))
+ eq("''''''''", fn.string("'''"))
+ eq("'a''b'''''", fn.string("a'b''"))
+ eq("'''b''''d'", fn.string("'b''d"))
+ eq("'a''b''c''d'", fn.string("a'b'c'd"))
end)
it('dumps NULL strings', function()
@@ -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.nvim_set_var('d', { v = true })
+ api.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.nvim_set_var('l', {})
+ api.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.nvim_set_var('d', { v = true })
- meths.nvim_set_var('l', {})
+ api.nvim_set_var('d', { v = true })
+ api.nvim_set_var('l', {})
eval('add(l, l)')
eval('add(l, function("Test1", l))')
eval('add(l, function("Test1", d))')
@@ -219,19 +219,19 @@ describe('string() function', function()
describe('used to represent lists', function()
it('dumps empty list', function()
- eq('[]', funcs.string({}))
+ eq('[]', fn.string({}))
end)
it('dumps nested lists', function()
- eq('[[[[[]]]]]', funcs.string({ { { { {} } } } }))
+ eq('[[[[[]]]]]', fn.string({ { { { {} } } } }))
end)
it('dumps nested non-empty lists', function()
- eq('[1, [[3, [[5], 4]], 2]]', funcs.string({ 1, { { 3, { { 5 }, 4 } }, 2 } }))
+ eq('[1, [[3, [[5], 4]], 2]]', fn.string({ 1, { { 3, { { 5 }, 4 } }, 2 } }))
end)
it('errors when dumping recursive lists', function()
- meths.nvim_set_var('l', {})
+ api.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.nvim_set_var('l', {})
+ api.nvim_set_var('l', {})
eval('add(l, l)')
eq(
'Vim(echo):E724: unable to correctly dump variable with self-referencing container',
@@ -266,11 +266,11 @@ describe('string() function', function()
end)
it('dumps non-empty dictionary', function()
- eq("{'t''est': 1}", funcs.string({ ["t'est"] = 1 }))
+ eq("{'t''est': 1}", fn.string({ ["t'est"] = 1 }))
end)
it('errors when dumping recursive dictionaries', function()
- meths.nvim_set_var('d', { d = 1 })
+ api.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.nvim_set_var('d', { d = 1 })
+ api.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/system_spec.lua b/test/functional/vimscript/system_spec.lua
index 19a5d4c806..d44f68e152 100644
--- a/test/functional/vimscript/system_spec.lua
+++ b/test/functional/vimscript/system_spec.lua
@@ -4,14 +4,14 @@ local helpers = require('test.functional.helpers')(after_each)
local assert_alive = helpers.assert_alive
local testprg = helpers.testprg
-local eq, call, clear, eval, feed_command, feed, meths =
+local eq, call, clear, eval, feed_command, feed, api =
helpers.eq,
helpers.call,
helpers.clear,
helpers.eval,
helpers.feed_command,
helpers.feed,
- helpers.meths
+ helpers.api
local command = helpers.command
local insert = helpers.insert
local expect = helpers.expect
@@ -220,8 +220,8 @@ describe('system()', function()
end)
it('prints verbose information', function()
- meths.nvim_set_option_value('shell', 'fake_shell', {})
- meths.nvim_set_option_value('shellcmdflag', 'cmdflag', {})
+ api.nvim_set_option_value('shell', 'fake_shell', {})
+ api.nvim_set_option_value('shellcmdflag', 'cmdflag', {})
screen:try_resize(72, 14)
feed(':4verbose echo system("echo hi")<cr>')
@@ -247,8 +247,8 @@ describe('system()', function()
feed(':edit ' .. tempfile .. '<cr>')
- local command_total_time = tonumber(helpers.funcs.split(helpers.funcs.getline(7))[2])
- local command_self_time = tonumber(helpers.funcs.split(helpers.funcs.getline(7))[3])
+ local command_total_time = tonumber(helpers.fn.split(helpers.fn.getline(7))[2])
+ local command_self_time = tonumber(helpers.fn.split(helpers.fn.getline(7))[3])
helpers.neq(nil, command_total_time)
helpers.neq(nil, command_self_time)
@@ -346,7 +346,7 @@ describe('system()', function()
input[#input + 1] = '01234567890ABCDEFabcdef'
end
input = table.concat(input, '\n')
- meths.nvim_set_var('input', input)
+ api.nvim_set_var('input', input)
eq(input, eval('system("cat -", g:input)'))
end)
end)
@@ -480,7 +480,7 @@ describe('systemlist()', function()
for _ = 1, 0xffff do
input[#input + 1] = '01234567890ABCDEFabcdef'
end
- meths.nvim_set_var('input', input)
+ api.nvim_set_var('input', input)
eq(input, eval('systemlist("cat -", g:input)'))
end)
end)
diff --git a/test/functional/vimscript/timer_spec.lua b/test/functional/vimscript/timer_spec.lua
index 02a5880949..3f53c21e7a 100644
--- a/test/functional/vimscript/timer_spec.lua
+++ b/test/functional/vimscript/timer_spec.lua
@@ -2,9 +2,9 @@ local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local feed, eq, eval, ok = helpers.feed, helpers.eq, helpers.eval, helpers.ok
local source, nvim_async, run = helpers.source, helpers.nvim_async, helpers.run
-local clear, command, funcs = helpers.clear, helpers.command, helpers.funcs
+local clear, command, fn = helpers.clear, helpers.command, helpers.fn
local exc_exec = helpers.exc_exec
-local meths = helpers.meths
+local api = helpers.api
local load_adjust = helpers.load_adjust
local retry = helpers.retry
@@ -111,7 +111,7 @@ describe('timers', function()
[1] = { bold = true, foreground = Screen.colors.Blue },
})
- meths.nvim_buf_set_lines(0, 0, -1, true, { 'ITEM 1', 'ITEM 2' })
+ api.nvim_buf_set_lines(0, 0, -1, true, { 'ITEM 1', 'ITEM 2' })
source([[
let g:cont = 0
func! AddItem(timer)
@@ -165,7 +165,7 @@ describe('timers', function()
local t_init_val = eval("[timer_start(5, 'MyHandler', {'repeat': -1}), g:val]")
eq(0, t_init_val[2])
run(nil, nil, nil, load_adjust(30))
- funcs.timer_stop(t_init_val[1])
+ fn.timer_stop(t_init_val[1])
local count = eval('g:val')
run(nil, load_adjust(300), nil, load_adjust(30))
local count2 = eval('g:val')
diff --git a/test/functional/vimscript/wait_spec.lua b/test/functional/vimscript/wait_spec.lua
index e6b244538d..4ee3b183b3 100644
--- a/test/functional/vimscript/wait_spec.lua
+++ b/test/functional/vimscript/wait_spec.lua
@@ -7,14 +7,14 @@ local eq = helpers.eq
local feed = helpers.feed
local feed_command = helpers.feed_command
local next_msg = helpers.next_msg
-local meths = helpers.meths
+local api = helpers.api
local source = helpers.source
local pcall_err = helpers.pcall_err
before_each(function()
clear()
- local channel = meths.nvim_get_api_info()[1]
- meths.nvim_set_var('channel', channel)
+ local channel = api.nvim_get_api_info()[1]
+ api.nvim_set_var('channel', channel)
end)
describe('wait()', function()
@@ -61,13 +61,13 @@ describe('wait()', function()
-- XXX: flaky (#11137)
helpers.retry(nil, nil, function()
- meths.nvim_set_var('counter', 0)
+ api.nvim_set_var('counter', 0)
eq(-1, call('wait', 20, 'Count() >= 5', 99999))
end)
- meths.nvim_set_var('counter', 0)
+ api.nvim_set_var('counter', 0)
eq(0, call('wait', 10000, 'Count() >= 5', 5))
- eq(5, meths.nvim_get_var('counter'))
+ eq(5, api.nvim_get_var('counter'))
end)
it('validates args', function()
diff --git a/test/functional/vimscript/writefile_spec.lua b/test/functional/vimscript/writefile_spec.lua
index 4de542f293..051e3794a3 100644
--- a/test/functional/vimscript/writefile_spec.lua
+++ b/test/functional/vimscript/writefile_spec.lua
@@ -3,8 +3,8 @@ local helpers = require('test.functional.helpers')(after_each)
local mkdir = helpers.mkdir
local clear = helpers.clear
local eq = helpers.eq
-local funcs = helpers.funcs
-local meths = helpers.meths
+local fn = helpers.fn
+local api = helpers.api
local exc_exec = helpers.exc_exec
local read_file = helpers.read_file
local write_file = helpers.write_file
@@ -34,19 +34,19 @@ end)
describe('writefile()', function()
it('writes empty list to a file', function()
eq(nil, read_file(fname))
- eq(0, funcs.writefile({}, fname))
+ eq(0, fn.writefile({}, fname))
eq('', read_file(fname))
os.remove(fname)
eq(nil, read_file(fname))
- eq(0, funcs.writefile({}, fname, 'b'))
+ eq(0, fn.writefile({}, fname, 'b'))
eq('', read_file(fname))
os.remove(fname)
eq(nil, read_file(fname))
- eq(0, funcs.writefile({}, fname, 'ab'))
+ eq(0, fn.writefile({}, fname, 'ab'))
eq('', read_file(fname))
os.remove(fname)
eq(nil, read_file(fname))
- eq(0, funcs.writefile({}, fname, 'a'))
+ eq(0, fn.writefile({}, fname, 'a'))
eq('', read_file(fname))
end)
@@ -66,41 +66,41 @@ describe('writefile()', function()
it('appends to a file', function()
eq(nil, read_file(fname))
- eq(0, funcs.writefile({ 'abc', 'def', 'ghi' }, fname))
+ eq(0, fn.writefile({ 'abc', 'def', 'ghi' }, fname))
eq('abc\ndef\nghi\n', read_file(fname))
- eq(0, funcs.writefile({ 'jkl' }, fname, 'a'))
+ eq(0, fn.writefile({ 'jkl' }, fname, 'a'))
eq('abc\ndef\nghi\njkl\n', read_file(fname))
os.remove(fname)
eq(nil, read_file(fname))
- eq(0, funcs.writefile({ 'abc', 'def', 'ghi' }, fname, 'b'))
+ eq(0, fn.writefile({ 'abc', 'def', 'ghi' }, fname, 'b'))
eq('abc\ndef\nghi', read_file(fname))
- eq(0, funcs.writefile({ 'jkl' }, fname, 'ab'))
+ eq(0, fn.writefile({ 'jkl' }, fname, 'ab'))
eq('abc\ndef\nghijkl', read_file(fname))
end)
it('correctly treats NLs', function()
- eq(0, funcs.writefile({ '\na\nb\n' }, fname, 'b'))
+ eq(0, fn.writefile({ '\na\nb\n' }, fname, 'b'))
eq('\0a\0b\0', read_file(fname))
- eq(0, funcs.writefile({ 'a\n\n\nb' }, fname, 'b'))
+ eq(0, fn.writefile({ 'a\n\n\nb' }, fname, 'b'))
eq('a\0\0\0b', read_file(fname))
end)
it('writes with s and S', function()
- eq(0, funcs.writefile({ '\na\nb\n' }, fname, 'bs'))
+ eq(0, fn.writefile({ '\na\nb\n' }, fname, 'bs'))
eq('\0a\0b\0', read_file(fname))
- eq(0, funcs.writefile({ 'a\n\n\nb' }, fname, 'bS'))
+ eq(0, fn.writefile({ 'a\n\n\nb' }, fname, 'bS'))
eq('a\0\0\0b', read_file(fname))
end)
it('correctly overwrites file', function()
- eq(0, funcs.writefile({ '\na\nb\n' }, fname, 'b'))
+ eq(0, fn.writefile({ '\na\nb\n' }, fname, 'b'))
eq('\0a\0b\0', read_file(fname))
- eq(0, funcs.writefile({ 'a\n' }, fname, 'b'))
+ eq(0, fn.writefile({ 'a\n' }, fname, 'b'))
eq('a\0', read_file(fname))
end)
it('shows correct file name when supplied numbers', function()
- meths.nvim_set_current_dir(dname)
+ api.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))
@@ -110,12 +110,12 @@ describe('writefile()', function()
it('writefile(..., "p") creates missing parent directories', function()
os.remove(dname)
eq(nil, read_file(dfname))
- eq(0, funcs.writefile({ 'abc', 'def', 'ghi' }, dfname, 'p'))
+ eq(0, fn.writefile({ 'abc', 'def', 'ghi' }, dfname, 'p'))
eq('abc\ndef\nghi\n', read_file(dfname))
os.remove(dfname)
os.remove(dname)
eq(nil, read_file(dfname))
- eq(0, funcs.writefile({ '\na\nb\n' }, dfname, 'pb'))
+ eq(0, fn.writefile({ '\na\nb\n' }, dfname, 'pb'))
eq('\0a\0b\0', read_file(dfname))
os.remove(dfname)
os.remove(dname)