VundleVim / Vundle.vim

Vundle, the plug-in manager for Vim
http://github.com/VundleVim/Vundle.Vim
MIT License
23.93k stars 2.57k forks source link

Conditionally load bundles #12

Open kevinjqiu opened 13 years ago

kevinjqiu commented 13 years ago

Add a mechanism for loading bundles based on conditions, such as filetype detection? For example, if I'm editing a Python file, I don't necessarily need to load all the Ruby plugins.

Feel free to close this issue if there's already a workaround I'm not aware of.

gmarik commented 13 years ago

Hey kevinjqiu!

Vim handles plugin loading, Vundle only manages runtimepath. The only case when Vundle sources scripts is when script is installed explicitly using :BundleInstall plugin_name command.

Let me know if we're on same page! Thanks

kevinjqiu commented 13 years ago

Hi,

I was referring to my vim state after BundleInstall. Hypothetically I have

Bundle "Python.vim"
Bundle "Ruby.vim"

and then did a :BundleInstall, now both plugins are in my .vim/bundle folder, and are automatically loaded because their paths are in the runtimepath. But if I'm editing foo.rb, I don't need to load Python.vim and its related files.

I'm wondering if there's a way to conditionally load the plugins.

gmarik commented 13 years ago

So you're suggesting that Vundle should remove ruby.vim from runtimepath in case you're editing python file?

That's sounds like a feature to me if I'm understanding you correctly. Or do you have specific issue that is caused by this behaviour?

kevinjqiu commented 13 years ago

Yeah, it is a feature request rather than an "issue". Sorry if it was misleading :) I'd be better if the filetype (or other criteria) determines which runtime paths to include, and hence which plugins to include.

gmarik commented 13 years ago

I see now. Vim automatically loads scripts, no matter what file type, that reside in script_name/plugin/*.vim dir. I believe if script's author considers putting scripts there instead ftplugin/ then that's "design" issue. This might save couple CPU cycles of traversing "unrelated" plugins, but it adds lots of complexity(cuz i have no idea how to do that now, unless you know ;)

I may be mistaken though...

kevinjqiu commented 13 years ago

It may very well be an optimization that's not necessary. My idea is something like autocmd BufRead *.py Call function_that_adds_python_plugins_to_runtime_path() I may give it a swing, but I'm not fluent at VimScript, so don't hold your breath :)

gmarik commented 13 years ago

Ya, it would be great if you could play with that... In meantime I will try to resolve other issues ;) Thanks! )

gmarik commented 13 years ago

you may want to look into tplugin (on demand loader)

rainux commented 13 years ago

Load bundles based on filetype is an interesting idea. Before read this issue, I already implemented a on demand mechanism that use tags and the new command BundleBind! manually. I'll try to figure out if it possible to implement this.

MarcWeber commented 10 years ago

364