" development/tests/test-coc-register-vim.vim — programmatic coc.nvim " registration. Relies on a stub autoload/coc.vim (created by the wrapper) that " records coc#config calls into g:_recorded. Drives nuwiki#lsp#start()'s coc " branch and asserts the exact languageserver config nuwiki injects (command, " filetypes, and the s:settings() payload with the global shorthand folded in). " Writes PASS/FAIL to $NUWIKI_COC_OUT. let s:out = [] function! s:check(desc, cond) abort call add(s:out, (a:cond ? 'PASS ' : 'FAIL ') . a:desc) endfunction " Pretend coc's node service is already up so registration runs synchronously. let g:coc_service_initialized = 1 let g:_recorded = {} " Make sure the vim-lsp branch is NOT taken. if exists('g:lsp_loaded') | unlet g:lsp_loaded | endif " A readable, executable 'binary' so nuwiki#lsp#start() gets past its check. let g:nuwiki_binary_path = executable('true') ? exepath('true') : '/usr/bin/true' " Config: single-wiki shorthand + a global display setting that must fold into " the wiki the server sees (the global shorthand). let g:nuwiki_wiki_root = '/tmp/realwiki' let g:nuwiki_toc_header_level = 2 call nuwiki#lsp#start() let s:r = get(g:, '_recorded', {}) call s:check('coc#config was called', !empty(s:r)) call s:check('section is languageserver.nuwiki', get(s:r, 'section', '') ==# 'languageserver.nuwiki') let s:v = get(s:r, 'value', {}) call s:check('command is the binary', get(s:v, 'command', '') ==# g:nuwiki_binary_path) call s:check('filetypes = [vimwiki]', get(s:v, 'filetypes', []) == ['vimwiki']) let s:io = get(s:v, 'initializationOptions', {}) call s:check('initOpts has wiki_root', get(s:io, 'wiki_root', '') ==# '/tmp/realwiki') call s:check('global toc_header_level folded into payload', get(s:io, 'toc_header_level', 0) == 2) call s:check('settings.nuwiki mirrors initOpts', get(get(s:v, 'settings', {}), 'nuwiki', {}) ==# s:io) call writefile(s:out, $NUWIKI_COC_OUT) qa!