From 0c84a3fcd17007cff9ff2131879118a086de2b33 Mon Sep 17 00:00:00 2001 From: ViViDboarder Date: Thu, 18 Jul 2024 14:08:46 -0700 Subject: [PATCH] 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. --- neovim/lua/utils.lua | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/neovim/lua/utils.lua b/neovim/lua/utils.lua index f23944e..2346b5d 100644 --- a/neovim/lua/utils.lua +++ b/neovim/lua/utils.lua @@ -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 }) local group_desc = M.tbl_pop(default_opts, "group_desc") if group_desc ~= nil then - M.try_require("which-key", function(wk) - wk.register({ - [prefix] = "+" .. group_desc, - }, default_opts) - end) + if M.is_plugin_loaded("which-key") then + M.try_require("which-key", function(wk) + wk.register({ + [prefix] = "+" .. group_desc, + }, default_opts) + end) + end end return function(lhs, rhs, opts)