folke / lazy.nvim

💤 A modern plugin manager for Neovim
https://lazy.folke.io/
Apache License 2.0
13.77k stars 329 forks source link

Multiple plugins in one directory/repo recently broke. #1610

Closed guill closed 1 month ago

guill commented 1 month ago

Did you check docs and existing issues?

Neovim version (nvim -v)

0.10.0

Operating system/version

Ubuntu 22.04 (WSL)

Describe the bug

mini.nvim is a large collection of plugins within a single repository: https://github.com/echasnovski/mini.nvim

Until now, I have been using the following lazy.nvim configuration in order to download mini.nvim as one repo, but lazily load each of the individual pieces:

{
    "echasnovski/mini.nvim",
    version = "*",
},
{
    name = "mini.splitjoin",
    main = "mini.splitjoin",
    dir = "mini.nvim",
    opts = {
        mappings = {
            toggle = "gs",
        },
    },
    keys = {
        { "gs", nil, mode = {'n', 'x'} },
    },
},
{
    name = "mini.align",
    main = "mini.align",
    dir = "mini.nvim",
    opts = {},
    keys = {
        { "ga", nil, mode = {'n', 'x'} },
        { "gA", nil, mode = {'n', 'x'} },
    },
},

Now, it appears that Lazy will only recognize a single plugin located in a particular directory. Using git bisect, I tracked this issue down to this commit: https://github.com/folke/lazy.nvim/commit/75ffe56f70faac43f077796b91178d2f1419f8ce

Steps To Reproduce

  1. Paste the contents of the repro file below into a file named "repro.lua".
  2. In the directory with that file, run nvim -u repro.lua
  3. --> When the Lazy window shows up, you will see that only one of mini.align or mini.splitjoin are recognized.

Expected Behavior

Previously, both mini.align and mini.splitjoin would be properly loaded.

If support for this loading strategy was intentionally removed, there should be a warning or error message that one of the plugins is ignored.

If there is a better way of solving this, please let me know!

Repro

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  {
    "echasnovski/mini.nvim",
    version = "*",
  },
  {
    name = "mini.splitjoin",
    main = "mini.splitjoin",
    dir = "mini.nvim",
    opts = {
      mappings = {
        toggle = "gs",
      },
    },
    keys = {
        { "gs", nil, mode = {'n', 'x'} },
    },
  },
  {
    name = "mini.align",
    main = "mini.align",
    dir = "mini.nvim",
    opts = {},
    keys = {
      { "ga", nil, mode = {'n', 'x'} },
      { "gA", nil, mode = {'n', 'x'} },
    },
  },
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here
folke commented 1 month ago

I'm sorry, but it was actually a bug that this used to work. It could actually give all sorts of issues.

The rewrite fixed this.

guill commented 1 month ago

@folke Is there another recommended way to deal with plugins like this? I've searched through documentation/examples, but haven't been able to find any. As far as I can tell, my options are:

  1. Manually reimplement the lazy-loading logic present in Lazy.nvim via autocmds and custom bindings.
  2. Try to get a second plugin manager (perhaps mini.deps) working alongside Lazy.nvim.
  3. Download each submodule of mini.nvim separately, and somehow ensure that when one is updated, any dependencies are updated to the same version.

None of those options seem particularly great. Am I missing something?

folke commented 1 month ago

Nope, that's just not supported.