Skip to content

Commit a7a909b

Browse files
committed
fix: update to which-key v3
1 parent 5235872 commit a7a909b

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

lua/astrocore/init.lua

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -269,9 +269,7 @@ function M.which_key_register()
269269
if M.which_key_queue then
270270
local wk_avail, wk = pcall(require, "which-key")
271271
if wk_avail then
272-
for mode, registration in pairs(M.which_key_queue) do
273-
wk.register(registration, { mode = mode })
274-
end
272+
wk.add(M.which_key_queue)
275273
M.which_key_queue = nil
276274
end
277275
end
@@ -312,11 +310,12 @@ function M.set_mappings(map_table, base)
312310
keymap_opts = vim.tbl_deep_extend("force", keymap_opts, options)
313311
keymap_opts[1] = nil
314312
end
315-
if not cmd or keymap_opts.name then -- if which-key mapping, queue it
316-
if not keymap_opts.name then keymap_opts.name = keymap_opts.desc end
313+
if not cmd then -- if which-key mapping, queue it
314+
---@cast keymap_opts wk.Spec
315+
keymap_opts[1], keymap_opts.mode = keymap, mode
316+
if not keymap_opts.group then keymap_opts.group = keymap_opts.desc end
317317
if not M.which_key_queue then M.which_key_queue = {} end
318-
if not M.which_key_queue[mode] then M.which_key_queue[mode] = {} end
319-
M.which_key_queue[mode][keymap] = keymap_opts
318+
table.insert(M.which_key_queue, keymap_opts)
320319
else -- if not which-key mapping, set it
321320
vim.keymap.set(mode, keymap, cmd, keymap_opts)
322321
end

0 commit comments

Comments
 (0)