We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
if i have some plugin which generates keybindings according to the conditions, which-key does not update the new ones in the prompt
an API like require("which-key").refresh()?
require("which-key").refresh()
for example, i use this plugin: https://github.com/j-morano/buffer_manager.nvim/, and for navigation between buffers i can do leader<number> to jump between buffers 1-10, it has this code
leader<number>
{ "j-morano/buffer_manager.nvim", lazy = true, event = { "BufAdd", "BufDelete", "BufEnter" }, keys = { { ",,", "<cmd>lua require('buffer_manager.ui').toggle_quick_menu()<CR>", desc = "Buffer Manager" }, }, config = function() local bm_status_ok, bm = pcall(require, "buffer_manager") if not bm_status_ok then print("Buffer Manager not found!") end bm.setup({ select_menu_item_commands = { edit = { key = "<CR>", command = "edit" }, v = { key = "<C-v>", command = "vsplit" }, h = { key = "<C-h>", command = "split" }, }, short_file_names = true, short_term_names = true, }) local keys = "1234567890" local bmui = require("buffer_manager.ui") for i = 1, #keys do local key = keys:sub(i, i) local desc = "Switch Buffer: " .. (i == 10 and "10" or key) vim.keymap.set({ "t", "n" }, string.format(",%s", key), function() bmui.nav_file(i) end, { desc = desc, noremap = true }) end vim.keymap.set({ "t", "n" }, ",s", function() bmui.toggle_quick_menu() vim.defer_fn(function() vim.fn.feedkeys("/") end, 50) end, { desc = "Search Buffer", noremap = true }) vim.api.nvim_set_hl(0, "BufferManagerModified", { fg = "#50fa7b" }) end, },
to jump between buffers, but it is not dynamic (if i dont have buffers from 6-10, it throws error), so i wrote this code:
local function count_buffers() local count = 1 for _, buffer in ipairs(vim.api.nvim_list_bufs()) do if vim.api.nvim_buf_is_loaded(buffer) then count = count + 1 end end return count end local buffer_count = count_buffers() for i = 1, buffer_count do local key = keys:sub(i, i) vim.keymap.set({ "t", "n" }, string.format(",%s", key), function() bmui.nav_file(i) end, { desc = "Switch Buffer: " .. key, noremap = true }) end
which dynamically makes keymaps so now it doesnt refresh the which-key window
No response
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Did you check the docs?
Is your feature request related to a problem? Please describe.
if i have some plugin which generates keybindings according to the conditions, which-key does not update the new ones in the prompt
Describe the solution you'd like
an API like
require("which-key").refresh()
?Describe alternatives you've considered
for example, i use this plugin: https://github.com/j-morano/buffer_manager.nvim/, and for navigation between buffers i can do
leader<number>
to jump between buffers 1-10, it has this codebuffer-manager repo
to jump between buffers, but it is not dynamic (if i dont have buffers from 6-10, it throws error), so i wrote this code:
which dynamically makes keymaps so now it doesnt refresh the which-key window
Additional context
No response
The text was updated successfully, but these errors were encountered: