if __name__ is None
if __name__ is None

Reputation: 11533

Why does Pathogen "magically" solve Vim syntax highlighting problems?

I have these 3 lines in my .vimrc.

" keeping pathogen only for its 'syntax on' bug workaround
Bundle "tpope/vim-pathogen"
execute pathogen#infect()

I must have removed and re-added these 3 lines about a dozen of times now. I'm on latest version of Vim, and yet, for some reasons, some syntax highlighting isn't working correctly.

On MacOS, Go syntax highlighting isn't working, while on Arch Linux is. But on Arch, coffeescript isn't highlighted. For some reason, executing pathogen#infect() solves all problems on both platforms.

Its kind of like black magic to me, so I'm wondering why is that. Is there any better way to fix this problem?

Answer: I have looked into my vimrc, and found the error. I had this line

filetype plugin indent on

before the Bundle's, where it should have been after the Bundles.

Upvotes: 1

Views: 1528

Answers (1)

Xavier T.
Xavier T.

Reputation: 42228

By default, Vim does not look in .vim/bundle directories when starting. So it means that your "ftdetect" won't be loaded.

Pathogen looks into every bundle directory and load them.

If you want to see for yourself, start Vim twice, once with and once without pathogen:infect(), and type :scriptnames after boot. You'll see the list of loaded scripts.

You can even do a :redir to write the output into a file before invoking :scriptnames to get the exact diff of loaded scripts.

Upvotes: 3

Related Questions