fix(vim): vim-lsp detection + drop hang-prone echo lines
`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:
@@ -27,14 +27,19 @@ function! nuwiki#lsp#start() abort
|
|||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if exists('*lsp#register_server')
|
if exists('g:lsp_loaded')
|
||||||
" vim-lsp
|
" 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({
|
call lsp#register_server({
|
||||||
\ 'name': 'nuwiki',
|
\ 'name': 'nuwiki',
|
||||||
\ 'cmd': {server_info -> [l:bin]},
|
\ 'cmd': {server_info -> [l:bin]},
|
||||||
\ 'allowlist': ['vimwiki'],
|
\ 'allowlist': ['vimwiki'],
|
||||||
\ 'config': { 'settings': { 'nuwiki': s:settings() } },
|
\ 'config': { 'settings': { 'nuwiki': s:settings() } },
|
||||||
\ })
|
\ })
|
||||||
|
" vim-lsp auto-enables servers when 'g:lsp_auto_enable' is on
|
||||||
|
" (default) — no manual `lsp#enable()` needed.
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|||||||
+3
-2
@@ -157,8 +157,9 @@ augroup NuwikiStart
|
|||||||
autocmd FileType vimwiki call nuwiki#lsp#start()
|
autocmd FileType vimwiki call nuwiki#lsp#start()
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
echo '[nuwiki-dev] ready — wiki root: $WIKI_DIR'
|
" Status messages go to :messages so they don't trigger "Press ENTER".
|
||||||
echo '[nuwiki-dev] :LspStatus for client diagnostics, :messages for log'
|
echomsg '[nuwiki-dev] ready — wiki root: $WIKI_DIR'
|
||||||
|
echomsg '[nuwiki-dev] :LspStatus for diagnostics, :messages for log'
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user