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

Avoiding the <cr> (RETURN) for a defined mapping when calling a <plug>(...) function #385

Closed
3 tasks done
farzadmf opened this issue Jan 6, 2023 · 2 comments
Closed
3 tasks done
Labels
bug Something isn't working

Comments

@farzadmf
Copy link

farzadmf commented Jan 6, 2023

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 exsiting issues of plugins related to this issue

Neovim version (nvim -v)

0.8.2

Operating system/version

MacOS 12.6

Describe the bug

Sorry, I'm not even sure if this is a bug/working as intended

I'm trying to create a custom mapping for vim-visual-multi, and when I do this:

vim.keymap.set('n', '<leader>md', '<Plug>(VM-Add-Cursor-Down)', { desc = 'Visual Multi cursor down' })

And I do, <leader>md, it works as expected.

But, if I enable which-key, then when I do <leader>md, it acts weirdly.

I asked the in the plugin repo mg979/vim-visual-multi#222, and the rhs should NOT have a <cr> at the end (just like it doesn't with the example I gave)

But I think which-key somehow adds that <cr> to this, which causes the mapping to misbehave

Steps To Reproduce

  1. Enable vim-visual-multi and disable which-key
  2. Configure the nmap keybinding
  3. Press <leader>md on a line and see the visual cursor being created (normal behavior)
  4. Enable which-key (require('which-key').setup())
  5. Press <leader>md on a line a couple of times and it misbehaving because of <cr>

Expected Behavior

I expect the behavior to be the same with which-key enabledd

Repro

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")
-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

vim.g.mapleader = ' '

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  {
    "folke/which-key.nvim",
    -- Commenting out these lines makes the mapping work fine
    config = function()
      require('which-key').setup()
    end,
  },
  -- add any other plugins here
  {
    "mg979/vim-visual-multi",
    init = function()
      vim.keymap.set('n', '<leader>md', '<Plug>(VM-Add-Cursor-Down)', { desc = 'Visual Multi cursor down' })
    end,
  }
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here
-- NOTE: added the plugins and config above
@farzadmf farzadmf added the bug Something isn't working label Jan 6, 2023
@folke
Copy link
Owner

folke commented Jan 7, 2023

Can you see if that PR fixed your issue?

@farzadmf
Copy link
Author

farzadmf commented Jan 7, 2023

It does indeed, thank you @folke for following up. Will close this

@farzadmf farzadmf closed this as completed Jan 7, 2023
njhoffman pushed a commit to njhoffman/which-key.nvim that referenced this issue Jan 23, 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

2 participants