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
This commit is contained in:
Claude 2026-02-17 04:52:33 +00:00
parent 5db1bc92bd
commit 2023edef66
No known key found for this signature in database

16
.vimrc
View file

@ -223,10 +223,12 @@ Plug 'honza/vim-snippets' " Snippet collection
" ===== Native LSP (vim-lsp: works without Node.js, Vim 8.0+ only) ===== " ===== Native LSP (vim-lsp: works without Node.js, Vim 8.0+ only) =====
" Used as fallback when CoC/Node.js is unavailable " Used as fallback when CoC/Node.js is unavailable
Plug 'prabirshrestha/vim-lsp' " Pure VimScript LSP client if !((has('nvim') || has('patch-8.0.1453')) && executable('node'))
Plug 'mattn/vim-lsp-settings' " Auto-configure language servers Plug 'prabirshrestha/vim-lsp' " Pure VimScript LSP client
Plug 'prabirshrestha/asyncomplete.vim' " Async completion framework Plug 'mattn/vim-lsp-settings' " Auto-configure language servers
Plug 'prabirshrestha/asyncomplete-lsp.vim' " LSP completion source for asyncomplete Plug 'prabirshrestha/asyncomplete.vim' " Async completion framework
Plug 'prabirshrestha/asyncomplete-lsp.vim' " LSP completion source for asyncomplete
endif
" ===== Enhanced UI Experience ===== " ===== Enhanced UI Experience =====
Plug 'mhinz/vim-startify' " Startup screen with recent files Plug 'mhinz/vim-startify' " Startup screen with recent files
@ -706,8 +708,10 @@ if g:use_vimlsp
nmap <buffer> <leader>o <plug>(lsp-document-symbol-search) nmap <buffer> <leader>o <plug>(lsp-document-symbol-search)
nmap <buffer> <leader>cd <plug>(lsp-document-diagnostics) nmap <buffer> <leader>cd <plug>(lsp-document-diagnostics)
" Enable auto-format on save for supported filetypes " Enable auto-format on save for filetypes with reliable LSP formatters
autocmd BufWritePre <buffer> LspDocumentFormatSync if index(['python', 'go', 'rust', 'typescript', 'javascript', 'sh'], &filetype) >= 0
autocmd BufWritePre <buffer> LspDocumentFormatSync
endif
endfunction endfunction
augroup lsp_install augroup lsp_install