feat: real range/bang/visual handling for the deferred command gaps
Implements the four items previously left as "needs handler work" — all
fully wired, not cosmetic.
- ToggleListItem / IncrementListItem / DecrementListItem are now -range
(both clients). The client loops the per-line op over [<line1>,<line2>]
(toggle_list_item_range / list_cycle_symbol_range). The server's edits are
version-less single-line WorkspaceEdits, so each line applies independently
— no server protocol change. `:'<,'>VimwikiToggleListItem` toggles the whole
selection.
- VimwikiRebuildTags gains -bang: `:…RebuildTags!` passes { all: true } and
the server (tags_rebuild) re-indexes every configured wiki via
wikis_snapshot(), not just the current one.
- VimwikiNormalizeLink is -nargs=?: with `1` (upstream's visual flag; the
x-mode `+` mapping now passes it) it wraps the '< / '> selection as
[[selection]] (new wrap_visual_as_wikilink in both clients).
- VimwikiCheckLinks is -range: a ranged invocation filters the broken-link
report to the current buffer's selected lines (client-side filter in
results_to_qf / check_links).
Tests: cmd.toggle_list_item_range + cmd.normalize_link_visual_wraps_selection
(test-keymaps.lua), normalize.visual_wraps_selection (test-keymaps-vim.vim).
README + doc/nuwiki.txt + gap doc updated. fmt/clippy clean; nvim 274,
vim 266+18, all Rust tests + config-parity green.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -577,6 +577,17 @@ call s:record(
|
||||
\ 'err=' . s:cz_e . ' real=' . synconcealed(3, 1)[0]
|
||||
\ . ' rgb=' . synconcealed(2, stridx(getline(2), '<span') + 1)[0])
|
||||
|
||||
" ===== NormalizeLink visual wraps the selection (pure-VimL) =====
|
||||
" `:VimwikiNormalizeLink 1` / the x-mode `+` wrap the `'<`/`'>` selection.
|
||||
call s:set_buf(['one two three'])
|
||||
call cursor(1, 5)
|
||||
call feedkeys("viw\<Esc>", 'tx')
|
||||
call nuwiki#commands#normalize_link(1)
|
||||
call s:record(
|
||||
\ getline(1) ==# 'one [[two]] three' ? 1 : 0,
|
||||
\ 'normalize.visual_wraps_selection',
|
||||
\ 'got ' . string(getline(1)))
|
||||
|
||||
" ===== Follow-link resolves + opens in the current window (regression) =====
|
||||
" follow_link_or_create() must resolve the definition itself and `:edit` the
|
||||
" target in the CURRENT window — including a page that does not exist yet
|
||||
|
||||
@@ -792,6 +792,34 @@ vim.defer_fn(function()
|
||||
end
|
||||
end)
|
||||
|
||||
-- ===== Visual-range list commands + normalize-visual (regression) =====
|
||||
-- :N,MVimwikiToggleListItem toggles every checkbox in the range (server,
|
||||
-- one request per line; wait for the edits to land).
|
||||
tobj_case('cmd.toggle_list_item_range', function()
|
||||
set_buf({ '- [ ] a', '- [ ] b', '- [ ] c' })
|
||||
vim.cmd('1,3VimwikiToggleListItem')
|
||||
local done = vim.wait(2000, function()
|
||||
for _, l in ipairs(vim.api.nvim_buf_get_lines(0, 0, -1, false)) do
|
||||
if not l:match('%[[xX]%]') then return false end
|
||||
end
|
||||
return true
|
||||
end, 30)
|
||||
if not done then
|
||||
error('range toggle incomplete: ' .. 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
|
||||
-- is -nargs=? not -range, so no `'<,'>`) wraps the last visual selection.
|
||||
tobj_case('cmd.normalize_link_visual_wraps_selection', function()
|
||||
set_buf({ 'one two three' })
|
||||
vim.cmd('normal! 0wviw\27') -- select 'two', leave visual (sets '<,'> marks)
|
||||
vim.cmd('VimwikiNormalizeLink 1')
|
||||
local got = vim.api.nvim_get_current_line()
|
||||
if got ~= 'one [[two]] three' then
|
||||
error('visual normalize did not wrap selection: ' .. got)
|
||||
end
|
||||
end)
|
||||
|
||||
-- ===== Wiki picker (config-driven, no LSP) =====
|
||||
-- The picker must build its list from config so it works from any buffer
|
||||
-- before the server attaches.
|
||||
|
||||
@@ -132,7 +132,10 @@ fix site.
|
||||
(align) vs `gww` (align w/o resize) distinction lost.
|
||||
- [ ] `VimwikiTable` is `-nargs=1` vs upstream `-nargs=*` (can't pass cols+rows).
|
||||
- [ ] `VimwikiListChangeLvl` is `-nargs=?` vs upstream `-range -nargs=+`.
|
||||
- [ ] `VimwikiRebuildTags` lacks `-bang` ("rebuild all" variant).
|
||||
- [x] `VimwikiRebuildTags` `-bang` ("rebuild all") — `:…RebuildTags!` now passes
|
||||
`{ all: true }`; the server (`tags_rebuild`) re-indexes **every** configured
|
||||
wiki (via `wikis_snapshot()`) instead of just the current one. `-bang` added to
|
||||
all four command defs.
|
||||
- [ ] `:VimwikiSearch` / `VWS` uses `lvimgrep`, not vimwiki's search engine.
|
||||
- [ ] `VimwikiIndex` family is buffer-local in nuwiki (upstream defines globally
|
||||
in `plugin/`); only `:…UISelect` is a global entry point.
|
||||
@@ -175,9 +178,12 @@ fix site.
|
||||
also switched both Neovim `Vimwiki/NuwikiTabIndex` from `vim.v.count` (always 0
|
||||
in command context) to `<count>`, so a `:NNuwikiTabIndex` count is now actually
|
||||
honored.
|
||||
- [ ] **`VimwikiToggleListItem` / `Increment` / `DecrementListItem` lack
|
||||
`-range`** (both branches) vs upstream's `-range` (`:350`) — no visual-range
|
||||
checkbox toggle / symbol cycle.
|
||||
- [x] **`VimwikiToggleListItem` / `Increment` / `DecrementListItem` `-range`** —
|
||||
all three (both branches) are now `-range`; the client loops the per-line op
|
||||
over `[<line1>, <line2>]` (`toggle_list_item_range` / `list_cycle_symbol_range`).
|
||||
The server edits are version-less single-line, so each line's edit applies
|
||||
independently — no server protocol change needed. Covered by
|
||||
`cmd.toggle_list_item_range` in `test-keymaps.lua`.
|
||||
- [ ] **Diary-note family lacks `-count`** _(new, 2026-05-31 re-audit)_ — upstream's
|
||||
`:Vimwiki{Make,TabMake,MakeYesterday,MakeTomorrow}DiaryNote` carry `-count=0`
|
||||
(the count selects the wiki number); nuwiki's diary-note commands declare no
|
||||
@@ -189,11 +195,14 @@ fix site.
|
||||
(colours), and the tag commands. nuwiki defines none, so `<Tab>` completion of
|
||||
page / tag / colour names at the `:` line is unavailable. _Fix:_
|
||||
`ftplugin/vimwiki.vim` (both branches) — VimL completers or LSP-backed.
|
||||
- [ ] **Minor command-attribute gaps** _(new)_ — `VimwikiNormalizeLink` lacks
|
||||
upstream's `-nargs=?`; `VimwikiCheckLinks` lacks `-range`. (`VimwikiColorize`
|
||||
`-nargs=1`→`-nargs=*` **done** — all four defs now match upstream, so a bare
|
||||
`:VimwikiColorize` prompts for the colour.) The remaining two would be
|
||||
accepted-but-ignored without handler work, so left open.
|
||||
- [x] **Minor command-attribute gaps** _(new)_ — all now real, not cosmetic:
|
||||
`VimwikiNormalizeLink` is `-nargs=?` and with `1` wraps the `'<`/`'>` selection
|
||||
(`wrap_visual_as_wikilink`, both clients; the `x`-mode `+` passes it too);
|
||||
`VimwikiCheckLinks` is `-range` and a ranged invocation filters the report to
|
||||
the current buffer's selected lines; `VimwikiColorize` `-nargs=1`→`-nargs=*`
|
||||
(bare `:VimwikiColorize` prompts). Covered by
|
||||
`normalize.visual_wraps_selection` (vim) /
|
||||
`cmd.normalize_link_visual_wraps_selection` (nvim).
|
||||
|
||||
### Config
|
||||
- [ ] `auto_header` — auto H1-from-filename on new page (server-side).
|
||||
|
||||
Reference in New Issue
Block a user