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: Bindings not honoring mode #542

Open
3 tasks done
bagnaram opened this issue Nov 16, 2023 · 1 comment
Open
3 tasks done

bug: Bindings not honoring mode #542

bagnaram opened this issue Nov 16, 2023 · 1 comment
Labels
bug Something isn't working stale

Comments

@bagnaram
Copy link

Did you check docs and existing issues?

  • I have read all the which-key.nvim docs
  • 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)

NVIM v0.9.2

Operating system/version

Fedora 39

Describe the bug

I am unable to get the following keymap descriptions to be captured by which-key. I have read a bit about how modes are handled, however the following bindings below aren't being shown in the which-key dialogue.

init.vim:

" copy into system buffer
xnoremap <leader>y "+y
nnoremap <leader>Y "+Y

which-key.lua

local wk = require("which-key")

wk.register({
  f = {
    name = "file", -- optional group name
    f = { "<cmd>Telescope find_files<cr>", "Find File" }, -- create a binding with label
    r = { "<cmd>Telescope oldfiles sort_lastused=true ignore_current_buffer=true <cr>", "Open Recent File", noremap=false},

    -- additional options for creating the keymap
    n = { "New File" }, -- just a label. don't create any mapping
    e = "Edit File", -- same as above
    ["1"] = "which_key_ignore",  -- special label to hide it in the popup
    b = { function() print("bar") end, "Foobar" } -- you can also pass functions!
  },
  g = {
    name = "Neogit",
    mode={'n', 'x'},
    g = { "status" },
    l = { "Copy git permalink to clipboard", mode={'n', 'x'}},
    L = { "Copy git permalink to clipboard", mode={'n', 'x'}},

  },
  p = {
    name = "Project",
    p = { "projects" },
    s = { function() require("telescope.builtin").grep_string({
      search = vim.fn.input("Grep > " ) })
   end, "find" }
  },
  s = {
    name = "Search",
    f = { "<cmd>Telescope find_files<cr>", "Search File Names" }, -- create a binding with label
    p = { "<cmd>Telescope grep_string<cr>", "Search Project" },
  },
  o = {
    name = "Open",
    p = { "projects" }
  },
  b = {
    name = "Buffers",
    b = { "list" },
    k = { "kill" }
  },
  Y = {
    name = "Yank line to system buffer",
    mode = 'n'
  },
  ["<"] = "buffers",
},
{
  prefix = "<leader>",
  mode = 'n'
})

wk.register({
  ['y'] = {
    name = "Yank to system buffer"
  },
},
{
  mode = 'x',
  prefix = "<leader>"
})

Steps To Reproduce

  1. Create the following keymaps in init.vim
  2. Add the following mapping definitions to whick-key
  3. Source configs and enter visual mode and press <LEADER>
  4. Bindings aren't picked up in the dialogue.

Expected Behavior

I should see the keymaps

Repro

N/A
@bagnaram bagnaram added the bug Something isn't working label Nov 16, 2023
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
bug Something isn't working stale
Projects
None yet
Development

No branches or pull requests

1 participant