From 7e8450f3e1890e02ea92723e24f142dcfa9e2f03 Mon Sep 17 00:00:00 2001 From: Reiner Herrmann Date: Sat, 25 Nov 2023 18:35:31 +0100 Subject: vim: call lsp functions only when plugin has been loaded --- vimrc | 70 ++++++++++++++++++++++++++++++++++--------------------------------- 1 file changed, 36 insertions(+), 34 deletions(-) (limited to 'vimrc') diff --git a/vimrc b/vimrc index 64d94b4..88f84af 100644 --- a/vimrc +++ b/vimrc @@ -146,40 +146,42 @@ let g:airline#extensions#tabline#enabled=1 " LSP settings packadd lsp -call LspOptionsSet(#{ - \ autoHighlight: v:true, - \ showDiagOnStatusLine: v:true, - \ showDiagWithVirtualText: v:true, - \ usePopupInCodeAction: v:true, - \ }) - -if executable("clangd") -call LspAddServer([#{ - \ name: 'clangd', - \ filetype: ['c', 'cpp'], - \ path: 'clangd', - \ args: ['--background-index'] - \ }]) -endif - -if executable("rust-analyzer") -call LspAddServer([#{ - \ name: 'rust-analyzer', - \ filetype: ['rust'], - \ path: 'rust-analyzer', - \ args: [], - \ syncInit: v:true, - \ initializationOptions: #{ - \ inlayHints: #{ - \ typeHints: #{ - \ enable: v:true - \ }, - \ parameterHints: #{ - \ enable: v:true - \ } - \ }, - \ } - \ }]) +if exists("g:loaded_lsp") + call LspOptionsSet(#{ + \ autoHighlight: v:true, + \ showDiagOnStatusLine: v:true, + \ showDiagWithVirtualText: v:true, + \ usePopupInCodeAction: v:true, + \ }) + + if executable("clangd") + call LspAddServer([#{ + \ name: 'clangd', + \ filetype: ['c', 'cpp'], + \ path: 'clangd', + \ args: ['--background-index'] + \ }]) + endif + + if executable("rust-analyzer") + call LspAddServer([#{ + \ name: 'rust-analyzer', + \ filetype: ['rust'], + \ path: 'rust-analyzer', + \ args: [], + \ syncInit: v:true, + \ initializationOptions: #{ + \ inlayHints: #{ + \ typeHints: #{ + \ enable: v:true + \ }, + \ parameterHints: #{ + \ enable: v:true + \ } + \ }, + \ } + \ }]) + endif endif " vim: set et:sw=4:sts=4 -- cgit v1.2.3