Question

I've been using Vim and pathogen for a while, and things were working fine, but recently I've started having load order issues with my ftplugin configuration.

The specific problem I'm having right now is that python-mode is overriding my ftplugin settings. I've got a ~/.vim/ftplugin/python.vim that contains the following line:

setlocal textwidth=119

python-mode comes with its own ftplugin file, which also sets textwidth, in ~/.vim/bundle/python-mode/ftplugin/python/pymode.vim.

The problem is that Vim is now loading python-mode's ftplugin file after my ftplugin file, so I'm ending up with its textwidth=79. I recently had to reinstall MacPorts, and I think something must have changed in the stock configuration.

I've tried various tricks involving turning filetype/plugin detection off before invoking pathogen, per various other answers, but none of them are helping.

Through the use of verbose set textwidth? and some echomsg debugging, I know that both ftplugin files are being invoked, and that they're being invoked in the wrong (for my needs) order.

Is there any way to force Vim/pathogen to invoke my ftplugin files after those of the plugins?

I've even tried putting my settings into ~/.vim/after/plugin/pymode.vim, but that's loaded immediately after pathogen sets up the plugin, so it still runs before ftplugin files, which only get loaded once I edit a Python file.

Was it helpful?

Solution

It turns out that maybe this never worked the way I thought. I didn't realize that Vim also supported ~/.vim/after/ftplugin, so I was able to move my overrides to ~/.vim/after/ftplugin/python.vim and get the behavior I was expecting. I'm loath to answer my own questions on SO, but hopefully this will help someone else.

OTHER TIPS

Plain Vim loads the plugin scripts in alphabetical order. This is from :help load-plugins

... all directories in the 'runtimepath' option will be
searched for the "plugin" sub-directory and all files ending in ".vim"
will be sourced (in alphabetical order per directory), also in
subdirectories.

So you can set plugin loading order by renaming <filetype>_plugin.vim to <filetype>/35plugin.vim. 35 is your desired loading order. I think this should work with Pathogen too by renaming the plugin directories inside bundle, but I haven't tested it.

I'm still looking for a more general answer to this load-order issue

As far as I know, you can't really do it with Pathogen. It is really easy with NeoBundle. Pathogen is really minimal, it doesn't provide you with a lot of flexibility - it does only one thing and does it well. If you're looking for configurability, I think you're using the wrong tool.

EDIT: Not really sure about ftplugins, but bundles in general are loaded as you specify them (with Vundle/NeoBundle). So I realise that this maybe is not the most relevant of answers.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top