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

Open
dbarnett opened this Issue Jan 18, 2014 · 3 comments

Projects

None yet

3 participants

@dbarnett

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

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
Collaborator
ZyX-I commented Jan 19, 2014

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
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment