feat(commands): command-line completion for Goto/Colorize/tag commands (P3)
CI / cargo fmt --check (push) Successful in 37s
CI / cargo clippy (push) Successful in 39s
CI / cargo test (push) Successful in 37s
CI / editor keymaps (push) Successful in 1m29s

Upstream attaches -complete= to several commands; nuwiki had none, so <Tab>
at the : line never completed page/tag/colour names. New
autoload/nuwiki/complete.vim adds pure client-side, synchronous completers
(config + filesystem, never the LSP — so they work under vim-lsp, coc and
Neovim), wired via -complete=customlist into all command contexts:

- nuwiki#complete#pages → VimwikiGoto/NuwikiGoto (glob wiki roots for page names)
- nuwiki#complete#colors → VimwikiColorize/NuwikiColorize (color_dic keys +
  colours already used in buffer color:… spans)
- nuwiki#complete#tags → VimwikiSearchTags/GenerateTagLinks/GenerateTags (+Nuwiki)
  (scan wiki files for :tag: runs — the tag index is server-side and a
  synchronous completer can't query it, so we read the same source it indexes)

Documented divergence: no file completer for VimwikiRenameFile — nuwiki
delegates renaming to the LSP rename request (no filename arg to complete),
unlike upstream which renames itself.

Tests: complete.{pages_globs_and_filters,tags_scans_wiki_files,
colors_from_buffer_spans} (test-keymaps-vim.vim). Both harnesses green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-31 20:40:22 +00:00
parent efea225240
commit 3b3d8ca782
4 changed files with 162 additions and 23 deletions
+18 -18
View File
@@ -69,7 +69,7 @@ if !has('nvim')
command! -buffer VimwikiBaddLink call nuwiki#commands#badd_link()
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 -nargs=1 -complete=customlist,nuwiki#complete#pages VimwikiGoto call nuwiki#commands#wiki_goto_page(<q-args>)
command! -buffer VimwikiDeleteFile call nuwiki#commands#delete_file()
command! -buffer VimwikiDeleteLink call nuwiki#commands#delete_file()
@@ -105,15 +105,15 @@ if !has('nvim')
command! -buffer VimwikiFindOrphans call nuwiki#commands#find_orphans()
command! -buffer -bang VimwikiRebuildTags call nuwiki#commands#tags_rebuild(<bang>0)
command! -buffer -nargs=? VimwikiSearchTags call nuwiki#commands#tags_search(<q-args>)
command! -buffer -nargs=? VimwikiGenerateTagLinks call nuwiki#commands#tags_generate_links(<q-args>)
command! -buffer -nargs=? VimwikiGenerateTags call nuwiki#commands#tags_generate_links(<q-args>)
command! -buffer -nargs=? -complete=customlist,nuwiki#complete#tags VimwikiSearchTags call nuwiki#commands#tags_search(<q-args>)
command! -buffer -nargs=? -complete=customlist,nuwiki#complete#tags VimwikiGenerateTagLinks call nuwiki#commands#tags_generate_links(<q-args>)
command! -buffer -nargs=? -complete=customlist,nuwiki#complete#tags VimwikiGenerateTags call nuwiki#commands#tags_generate_links(<q-args>)
" Tables, colorize, and clipboard paste.
command! -buffer -nargs=* VimwikiTable call nuwiki#commands#table_insert(<f-args>)
command! -buffer VimwikiTableMoveColumnLeft call nuwiki#commands#table_move_column_left()
command! -buffer VimwikiTableMoveColumnRight call nuwiki#commands#table_move_column_right()
command! -buffer -nargs=* -range VimwikiColorize call nuwiki#commands#colorize(<q-args>, <range>)
command! -buffer -nargs=* -range -complete=customlist,nuwiki#complete#colors VimwikiColorize call nuwiki#commands#colorize(<q-args>, <range>)
command! -buffer VimwikiPasteLink call nuwiki#commands#paste_link()
command! -buffer VimwikiPasteUrl call nuwiki#commands#paste_url()
command! -buffer VimwikiCatUrl call nuwiki#commands#cat_url()
@@ -149,9 +149,9 @@ if !has('nvim')
command! -buffer -range NuwikiCheckLinks call nuwiki#commands#check_links(<range>, <line1>, <line2>)
command! -buffer NuwikiFindOrphans call nuwiki#commands#find_orphans()
command! -buffer -bang NuwikiRebuildTags call nuwiki#commands#tags_rebuild(<bang>0)
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>)
command! -buffer -nargs=? -complete=customlist,nuwiki#complete#tags NuwikiSearchTags call nuwiki#commands#tags_search(<q-args>)
command! -buffer -nargs=? -complete=customlist,nuwiki#complete#tags NuwikiGenerateTagLinks call nuwiki#commands#tags_generate_links(<q-args>)
command! -buffer -nargs=1 -complete=customlist,nuwiki#complete#pages NuwikiGoto call nuwiki#commands#wiki_goto_page(<q-args>)
" Canonical :Nuwiki* names that mirror the documented surface.
" The older :Nuwiki* spellings above stay defined for back-compat.
@@ -185,7 +185,7 @@ if !has('nvim')
command! -buffer -nargs=* NuwikiTable call nuwiki#commands#table_insert(<f-args>)
command! -buffer NuwikiTableMoveColumnLeft call nuwiki#commands#table_move_column_left()
command! -buffer NuwikiTableMoveColumnRight call nuwiki#commands#table_move_column_right()
command! -buffer -nargs=* -range NuwikiColorize call nuwiki#commands#colorize(<q-args>, <range>)
command! -buffer -nargs=* -range -complete=customlist,nuwiki#complete#colors NuwikiColorize call nuwiki#commands#colorize(<q-args>, <range>)
command! -buffer NuwikiPasteLink call nuwiki#commands#paste_link()
command! -buffer NuwikiPasteUrl call nuwiki#commands#paste_url()
command! -buffer NuwikiCatUrl call nuwiki#commands#cat_url()
@@ -412,7 +412,7 @@ command! -buffer VimwikiTabDropLink lua require('nuwiki.commands').follow
command! -buffer VimwikiNextLink lua require('nuwiki.commands').link_next()
command! -buffer VimwikiPrevLink lua require('nuwiki.commands').link_prev()
command! -buffer VimwikiBaddLink lua require('nuwiki.commands').badd_link()
command! -buffer -nargs=1 VimwikiGoto lua require('nuwiki.commands').wiki_goto_page(<q-args>)
command! -buffer -nargs=1 -complete=customlist,nuwiki#complete#pages VimwikiGoto lua require('nuwiki.commands').wiki_goto_page(<q-args>)
command! -buffer VimwikiBacklinks lua vim.lsp.buf.references()
command! -buffer VWB lua vim.lsp.buf.references()
command! -buffer -nargs=1 VimwikiSearch lvimgrep /<args>/ **
@@ -453,15 +453,15 @@ command! -buffer -range VimwikiCheckLinks lua require('nuwiki.commands').
command! -buffer VimwikiFindOrphans lua require('nuwiki.commands').find_orphans()
command! -buffer -bang VimwikiRebuildTags lua require('nuwiki.commands').tags_rebuild('<bang>' == '!')
command! -buffer -nargs=? VimwikiSearchTags lua require('nuwiki.commands').tags_search(<q-args>)
command! -buffer -nargs=? VimwikiGenerateTagLinks lua require('nuwiki.commands').tags_generate_links(<q-args>)
command! -buffer -nargs=? VimwikiGenerateTags lua require('nuwiki.commands').tags_generate_links(<q-args>)
command! -buffer -nargs=? -complete=customlist,nuwiki#complete#tags VimwikiSearchTags lua require('nuwiki.commands').tags_search(<q-args>)
command! -buffer -nargs=? -complete=customlist,nuwiki#complete#tags VimwikiGenerateTagLinks lua require('nuwiki.commands').tags_generate_links(<q-args>)
command! -buffer -nargs=? -complete=customlist,nuwiki#complete#tags VimwikiGenerateTags lua require('nuwiki.commands').tags_generate_links(<q-args>)
" Tables, colorize, and clipboard paste.
command! -buffer -nargs=* VimwikiTable lua require('nuwiki.commands').table_insert(<f-args>)
command! -buffer VimwikiTableMoveColumnLeft lua require('nuwiki.commands').table_move_column_left()
command! -buffer VimwikiTableMoveColumnRight lua require('nuwiki.commands').table_move_column_right()
command! -buffer -nargs=* -range VimwikiColorize lua require('nuwiki.commands').colorize(<q-args>, <range> > 0)
command! -buffer -nargs=* -range -complete=customlist,nuwiki#complete#colors VimwikiColorize lua require('nuwiki.commands').colorize(<q-args>, <range> > 0)
command! -buffer VimwikiPasteLink lua require('nuwiki.commands').paste_link()
command! -buffer VimwikiPasteUrl lua require('nuwiki.commands').paste_url()
command! -buffer VimwikiCatUrl lua require('nuwiki.commands').cat_url()
@@ -493,9 +493,9 @@ command! -buffer NuwikiGenerateLinks lua require('nuwiki.commands').
command! -buffer -range NuwikiCheckLinks lua require('nuwiki.commands').check_links(<range>, <line1>, <line2>)
command! -buffer NuwikiFindOrphans lua require('nuwiki.commands').find_orphans()
command! -buffer -bang NuwikiRebuildTags lua require('nuwiki.commands').tags_rebuild('<bang>' == '!')
command! -buffer -nargs=? NuwikiSearchTags lua require('nuwiki.commands').tags_search(<q-args>)
command! -buffer -nargs=? NuwikiGenerateTagLinks lua require('nuwiki.commands').tags_generate_links(<q-args>)
command! -buffer -nargs=1 NuwikiGoto lua require('nuwiki.commands').wiki_goto_page(<q-args>)
command! -buffer -nargs=? -complete=customlist,nuwiki#complete#tags NuwikiSearchTags lua require('nuwiki.commands').tags_search(<q-args>)
command! -buffer -nargs=? -complete=customlist,nuwiki#complete#tags NuwikiGenerateTagLinks lua require('nuwiki.commands').tags_generate_links(<q-args>)
command! -buffer -nargs=1 -complete=customlist,nuwiki#complete#pages NuwikiGoto lua require('nuwiki.commands').wiki_goto_page(<q-args>)
" Canonical :Nuwiki* names that mirror the documented surface.
" The older :Nuwiki* spellings above stay defined for back-compat.
@@ -533,7 +533,7 @@ command! -buffer NuwikiTableAlign lua require('nuwiki.command
command! -buffer -nargs=* NuwikiTable lua require('nuwiki.commands').table_insert(<f-args>)
command! -buffer NuwikiTableMoveColumnLeft lua require('nuwiki.commands').table_move_column_left()
command! -buffer NuwikiTableMoveColumnRight lua require('nuwiki.commands').table_move_column_right()
command! -buffer -nargs=* -range NuwikiColorize lua require('nuwiki.commands').colorize(<q-args>, <range> > 0)
command! -buffer -nargs=* -range -complete=customlist,nuwiki#complete#colors NuwikiColorize lua require('nuwiki.commands').colorize(<q-args>, <range> > 0)
command! -buffer NuwikiPasteLink lua require('nuwiki.commands').paste_link()
command! -buffer NuwikiPasteUrl lua require('nuwiki.commands').paste_url()
command! -buffer NuwikiCatUrl lua require('nuwiki.commands').cat_url()