folke / lazy.nvim

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

bug: "keys" configuration NOT triggering plugin load. #662

Closed henryoliver closed 1 year ago

henryoliver commented 1 year ago

Did you check docs and existing issues?

Neovim version (nvim -v)

NVIM v0.8.3 Build type: Release

Operating system/version

MacOs 13.2.1 (22D68)

Describe the bug

What is wrong with this code here? Why don't the keys load the plugin?

It should be straightforward. Whatever the user hits the "key", lazynvim should load the plugin.

    -- ChatGPT
    {
        "jackMort/ChatGPT.nvim",
        keys = { "<Leader>i", { "<Leader>i", mode = "v" } },
        dependencies = {
            "MunifTanjim/nui.nvim",
            "nvim-lua/plenary.nvim",
            "nvim-telescope/telescope.nvim",
        },
        config = true,
        -- Mappings
        init = function()
            require("which-key").register({
                ["<Leader>i"] = { name = "ChatGPT" },
                ["<Leader>ic"] = { "<Cmd>ChatGPT<CR>", "ChatGPT" },
                ["<Leader>ia"] = { "<Cmd>ChatGPTActAs<CR>", "Awesome ChatGPT Prompts" },
                ["<Leader>ie"] = { "<Cmd>ChatGPTEditWithInstructions<CR>", "Edit Window" },
            })

            require("which-key").register({
                ["<Leader>i"] = { name = "ChatGPT" },
                ["<Leader>ie"] = { "<Cmd>ChatGPTEditWithInstructions<CR>", "Edit Selection" },
            }, { mode = "v" })
        end,
    },

Steps To Reproduce

  1. Add your "keys" configuration
  2. Hit the key in the "keys" configuration

Expected Behavior

Should load the plugin.

folke commented 1 year ago

That can't work.

You've bound <leader>ic to "ChatGPT". in the init function. That will never load ChatGPT.

Doing <leader>i will load it as you have specified, but that's probably not what you want.

Just all the keymaps in keys, you can use desc = "ddd" so it will show correctly in which-key.

No need to register those mappinsg again in which-key

henryoliver commented 1 year ago

@folke in this example <Leader>i is NOT loading the plugin at all. Any subsequential key will fail so there will be no <Cmd> available from the plugin. Make sense?

folke commented 1 year ago

The repro does load on leader i for me. Anyway what you have there is not what you want. Read the docs. You'll figure it out