I would like to check in .vimrc
whether pathogen is present, and call pathogen#infect
if it is.
This obviously works:
call pathogen#infect()
So I'm confident pathogen is properly installed.
But this does not load pathogen:
if exists("*pathogen#infect")
call pathogen#infect()
endif
Neither does this:
if exists("g:loaded_pathogen")
call pathogen#infect()
endif
What am I missing?
Look for a line that says ~/. vim/autoload/pathogen. vim . If you see it pathogen is installed properly.
vim-pathogen is a runtimepath manager created by Tim Pope to make it easy to install plugins and runtime files in their own private directories.
Your check doesn't work because of the autoload mechanism. You could force the autoload by explicitly sourcing it:
runtime! autoload/pathogen.vim
if exists("*pathogen#infect")
call pathogen#infect()
endif
But in the end, you probably just want to avoid errors from your .vimrc when Pathogen isn't installed. For that, just silence any resulting errors with :silent!
:
silent! call pathogen#infect()
The only downside is that any Pathogen plugin errors would be suppressed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With