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

feature: Excluding a mapped key #541

Open
1 task done
Myzel394 opened this issue Nov 11, 2023 · 4 comments
Open
1 task done

feature: Excluding a mapped key #541

Myzel394 opened this issue Nov 11, 2023 · 4 comments
Labels
enhancement New feature or request stale

Comments

@Myzel394
Copy link

Did you check the docs?

  • I have read all the which-key.nvim docs

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

Given the following maps:

for i = 1, 10 do
    vim.keymap.set("n", "<leader>" .. i, function() ui.nav_file(i) end)
end

it's obvious for me what <leader> + number does. I'd like to be able to exclude them from showing up in which-key.

Describe the solution you'd like

Add an option to make fields hidden.

Describe alternatives you've considered

I tried to add them to hidden using:

hidden = { "<silent>", "<cmd>", "<Cmd>", "<CR>", "^:", "^ ", "^call ", "^lua ", "<leader>1", "^<leader>1", ... plus the other numbers }

and also tried to create a custom mapping as instructed in https://github.com/folke/which-key.nvim#%EF%B8%8F-mappings but the key was still shown.

Additional context

No response

@Myzel394 Myzel394 added the enhancement New feature or request label Nov 11, 2023
@gagiD
Copy link

gagiD commented Nov 14, 2023

+1

@arpangreat
Copy link

If you are using custom mappings using which key itself, just pass which_key_ignore label in the name/desc of the command , it's in the mappings section of the readme.

@gagiD
Copy link

gagiD commented Nov 17, 2023

@arpangreat Thank you.

For the record, this works for me:

local opts = { noremap = true, silent = true, desc = "which_key_ignore" }

vim.api.nvim_set_keymap("n", "<leader>1", ":BufferLineGoToBuffer 1<CR>", opts)

Copy link
Contributor

github-actions bot commented Jul 6, 2024

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the stale label Jul 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request stale
Projects
None yet
Development

No branches or pull requests

3 participants