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]: select_prompt refuses a string but accept a function #440

Closed PetitBandit closed 7 months ago

PetitBandit commented 7 months ago

Similar Issues

Neovim Version

NVIM v0.9.5 Build type: Release LuaJIT 2.1.1703358377

Steps to Reproduce

  1. type this :lua require('legendary').find({ select_prompt = 'Custom prompt' }) (comes from the documentation)

but it works when i type this :lua require('legendary').find({ select_prompt = function() return 'Custom prompt' end })

Expected Behavior

the exemple in the doc file of custom prompt: :lua require('legendary').find({ select_prompt = 'Custom prompt' }) returns legendary with 'Custom prompt'

or

the documentation to not include that exemple

Actual Behavior

E5108: Error executing lua ...nouveauvim/lazy/legendary.nvim/lua/legendary/ui/init.lua:28: select_prompt: expected function, got string
stack traceback:
[C]: in function 'error'
vim/shared.lua: in function 'validate'
...nouveauvim/lazy/legendary.nvim/lua/legendary/ui/init.lua:28: in function 'select_inner'
...nouveauvim/lazy/legendary.nvim/lua/legendary/ui/init.lua:110: in function 'select'
...re/nouveauvim/lazy/legendary.nvim/lua/legendary/init.lua:110: in function 'find'
[string ":lua"]:1: in main chunk

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',
    dependencies = {
      -- place your `vim.ui.select()` handler plugin here
      -- for example:
      -- 'nvim-telescope/telescope.nvim',
       'stevearc/dressing.nvim',
-- doesnt this need to be uncommented for the plugin to be called in it's setup ?
    },
  },
  -- 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) ``` ```

Additional Details and/or Screenshots

No response

mrjones2014 commented 7 months ago

Thanks for the report!