From a9efe38ff9ed908a1236d5c6d9c013a91dc3ec46 Mon Sep 17 00:00:00 2001 From: Mat Jones Date: Mon, 23 Oct 2023 07:24:37 -0400 Subject: [PATCH] fix(extension): Make which_key extension respect auto_register config --- lua/legendary/extensions/which_key.lua | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lua/legendary/extensions/which_key.lua b/lua/legendary/extensions/which_key.lua index 9e715bd..4748f83 100644 --- a/lua/legendary/extensions/which_key.lua +++ b/lua/legendary/extensions/which_key.lua @@ -29,14 +29,16 @@ return function(opts) end end - local original = wk.register - local listener = function(whichkey_tbls, whichkey_opts) - Log.trace('Preparing to register items from which-key.nvim automatically') - util.bind_whichkey(whichkey_tbls, whichkey_opts, opts.do_binding, opts.use_groups) - original(whichkey_tbls, whichkey_opts) - Log.trace('Successfully registered items from which-key.nvim') + if opts.auto_register then + local original = wk.register + local listener = function(whichkey_tbls, whichkey_opts) + Log.trace('Preparing to register items from which-key.nvim automatically') + util.bind_whichkey(whichkey_tbls, whichkey_opts, opts.do_binding, opts.use_groups) + original(whichkey_tbls, whichkey_opts) + Log.trace('Successfully registered items from which-key.nvim') + end + wk.register = listener end - wk.register = listener else Log.warn( 'which-key.nvim not available. If you are lazy-loading, be sure that which-key.nvim is added to runtime path '