test(config): verify Vim/Neovim config payload parity
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>
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
" development/tests/test-config-vim.vim — Vim counterpart of
|
||||
" test-config.lua. Dumps the Vim client's `initialization_options` payload
|
||||
" (nuwiki#lsp#settings()) for the same two scenarios as the Neovim harness,
|
||||
" as byte-identical `key=value` lines, so both can be diffed against the
|
||||
" shared golden development/tests/config-expected.txt.
|
||||
"
|
||||
" "nvim == golden" and "vim == golden" together prove Vim/Neovim config
|
||||
" parity for everything the server consumes.
|
||||
|
||||
let s:out = $NUWIKI_CONFIG_OUT
|
||||
let s:lines = []
|
||||
|
||||
function! s:dump(payload) abort
|
||||
call add(s:lines, 'wiki_root=' . a:payload.wiki_root)
|
||||
call add(s:lines, 'file_extension=' . a:payload.file_extension)
|
||||
call add(s:lines, 'syntax=' . a:payload.syntax)
|
||||
call add(s:lines, 'log_level=' . a:payload.log_level)
|
||||
if has_key(a:payload, 'wikis')
|
||||
let l:i = 0
|
||||
for l:w in a:payload.wikis
|
||||
for l:k in sort(keys(l:w))
|
||||
call add(s:lines, printf('wikis[%d].%s=%s', l:i, l:k, l:w[l:k]))
|
||||
endfor
|
||||
let l:i += 1
|
||||
endfor
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Scenario 1: defaults (no globals set).
|
||||
unlet! g:nuwiki_wiki_root g:nuwiki_file_extension g:nuwiki_syntax
|
||||
unlet! g:nuwiki_log_level g:nuwiki_wikis
|
||||
call add(s:lines, '[default]')
|
||||
call s:dump(nuwiki#lsp#settings())
|
||||
|
||||
" Scenario 2: same representative config as the Neovim harness.
|
||||
let g:nuwiki_wiki_root = '/tmp/base'
|
||||
let g:nuwiki_file_extension = '.md'
|
||||
let g:nuwiki_syntax = 'vimwiki'
|
||||
let g:nuwiki_log_level = 'debug'
|
||||
let g:nuwiki_wikis = [
|
||||
\ { 'name': 'personal', 'root': '/tmp/personal',
|
||||
\ 'file_extension': '.wiki', 'index': 'home',
|
||||
\ 'diary_rel_path': 'journal' },
|
||||
\ { 'name': 'work', 'root': '/tmp/work' },
|
||||
\ ]
|
||||
call add(s:lines, '[sample]')
|
||||
call s:dump(nuwiki#lsp#settings())
|
||||
|
||||
call writefile(s:lines, s:out)
|
||||
qall!
|
||||
Reference in New Issue
Block a user