Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conditionally load bundles #12

Open
kevinjqiu opened this issue Apr 8, 2011 · 10 comments
Open

Conditionally load bundles #12

kevinjqiu opened this issue Apr 8, 2011 · 10 comments
Labels

Comments

@kevinjqiu
Copy link

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
Copy link
Contributor

gmarik commented Apr 8, 2011

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
Copy link
Author

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
Copy link
Contributor

gmarik commented Apr 8, 2011

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
Copy link
Author

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
Copy link
Contributor

gmarik commented Apr 8, 2011

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
Copy link
Author

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
Copy link
Contributor

gmarik commented Apr 8, 2011

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

@gmarik
Copy link
Contributor

gmarik commented Apr 8, 2011

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

@rainux
Copy link

rainux commented Oct 23, 2011

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
Copy link

#364

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants