packer.nvim icon indicating copy to clipboard operation
packer.nvim copied to clipboard

Dependencies cannot use aliases

Open svvac opened this issue 3 years ago • 0 comments

Referencing a dependency by its alias currently doesn't work.


use {
  'some/dep',
  requires = { 'other_dep' },
}

use {
  'other/dep',
  as = 'other_dep',
}

Looking around, it appears the conflict checks on a new dependency are too strict. When the actual aliased module gets registered afterwards, the name conflict check against the alias prevents the setup to properly execute.

https://github.com/wbthomason/packer.nvim/blob/90b323bccc04ad9b23c971a85813a1405c7725a8/lua/packer.lua#L206-L222

The second call to use above warns that the alias is already used because fails check on L211. As opposed to L206, this check doesn't guard against from_requires to deduplicate.

In any case, it seems that the second check is redundant, as name always equals plugin_spec.as if set

https://github.com/wbthomason/packer.nvim/blob/90b323bccc04ad9b23c971a85813a1405c7725a8/lua/packer.lua#L199

https://github.com/wbthomason/packer.nvim/blob/90b323bccc04ad9b23c971a85813a1405c7725a8/lua/packer/util.lua#L66

I suggest dropping it entirely.

svvac avatar Aug 18 '22 19:08 svvac