From 2023edef661d231b5b5822af689b56f168ebfff2 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Feb 2026 04:52:33 +0000 Subject: [PATCH] Fix review issues: conditional vim-lsp loading and scoped auto-format - Wrap vim-lsp/asyncomplete plugins in a condition so they only load when CoC (Node.js) is unavailable, preventing redundant plugin initialization and potential conflicts on Node.js-capable systems - Limit LspDocumentFormatSync on BufWritePre to known-reliable filetypes (python, go, rust, typescript, javascript, sh) to avoid silent delays or errors on markdown/yaml/text files with no LSP formatter support --- .vimrc | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/.vimrc b/.vimrc index 07adbf5..69d34c0 100644 --- a/.vimrc +++ b/.vimrc @@ -223,10 +223,12 @@ Plug 'honza/vim-snippets' " Snippet collection " ===== Native LSP (vim-lsp: works without Node.js, Vim 8.0+ only) ===== " Used as fallback when CoC/Node.js is unavailable -Plug 'prabirshrestha/vim-lsp' " Pure VimScript LSP client -Plug 'mattn/vim-lsp-settings' " Auto-configure language servers -Plug 'prabirshrestha/asyncomplete.vim' " Async completion framework -Plug 'prabirshrestha/asyncomplete-lsp.vim' " LSP completion source for asyncomplete +if !((has('nvim') || has('patch-8.0.1453')) && executable('node')) + Plug 'prabirshrestha/vim-lsp' " Pure VimScript LSP client + Plug 'mattn/vim-lsp-settings' " Auto-configure language servers + Plug 'prabirshrestha/asyncomplete.vim' " Async completion framework + Plug 'prabirshrestha/asyncomplete-lsp.vim' " LSP completion source for asyncomplete +endif " ===== Enhanced UI Experience ===== Plug 'mhinz/vim-startify' " Startup screen with recent files @@ -706,8 +708,10 @@ if g:use_vimlsp nmap o (lsp-document-symbol-search) nmap cd (lsp-document-diagnostics) - " Enable auto-format on save for supported filetypes - autocmd BufWritePre LspDocumentFormatSync + " Enable auto-format on save for filetypes with reliable LSP formatters + if index(['python', 'go', 'rust', 'typescript', 'javascript', 'sh'], &filetype) >= 0 + autocmd BufWritePre LspDocumentFormatSync + endif endfunction augroup lsp_install