Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: Unexpected behaviour of "hidden" in combination with "expand" #874

Open
4 tasks done
metalinspired opened this issue Oct 28, 2024 · 0 comments
Open
4 tasks done
Labels
bug Something isn't working

Comments

@metalinspired
Copy link

Did you check docs and existing issues?

  • I have read all the which-key.nvim docs
  • I have updated the plugin to the latest version before submitting this issue
  • I have searched the existing issues of which-key.nvim
  • I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

0.11.0-dev-1050+g45e319ade

Operating system/version

Kubunut 24.04

Describe the bug

I am using "expand" to dynamically add Harpoon marks to keymap.
This works fine but I wanted to implement functionality to only show first five mappings.
Here I found out that "hidden" is completely ignored.
Then I thought I might as well hide all the Harpoon mark keymaps since I implemented a list of existing marks in the status line.
However, setting "hidden" here prevents which-key from showing up when leader key is pressed and Harpoon mark keymaps do not work.

Steps To Reproduce

Example for first case:

  {
    'folke/which-key.nvim',
    event = 'VimEnter',
    opts = {
      spec = {
         {  
          '<leader>',
          group = 'Harpoon',
          expand = function()
            local harpoon = require 'harpoon'
            local marks = harpoon:list().items
            local ret = {}

            for i, _ in ipairs(marks) do
              ret[i] = {
                tostring(i),
                function() harpoon:list():select(i) end,
                desc = 'Harpoon file ' .. i,
              }
              if i > 1 then
                ret[i]['hidden'] = true
              end
            end

            return ret
          end,
        }
      }
    }
  }

Example for second case:

  {
    'folke/which-key.nvim',
    event = 'VimEnter',
    opts = {
      spec = {
          {
          '<leader>',
          group = 'Harpoon',
          hidden = true,
          expand = function()
            local harpoon = require 'harpoon'
            local marks = harpoon:list().items
            local ret = {}

            for i, _ in ipairs(marks) do
              ret[i] = {
                tostring(i),
                function() harpoon:list():select(i) end,
                desc = 'Harpoon file ' .. i,
              }
            end

            return ret
          end,
        }
      }
    }
  }

Expected Behavior

For first case, to hide only the items where hidden is set.
For second, not to disable which-key showing up when leader key is pressed and for mappings to work.

Health

No response

Log

No response

Repro

No response

@metalinspired metalinspired added the bug Something isn't working label Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant