folke / lazy.nvim

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

Lazy load with keys has something wrong #937

Closed lianghx-319 closed 1 year ago

lianghx-319 commented 1 year ago

Did you check docs and existing issues?

Neovim version (nvim -v)

v0.9.1

Operating system/version

MacOS 14

Describe the bug

Plugin not load when trigger some keys, the config like this. When I press c which-key was not loaded, but the leader key will loaded. Other plugin like yanky has the same issue.

{
    "folke/which-key.nvim",
    keys = { "<leader>", '"', "'", "`", "c", "v", "g" },
    init = function()
      require("core.utils").load_mappings "whichkey"
    end,
    config = function(_, opts)
      dofile(vim.g.base46_cache .. "whichkey")
      require("which-key").setup(opts)
    end,
  }

Steps To Reproduce

  1. maybe my nvim config will reproduce this, I don't known how to create a minimal repro.lua
  2. https://github.com/lianghx-319/NvChad.git

Expected Behavior

Every keys will load the specify plugin

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",
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

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

for the minimal repro you should just use the template at the end and add your plugin spec

since often issues like this occur because of other things in your config you should really try to provide one of this because you can't expect maintainers to debug your whole config

lianghx-319 commented 1 year ago

for the minimal repro you should just use the template at the end and add your plugin spec

since often issues like this occur because of other things in your config you should really try to provide one of this because you can't expect maintainers to debug your whole config

I will try to create a minimal repro later.

max397574 commented 1 year ago

if this really is a lazy.nvim bug you should be able to just copy the spec you wrote above into the template at the bottom and get rid of the external thigs (highlights cache and see what from the load mappings function you have to include)

folke commented 1 year ago

That's not how you should use keys. Those keys won't trigger which-key to load.

lianghx-319 commented 1 year ago

That's not how you should use keys. Those keys won't trigger which-key to load.

But only the c not trigger which-key, other keys work find. Maybe I should create an issue to Nvchad

lianghx-319 commented 1 year ago

That's not how you should use keys. Those keys won't trigger which-key to load.

But only the c not trigger which-key, other keys work find. Maybe I should create an issue to Nvchad

I found that the hardtime.nvim make this happened, maybe I should make it lazy load after which-key