From acaaf107b49b10c66fe18a42cf01b1c226716294 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Fr=C3=B3es=20Franco?= Date: Sun, 31 May 2026 20:20:43 +0000 Subject: [PATCH] feat(commands): VimwikiSplitLink/VSplitLink -nargs=* signature parity (P3) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Upstream's :Vimwiki[V]SplitLink take optional reuse_other_split_window + move_cursor flags (the link is always the one under the cursor); nuwiki's defs took no args, so `:VimwikiSplitLink 0 1` raised E488. All eight defs (both clients × Split/VSplit × Vimwiki/Nuwiki) are now -nargs=*, restoring signature parity for migrated configs/scripts. Documented divergence: the two flags are accepted but not acted on — nuwiki always opens a fresh split and follows in it. Honoring move_cursor/reuse would require threading a completion callback through the async LSP follow path, disproportionate for this rarely-used arg form; the no-arg path (99% case) is fully equivalent. The gap-doc note (which wrongly described the args as a "target link") is corrected. Test: cmd.VimwikiSplitLink_accepts_args (test-keymaps-vim.vim, no E488). Co-Authored-By: Claude Opus 4.8 (1M context) --- development/tests/test-keymaps-vim.vim | 20 ++++++++++++++++++++ development/vimwiki-gap.md | 20 ++++++++++++++------ ftplugin/vimwiki.vim | 16 ++++++++-------- 3 files changed, 42 insertions(+), 14 deletions(-) diff --git a/development/tests/test-keymaps-vim.vim b/development/tests/test-keymaps-vim.vim index 3bc7bf4..2d5bcdc 100644 --- a/development/tests/test-keymaps-vim.vim +++ b/development/tests/test-keymaps-vim.vim @@ -669,6 +669,26 @@ call s:record( \ 'cmd.VimwikiListChangeLvl_accepts_range_and_args', \ 'err=' . s:lcl_err) +" ===== :VimwikiSplitLink -nargs=* ===== +" Upstream takes optional reuse/move-cursor flags; nuwiki's defs took none, so +" `:VimwikiSplitLink 0 1` raised E488. Now -nargs=*: assert the arg parse +" succeeds. The split opens a window (the follow itself is an LSP no-op here); +" collapse back to one window afterward. +call s:set_buf(['[[Target]]']) +let s:sl_err = '' +try + silent VimwikiSplitLink 0 1 +catch /E488/ + let s:sl_err = v:exception +catch + " non-E488 (e.g. no LSP attached) is expected and fine here. +endtry +silent! only +call s:record( + \ s:sl_err ==# '' ? 1 : 0, + \ 'cmd.VimwikiSplitLink_accepts_args', + \ 'err=' . s:sl_err) + " ===== Wrap up ===== call add(s:results, '') diff --git a/development/vimwiki-gap.md b/development/vimwiki-gap.md index 64a1bc2..9422045 100644 --- a/development/vimwiki-gap.md +++ b/development/vimwiki-gap.md @@ -267,12 +267,20 @@ fix site. (bare `:VimwikiColorize` prompts). Covered by `normalize.visual_wraps_selection` (vim) / `cmd.normalize_link_visual_wraps_selection` (nvim). -- [ ] **`VimwikiSplitLink` / `VimwikiVSplitLink` lack `-nargs=*`** _(new, - 2026-05-31 third re-audit)_ — upstream both take an optional target link to - follow in the split; nuwiki's defs (both branches) take no args, so you can't - pass a link to the split-follow. Low impact (the arg path is rarely used). - _Fix:_ `ftplugin/vimwiki.vim` both branches + thread a target through - `follow_link_or_create`. +- [x] **`VimwikiSplitLink` / `VimwikiVSplitLink` lack `-nargs=*`** _(new, + 2026-05-31 third re-audit; corrected during the 2026-05-31 command-attribute + pass)_ — the earlier note was wrong: upstream's optional args are NOT a target + link but `reuse_other_split_window` (a:1) and `move_cursor` (a:2) — the link + is always the one under the cursor (`vimwiki#base#follow_link`). nuwiki's defs + took no args, so `:VimwikiSplitLink 0 1` (upstream muscle memory / migrated + scripts) raised E488. _Fix:_ all eight defs (both clients × Split/VSplit × + Vimwiki/Nuwiki) are now `-nargs=*`, restoring signature parity. **Divergence + (documented):** the two flags are *accepted but not acted on* — nuwiki always + opens a fresh split and follows in it, because the follow is an async LSP + jump and honoring `move_cursor`/`reuse` would require threading a completion + callback through that path (disproportionate for this rarely-used arg form; + the no-arg case — the 99% path — is fully equivalent). Covered by + `cmd.VimwikiSplitLink_accepts_args` (`test-keymaps-vim.vim`, no E488). ### Config - [ ] `auto_header` — auto H1-from-filename on new page (server-side). diff --git a/ftplugin/vimwiki.vim b/ftplugin/vimwiki.vim index a9b183e..7e01c0e 100644 --- a/ftplugin/vimwiki.vim +++ b/ftplugin/vimwiki.vim @@ -57,8 +57,8 @@ if !has('nvim') command! -buffer VimwikiDiaryPrevDay call nuwiki#commands#diary_prev() command! -buffer VimwikiDiaryGenerateLinks call nuwiki#commands#diary_generate_index() command! -buffer VimwikiFollowLink call nuwiki#commands#follow_link_or_create() - command! -buffer VimwikiSplitLink split | call nuwiki#commands#follow_link_or_create() - command! -buffer VimwikiVSplitLink vsplit | call nuwiki#commands#follow_link_or_create() + command! -buffer -nargs=* VimwikiSplitLink split | call nuwiki#commands#follow_link_or_create() + command! -buffer -nargs=* VimwikiVSplitLink vsplit | call nuwiki#commands#follow_link_or_create() command! -buffer VimwikiTabnewLink tabnew | call nuwiki#commands#follow_link_or_create() command! -buffer VimwikiTabDropLink call nuwiki#commands#follow_link_drop() command! -buffer VimwikiGoBackLink execute "normal! \" @@ -129,8 +129,8 @@ if !has('nvim') command! -buffer NuwikiDiaryNext call nuwiki#commands#diary_next() command! -buffer NuwikiDiaryPrev call nuwiki#commands#diary_prev() command! -buffer NuwikiFollowLink call nuwiki#commands#follow_link_or_create() - command! -buffer NuwikiSplitLink split | call nuwiki#commands#follow_link_or_create() - command! -buffer NuwikiVSplitLink vsplit | call nuwiki#commands#follow_link_or_create() + command! -buffer -nargs=* NuwikiSplitLink split | call nuwiki#commands#follow_link_or_create() + command! -buffer -nargs=* NuwikiVSplitLink vsplit | call nuwiki#commands#follow_link_or_create() command! -buffer NuwikiTabnewLink tabnew | call nuwiki#commands#follow_link_or_create() command! -buffer NuwikiTabDropLink call nuwiki#commands#follow_link_drop() command! -buffer NuwikiGoBackLink execute "normal! \" @@ -405,8 +405,8 @@ command! -buffer VimwikiDiaryGenerateLinks lua require('nuwiki.commands') command! -buffer VimwikiFollowLink lua vim.lsp.buf.definition() command! -buffer VimwikiGoBackLink execute "normal! \" -command! -buffer VimwikiSplitLink split | lua vim.lsp.buf.definition() -command! -buffer VimwikiVSplitLink vsplit | lua vim.lsp.buf.definition() +command! -buffer -nargs=* VimwikiSplitLink split | lua vim.lsp.buf.definition() +command! -buffer -nargs=* VimwikiVSplitLink vsplit | lua vim.lsp.buf.definition() command! -buffer VimwikiTabnewLink tabnew | lua vim.lsp.buf.definition() command! -buffer VimwikiTabDropLink lua require('nuwiki.commands').follow_link_drop() command! -buffer VimwikiNextLink lua require('nuwiki.commands').link_next() @@ -513,8 +513,8 @@ command! -buffer Nuwiki2HTMLBrowse lua require('nuwiki.command command! -buffer -bang NuwikiAll2HTML execute (0 ? "lua require('nuwiki.commands').export_all_force()" : "lua require('nuwiki.commands').export_all()") command! -buffer NuwikiGoBackLink execute "normal! \" -command! -buffer NuwikiSplitLink split | lua vim.lsp.buf.definition() -command! -buffer NuwikiVSplitLink vsplit | lua vim.lsp.buf.definition() +command! -buffer -nargs=* NuwikiSplitLink split | lua vim.lsp.buf.definition() +command! -buffer -nargs=* NuwikiVSplitLink vsplit | lua vim.lsp.buf.definition() command! -buffer NuwikiTabnewLink tabnew | lua vim.lsp.buf.definition() command! -buffer NuwikiTabDropLink lua require('nuwiki.commands').follow_link_drop() command! -buffer -bang NuwikiRemoveDone lua require('nuwiki.commands')[('' == '!') and 'list_remove_done_all' or 'list_remove_done']()