`wants` documentation
Describe the feature
I see a lot of people use wants term which is not mentioned in README.
Could you please explain what it is for and how I should use it?
@horseinthesky I believe the reason that wants isn't documented is that the plan was for it to be quite a short-lived key that solved an issue for the user that contributed it. There's some plan to refactor the way the sequencing keys work which will probably lead to it being deprecated or it working differently, it isn't being advertised or explained to avoid people using it I think, although @wbthomason might have changed his mind, but from the original discussion I don't think it was planned that it would remain available in this form for this long. See https://github.com/wbthomason/packer.nvim/pull/264#issuecomment-805848798 for reference.
Understood.
For not I don't quite understand how
use {
"hrsh7th/nvim-compe",
requires = {
{
"tzachar/compe-tabnine",
run = "./install.sh",
opt = true,
},
{ "honza/vim-snippets", opt = true },
{
"SirVer/ultisnips",
wants = "vim-snippets",
opt = true,
},
},
event = "InsertEnter",
wants = { "compe-tabnine", "ultisnips" },
config = function()
require "config.compe"
end
}
works exactly.
Removing wants leads to ultisnips is not loaded.
Tbh I personally don't use the key so am not an expert on it. I've always envisioned it will change or be removed and would rather not have to tweak my config, that being said I believe the general idea around this key is that it checks if a plugin in the wants table is loaded when the plugin using the wants key is about to be loaded and if the plugin is not it then loads the plugins in the wants table, that should recursively load any plugins wanted by those plugins and so on and so for but don't know how well it all works/exactly what bits were implemented.
That is correct.
I decided to open the issue due to:
- People use the feature constantly.
- It is not documented.
- I don't see any other option for a plugin to load some other plugins it depends on.
Will leave this for @wbthomason other than providing context not sure what else I can add. If the plan is still to change it's behaviour, rename or remove it then as was initially discussed in the issue then I advise against using it or documenting its current behaviour. The cat might be out of the bag a little and people are now using it but I think it still shouldn't be encouraged yet till the longterm plan for it is complete.
In any event I don't really have much else to add.
This feature doesn't seem to be working properly. Take the following setup code as example.
require'packer'.startup{
{
-- `nvim-web-devicons` is denpency of several other plugins.
{'kyazdani42/nvim-web-devicons', opt = true},
-- `nvim-tree.lua` requires `nvim-web-devicons` to be loaded first.
{'kyazdani42/nvim-tree.lua', wants = 'nvim-web-devicons'},
},
{},
}
After running :PackerSync and restarting Neovim, nvim-tree.lua is working, but with no icons because it requires nvim-web-devicons to be loaded, which isn't. :PackerStatus can be used to check this behavior.
@atchim: Please open a new issue for the problem you're observing. Thanks!
Here is my 2 cents (revised):
"wants" is currently undocumented.
"after" is documented oddly with before in example found doc/packer.txt and README.md as :
after = string or list, -- Specifies plugins to load before this plugin.
This is correct but confusing for careless person like me.
Isn't it more like:
after = string or list, -- Specifies this plugin to be loaded after listed plugin(s).
(Above fixed. I was typing with sleepy eyes.)
Of course, if wants is deprecated interface over require and after, the entry for wants can be skipped. (I am new to this packer thing).
@atchim: Please open a new issue for the problem you're observing. Thanks!
@wbthomason, I already created an issue for this. You can find it here.
Nobody wants to care about this one.
Wow, I just spent 2 hours debugging my plugin dependencies and the reason turns out to be an undocumented option. It is a shame that wants is still undocumented after almost 3 years since this issue had been opened.
Neither after nor requires let me specify load dependencies correctly, which is crucial when the dependencies are optional.