From ebb7c38ca2e59ca7b413750d83ac1cf38d7bb180 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Wed, 26 Nov 2025 01:17:06 -0500 Subject: docs: misc fix https://github.com/neovim/neovim.github.io/issues/419 Co-authored-by: Rob Pilling --- test/functional/api/command_spec.lua | 58 +++++++++++++++++++++++++++--------- 1 file changed, 44 insertions(+), 14 deletions(-) (limited to 'test/functional/api/command_spec.lua') diff --git a/test/functional/api/command_spec.lua b/test/functional/api/command_spec.lua index bd23c59a96..503b4a48b3 100644 --- a/test/functional/api/command_spec.lua +++ b/test/functional/api/command_spec.lua @@ -159,6 +159,39 @@ describe('nvim_get_commands', function() keepscript = false, script_id = 4, } + local previewCmd = { + addr = NIL, + bang = false, + bar = false, + complete = 'customlist', + complete_arg = 's:cpt', + count = NIL, + definition = '', + name = 'PreviewCmd', + nargs = '1', + range = NIL, + register = false, + keepscript = false, + script_id = 5, + } + local previewLuaCmd = { + addr = NIL, + bang = false, + bar = false, + callback = NIL, -- RPC serializes Lua callback as NIL. + complete = NIL, -- RPC serializes Lua callback as NIL. + preview = NIL, -- RPC serializes Lua callback as NIL. + complete_arg = NIL, + count = NIL, + definition = '', + name = 'PreviewLuaCmd', + nargs = '1', + range = NIL, + register = false, + keepscript = false, + script_id = -8, -- Lua + } + source([[ let s:foo = 1 command -complete=custom,ListUsers -nargs=+ Finger !finger @@ -186,12 +219,12 @@ describe('nvim_get_commands', function() function! s:cpt() abort return 1 endfunction - command -nargs=1 -complete=customlist,s:cpt CmdWithPreview + command -nargs=1 -complete=customlist,s:cpt PreviewCmd ]]) source([[ lua << EOF vim.api.nvim_create_user_command( - 'CmdWithPreviewLua', + 'PreviewLuaCmd', function() end, { nargs = 1, @@ -203,18 +236,15 @@ describe('nvim_get_commands', function() ]]) -- TODO(justinmk): Order is stable but undefined. Sort before return? local commands = api.nvim_get_commands({ builtin = false }) - local cmd_with_preview = commands.CmdWithPreview - commands.CmdWithPreview = nil - local cmd_with_preview_lua = commands.CmdWithPreviewLua - commands.CmdWithPreviewLua = nil - eq({ Cmd2 = cmd2, Cmd3 = cmd3, Cmd4 = cmd4, Finger = cmd1, TestCmd = cmd0 }, commands) - - eq(cmd_with_preview.complete, 'customlist') - eq(cmd_with_preview.preview, nil) - - -- user data (NIL), because these are passed through RPC: - eq(cmd_with_preview_lua.complete, NIL) - eq(cmd_with_preview_lua.preview, NIL) + eq({ + Cmd2 = cmd2, + Cmd3 = cmd3, + Cmd4 = cmd4, + Finger = cmd1, + TestCmd = cmd0, + PreviewCmd = previewCmd, + PreviewLuaCmd = previewLuaCmd, + }, commands) end) it('gets callbacks defined as Lua functions', function() -- cgit