Avoid wk error if not loaded when currying keymaps

I guess requiring doesn't force init. Not sure if there is a way to do that.
This commit is contained in:
ViViDboarder 2024-07-18 14:08:46 -07:00
parent 474cfc0604
commit 0c84a3fcd1

View File

@ -165,11 +165,13 @@ function M.curry_keymap(mode, prefix, default_opts)
default_opts = vim.tbl_extend("keep", default_opts or {}, { noremap = true, silent = true }) default_opts = vim.tbl_extend("keep", default_opts or {}, { noremap = true, silent = true })
local group_desc = M.tbl_pop(default_opts, "group_desc") local group_desc = M.tbl_pop(default_opts, "group_desc")
if group_desc ~= nil then if group_desc ~= nil then
M.try_require("which-key", function(wk) if M.is_plugin_loaded("which-key") then
wk.register({ M.try_require("which-key", function(wk)
[prefix] = "+" .. group_desc, wk.register({
}, default_opts) [prefix] = "+" .. group_desc,
end) }, default_opts)
end)
end
end end
return function(lhs, rhs, opts) return function(lhs, rhs, opts)