feat(commands): VimwikiListChangeLvl -range -nargs=+ (P3 parity)
CI / cargo fmt --check (push) Successful in 17s
CI / cargo clippy (push) Successful in 28s
CI / cargo test (push) Successful in 50s
CI / editor keymaps (push) Successful in 1m58s

Upstream is `-range -nargs=+` (change_level(line1, line2, direction,
plus_children)); nuwiki was -nargs=? and range-less, so `:1,3VimwikiListChangeLvl
increase 0` raised E481/E488 and the level change never spanned a selection.

All four defs (Vim+Neovim × Vimwiki+Nuwiki) are now -range -nargs=+ and forward
<line1>, <line2>, <f-args>. list_change_lvl(line1, line2, direction,
[plus_children]) (both clients) parses the required direction + optional subtree
flag and applies the change to every list item in the range via the existing
over_range helper.

Tests: cmd.ListChangeLvl_range_indents (test-keymaps.lua) +
cmd.VimwikiListChangeLvl_accepts_range_and_args (test-keymaps-vim.vim).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-31 20:16:10 +00:00
parent fe116088bb
commit 4710ba03c8
6 changed files with 62 additions and 14 deletions
+9 -5
View File
@@ -800,11 +800,15 @@ function! nuwiki#commands#list_change_level(delta, whole_subtree) abort
call s:exec('nuwiki.list.changeLevel', l:args) call s:exec('nuwiki.list.changeLevel', l:args)
endfunction endfunction
" `:VimwikiListChangeLvl decrease|increase 0` compat entry. " `:[range]VimwikiListChangeLvl {increase|decrease} [plus_children]` — upstream
function! nuwiki#commands#list_change_lvl(...) abort " is `-range -nargs=+`: direction is required, the optional second arg cascades
let l:dir = a:0 >= 1 ? a:1 : 'increase' " the level change to each item's subtree, and a range applies it to every list
let l:delta = (l:dir ==# 'increase' || l:dir ==# 'indent') ? 1 : -1 " item in the selection.
call nuwiki#commands#list_change_level(l:delta, 0) function! nuwiki#commands#list_change_lvl(line1, line2, direction, ...) abort
let l:delta = (a:direction ==# 'increase' || a:direction ==# 'indent') ? 1 : -1
let l:children = a:0 >= 1 ? (str2nr(a:1) != 0) : 0
call s:over_range(a:line1, a:line2,
\ { -> nuwiki#commands#list_change_level(l:delta, l:children) })
endfunction endfunction
" Cycle the list marker through vimwiki's canonical order. " Cycle the list marker through vimwiki's canonical order.
+18
View File
@@ -651,6 +651,24 @@ call s:record(
\ 'cmd.VimwikiTable_accepts_cols_rows', \ 'cmd.VimwikiTable_accepts_cols_rows',
\ 'err=' . s:tbl_err) \ 'err=' . s:tbl_err)
" ===== :VimwikiListChangeLvl -range -nargs=+ =====
" Was -nargs=? (range-less): `:1,3VimwikiListChangeLvl increase 0` raised E481
" (no range allowed) and/or E488 (trailing chars). The level change is an LSP
" roundtrip (no server here), so assert only the attribute parse: no E481/E488.
call s:set_buf(['- a', '- b', '- c'])
let s:lcl_err = ''
try
silent 1,3VimwikiListChangeLvl increase 0
catch /E481\|E488/
let s:lcl_err = v:exception
catch
" non-attribute error (e.g. no LSP) is expected and fine here.
endtry
call s:record(
\ s:lcl_err ==# '' ? 1 : 0,
\ 'cmd.VimwikiListChangeLvl_accepts_range_and_args',
\ 'err=' . s:lcl_err)
" ===== Wrap up ===== " ===== Wrap up =====
call add(s:results, '') call add(s:results, '')
+15
View File
@@ -834,6 +834,21 @@ vim.defer_fn(function()
error('want 5 table lines (hdr+sep+3 rows), got ' .. #tbl) error('want 5 table lines (hdr+sep+3 rows), got ' .. #tbl)
end end
end) end)
-- `:[range]VimwikiListChangeLvl {dir} [plus_children]` — now -range -nargs=+
-- (was -nargs=?, range-less). A 1,3 range with `increase` must indent the
-- items that have somewhere to nest (the 2nd item under the 1st).
tobj_case('cmd.ListChangeLvl_range_indents', function()
set_buf({ '- a', '- b', '- c' })
vim.cmd('1,3VimwikiListChangeLvl increase 0')
local done = vim.wait(2000, function()
local l = vim.api.nvim_buf_get_lines(0, 0, -1, false)
return l[2] ~= nil and l[2]:match('^%s%s*%-') ~= nil
end, 30)
if not done then
error('range list-change-lvl did not indent: '
.. vim.inspect(vim.api.nvim_buf_get_lines(0, 0, -1, false)))
end
end)
-- `:VimwikiNormalizeLink 1` (the arg is upstream's visual flag; the command -- `:VimwikiNormalizeLink 1` (the arg is upstream's visual flag; the command
-- is -nargs=? not -range, so no `'<,'>`) wraps the last visual selection. -- is -nargs=? not -range, so no `'<,'>`) wraps the last visual selection.
tobj_case('cmd.normalize_link_visual_wraps_selection', function() tobj_case('cmd.normalize_link_visual_wraps_selection', function()
+9 -1
View File
@@ -183,7 +183,15 @@ fix site.
cols/rows). Covered by `cmd.VimwikiTable_passes_cols_and_rows` cols/rows). Covered by `cmd.VimwikiTable_passes_cols_and_rows`
(`test-keymaps.lua`, asserts a `:VimwikiTable 4 3` → 4-col, 3-row table) and (`test-keymaps.lua`, asserts a `:VimwikiTable 4 3` → 4-col, 3-row table) and
`cmd.VimwikiTable_accepts_cols_rows` (`test-keymaps-vim.vim`, no E488). `cmd.VimwikiTable_accepts_cols_rows` (`test-keymaps-vim.vim`, no E488).
- [ ] `VimwikiListChangeLvl` is `-nargs=?` vs upstream `-range -nargs=+`. - [x] `VimwikiListChangeLvl` was `-nargs=?` (range-less) vs upstream
`-range -nargs=+`. _Fix:_ all four defs are now `-range -nargs=+` passing
`<line1>, <line2>, <f-args>`; `list_change_lvl(line1, line2, direction,
[plus_children])` (both clients) parses the required direction + optional
subtree flag and applies the level change to every list item in the range
via the existing `over_range` helper. Covered by
`cmd.ListChangeLvl_range_indents` (`test-keymaps.lua`) and
`cmd.VimwikiListChangeLvl_accepts_range_and_args` (`test-keymaps-vim.vim`,
no E481/E488).
- [x] `VimwikiRebuildTags` `-bang` ("rebuild all") — `:…RebuildTags!` now passes - [x] `VimwikiRebuildTags` `-bang` ("rebuild all") — `:…RebuildTags!` now passes
`{ all: true }`; the server (`tags_rebuild`) re-indexes **every** configured `{ all: true }`; the server (`tags_rebuild`) re-indexes **every** configured
wiki (via `wikis_snapshot()`) instead of just the current one. `-bang` added to wiki (via `wikis_snapshot()`) instead of just the current one. `-bang` added to
+4 -4
View File
@@ -87,7 +87,7 @@ if !has('nvim')
command! -buffer -bang VimwikiRemoveDone if <bang>0 | call nuwiki#commands#list_remove_done_all() | else | call nuwiki#commands#list_remove_done() | endif command! -buffer -bang VimwikiRemoveDone if <bang>0 | call nuwiki#commands#list_remove_done_all() | else | call nuwiki#commands#list_remove_done() | endif
command! -buffer -range VimwikiRemoveSingleCB call nuwiki#commands#list_remove_checkbox() command! -buffer -range VimwikiRemoveSingleCB call nuwiki#commands#list_remove_checkbox()
command! -buffer VimwikiRemoveCBInList call nuwiki#commands#list_remove_checkbox_in_list() command! -buffer VimwikiRemoveCBInList call nuwiki#commands#list_remove_checkbox_in_list()
command! -buffer -nargs=? VimwikiListChangeLvl call nuwiki#commands#list_change_lvl() command! -buffer -range -nargs=+ VimwikiListChangeLvl call nuwiki#commands#list_change_lvl(<line1>, <line2>, <f-args>)
command! -buffer -nargs=? VimwikiNormalizeLink call nuwiki#commands#normalize_link(<args>) command! -buffer -nargs=? VimwikiNormalizeLink call nuwiki#commands#normalize_link(<args>)
command! -buffer VimwikiRenumberList call nuwiki#commands#list_renumber() command! -buffer VimwikiRenumberList call nuwiki#commands#list_renumber()
command! -buffer VimwikiRenumberAllLists call nuwiki#commands#list_renumber_all() command! -buffer VimwikiRenumberAllLists call nuwiki#commands#list_renumber_all()
@@ -172,7 +172,7 @@ if !has('nvim')
command! -buffer -bang NuwikiRemoveDone if <bang>0 | call nuwiki#commands#list_remove_done_all() | else | call nuwiki#commands#list_remove_done() | endif command! -buffer -bang NuwikiRemoveDone if <bang>0 | call nuwiki#commands#list_remove_done_all() | else | call nuwiki#commands#list_remove_done() | endif
command! -buffer -range NuwikiRemoveCheckbox call nuwiki#commands#list_remove_checkbox() command! -buffer -range NuwikiRemoveCheckbox call nuwiki#commands#list_remove_checkbox()
command! -buffer NuwikiRemoveCheckboxInList call nuwiki#commands#list_remove_checkbox_in_list() command! -buffer NuwikiRemoveCheckboxInList call nuwiki#commands#list_remove_checkbox_in_list()
command! -buffer -nargs=? NuwikiListChangeLvl call nuwiki#commands#list_change_lvl() command! -buffer -range -nargs=+ NuwikiListChangeLvl call nuwiki#commands#list_change_lvl(<line1>, <line2>, <f-args>)
command! -buffer NuwikiListToggle call nuwiki#commands#list_toggle_or_add_checkbox() command! -buffer NuwikiListToggle call nuwiki#commands#list_toggle_or_add_checkbox()
command! -buffer -range NuwikiIncrementListItem call nuwiki#commands#list_cycle_symbol_range(1, <line1>, <line2>) command! -buffer -range NuwikiIncrementListItem call nuwiki#commands#list_cycle_symbol_range(1, <line1>, <line2>)
command! -buffer -range NuwikiDecrementListItem call nuwiki#commands#list_cycle_symbol_range(-1, <line1>, <line2>) command! -buffer -range NuwikiDecrementListItem call nuwiki#commands#list_cycle_symbol_range(-1, <line1>, <line2>)
@@ -435,7 +435,7 @@ command! -buffer -nargs=1 VimwikiChangeSymbolInListTo lua require('nuwiki.comman
command! -buffer -bang VimwikiRemoveDone lua require('nuwiki.commands')[('<bang>' == '!') and 'list_remove_done_all' or 'list_remove_done']() command! -buffer -bang VimwikiRemoveDone lua require('nuwiki.commands')[('<bang>' == '!') and 'list_remove_done_all' or 'list_remove_done']()
command! -buffer -range VimwikiRemoveSingleCB lua require('nuwiki.commands').list_remove_checkbox() command! -buffer -range VimwikiRemoveSingleCB lua require('nuwiki.commands').list_remove_checkbox()
command! -buffer VimwikiRemoveCBInList lua require('nuwiki.commands').list_remove_checkbox_in_list() command! -buffer VimwikiRemoveCBInList lua require('nuwiki.commands').list_remove_checkbox_in_list()
command! -buffer -nargs=? VimwikiListChangeLvl lua require('nuwiki.commands').list_change_lvl() command! -buffer -range -nargs=+ VimwikiListChangeLvl lua require('nuwiki.commands').list_change_lvl(<line1>, <line2>, <f-args>)
command! -buffer -nargs=? VimwikiNormalizeLink lua require('nuwiki.commands').normalize_link(<args>) command! -buffer -nargs=? VimwikiNormalizeLink lua require('nuwiki.commands').normalize_link(<args>)
command! -buffer VimwikiRenumberList lua require('nuwiki.commands').list_renumber() command! -buffer VimwikiRenumberList lua require('nuwiki.commands').list_renumber()
command! -buffer VimwikiRenumberAllLists lua require('nuwiki.commands').list_renumber_all() command! -buffer VimwikiRenumberAllLists lua require('nuwiki.commands').list_renumber_all()
@@ -520,7 +520,7 @@ command! -buffer NuwikiTabDropLink lua require('nuwiki.commands').follow_
command! -buffer -bang NuwikiRemoveDone lua require('nuwiki.commands')[('<bang>' == '!') and 'list_remove_done_all' or 'list_remove_done']() command! -buffer -bang NuwikiRemoveDone lua require('nuwiki.commands')[('<bang>' == '!') and 'list_remove_done_all' or 'list_remove_done']()
command! -buffer -range NuwikiRemoveCheckbox lua require('nuwiki.commands').list_remove_checkbox() command! -buffer -range NuwikiRemoveCheckbox lua require('nuwiki.commands').list_remove_checkbox()
command! -buffer NuwikiRemoveCheckboxInList lua require('nuwiki.commands').list_remove_checkbox_in_list() command! -buffer NuwikiRemoveCheckboxInList lua require('nuwiki.commands').list_remove_checkbox_in_list()
command! -buffer -nargs=? NuwikiListChangeLvl lua require('nuwiki.commands').list_change_lvl() command! -buffer -range -nargs=+ NuwikiListChangeLvl lua require('nuwiki.commands').list_change_lvl(<line1>, <line2>, <f-args>)
command! -buffer NuwikiListToggle lua require('nuwiki.commands').list_toggle_or_add_checkbox() command! -buffer NuwikiListToggle lua require('nuwiki.commands').list_toggle_or_add_checkbox()
command! -buffer -range NuwikiIncrementListItem lua require('nuwiki.commands').list_cycle_symbol_range(1, <line1>, <line2>) command! -buffer -range NuwikiIncrementListItem lua require('nuwiki.commands').list_cycle_symbol_range(1, <line1>, <line2>)
command! -buffer -range NuwikiDecrementListItem lua require('nuwiki.commands').list_cycle_symbol_range(-1, <line1>, <line2>) command! -buffer -range NuwikiDecrementListItem lua require('nuwiki.commands').list_cycle_symbol_range(-1, <line1>, <line2>)
+7 -4
View File
@@ -585,11 +585,14 @@ function M.list_change_level(delta, whole_subtree)
exec('nuwiki.list.changeLevel', { args }) exec('nuwiki.list.changeLevel', { args })
end end
-- Vimwiki's `:VimwikiListChangeLvl decrease|increase 0` keeps a single -- `:[range]VimwikiListChangeLvl {increase|decrease} [plus_children]` — upstream
-- entry point. Forward to changeLevel. -- is `-range -nargs=+`. Direction is required; the optional second arg cascades
function M.list_change_lvl(direction) -- to each item's subtree; a range applies it to every list item in the range.
function M.list_change_lvl(line1, line2, direction, plus_children)
local delta = (direction == 'increase' or direction == 'indent') and 1 or -1 local delta = (direction == 'increase' or direction == 'indent') and 1 or -1
M.list_change_level(delta, false) local n = tonumber(plus_children)
local children = n ~= nil and n ~= 0
over_range(line1, line2, function() M.list_change_level(delta, children) end)
end end
--- Cycle the list marker forward (`direction = 1`) or backward --- Cycle the list marker forward (`direction = 1`) or backward