fix(wiki): build wiki picker list from config so it works before opening a file
The picker fetched the wiki list via workspace/executeCommand, but the LSP only starts once a vimwiki buffer exists — so a wiki could not be selected until one was already open (chicken-and-egg). Read the list straight from config instead (g:nuwiki_wikis / scalar fallback, the same source as open_wiki_path) and open the chosen index directly; that auto-starts the server via the FileType autocmd. - Vim: new public nuwiki#commands#wiki_list(); wiki_ui_select() uses it + inputlist() + :edit. Global :VimwikiUISelect / :NuwikiUISelect commands. - Neovim: config.wiki_cfg(n) + config.wiki_list() (init.lua delegates); commands.wiki_ui_select() uses them + vim.ui.select + :edit; global VimwikiUISelect / NuwikiUISelect user commands registered in setup(). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -321,6 +321,30 @@ call s:record(
|
||||
\ 'conceal.cursor_line_revealed_in_normal_mode',
|
||||
\ '&l:concealcursor=' . &l:concealcursor)
|
||||
|
||||
" ===== Wiki picker (config-driven, no LSP) =====
|
||||
|
||||
" The picker builds its list straight from config so it works from any buffer
|
||||
" before the LSP (which only starts on a wiki buffer) is running.
|
||||
let g:nuwiki_wikis = [
|
||||
\ {'name': 'Personal', 'root': '/tmp/nuwiki-a'},
|
||||
\ {'name': 'Work', 'root': '/tmp/nuwiki-b', 'file_extension': 'md'},
|
||||
\ ]
|
||||
let s:wl = nuwiki#commands#wiki_list()
|
||||
call s:record(
|
||||
\ len(s:wl) == 2 ? 1 : 0,
|
||||
\ 'wiki_select.lists_all_configured_wikis',
|
||||
\ 'count=' . len(s:wl))
|
||||
call s:record(
|
||||
\ get(get(s:wl, 0, {}), 'name', '') ==# 'Personal'
|
||||
\ && get(get(s:wl, 1, {}), 'name', '') ==# 'Work' ? 1 : 0,
|
||||
\ 'wiki_select.preserves_names_and_order',
|
||||
\ 'names=' . string(map(copy(s:wl), 'get(v:val, "name", "")')))
|
||||
call s:record(
|
||||
\ get(get(s:wl, 1, {}), 'ext', '') ==# '.md' ? 1 : 0,
|
||||
\ 'wiki_select.honours_per_wiki_extension',
|
||||
\ 'ext=' . get(get(s:wl, 1, {}), 'ext', ''))
|
||||
unlet g:nuwiki_wikis
|
||||
|
||||
" ===== Wrap up =====
|
||||
|
||||
call add(s:results, '')
|
||||
|
||||
Reference in New Issue
Block a user