feat(commands): command-line completion for Goto/Colorize/tag commands (P3)
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:
@@ -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, '')
|
||||
|
||||
@@ -270,11 +270,26 @@ fix site.
|
||||
half is done: all four defs now use upstream's `-count=0` instead of bare
|
||||
`-count`; `wiki_index`/`wiki_tab_index` already map the count to the wiki
|
||||
number.)_
|
||||
- [ ] **No `-complete=` specs** _(new)_ — upstream attaches command-line completion
|
||||
to `VimwikiGoto` (links), `VimwikiRenameFile` (files), `VimwikiColorize`
|
||||
(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.
|
||||
- [x] **`-complete=` specs** _(new; done 2026-05-31 command-attribute pass)_ —
|
||||
upstream attaches command-line completion to several commands; nuwiki had
|
||||
none, so `<Tab>` at the `:` line never completed page / tag / colour names.
|
||||
_Fix:_ new `autoload/nuwiki/complete.vim` with pure client-side, synchronous
|
||||
completers (config + filesystem, never the LSP, so they work under vim-lsp,
|
||||
coc and Neovim alike), wired via `-complete=customlist,…` into all branches:
|
||||
- `nuwiki#complete#pages` → `VimwikiGoto`/`NuwikiGoto` (globs every wiki
|
||||
root's `*<ext>` files → root-relative page names).
|
||||
- `nuwiki#complete#colors` → `VimwikiColorize`/`NuwikiColorize` (keys from a
|
||||
configured `color_dic` + colours already used in buffer `color:…` spans).
|
||||
- `nuwiki#complete#tags` → `VimwikiSearchTags`/`GenerateTagLinks`/
|
||||
`GenerateTags` (+ Nuwiki forms) — scans the wikis' files for `:tag:` runs
|
||||
(the tag index lives in the server, which a synchronous completer can't
|
||||
query; the file scan reads the same source the server indexes).
|
||||
**Divergence (documented):** no file completer for `VimwikiRenameFile` —
|
||||
upstream completes a new-name arg because it renames itself, but nuwiki
|
||||
delegates renaming to the LSP rename request (`:LspRename`/coc), which drives
|
||||
its own prompt and takes no filename argument. Covered by
|
||||
`complete.pages_globs_and_filters`, `complete.tags_scans_wiki_files`,
|
||||
`complete.colors_from_buffer_spans` (`test-keymaps-vim.vim`).
|
||||
- [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);
|
||||
|
||||
Reference in New Issue
Block a user