Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check whether pathogen is installed in vimrc

Tags:

vim

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?

like image 264
chys Avatar asked Sep 02 '13 15:09

chys


People also ask

How do I know if a pathogen is installed?

Look for a line that says ~/. vim/autoload/pathogen. vim . If you see it pathogen is installed properly.

What is pathogen in vim?

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.


1 Answers

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.

like image 66
Ingo Karkat Avatar answered Sep 22 '22 16:09

Ingo Karkat