Did you check docs and existing issues?
Neovim version (nvim -v)
NVIM v0.10.0-dev-646+gc4df2f08b
Operating system/version
MacOS 13.4
Describe the bug
Hitting the <localleader> key doesn't trigger the which-key menu for buffer local mappings involving the <localleader> key. Interestingly enough, it loads properly after loading the which-key menu for <leader> in the same buffer prior to pressing <localleader>. This is primarily an issue with plugins like spectre, vimtex, diffview, etc. which set keybindings for a specific plugin related filetype.
Btw, this is a duplicate of #172 (sorry), but I noticed that it still seems to be around so I thought I might bring it up again. The workaround suggested in that issue works, but is rather cumbersome:
vim.api.nvim_create_autocmd("FileType", {
desc = "Set up Spectre Which-Key descriptions",
group = vim.api.nvim_create_augroup("spectre_mapping_descriptions", { clear = true }),
pattern = "spectre_panel",
callback = function()
vim.keymap.set("n", "<localleader>", function() require("which-key").show "," end, { buffer = true })
end,
})
Steps To Reproduce
- Enter a buffer with buffer local mappings (in the provided config,
:Spectre or hit <leader>s
- Hit the localleader key
- Which-key menu doesn't show up
Expected Behavior
I would expect the which-key menu to display for localleader mappings in a specific buffer.
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 = " "
vim.g.maplocalleader = ","
-- install plugins
local plugins = {
"folke/tokyonight.nvim",
{ "folke/which-key.nvim", opts = {} },
{
"nvim-pack/nvim-spectre",
cmd = "Spectre",
dependencies = "nvim-lua/plenary.nvim",
init = function()
local wk = require "which-key"
end,
opts = function()
local prefix = "<localleader>"
return {
open_cmd = "new",
mapping = {
send_to_qf = { map = prefix .. "q" },
replace_cmd = { map = prefix .. "c" },
show_option_menu = { map = prefix .. "o" },
run_current_replace = { map = prefix .. "r" },
run_replace = { map = prefix .. "R" },
change_view_mode = { map = prefix .. "v" },
resume_last_search = { map = prefix .. "l" },
},
}
end,
keys = { { "<leader>s", function() require("spectre").open() end, desc = "Spectre", }, },
},
}
require("lazy").setup(plugins, {
root = root .. "/plugins",
})
vim.cmd.colorscheme("tokyonight")
Did you check docs and existing issues?
Neovim version (nvim -v)
NVIM v0.10.0-dev-646+gc4df2f08b
Operating system/version
MacOS 13.4
Describe the bug
Hitting the
<localleader>key doesn't trigger the which-key menu for buffer local mappings involving the<localleader>key. Interestingly enough, it loads properly after loading the which-key menu for<leader>in the same buffer prior to pressing<localleader>. This is primarily an issue with plugins like spectre, vimtex, diffview, etc. which set keybindings for a specific plugin related filetype.Btw, this is a duplicate of #172 (sorry), but I noticed that it still seems to be around so I thought I might bring it up again. The workaround suggested in that issue works, but is rather cumbersome:
Steps To Reproduce
:Spectreor hit<leader>sExpected Behavior
I would expect the which-key menu to display for localleader mappings in a specific buffer.
Repro