feat(vim): :Vimwiki* / :Nuwiki* commands for plain Vim via vim-lsp
CI / cargo fmt --check (push) Successful in 30s
CI / cargo clippy (push) Successful in 1m16s
CI / cargo test (push) Successful in 1m27s

The Phase 19 ftplugin only registered the command surface on Neovim
and finished early for plain Vim, leaving `start-vim.sh` users with
only commentstring + suffixesadd — exactly the "no commands" report.

`autoload/nuwiki/commands.vim` now ships the Vim-side dispatch:
- `s:exec` sends `workspace/executeCommand` through vim-lsp's
  `lsp#send_request`. Optional callback for commands that return data.
- `s:open_uri_from` reads `{ uri }` out of the LSP response and runs
  `:edit` (or `:tabedit` for the tab variants).
- `s:results_to_qf` lifts `checkLinks` / `findOrphans` / `tags.search`
  arrays into the quickfix list and opens `:copen` — same UX as the
  Neovim path.
- `s:open_browser` fires `open` / `xdg-open` after `export.browse`.
- §13.1 deferred commands stub out with a "not yet implemented"
  notification so users get the same signal as on Neovim.

`ftplugin/vimwiki.vim` defines the same `:Vimwiki*` / `:Nuwiki*`
command set on the plain-Vim path, each delegating to its
`nuwiki#commands#…` autoload counterpart. `:VimwikiFollowLink` /
`:VimwikiBacklinks` map straight to vim-lsp's `:LspDefinition` /
`:LspReferences`. coc.nvim users can still use `:CocCommand` directly
and ignore the aliases entirely.

Verified with `vim -e -s -u .vimrc index.wiki`:
  filetype=vimwiki, did_ftplugin=1,
  :VimwikiTOC, :NuwikiIndex, :VimwikiToggleListItem all defined.

Total 377 tests still pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-11 22:23:06 +00:00
parent 09b9bd98a3
commit 04df170791
2 changed files with 332 additions and 3 deletions
+82 -3
View File
@@ -22,9 +22,88 @@ setlocal iskeyword+=-
let b:undo_ftplugin = 'setlocal commentstring< comments< formatoptions< suffixesadd< iskeyword<'
if !has('nvim')
" Plain Vim — the buffer-local options above are all we ship. Vim users
" interact via the LSP client (vim-lsp / coc) which already exposes
" `:LspDefinition`, `:LspReferences`, `:LspRename`, etc.
" ===== Plain Vim path =====
"
" Define the same `:Vimwiki*` / `:Nuwiki*` surface here, dispatching
" through `autoload/nuwiki/commands.vim` (which talks to vim-lsp).
" coc.nvim users can run `:CocCommand nuwiki.x` directly and skip
" these aliases.
command! -buffer -count VimwikiIndex call nuwiki#commands#wiki_index(<count>)
command! -buffer -count VimwikiTabIndex call nuwiki#commands#wiki_tab_index(<count>)
command! -buffer VimwikiDiaryIndex call nuwiki#commands#diary_index()
command! -buffer VimwikiMakeDiaryNote call nuwiki#commands#diary_today()
command! -buffer VimwikiMakeYesterdayDiaryNote call nuwiki#commands#diary_yesterday()
command! -buffer VimwikiMakeTomorrowDiaryNote call nuwiki#commands#diary_tomorrow()
command! -buffer VimwikiDiaryNextDay call nuwiki#commands#diary_next()
command! -buffer VimwikiDiaryPrevDay call nuwiki#commands#diary_prev()
command! -buffer VimwikiDiaryGenerateLinks call nuwiki#commands#diary_generate_index()
command! -buffer VimwikiFollowLink LspDefinition
command! -buffer VimwikiBacklinks LspReferences
command! -buffer VWB LspReferences
command! -buffer -nargs=1 VimwikiSearch lvimgrep /<args>/ **
command! -buffer -nargs=1 VWS lvimgrep /<args>/ **
command! -buffer -nargs=1 VimwikiGoto call nuwiki#commands#wiki_goto_page(<q-args>)
command! -buffer VimwikiDeleteFile call nuwiki#commands#delete_file()
command! -buffer VimwikiRenameFile call nuwiki#commands#rename_file()
command! -buffer VimwikiNextTask call nuwiki#commands#next_task()
command! -buffer VimwikiToggleListItem call nuwiki#commands#toggle_list_item()
command! -buffer VimwikiToggleRejectedListItem call nuwiki#commands#reject_list_item()
command! -buffer VimwikiRemoveDone call nuwiki#commands#list_remove_done()
command! -buffer -nargs=? VimwikiListChangeLvl call nuwiki#commands#list_change_lvl()
command! -buffer Vimwiki2HTML call nuwiki#commands#export_current()
command! -buffer Vimwiki2HTMLBrowse call nuwiki#commands#export_browse()
command! -buffer -bang VimwikiAll2HTML if <bang>0 | call nuwiki#commands#export_all_force() | else | call nuwiki#commands#export_all() | endif
command! -buffer VimwikiRss call nuwiki#commands#export_rss()
command! -buffer VimwikiTOC call nuwiki#commands#toc_generate()
command! -buffer VimwikiGenerateLinks call nuwiki#commands#links_generate()
command! -buffer VimwikiCheckLinks call nuwiki#commands#check_links()
command! -buffer VimwikiFindOrphans call nuwiki#commands#find_orphans()
command! -buffer VimwikiRebuildTags call nuwiki#commands#tags_rebuild()
command! -buffer -nargs=? VimwikiSearchTags call nuwiki#commands#tags_search(<q-args>)
command! -buffer -nargs=? VimwikiGenerateTagLinks call nuwiki#commands#tags_generate_links(<q-args>)
" §13.1 deferred stubs.
command! -buffer -nargs=1 VimwikiTable call nuwiki#commands#table_insert()
command! -buffer VimwikiTableMoveColumnLeft call nuwiki#commands#table_move_left()
command! -buffer VimwikiTableMoveColumnRight call nuwiki#commands#table_move_right()
command! -buffer -nargs=1 VimwikiColorize call nuwiki#commands#colorize(<q-args>)
command! -buffer VimwikiPasteLink call nuwiki#commands#paste_link()
command! -buffer VimwikiPasteUrl call nuwiki#commands#paste_url()
" :Nuwiki* canonical aliases (P10) — Vim side.
command! -buffer -count NuwikiIndex call nuwiki#commands#wiki_index(<count>)
command! -buffer NuwikiTabIndex call nuwiki#commands#wiki_tab_index(<count>)
command! -buffer NuwikiDiaryIndex call nuwiki#commands#diary_index()
command! -buffer NuwikiDiaryToday call nuwiki#commands#diary_today()
command! -buffer NuwikiDiaryYesterday call nuwiki#commands#diary_yesterday()
command! -buffer NuwikiDiaryTomorrow call nuwiki#commands#diary_tomorrow()
command! -buffer NuwikiDiaryNext call nuwiki#commands#diary_next()
command! -buffer NuwikiDiaryPrev call nuwiki#commands#diary_prev()
command! -buffer NuwikiFollowLink LspDefinition
command! -buffer NuwikiBacklinks LspReferences
command! -buffer NuwikiDeleteFile call nuwiki#commands#delete_file()
command! -buffer NuwikiRenameFile call nuwiki#commands#rename_file()
command! -buffer NuwikiNextTask call nuwiki#commands#next_task()
command! -buffer NuwikiToggleListItem call nuwiki#commands#toggle_list_item()
command! -buffer NuwikiToggleRejected call nuwiki#commands#reject_list_item()
command! -buffer NuwikiExport call nuwiki#commands#export_current()
command! -buffer NuwikiExportBrowse call nuwiki#commands#export_browse()
command! -buffer -bang NuwikiExportAll if <bang>0 | call nuwiki#commands#export_all_force() | else | call nuwiki#commands#export_all() | endif
command! -buffer NuwikiRss call nuwiki#commands#export_rss()
command! -buffer NuwikiTOC call nuwiki#commands#toc_generate()
command! -buffer NuwikiGenerateLinks call nuwiki#commands#links_generate()
command! -buffer NuwikiCheckLinks call nuwiki#commands#check_links()
command! -buffer NuwikiFindOrphans call nuwiki#commands#find_orphans()
command! -buffer NuwikiRebuildTags call nuwiki#commands#tags_rebuild()
command! -buffer -nargs=? NuwikiSearchTags call nuwiki#commands#tags_search(<q-args>)
command! -buffer -nargs=? NuwikiGenerateTagLinks call nuwiki#commands#tags_generate_links(<q-args>)
command! -buffer -nargs=1 NuwikiGoto call nuwiki#commands#wiki_goto_page(<q-args>)
finish
endif