How to detect if powerline is installed?

232 Views Asked by At

I have powerline installed on some of my computers, but not on others. I'd like my .vimrc to detect if it is installed before trying to load/enable the powerline package so I can avoid the errors that are generated.

How can I detect if powerline is installed?

I should note that I use Vundle as my Vim package manager.

1

There are 1 best solutions below

1
Peter Rincker On

I do not use powerline, but this is the generic method.

Assuming you using Vim's packages you move your extra plugins to be optional packages and then just use :silent! when doing :packadd in your vimrc.

silent! packadd other_plugin

Alternatively you can use exists() & VimEnter autocmd if you need something more complex.

augroup load_more
  autocmd!
  autocmd VimEnter * if exists(':SomeCommand') | packadd foo | endif
augroup END

NOTE: I do not use powerline so I do not know what commands or variables are provided to use. It could provide a custom autocmd event to simplify this or have some other method for loading related plugins.

For more help see:

:h exists()
:h VimEnter
:h :silent
:h packages