wbthomason / packer.nvim

A use-package inspired plugin manager for Neovim. Uses native packages, supports Luarocks dependencies, written in Lua, allows for expressive config
MIT License
7.82k stars 266 forks source link

Dependencies cannot use aliases #1017

Open svvac opened 2 years ago

svvac commented 2 years ago

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.