mrjones2014 / legendary.nvim

🗺️ A legend for your keymaps, commands, and autocmds, integrates with which-key.nvim, lazy.nvim, and more.
MIT License
1.14k stars 19 forks source link

[Bug]: Error in LazyVim 9 #397

Closed Martin1887 closed 1 year ago

Martin1887 commented 1 year ago

Similar Issues

Neovim Version

0.9.2

Steps to Reproduce

  1. Open Neovim
  2. Error happens

Expected Behavior

No errors

Actual Behavior

notify.error lazy.nvim Failed to run `config` for legendary.nvim

...e/nvim/lazy/legendary.nvim/lua/legendary/data/keymap.lua:40: 1: expected string, got nil

# stacktrace:
  - vim/shared.lua:0 _in_ **validate**
  - /legendary.nvim/lua/legendary/data/keymap.lua:40 _in_ **parse**
  - /legendary.nvim/lua/legendary/init.lua:49
  - vim/shared.lua:0 _in_ **tbl_map**
  - /legendary.nvim/lua/legendary/init.lua:45 _in_ **keymaps**
  - /legendary.nvim/lua/legendary/init.lua:138 _in_ **keymap**
  - /legendary.nvim/lua/legendary/init.lua:89 _in_ **setup**
  - ~/.config/nvim/lua/config/lazy.lua:9
  - nvim/init.lua:2

Minimal Configuration to Reproduce

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',
    '--single-branch',
    'https://github.com/folke/lazy.nvim.git',
    lazypath,
  })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  -- do not remove the colorscheme! it makes testing nicer
  'folke/tokyonight.nvim',
  {
    'mrjones2014/legendary.nvim',
    version = "v2.12.1",
    -- since legendary.nvim handles all your keymaps/commands,
    -- its recommended to load legendary.nvim before other plugins
    priority = 10000,
    lazy = false,
    keys = {
      { "<leader>P", "<cmd>Legendary<cr>", desc = "Legendary Command Palette" },
    },
    opts = {
      sort = { frecency = false },
      lazy_nvim = {
        auto_register = true,
      },
      which_key = {
        auto_register = true,
        use_groups = false,
      },
    },
    dependencies = {
      -- place your `vim.ui.select()` handler plugin here
      -- for example:
      'nvim-telescope/telescope.nvim',
      'stevearc/dressing.nvim',
      'folke/which-key.nvim',
    },
  },
  -- add any other pugins here
}

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

require('dressing').setup()

require('legendary').setup({
  -- add any options here
})

-- add anything else here
vim.opt.termguicolors = true
-- do not remove the colorscheme! it makes testing nicer
vim.cmd([[colorscheme tokyonight]])

Output from :LegendaryLog

:LegendaryLog output (click to expand) ``` [lun 09 oct 2023 09:14:39][legendary.nvim] Took 1.00482 ms to filter items in context. [lun 09 oct 2023 09:14:39][legendary.nvim] Launching select UI ```

Additional Details and/or Screenshots

It may be a problem with which-key because items from which-key seem to not be registered.

ls-devs commented 1 year ago

It may not be a problem with which-key since I have the same error and dont use it.

Neovim version :

NVIM v0.10.0-dev-1304+gdadc06ced-dirty
Build type: RelWithDebInfo
LuaJIT 2.1.1696795921

Error :

Failed to run `config` for legendary.nvim

...e/nvim/lazy/legendary.nvim/lua/legendary/data/keymap.lua:40: 1: expected string, got nil

# stacktrace:
  - vim/shared.lua:0 _in_ **validate**
  - /legendary.nvim/lua/legendary/data/keymap.lua:40 _in_ **parse**
  - /legendary.nvim/lua/legendary/init.lua:49
  - vim/shared.lua:0 _in_ **tbl_map**
  - /legendary.nvim/lua/legendary/init.lua:45 _in_ **keymaps**
  - /legendary.nvim/lua/legendary/init.lua:138 _in_ **keymap**
  - /legendary.nvim/lua/legendary/init.lua:89 _in_ **setup**
  - ~/.config/nvim/lua/ls-devs/plugins/legendary.lua:5 _in_ **config**
mrjones2014 commented 1 year ago

It's a problem with the lazy.nvim integration. Looks like the API changed to return the left-hand-side of the keymap as keymap.lhs where it used to be keymap[1].

Pushing up a PR to fix right now...

mrjones2014 commented 1 year ago

Fixed in version 2.12.2 which I just tagged.