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
+38
View File
@@ -689,6 +689,44 @@ call s:record(
\ 'cmd.VimwikiSplitLink_accepts_args',
\ 'err=' . s:sl_err)
" ===== Command-line completion (nuwiki#complete#*) =====
" Pure client-side completers backing the -complete= specs on VimwikiGoto
" (pages), VimwikiColorize (colours), and the tag commands. Driven directly
" (no LSP) against a throwaway wiki dir.
let s:cw = tempname()
call mkdir(s:cw, 'p')
call writefile(['= alpha =', 'tagged :foo:bar:'], s:cw . '/alpha.wiki')
call writefile(['= beta ='], s:cw . '/beta.wiki')
let s:save_root = get(g:, 'nuwiki_wiki_root', v:null)
let g:nuwiki_wiki_root = s:cw
let s:pg = nuwiki#complete#pages('a', '', 0)
call s:record(
\ (index(s:pg, 'alpha') >= 0 && index(s:pg, 'beta') < 0) ? 1 : 0,
\ 'complete.pages_globs_and_filters',
\ 'got ' . string(s:pg))
let s:tg = nuwiki#complete#tags('', '', 0)
call s:record(
\ (index(s:tg, 'foo') >= 0 && index(s:tg, 'bar') >= 0) ? 1 : 0,
\ 'complete.tags_scans_wiki_files',
\ 'got ' . string(s:tg))
if s:save_root is v:null
unlet g:nuwiki_wiki_root
else
let g:nuwiki_wiki_root = s:save_root
endif
call delete(s:cw, 'rf')
" Colours come from `color:NAME` spans already in the buffer.
call s:set_buf(['<span style="color:tomato">x</span> plain'])
let s:cl = nuwiki#complete#colors('t', '', 0)
call s:record(
\ index(s:cl, 'tomato') >= 0 ? 1 : 0,
\ 'complete.colors_from_buffer_spans',
\ 'got ' . string(s:cl))
" ===== Wrap up =====
call add(s:results, '')