mrjones2014 / legendary.nvim

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

[Bug]: Not working with mini.pick ui select #437

Closed towry closed 6 months ago

towry commented 6 months ago

Similar Issues

Neovim Version

NVIM v0.10.0-dev-build-20231109-1232-g16a416cb3 Build type: Release LuaJIT 2.1.1710088188 Run "nvim -V1 -v" for more info

Steps to Reproduce

  1. nvim -u init.lua
  2. press <space><space> to select first item.
  3. nothing happens.

:LegendaryLog shows :

[Thu Mar 21 23:26:20 2024][legendary.nvim] Unsupported item type selected from finder UI: {
  builtin = false,

Expected Behavior

It would be great that it works with mini.pick

Actual Behavior

Not works in some picker ui.

Minimal Configuration to Reproduce

vim.g.mapleader = " "
vim.g.maplocalleader = ","

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 = {
    {
        "mrjones2014/legendary.nvim",
        dependencies = {
            -- place your `vim.ui.select()` handler plugin here
            -- for example:
            "nvim-lua/plenary.nvim",
            {
                "echasnovski/mini.pick",
                keys = {
                    {
                        "<leader>p",
                        function()
                            vim.ui.select({
                                "apple",
                                "banana",
                            }, {}, function(item)
                                vim.print(item)
                            end)
                        end,
                        desc = "test mini pick",
                    },
                },
                config = function()
                    require("mini.pick").setup({ window = { config = { border = "single" } } })
                    vim.ui.select = require("mini.pick").ui_select
                end,
            },
        },
    },
    -- add any other pugins here
}

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

require("legendary").setup({
    -- add any options here
    commands = {
        {
            ":Ex",
            description = "Ex",
        },
    },
})

require("legendary").itemgroup({
    itemgroup = "obsidian",
    commands = {
        {
            ":Obsidian",
            function()
                vim.notify("test command")
            end,
            description = "Obsidian test command",
        },
    },
})

vim.keymap.set("n", "<space><space>", function()
    require("legendary").find({
        itemgroup = "obsidian",
    })
end, {})

-- add anything else here
vim.opt.termguicolors = true

Output from :LegendaryLog

:LegendaryLog output (click to expand) ``` [Thu Mar 21 23:33:18 2024][legendary.nvim] Unsupported item type selected from finder UI: { builtin = false, class = { __declaredMethods = { __tostring = , apply = , frecency_id = , id = , initialize = , isInstanceOf = , parse = , parse_filters = , vim_cmd = }, __instanceDict = <1>{ __index = , __tostring = , apply = , frecency_id = , id = , initialize = , isInstanceOf = , parse = , parse_filters = , vim_cmd = }, name = "Command", static = { allocate = , include = , isSubclassOf = , new = , subclass = , subclassed = , = <2>{ __index = } }, subclasses = { = { __mode = "k" } }, = { __call = , __index = { allocate = , include = , isSubclassOf = , new = , subclass = , subclassed = , =
}, __newindex = , __tostring = } }, cmd = ":Obsidian", description = "Obsidian test command", hide = false, implementation = , unfinished = false, = <3>{ __index =
, __tostring = , apply = , frecency_id = , id = , initialize = , isInstanceOf = , parse = , parse_filters = , vim_cmd = } } [Thu Mar 21 23:33:18 2024][legendary.nvim] Config.sort.frecency is enabled, but sqlite is not available or database could not be opened, frecency is automatically disabled. [Thu Mar 21 23:33:18 2024][legendary.nvim] Preparing to execute selected item [Thu Mar 21 23:33:17 2024][legendary.nvim] Took 0.039321 ms to filter items in context. [Thu Mar 21 23:33:17 2024][legendary.nvim] Config.sort.frecency is enabled, but sqlite is not available or database could not be opened, frecency is automatically disabled. [Thu Mar 21 23:33:17 2024][legendary.nvim] Relaunching select UI for an item group [Thu Mar 21 23:33:15 2024][legendary.nvim] setup() parsed and applied all configuration. ```

Additional Details and/or Screenshots

No response

mrjones2014 commented 6 months ago

Looks like mini.pick is doing something with the selected result that's causing my type checking to fail, like maybe deep-copying the item or something. I've figured out a fix for this and I'll put up a PR shortly.