b922f0d612
Expose the init_options payload builders publicly in both clients
(M.init_options/M.server_settings in Lua, nuwiki#lsp#settings() in Vim) so
they can be inspected. Add editor harnesses that dump each client's
server-bound config as deterministic key=value lines and diff against a
shared golden file: nvim == golden and vim == golden together prove the two
clients send identical config. Add a server-side test asserting the Vim flat
shape and the Neovim {nuwiki:{...}} wrapper desugar to the same WikiConfig.
Wire both harnesses into CI.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
75 lines
2.2 KiB
Lua
75 lines
2.2 KiB
Lua
-- development/tests/test-config.lua — dump the Neovim client's
|
|
-- `initialization_options` payload for two scenarios (default config and a
|
|
-- representative multi-wiki sample) as deterministic `key=value` lines.
|
|
--
|
|
-- The runner (test-config.sh) diffs the output against
|
|
-- development/tests/config-expected.txt. The Vim harness
|
|
-- (test-config-vim.vim) emits byte-identical lines against the SAME golden,
|
|
-- so "nvim == golden" and "vim == golden" together prove the two clients
|
|
-- send the same server-bound config — i.e. Vim/Neovim config parity.
|
|
--
|
|
-- Only the server-relevant keys are emitted (wiki_root, file_extension,
|
|
-- syntax, log_level, wikis[*]). `mappings`/`folding` are client-side
|
|
-- concerns the server ignores, so they're intentionally excluded.
|
|
|
|
local out = assert(os.getenv('NUWIKI_CONFIG_OUT'), 'NUWIKI_CONFIG_OUT unset')
|
|
|
|
local config = require('nuwiki.config')
|
|
local lsp = require('nuwiki.lsp')
|
|
|
|
local lines = {}
|
|
local function emit(s)
|
|
lines[#lines + 1] = s
|
|
end
|
|
|
|
local function dump(payload)
|
|
emit('wiki_root=' .. tostring(payload.wiki_root))
|
|
emit('file_extension=' .. tostring(payload.file_extension))
|
|
emit('syntax=' .. tostring(payload.syntax))
|
|
emit('log_level=' .. tostring(payload.log_level))
|
|
if payload.wikis then
|
|
for i, w in ipairs(payload.wikis) do
|
|
local keys = {}
|
|
for k in pairs(w) do
|
|
keys[#keys + 1] = k
|
|
end
|
|
table.sort(keys)
|
|
for _, k in ipairs(keys) do
|
|
emit(string.format('wikis[%d].%s=%s', i - 1, k, tostring(w[k])))
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
-- Scenario 1: defaults (no user config, no VimL globals).
|
|
vim.g.nuwiki_wikis = nil
|
|
config.apply({})
|
|
emit('[default]')
|
|
dump(lsp.init_options())
|
|
|
|
-- Scenario 2: representative config exercising scalar keys + a wikis list.
|
|
config.apply({
|
|
wiki_root = '/tmp/base',
|
|
file_extension = '.md',
|
|
syntax = 'vimwiki',
|
|
log_level = 'debug',
|
|
wikis = {
|
|
{
|
|
name = 'personal',
|
|
root = '/tmp/personal',
|
|
file_extension = '.wiki',
|
|
index = 'home',
|
|
diary_rel_path = 'journal',
|
|
},
|
|
{ name = 'work', root = '/tmp/work' },
|
|
},
|
|
})
|
|
emit('[sample]')
|
|
dump(lsp.init_options())
|
|
|
|
local f = assert(io.open(out, 'w'))
|
|
f:write(table.concat(lines, '\n') .. '\n')
|
|
f:close()
|
|
|
|
vim.cmd('qa!')
|