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:
+21
-22
@@ -247,30 +247,29 @@ function M.wiki_tab_index(count)
|
||||
end)
|
||||
end
|
||||
|
||||
-- Pick a wiki and open its index. The list is read straight from config
|
||||
-- (no LSP round-trip) so this works from any buffer before a wiki file is
|
||||
-- ever opened; opening the index then auto-starts the server.
|
||||
function M.wiki_ui_select()
|
||||
exec('nuwiki.wiki.select', { {} }, function(r)
|
||||
if type(r) ~= 'table' or #r == 0 then
|
||||
vim.notify('nuwiki: no wikis configured')
|
||||
return
|
||||
local wikis = require('nuwiki.config').wiki_list()
|
||||
if #wikis == 0 then
|
||||
vim.notify('nuwiki: no wikis configured', vim.log.levels.WARN)
|
||||
return
|
||||
end
|
||||
vim.ui.select(
|
||||
wikis,
|
||||
{
|
||||
prompt = 'Select a wiki',
|
||||
format_item = function(w)
|
||||
return string.format('%s (%s)', w.name, w.root)
|
||||
end,
|
||||
},
|
||||
function(choice)
|
||||
if not choice then return end
|
||||
local path = choice.root .. '/' .. choice.idx .. choice.ext
|
||||
vim.cmd('edit ' .. vim.fn.fnameescape(vim.fn.expand(path)))
|
||||
end
|
||||
vim.ui.select(
|
||||
r,
|
||||
{
|
||||
prompt = 'Pick a wiki',
|
||||
format_item = function(w)
|
||||
return string.format('%d. %s (%s)', (w.id or 0) + 1, w.name or '?', tostring(w.root))
|
||||
end,
|
||||
},
|
||||
function(choice)
|
||||
if not choice then return end
|
||||
exec(
|
||||
'nuwiki.wiki.openIndex',
|
||||
{ { wiki = choice.id } },
|
||||
function(rr) if rr and rr.uri then open_uri(rr.uri) end end
|
||||
)
|
||||
end
|
||||
)
|
||||
end)
|
||||
)
|
||||
end
|
||||
|
||||
function M.wiki_goto_page(name)
|
||||
|
||||
Reference in New Issue
Block a user