folke / which-key.nvim

💥 Create key bindings that stick. WhichKey helps you remember your Neovim keymaps, by showing available keybindings in a popup as you type.
Apache License 2.0
5.12k stars 163 forks source link

feature: Ability to mimic old "blacklist" feature. #756

Closed prdanelli closed 1 month ago

prdanelli commented 1 month ago

Did you check the docs?

Is your feature request related to a problem? Please describe.

I've been reading the docs and can't find anything related to how I can bypass which-key for certain keymaps - similar to the "blacklist" feature in v2.x.

I have a series of custom keymaps for things like oo, which inserts a line below and returns to normal mode, and OO which adds a line above and returns to the normal mode.

Since updating to v3, using O, to jump into insert mode on the line above, now presents the which-key panel with a single option for O.

I did have this disabled by using the disable method:

      ---@type fun(ctx: { keys: string, mode: string, plugin?: string }):boolean?
      trigger = function(ctx)
        local keysArray = { "<Esc>", "O", "b", "B", "o", "O", "j", "k", "h", "l", "v", "V" }
        local isKeyInArray = false

        for _, key in ipairs(keysArray) do
          if ctx.keys == key then
            isKeyInArray = true
            break
          end
        end

        return isKeyInArray
      end,
    },

However that seems to have been removed now.

Describe the solution you'd like

Similar to "blacklist", i'd like to be able to define a table to characters that would be ignored by which-key completely.

Describe alternatives you've considered

.

Additional context

.

max397574 commented 1 month ago

I guess this can be done with the triggers option in the config now

folke commented 1 month ago

wk should never bind triggers to builtin keymaps. I already added protection for this for lower-case keys, but forgot to do the same for uppercase. Will do so now.

folke commented 1 month ago

Added. Turns out that only Z is a safe upper-case letter. All the others are builtin keymaps.

prdanelli commented 1 month ago

Thank you so much.

On Thu, 18 Jul 2024 at 15:28, Folke Lemaitre @.***> wrote:

Added. Turns out that only Z is a safe upper-case letter. All the others are builtin keymaps.

— Reply to this email directly, view it on GitHub https://github.com/folke/which-key.nvim/issues/756#issuecomment-2236701192, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJE62KWCKKAWDYV7WMJPGTZM7GKRAVCNFSM6AAAAABLCTVE22VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMZWG4YDCMJZGI . You are receiving this because you authored the thread.Message ID: @.***>