From c3a8eae9d04ba523e3c5bb28ccbd4527b2bd922e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Fr=C3=B3es=20Franco?= Date: Tue, 12 May 2026 01:15:53 +0000 Subject: [PATCH] fix(vim): vim-lsp detection + drop hang-prone echo lines MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `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) --- autoload/nuwiki/lsp.vim | 9 +++++++-- start-vim.sh | 5 +++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/autoload/nuwiki/lsp.vim b/autoload/nuwiki/lsp.vim index b7e673c..f2251bc 100644 --- a/autoload/nuwiki/lsp.vim +++ b/autoload/nuwiki/lsp.vim @@ -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 diff --git a/start-vim.sh b/start-vim.sh index 7348557..815929d 100755 --- a/start-vim.sh +++ b/start-vim.sh @@ -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 }