fix(vim): buffer commands honour g:vimwiki_list (<Leader>ww opened ~/vimwiki)
CI / cargo fmt --check (push) Successful in 33s
CI / cargo clippy (push) Successful in 33s
CI / cargo test (push) Successful in 41s
CI / editor keymaps (push) Successful in 1m23s

The g:vimwiki_* drop-in only fed the LSP payload (lsp.vim s:settings).
The buffer-side commands — <Leader>ww (wiki_index), :VimwikiSearch,
auto_chdir, diary, completion — resolve the wiki list independently via
s:wiki_cfg / nuwiki#commands#wiki_list, which read only g:nuwiki_wikis /
g:nuwiki_wiki_root. So with a g:vimwiki_list config the server knew the
wikis but <Leader>ww fell back to the default ~/vimwiki and opened an
empty index.

Extract the resolution into a single source of truth,
autoload/nuwiki/config.vim (nuwiki#config#wikis / #scalar_globals), which
resolves g:nuwiki_wikis or an upstream g:vimwiki_list and folds the global
scalar defaults. lsp.vim (payload), commands.vim, and diary.vim all route
through it — also dedups the s:wiki_cfg copy that lived in both
commands.vim and diary.vim.

Regression guard in test-vimwiki-compat-vim: nuwiki#commands#wiki_list()
must resolve the g:vimwiki_list roots (21 checks). All Vim harnesses +
config-parity goldens green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-05 00:40:48 +00:00
parent 346e8b0de6
commit 9d6d28a1b6
5 changed files with 137 additions and 131 deletions
@@ -41,6 +41,14 @@ call s:check('w0 numbering_sym', get(s:w0, 'html_header_numbering_sym', '')
call s:check('w1 root', get(s:w1, 'root', '') ==# '~/.vimwiki/ifood_wiki')
call s:check('w1 globals applied', get(s:w1, 'toc_header_level', 0) == 2)
" The buffer-side commands (e.g. <Leader>ww) must resolve the SAME wikis from
" g:vimwiki_list — not just the LSP payload. Regression guard for "<Leader>ww
" opens an empty ~/vimwiki".
let s:wl = nuwiki#commands#wiki_list()
call s:check('wiki_list sees vimwiki config', len(s:wl) == 2)
call s:check('wiki_list w0 root', len(s:wl) >= 1 && s:wl[0].root ==# expand('~/.vimwiki/personal_wiki'))
call s:check('wiki_list w1 root', len(s:wl) >= 2 && s:wl[1].root ==# expand('~/.vimwiki/ifood_wiki'))
" ----- nuwiki-native config wins over vimwiki -----
let g:nuwiki_wikis = [{'root': '~/native', 'name': 'native'}]
let s:cfg2 = nuwiki#lsp#settings()