Skip to content

Commit

Permalink
Merge pull request #418 from mrjones2014/mrj/417/which-key-auto-register
Browse files Browse the repository at this point in the history
fix(extension): Make which_key extension respect auto_register config
  • Loading branch information
mrjones2014 authored Oct 23, 2023
2 parents 6ea46c2 + a9efe38 commit 05af688
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions lua/legendary/extensions/which_key.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 '
Expand Down

0 comments on commit 05af688

Please sign in to comment.