MarcWeber / vim-addon-manager

manage and install vim plugins (including their dependencies) in a sane way. If you have any trouble contact me. Usually I reply within 24 hours
Other
660 stars 59 forks source link

Add "post-activate-hook" support to addon-info.json #142

Open dbarnett opened 10 years ago

dbarnett commented 10 years ago

In a few cases, it's useful for addons to be able to execute code as soon as possible after they're activated. It would be nice to have support for a "post-activate-hook".

For example, plugins that provide sensible default settings like tpope/vim-sensible should execute their settings modifications as soon as possible so the user has a chance to override any settings in their .vimrc (otherwise, the modifications always happen after vimrc time and can only be overridden using a file in after/).

dbarnett commented 10 years ago

Of course, very few if any addons should be using a mechanism like this, and there's definitely the potential for it to be abused. I think the fact that hooks are only a single command helps by at least making it slightly awkward to do a bunch of heavy operations. A big warning to not abuse it in the docs would also go a long way.

ZyX-I commented 10 years ago

vim-sensible has three far more universal options: after/ directory that you have mentioned, using global variables to disable some settings or groups of them and placing settings in the directory that is not sourced automatically and requiring to trigger sourcing manually: e.g. by using autoload functions or just like matchit.vim plugin is supposed to be activated (by placing runtime macros/matchit.vim into the vimrc).

Note that actual activation does not necessary happen when vam#ActivateAddons is called (by “actual activation” I mean sourcing of plugin files). If post-activate-hook is deferred until VimEnter this solution is actually worse because you can no longer use after/ directory to override settings. If post-activate-hook is performed after vam#ActivateAddons did its job then it means you cannot tell for sure whether plugin files were already sourced.

MarcWeber commented 10 years ago

If plugins need "setup" and pulgin/.pvim or after/plugin/ files don't help I recommend introducing a Setup() like function in those plugins so that plugins who depend on it can force the setup. vam's AcitvateAddons function has an force_loading_plugins_now option, too. If this is not enough we should discuss the use case.