-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #400 from mrjones2014/mrj/399/lazy-nvim-and-whichk…
…ey-extensions feat(extension)!: Move which-key.nvim and lazy.nvim integrations to extensions
- Loading branch information
Showing
10 changed files
with
96 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
local Log = require('legendary.log') | ||
local util = require('legendary.util.which_key') | ||
|
||
---@class LegendaryWhichkeyConfig | ||
---@field auto_register boolean | ||
---@field mappings table[] | ||
---@field opts table | ||
---@field do_binding boolean | ||
---@field use_groups boolean | ||
|
||
---@param opts LegendaryWhichkeyConfig | ||
return function(opts) | ||
local loaded, which_key = pcall(require, 'which-key') | ||
|
||
if loaded then | ||
local wk = which_key | ||
|
||
if opts then | ||
if opts.do_binding == nil then | ||
opts.do_binding = false | ||
end | ||
|
||
if #vim.tbl_keys(opts.mappings or {}) > 0 then | ||
util.bind_whichkey(opts.mappings, opts.opts, opts.do_binding) | ||
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, false) | ||
original(whichkey_tbls, whichkey_opts) | ||
Log.trace('Successfully registered items from which-key.nvim') | ||
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 ' | ||
.. 'before running legendary.nvim config.' | ||
) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters