feat(config): bridge setup({wikis}) to g:nuwiki_wikis for VimL plugins
A Lua-only `setup({ wikis = … })` config is invisible to the VimL side:
the buffer helpers in autoload/nuwiki/config.vim and the vimwiki compat
shim (autoload/vimwiki/vars.vim, which third-party plugins like
vimwiki-sync call via vimwiki#vars#get_wikilocal) read g:nuwiki_wikis. So
a Neovim user who migrated from g:vimwiki_list to native setup({wikis})
would break vimwiki-sync (it'd resolve the default ~/vimwiki).
setup() now publishes the resolved wiki list to g:nuwiki_wikis when the
config came from setup() opts (the only case VimL can't already see —
g:nuwiki_wikis / g:vimwiki_list configs are global and visible). Verified
vimwiki#vars#get_wikilocal('path', n) returns the right roots from a
pure-Lua setup() config. test-global-shorthand grows two bridge checks
(17). Goldens + keymap harnesses green.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -71,6 +71,16 @@ vim.g.nuwiki_wikis = nil
|
|||||||
vim.g.vimwiki_list = nil
|
vim.g.vimwiki_list = nil
|
||||||
vim.g.vimwiki_toc_header_level = nil
|
vim.g.vimwiki_toc_header_level = nil
|
||||||
|
|
||||||
|
-- ----- setup({ wikis }) bridges the Lua config to VimL (g:nuwiki_wikis) -----
|
||||||
|
-- So buffer-side VimL helpers + the vimwiki-sync compat shim see the same
|
||||||
|
-- wikis as the LSP, even though setup() config lives only in Lua.
|
||||||
|
require('nuwiki').setup({ wikis = { { root = '/tmp/a', name = 'A' }, { root = '/tmp/b' } } })
|
||||||
|
check('setup() bridges to g:nuwiki_wikis',
|
||||||
|
vim.g.nuwiki_wikis ~= nil and #vim.g.nuwiki_wikis == 2)
|
||||||
|
check('bridged wiki root visible to VimL',
|
||||||
|
vim.g.nuwiki_wikis and vim.g.nuwiki_wikis[1].root == '/tmp/a')
|
||||||
|
vim.g.nuwiki_wikis = nil
|
||||||
|
|
||||||
local f = assert(io.open(os.getenv('NUWIKI_GS_OUT'), 'w'))
|
local f = assert(io.open(os.getenv('NUWIKI_GS_OUT'), 'w'))
|
||||||
f:write(table.concat(out, '\n') .. '\n')
|
f:write(table.concat(out, '\n') .. '\n')
|
||||||
f:close()
|
f:close()
|
||||||
|
|||||||
@@ -93,6 +93,17 @@ end
|
|||||||
function M.setup(opts)
|
function M.setup(opts)
|
||||||
config.apply(opts or {})
|
config.apply(opts or {})
|
||||||
|
|
||||||
|
-- Bridge a Lua-only `setup({ wikis = … })` config to VimL. The buffer-side
|
||||||
|
-- VimL helpers (autoload/nuwiki/config.vim) and the vimwiki compat shim
|
||||||
|
-- (autoload/vimwiki/vars.vim — used by third-party plugins such as
|
||||||
|
-- vimwiki-sync) read `g:nuwiki_wikis`, which can't see a config that only
|
||||||
|
-- lives in Lua. Publishing the resolved list keeps both worlds in sync. (A
|
||||||
|
-- `g:nuwiki_wikis` / `g:vimwiki_list` config is already VimL-visible, so this
|
||||||
|
-- only fires for the pure-`setup()` case.)
|
||||||
|
if type(config.options.wikis) == 'table' and #config.options.wikis > 0 then
|
||||||
|
vim.g.nuwiki_wikis = config.wikis()
|
||||||
|
end
|
||||||
|
|
||||||
-- Neovim 0.7+ resolves filetypes via `vim.filetype.match` before any
|
-- Neovim 0.7+ resolves filetypes via `vim.filetype.match` before any
|
||||||
-- `ftdetect/*.vim` autocmd fires, and its bundled rule for `*.wiki`
|
-- `ftdetect/*.vim` autocmd fires, and its bundled rule for `*.wiki`
|
||||||
-- returns `mediawiki`. Register an authoritative rule here so this
|
-- returns `mediawiki`. Register an authoritative rule here so this
|
||||||
|
|||||||
Reference in New Issue
Block a user