feat(commands): VimwikiTable -nargs=* + Index/TabIndex -count=0 (P3 parity)
CI / cargo fmt --check (push) Successful in 34s
CI / cargo clippy (push) Successful in 21s
CI / cargo test (push) Successful in 30s
CI / editor keymaps (push) Successful in 1m34s

Two command-attribute parity fixes (audited against upstream vimwiki master):

- VimwikiTable / NuwikiTable were -nargs=1 and called table_insert() with no
  args, so `:VimwikiTable 4 3` raised E488 and cols/rows were unreachable.
  All four defs (Vim+Neovim × Vimwiki+Nuwiki) are now -nargs=* and forward
  <f-args>; the backing table_insert already parsed cols (a:1) + rows (a:2).

- VimwikiIndex/TabIndex (and Nuwiki forms) switch from bare -count to
  upstream's -count=0. Behavior is unchanged (both default count to 0;
  wiki_index already maps a count to the 1-indexed wiki number) — this just
  matches the upstream declaration exactly.

Tests: cmd.VimwikiTable_passes_cols_and_rows (test-keymaps.lua — asserts a
4-col/3-row table) and cmd.VimwikiTable_accepts_cols_rows (test-keymaps-vim.vim
— no E488). gap doc updated.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-31 20:10:53 +00:00
parent 724c12ac16
commit a7f7e8e61f
5 changed files with 70 additions and 16 deletions
+26
View File
@@ -808,6 +808,32 @@ vim.defer_fn(function()
error('range toggle incomplete: ' .. vim.inspect(vim.api.nvim_buf_get_lines(0, 0, -1, false)))
end
end)
-- `:VimwikiTable {cols} [rows]` — now -nargs=* (was -nargs=1, which dropped
-- the args entirely). A 4-col table has 5 pipes per row; 3 data rows give
-- header + separator + 3 = 5 table lines.
tobj_case('cmd.VimwikiTable_passes_cols_and_rows', function()
set_buf({ '' })
vim.api.nvim_win_set_cursor(0, { 1, 0 })
vim.cmd('VimwikiTable 4 3')
local tbl = {}
local done = vim.wait(2000, function()
tbl = {}
for _, l in ipairs(vim.api.nvim_buf_get_lines(0, 0, -1, false)) do
if l:find('|', 1, true) then tbl[#tbl + 1] = l end
end
return #tbl >= 5
end, 30)
if not done then
error('table not inserted: ' .. vim.inspect(vim.api.nvim_buf_get_lines(0, 0, -1, false)))
end
local pipes = select(2, tbl[1]:gsub('|', ''))
if pipes ~= 5 then
error('want 4 cols (5 pipes), got ' .. pipes .. ': ' .. tbl[1])
end
if #tbl ~= 5 then
error('want 5 table lines (hdr+sep+3 rows), got ' .. #tbl)
end
end)
-- `:VimwikiNormalizeLink 1` (the arg is upstream's visual flag; the command
-- is -nargs=? not -range, so no `'<,'>`) wraps the last visual selection.
tobj_case('cmd.normalize_link_visual_wraps_selection', function()