fix(vim): vim-lsp detection + drop hang-prone echo lines
CI / cargo fmt --check (push) Successful in 32s
CI / cargo clippy (push) Successful in 1m22s
CI / cargo test (push) Successful in 1m18s

`autoload/nuwiki/lsp.vim` probed vim-lsp via `exists('*lsp#register_server')`
but autoload functions aren't loaded until first call — that check
always returned false on the dev script's setup, so the plugin
printed "no supported LSP client found" even after vim-lsp had been
cloned + added to the runtimepath.

vim-lsp's `plugin/lsp.vim` sets `g:lsp_loaded = 1` only when its
hard requirements (`json_encode`, `timers`, `lambda`) are met, so
that's the reliable presence flag. Switched to `exists('g:lsp_loaded')`.

Also replaced `echo` with `echomsg` in the generated `start-vim.sh`
vimrc — the two startup status lines were pushing past `'cmdheight'`
and triggering "Press ENTER or type command to continue", which made
non-interactive invocations exit before the buffer was usable.
`echomsg` writes to `:messages` history without the prompt.

Verified with `vim --clean -u $DEV/vimrc index.wiki`:
- `g:lsp_loaded = 1`
- `filetype = vimwiki`
- `:VimwikiTOC` defined (buffer-local), `b:did_ftplugin = 1`
- No "press ENTER" hang.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-12 01:15:53 +00:00
parent f1bf70d448
commit c3a8eae9d0
2 changed files with 10 additions and 4 deletions
+7 -2
View File
@@ -27,14 +27,19 @@ function! nuwiki#lsp#start() abort
return
endif
if exists('*lsp#register_server')
" vim-lsp
if exists('g:lsp_loaded')
" vim-lsp — its autoload functions aren't triggered by `exists('*…')`,
" but its plugin/lsp.vim sets `g:lsp_loaded = 1` once requirements
" (json_encode + timers + lambda) are met, so that's the reliable
" presence check.
call lsp#register_server({
\ 'name': 'nuwiki',
\ 'cmd': {server_info -> [l:bin]},
\ 'allowlist': ['vimwiki'],
\ 'config': { 'settings': { 'nuwiki': s:settings() } },
\ })
" vim-lsp auto-enables servers when 'g:lsp_auto_enable' is on
" (default) — no manual `lsp#enable()` needed.
return
endif
+3 -2
View File
@@ -157,8 +157,9 @@ augroup NuwikiStart
autocmd FileType vimwiki call nuwiki#lsp#start()
augroup END
echo '[nuwiki-dev] ready — wiki root: $WIKI_DIR'
echo '[nuwiki-dev] :LspStatus for client diagnostics, :messages for log'
" Status messages go to :messages so they don't trigger "Press ENTER".
echomsg '[nuwiki-dev] ready — wiki root: $WIKI_DIR'
echomsg '[nuwiki-dev] :LspStatus for diagnostics, :messages for log'
EOF
}