changeset 484:759ccf5befb2

Make lightline work when some other plugins are not enabled.
author Ludovic Chabant <ludovic@chabant.com>
date Thu, 24 Sep 2020 23:10:38 -0700
parents 1a54ffbc3b15
children 25bdfc963612
files vim/vimrc
diffstat 1 files changed, 40 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/vim/vimrc	Thu Sep 24 23:07:10 2020 -0700
+++ b/vim/vimrc	Thu Sep 24 23:10:38 2020 -0700
@@ -447,13 +447,23 @@
       \    },
       \}
 
-function! _LightlineFugitive()
-    return fugitive#head()
-endfunction
+if s:HasPlugin('fugitive')
+    function! _LightlineFugitive()
+        return fugitive#head()
+    endfunction
+else
+    function! _LightlineFugitive()
+    endfunction
+endif
 
-function! _LightlineLawrencium()
-    return lawrencium#statusline()
-endfunction
+if s:HasPlugin('lawrencium')
+    function! _LightlineLawrencium()
+        return lawrencium#statusline()
+    endfunction
+else
+    function! _LightlineLawrencium()
+    endfunction
+endif
 
 function! _LightlineCtrlPMark()
     if expand('%:t') =~ 'ControlP' && has_key(g:lightline, 'ctrlp_item')
@@ -468,9 +478,14 @@
     endif
 endfunction
 
-function! _LightlineGutentags()
-    return gutentags#statusline('', '', '♨')
-endfunction
+if s:HasPlugin('gutentags')
+    function! _LightlineGutentags()
+        return gutentags#statusline('', '', '♨')
+    endfunction
+else
+    function! _LightlineGutentags()
+    endfunction
+endif
 
 if s:HasPlugin('syntastic')
     function! _LightlineLinter()
@@ -491,15 +506,23 @@
     endfunction
 endif
 
-function! _LightlineYcmErrors()
-    let l:cnt = youcompleteme#GetErrorCount()
-    return l:cnt > 0 ? string(l:cnt) : ''
-endfunction
+if s:HasPlugin('youcompleteme')
+    function! _LightlineYcmErrors()
+        let l:cnt = youcompleteme#GetErrorCount()
+        return l:cnt > 0 ? string(l:cnt) : ''
+    endfunction
 
-function! _LightlineYcmWarnings()
-    let l:cnt = youcompleteme#GetWarningCount()
-    return l:cnt > 0 ? string(l:cnt) : ''
-endfunction
+    function! _LightlineYcmWarnings()
+        let l:cnt = youcompleteme#GetWarningCount()
+        return l:cnt > 0 ? string(l:cnt) : ''
+    endfunction
+else
+    function! _LightlineYcmErrors()
+    endfunction
+
+    function! _LightlineYcmWarnings()
+    endfunction
+endif
 " }}}
 
 " YouCompleteMe {{{