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:
@@ -462,11 +462,56 @@ endfunction
|
||||
|
||||
" ===== §13.1 deferred =====
|
||||
|
||||
function! nuwiki#commands#list_change_lvl() abort
|
||||
call s:notify_deferred(':VimwikiListChangeLvl')
|
||||
endfunction
|
||||
" §13.1 Cluster A — list rewriters.
|
||||
|
||||
function! nuwiki#commands#list_remove_done() abort
|
||||
call s:notify_deferred(':VimwikiRemoveDone')
|
||||
let l:args = [{ 'uri': s:buf_uri() }]
|
||||
call s:exec('nuwiki.list.removeDone', l:args)
|
||||
endfunction
|
||||
|
||||
function! nuwiki#commands#list_renumber() abort
|
||||
let l:p = s:cursor_position()
|
||||
let l:args = [{ 'uri': l:p['textDocument']['uri'], 'position': l:p['position'] }]
|
||||
call s:exec('nuwiki.list.renumber', l:args)
|
||||
endfunction
|
||||
|
||||
function! nuwiki#commands#list_renumber_all() abort
|
||||
let l:p = s:cursor_position()
|
||||
let l:args = [{
|
||||
\ 'uri': l:p['textDocument']['uri'],
|
||||
\ 'position': l:p['position'],
|
||||
\ 'whole_file': v:true,
|
||||
\ }]
|
||||
call s:exec('nuwiki.list.renumber', l:args)
|
||||
endfunction
|
||||
|
||||
function! nuwiki#commands#list_change_symbol(symbol, whole_list) abort
|
||||
let l:p = s:cursor_position()
|
||||
let l:args = [{
|
||||
\ 'uri': l:p['textDocument']['uri'],
|
||||
\ 'position': l:p['position'],
|
||||
\ 'symbol': a:symbol,
|
||||
\ 'whole_list': a:whole_list ? v:true : v:false,
|
||||
\ }]
|
||||
call s:exec('nuwiki.list.changeSymbol', l:args)
|
||||
endfunction
|
||||
|
||||
function! nuwiki#commands#list_change_level(delta, whole_subtree) abort
|
||||
let l:p = s:cursor_position()
|
||||
let l:args = [{
|
||||
\ 'uri': l:p['textDocument']['uri'],
|
||||
\ 'position': l:p['position'],
|
||||
\ 'delta': a:delta,
|
||||
\ 'whole_subtree': a:whole_subtree ? v:true : v:false,
|
||||
\ }]
|
||||
call s:exec('nuwiki.list.changeLevel', l:args)
|
||||
endfunction
|
||||
|
||||
" `:VimwikiListChangeLvl decrease|increase 0` compat entry.
|
||||
function! nuwiki#commands#list_change_lvl(...) abort
|
||||
let l:dir = a:0 >= 1 ? a:1 : 'increase'
|
||||
let l:delta = (l:dir ==# 'increase' || l:dir ==# 'indent') ? 1 : -1
|
||||
call nuwiki#commands#list_change_level(l:delta, 0)
|
||||
endfunction
|
||||
function! nuwiki#commands#table_insert() abort
|
||||
call s:notify_deferred(':VimwikiTable')
|
||||
|
||||
Reference in New Issue
Block a user