vim, pathogen, and load order of ftplugin files
Asked Answered
W

3

6

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.

Whitsunday answered 17/11, 2013 at 22:17 Comment(1)
I'm solving this specific issue by setting let g:pymode_options = 0 in ~/.vim/after/plugin/pymode.vim, since I don't want any of python-mode's options, but I'm still looking for a more general answer to this load-order issue.Whitsunday
W
8

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.

Whitsunday answered 17/11, 2013 at 23:1 Comment(1)
I think answering one's own questions is specifically encouraged. stackoverflow.com/help/self-answerIaverne
E
6

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.

Erelia answered 28/4, 2015 at 18:13 Comment(1)
It works with Pathogen by renaming the plugin directories inside bundle --- tested in v7.4. (Yeah, I need to update. :D ) Separately, note that autoload files may be loaded in a different order than their directory names, depending on when functions in those files are invoked.Haggai
T
0

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.

Tallie answered 18/11, 2013 at 4:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.