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

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

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

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

dbarnett opened this issue Jan 18, 2014 · 3 comments

Comments

@dbarnett
Copy link

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

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
Copy link
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
Copy link
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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants