feat(13.1-A): list rewriters — removeDone, renumber, changeSymbol/Level

Closes the four-command list-rewriter cluster from SPEC §13.1.

Server-side (commands.rs ops module):
- `parse_symbol` / `render_marker` — round-trip between
  `:VimwikiListChangeSymbol` arg shapes (`-`, `1.`, `a)`, `i)`,
  `Dash`, `Numeric`, …) and the rendered marker text. `render_marker`
  knows how to spell `a/b/…/z/aa` and `i/ii/iv/v/…/MMM` for the
  alphabetic + roman variants.
- `remove_done_edit` — walks every list (recursively through
  blockquotes and sublists), emits delete TextEdits for items whose
  checkbox is `Done` or `Rejected`. Item span gets extended through
  the trailing newline so we don't leave behind empty lines. Accepts
  an optional `position` to scope the operation to the item under
  cursor + its descendants.
- `renumber_edit` — finds the list containing the cursor line (or
  every list when `whole_file: true`), re-sequences numeric
  markers in-place. Unordered lists are left alone.
- `change_symbol_edit` — rewrites the leading marker on a single
  item, or every item in a list when `whole_list: true`. Uses
  `render_marker` so ordered variants get the right index.
- `change_level_edit` — re-indents the marker line (or every line of
  the item subtree when `whole_subtree: true`) by ±2 spaces per
  level. Dedent clamps at column 0.
- `find_list_at_line` + `find_marker_span` — pure helpers reused by
  the three above.

Editor glue:
- `lua/nuwiki/commands.lua` / `autoload/nuwiki/commands.vim` —
  removed all four "not yet implemented" stubs and wired them to the
  real LSP commands. Lua also exposes `list_change_lvl(direction)`
  for the `:VimwikiListChangeLvl decrease|increase` compat entry.
- Keymaps for `glh` / `gll` / `gLh` / `gLl` (list level single +
  subtree), `glr` / `gLr` (renumber list + whole-file),
  `gl<Space>` / `gL<Space>` (remove done items) now hit the real
  commands instead of printing a "deferred" notification.

Tests: 16 new in `cluster_a_list_rewriters.rs` covering
symbol parsing, marker rendering (alpha + roman + numeric),
removeDone shape, scoped removeDone, no-match cases, renumber
sequencing, whole-file walk, changeSymbol single + whole-list,
changeLevel single + subtree + clamp, and COMMANDS list completeness.
Total 402 Rust tests pass; clippy clean; keymap harness still at
20/20.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-12 14:37:11 +00:00
parent cebc806ce3
commit 9d34c8baa2
6 changed files with 983 additions and 23 deletions
+8 -8
View File
@@ -155,14 +155,14 @@ if !has('nvim')
xnoremap <silent><buffer> glp :<C-u>call nuwiki#commands#cycle_list_item()<CR>
nnoremap <silent><buffer> glx :call nuwiki#commands#reject_list_item()<CR>
xnoremap <silent><buffer> glx :<C-u>call nuwiki#commands#reject_list_item()<CR>
nnoremap <silent><buffer> glh :echohl WarningMsg<bar>echom 'nuwiki: list level not yet implemented — see SPEC §13.1'<bar>echohl None<CR>
nnoremap <silent><buffer> gll :echohl WarningMsg<bar>echom 'nuwiki: list level not yet implemented — see SPEC §13.1'<bar>echohl None<CR>
nnoremap <silent><buffer> gLh :echohl WarningMsg<bar>echom 'nuwiki: list level subtree not yet implemented — see SPEC §13.1'<bar>echohl None<CR>
nnoremap <silent><buffer> gLl :echohl WarningMsg<bar>echom 'nuwiki: list level subtree not yet implemented — see SPEC §13.1'<bar>echohl None<CR>
nnoremap <silent><buffer> glr :echohl WarningMsg<bar>echom 'nuwiki: list renumber not yet implemented — see SPEC §13.1'<bar>echohl None<CR>
nnoremap <silent><buffer> gLr :echohl WarningMsg<bar>echom 'nuwiki: list renumber-all not yet implemented — see SPEC §13.1'<bar>echohl None<CR>
nnoremap <silent><buffer> gl<Space> :echohl WarningMsg<bar>echom 'nuwiki: :VimwikiRemoveSingleCB not yet implemented — see SPEC §13.1'<bar>echohl None<CR>
nnoremap <silent><buffer> gL<Space> :echohl WarningMsg<bar>echom 'nuwiki: :VimwikiRemoveCBInList not yet implemented — see SPEC §13.1'<bar>echohl None<CR>
nnoremap <silent><buffer> glh :call nuwiki#commands#list_change_level(-1, 0)<CR>
nnoremap <silent><buffer> gll :call nuwiki#commands#list_change_level(1, 0)<CR>
nnoremap <silent><buffer> gLh :call nuwiki#commands#list_change_level(-1, 1)<CR>
nnoremap <silent><buffer> gLl :call nuwiki#commands#list_change_level(1, 1)<CR>
nnoremap <silent><buffer> glr :call nuwiki#commands#list_renumber()<CR>
nnoremap <silent><buffer> gLr :call nuwiki#commands#list_renumber_all()<CR>
nnoremap <silent><buffer> gl<Space> :call nuwiki#commands#list_remove_done()<CR>
nnoremap <silent><buffer> gL<Space> :call nuwiki#commands#list_remove_done()<CR>
nnoremap <silent><buffer> o :call nuwiki#commands#open_below_with_bullet()<CR>
nnoremap <silent><buffer> O :call nuwiki#commands#open_above_with_bullet()<CR>