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]: Description not taken into account with `itemgroup` commands #455

Closed pidgeon777 closed 5 months ago

pidgeon777 commented 5 months ago

Similar Issues

Neovim Version

NVIM v0.10.0
Build type: Release
LuaJIT 2.1.1713484068
Run "nvim -V1 -v" for more info

Steps to Reproduce

Run :Legendary.

Expected Behavior

I would expect the description to be shown for each of the grouped commands.

Actual Behavior

When you run :Legendary, there will be some new folders in the results (Debug, LSP, Utils) and the commands will be grouped under them:

image

The problem is that no description will be shown for the folder sub-items, but just the raw command string, instead of the command description:

image

Minimal Configuration to Reproduce

Use this legendary.nvim config:

{
  -- Initial commands to bind, can also be a function that returns the list
  commands = {
    {
      ":Telescope live_grep",
      description = "Find Text ( live grep )",
    },
    {
      -- groups with same itemgroup will be merged
      itemgroup = "Debug",
      -- don't need to copy the other group data because
      -- it will be merged with the one from the keymaps table
      commands = {
        -- PROFILING
        {
          "<CMD>lua require('mine.general_functions').profile_activator(1)<CR>",
          description = "Profiler Activate",
        },
        {
          "<CMD>lua require('mine.general_functions').profile_activator(0)<CR>",
          description = "Profiler Deactivate",
        },
        -- LSP
        {
          "<CMD>lua vim.notify(vim.inspect(vim.lsp.buf_request_sync(0, 'textDocument/documentSymbol', { textDocument = vim.lsp.util.make_text_document_params() }, 4000)))",
          description = "Print LSP symbols for current buffer",
        },
        -- TREESITTER
        {
          "<CMD>lua=vim.treesitter.highlighter.active[vim.api.nvim_get_current_buf()]<CR>",
          description = "Detect treesitter",
        },
      },
    },
    {
      itemgroup = "LSP",
      commands = {
        {
          "<CMD>lua vim.diagnostic.reset()<CR>",
          description = "Reset LSP diagnostics",
        },
        {
          "<CMD>lua vim.lsp.codelens.get()<CR>",
          description = "Get LSP codelens for the current buffer",
        },
      },
    },
    {
      itemgroup = "Utils",
      commands = {
        -- PROFILING
        {
          "<CMD>set guifont=*<CR>",
          description = "List available fonts",
        },
      },
    },
  },
}

Output from :LegendaryLog

:LegendaryLog output (click to expand) ``` [22/05/2024 14:29:44][legendary.nvim] setup() parsed and applied all configuration. [22/05/2024 14:27:57][legendary.nvim] setup() parsed and applied all configuration. [22/05/2024 14:24:06][legendary.nvim] Took 0.0756 ms to filter items in context. [22/05/2024 14:24:06][legendary.nvim] Config.sort.frecency is enabled, but sqlite is not available or database could not be opened, frecency is automatically disabled. [22/05/2024 14:24:06][legendary.nvim] Relaunching select UI for an item group [22/05/2024 14:23:48][legendary.nvim] setup() parsed and applied all configuration. [22/05/2024 14:22:55][legendary.nvim] Took 0.4923 ms to filter items in context. [22/05/2024 14:22:55][legendary.nvim] Config.sort.frecency is enabled, but sqlite is not available or database could not be opened, frecency is automatically disabled. [22/05/2024 14:18:46][legendary.nvim] setup() parsed and applied all configuration. [22/05/2024 14:16:56][legendary.nvim] setup() parsed and applied all configuration. [22/05/2024 14:16:08][legendary.nvim] setup() parsed and applied all configuration. [22/05/2024 14:15:07][legendary.nvim] Took 0.1672 ms to filter items in context. [22/05/2024 14:15:07][legendary.nvim] Config.sort.frecency is enabled, but sqlite is not available or database could not be opened, frecency is automatically disabled. [22/05/2024 14:15:07][legendary.nvim] Relaunching select UI for an item group [22/05/2024 14:15:06][legendary.nvim] Took 1.4557 ms to filter items in context. [22/05/2024 14:15:06][legendary.nvim] Config.sort.frecency is enabled, but sqlite is not available or database could not be opened, frecency is automatically disabled. [22/05/2024 14:14:46][legendary.nvim] Took 0.5837 ms to filter items in context. [22/05/2024 14:14:46][legendary.nvim] Config.sort.frecency is enabled, but sqlite is not available or database could not be opened, frecency is automatically disabled. [22/05/2024 14:14:44][legendary.nvim] Took 3.5659 ms to filter items in context. [22/05/2024 14:14:44][legendary.nvim] Config.sort.frecency is enabled, but sqlite is not available or database could not be opened, frecency is automatically disabled. [22/05/2024 14:14:43][legendary.nvim] Took 0.415 ms to filter items in context. [22/05/2024 14:14:43][legendary.nvim] Config.sort.frecency is enabled, but sqlite is not available or database could not be opened, frecency is automatically disabled. [22/05/2024 14:14:36][legendary.nvim] Took 0.168 ms to filter items in context. [22/05/2024 14:14:36][legendary.nvim] Config.sort.frecency is enabled, but sqlite is not available or database could not be opened, frecency is automatically disabled. [22/05/2024 14:14:36][legendary.nvim] Relaunching select UI for an item group [22/05/2024 14:14:31][legendary.nvim] Took 0.8971 ms to filter items in context. [22/05/2024 14:14:31][legendary.nvim] Config.sort.frecency is enabled, but sqlite is not available or database could not be opened, frecency is automatically disabled. [22/05/2024 14:14:17][legendary.nvim] setup() parsed and applied all configuration. [22/05/2024 14:13:33][legendary.nvim] setup() parsed and applied all configuration. [22/05/2024 13:57:20][legendary.nvim] Took 0.0837 ms to filter items in context. [22/05/2024 13:57:20][legendary.nvim] Config.sort.frecency is enabled, but sqlite is not available or database could not be opened, frecency is automatically disabled. [22/05/2024 13:57:20][legendary.nvim] Relaunching select UI for an item group [22/05/2024 13:57:19][legendary.nvim] Took 0.4672 ms to filter items in context. [22/05/2024 13:57:19][legendary.nvim] Config.sort.frecency is enabled, but sqlite is not available or database could not be opened, frecency is automatically disabled. [22/05/2024 13:57:19][legendary.nvim] setup() parsed and applied all configuration. [22/05/2024 13:55:41][legendary.nvim] Config.sort.frecency is enabled, but sqlite is not available or database could not be opened, frecency is automatically disabled. [22/05/2024 13:55:41][legendary.nvim] Preparing to execute selected item [22/05/2024 13:55:40][legendary.nvim] Took 0.0628 ms to filter items in context. [22/05/2024 13:55:40][legendary.nvim] Config.sort.frecency is enabled, but sqlite is not available or database could not be opened, frecency is automatically disabled. [22/05/2024 13:55:40][legendary.nvim] Relaunching select UI for an item group [22/05/2024 13:55:39][legendary.nvim] Took 0.5087 ms to filter items in context. [22/05/2024 13:55:39][legendary.nvim] Config.sort.frecency is enabled, but sqlite is not available or database could not be opened, frecency is automatically disabled. [22/05/2024 13:55:38][legendary.nvim] Config.sort.frecency is enabled, but sqlite is not available or database could not be opened, frecency is automatically disabled. [22/05/2024 13:55:38][legendary.nvim] Preparing to execute selected item [22/05/2024 13:55:38][legendary.nvim] Took 0.01 ms to filter items in context. [22/05/2024 13:55:38][legendary.nvim] Config.sort.frecency is enabled, but sqlite is not available or database could not be opened, frecency is automatically disabled. [22/05/2024 13:55:38][legendary.nvim] Relaunching select UI for an item group [22/05/2024 13:55:37][legendary.nvim] Took 0.9621 ms to filter items in context. [22/05/2024 13:55:37][legendary.nvim] Config.sort.frecency is enabled, but sqlite is not available or database could not be opened, frecency is automatically disabled. [22/05/2024 13:55:36][legendary.nvim] Config.sort.frecency is enabled, but sqlite is not available or database could not be opened, frecency is automatically disabled. [22/05/2024 13:55:36][legendary.nvim] Preparing to execute selected item [22/05/2024 13:55:34][legendary.nvim] Took 0.1342 ms to filter items in context. [22/05/2024 13:55:34][legendary.nvim] Config.sort.frecency is enabled, but sqlite is not available or database could not be opened, frecency is automatically disabled. [22/05/2024 13:55:34][legendary.nvim] Relaunching select UI for an item group [22/05/2024 13:55:30][legendary.nvim] Took 9.1982 ms to filter items in context. [22/05/2024 13:55:30][legendary.nvim] Config.sort.frecency is enabled, but sqlite is not available or database could not be opened, frecency is automatically disabled. [22/05/2024 13:55:28][legendary.nvim] Config.sort.frecency is enabled, but sqlite is not available or database could not be opened, frecency is automatically disabled. [22/05/2024 13:55:28][legendary.nvim] Preparing to execute selected item [22/05/2024 13:55:24][legendary.nvim] Took 0.0315 ms to filter items in context. [22/05/2024 13:55:24][legendary.nvim] Config.sort.frecency is enabled, but sqlite is not available or database could not be opened, frecency is automatically disabled. [22/05/2024 13:55:24][legendary.nvim] Relaunching select UI for an item group [22/05/2024 13:55:22][legendary.nvim] Took 6.9534 ms to filter items in context. [22/05/2024 13:55:22][legendary.nvim] Config.sort.frecency is enabled, but sqlite is not available or database could not be opened, frecency is automatically disabled. [22/05/2024 13:55:18][legendary.nvim] Took 0.0401 ms to filter items in context. [22/05/2024 13:55:18][legendary.nvim] Config.sort.frecency is enabled, but sqlite is not available or database could not be opened, frecency is automatically disabled. [22/05/2024 13:55:18][legendary.nvim] Relaunching select UI for an item group [22/05/2024 13:55:09][legendary.nvim] Took 4.4476 ms to filter items in context. [22/05/2024 13:55:09][legendary.nvim] Config.sort.frecency is enabled, but sqlite is not available or database could not be opened, frecency is automatically disabled. [22/05/2024 13:54:46][legendary.nvim] Config.sort.frecency is enabled, but sqlite is not available or database could not be opened, frecency is automatically disabled. [22/05/2024 13:54:46][legendary.nvim] Preparing to execute selected item [22/05/2024 13:54:45][legendary.nvim] Took 0.0745 ms to filter items in context. [22/05/2024 13:54:45][legendary.nvim] Config.sort.frecency is enabled, but sqlite is not available or database could not be opened, frecency is automatically disabled. [22/05/2024 13:54:45][legendary.nvim] Relaunching select UI for an item group [22/05/2024 13:54:42][legendary.nvim] Took 0.9508 ms to filter items in context. [22/05/2024 13:54:42][legendary.nvim] Config.sort.frecency is enabled, but sqlite is not available or database could not be opened, frecency is automatically disabled. [22/05/2024 13:54:34][legendary.nvim] Config.sort.frecency is enabled, but sqlite is not available or database could not be opened, frecency is automatically disabled. [22/05/2024 13:54:34][legendary.nvim] Preparing to execute selected item [22/05/2024 13:54:28][legendary.nvim] Took 0.1571 ms to filter items in context. [22/05/2024 13:54:28][legendary.nvim] Config.sort.frecency is enabled, but sqlite is not available or database could not be opened, frecency is automatically disabled. [22/05/2024 13:54:28][legendary.nvim] Relaunching select UI for an item group [22/05/2024 13:54:05][legendary.nvim] Took 0.4791 ms to filter items in context. [22/05/2024 13:54:05][legendary.nvim] Config.sort.frecency is enabled, but sqlite is not available or database could not be opened, frecency is automatically disabled. [22/05/2024 13:54:03][legendary.nvim] Took 3.3629 ms to filter items in context. [22/05/2024 13:54:03][legendary.nvim] Config.sort.frecency is enabled, but sqlite is not available or database could not be opened, frecency is automatically disabled. [22/05/2024 13:54:00][legendary.nvim] Took 1.5875 ms to filter items in context. [22/05/2024 13:54:00][legendary.nvim] Config.sort.frecency is enabled, but sqlite is not available or database could not be opened, frecency is automatically disabled. [22/05/2024 13:54:00][legendary.nvim] setup() parsed and applied all configuration. [22/05/2024 13:51:44][legendary.nvim] Took 1.1046 ms to filter items in context. [22/05/2024 13:51:44][legendary.nvim] Config.sort.frecency is enabled, but sqlite is not available or database could not be opened, frecency is automatically disabled. [22/05/2024 13:51:01][legendary.nvim] Took 0.5238 ms to filter items in context. [22/05/2024 13:51:01][legendary.nvim] Config.sort.frecency is enabled, but sqlite is not available or database could not be opened, frecency is automatically disabled. [22/05/2024 13:50:49][legendary.nvim] Config.sort.frecency is enabled, but sqlite is not available or database could not be opened, frecency is automatically disabled. [22/05/2024 13:50:49][legendary.nvim] Preparing to execute selected item [22/05/2024 13:50:44][legendary.nvim] Took 1.2398 ms to filter items in context. [22/05/2024 13:50:44][legendary.nvim] Config.sort.frecency is enabled, but sqlite is not available or database could not be opened, frecency is automatically disabled. [22/05/2024 13:50:44][legendary.nvim] Config.sort.frecency is enabled, but sqlite is not available or database could not be opened, frecency is automatically disabled. [22/05/2024 13:50:44][legendary.nvim] Preparing to execute selected item [22/05/2024 13:50:43][legendary.nvim] Took 1.2021 ms to filter items in context. [22/05/2024 13:50:43][legendary.nvim] Config.sort.frecency is enabled, but sqlite is not available or database could not be opened, frecency is automatically disabled. [22/05/2024 13:50:43][legendary.nvim] Config.sort.frecency is enabled, but sqlite is not available or database could not be opened, frecency is automatically disabled. [22/05/2024 13:50:43][legendary.nvim] Preparing to execute selected item [22/05/2024 13:50:38][legendary.nvim] Took 0.4417 ms to filter items in context. [22/05/2024 13:50:38][legendary.nvim] Config.sort.frecency is enabled, but sqlite is not available or database could not be opened, frecency is automatically disabled. [22/05/2024 13:50:38][legendary.nvim] setup() parsed and applied all configuration. ```

Additional Details and/or Screenshots

No response

pidgeon777 commented 5 months ago

Additionally, it would be cool to display descriptions for the folders themselves, instead of the Expand to select an item... text.

mrjones2014 commented 5 months ago

So, a couple things:

    commands = {
        {
          "<CMD>lua require('mine.general_functions').profile_activator(1)<CR>",
          description = "Profiler Activate",
        },
        -- .... 
    },

It looks like you're using the right-hand side (RHS) of a mapping, the first value in a command table is supposed to be the LHS (like :MyCommand, e.g. the name of the command to run). I think probably what you actually want here is:

functions = {
  {
    function()
      require('mine.general_functions').profile_activator(1)
    end,
    description = "Profiler Activate",
  },
},

Additionally, it would be cool to display descriptions for the folders themselves, instead of the Expand to select an item... text.

This should be a very easy fix though.

pidgeon777 commented 5 months ago

It appears that no description was shown in the Legendary panel because the width was too small: in reality, the description was there, but it was not visible.

Also, adding description under the itemgroup field in the Legendary settings, actually replaced the Expand to select an item... text with the description.

mrjones2014 commented 5 months ago

Gotcha, that makes sense. I'd recommend using functions instead of commands for the type of items you've listed above. It will work the same but give you a better UX experience.

Sounds like this is a non-issue then.