echasnovski / mini.nvim

Library of 40+ independent Lua modules improving overall Neovim (version 0.8 and higher) experience with minimal effort
MIT License
5.19k stars 187 forks source link

'lazy.nvim' doesn't load 'mini.clue' config for standalone plugin #612

Closed simonmandlik closed 10 months ago

simonmandlik commented 10 months ago

Contributing guidelines

Module(s)

mini.clue (but perhaps more)

Description

When I install mini.clue as a standalone plugin, it is not working properly (some clues are missing and when opening new file with :e it stops working entirely)

Neovim version

v0.10.0-dev-1506+g610f50dda-Homebrew

Steps to reproduce

  1. nvim -nu repro.lua
  2. g
  3. :e repro.lua
  4. g

repro.lua:

print("REPRO")

local root = vim.fn.fnamemodify("./.repro", ":p")
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end
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)

-- this works:
-- local plugins = {
--     { 'echasnovski/mini.nvim',
--     version = '*',
--     config = function()
--         local miniclue = require('mini.clue')
--         miniclue.setup {
--             triggers = { { mode = 'n', keys = 'g' } },
--             clues = { miniclue.gen_clues.g() },
--         }
--     end
--     }
-- }

-- this doesn't work:
local plugins = {
    { 'echasnovski/mini.clue',
    version = '*',
    opts = function()
        local miniclue = require("mini.clue")
        miniclue.setup {
            triggers = { { mode = "n", keys = "g" } },
            clues = { miniclue.gen_clues.g() },
        }
    end
    }
}

require("lazy").setup(plugins, {
    root = root .. "/plugins",
})

vim.cmd[[set termguicolors]]

Expected behavior

First g:

image

Second g:

image

Actual behavior

First g (only two clues are shown):

image

Second g (notice the "g" in the lower bar, no clues are shown):

image
echasnovski commented 10 months ago

This is not an issue with 'mini.clue', but with how 'lazy.nvim' is used here to call configure 'mini.clues'. In the case of standalone plugin, executing :=MiniClue right after first step shows that require('mini.clue').setup() is called without supplied opts. While with 'mini.nvim' it does.

I this is because 'lazy.nvim' does special detection of 'mini.nvim' which might for some reason not work here.

Using config key instead of opts key for standalone plugin solves this.

simonmandlik commented 10 months ago

Thank you!