fix: which-key group names can now be properly set with M.groups & refactoring
This commit is contained in:
parent
ec62a5cee8
commit
5716bbcca0
2 changed files with 21 additions and 15 deletions
|
@ -58,17 +58,25 @@ local options = {
|
|||
require("plugins.configs.others").misc_mappings()
|
||||
|
||||
local mappings = nvchad.load_config().mappings
|
||||
local mapping_groups = { groups = vim.deepcopy(mappings.groups) }
|
||||
mappings.disabled = nil
|
||||
mappings.groups = nil
|
||||
|
||||
-- register mappings
|
||||
for mode, opt in pairs(options.mode_opts) do
|
||||
for _, value in pairs(mappings) do
|
||||
if value[mode] then
|
||||
local mode_opts = value["mode_opts"] and vim.tbl_deep_extend("force", opt, value["mode_opts"]) or opt
|
||||
wk.register(value[mode], mode_opts)
|
||||
local function register_mappings(maps, opts)
|
||||
for mode, opt in pairs(opts.mode_opts) do
|
||||
for _, value in pairs(maps) do
|
||||
if value[mode] then
|
||||
local mode_opts = value["mode_opts"] and vim.tbl_deep_extend("force", opt, value["mode_opts"]) or opt
|
||||
wk.register(value[mode], mode_opts)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
register_mappings(mappings, options)
|
||||
register_mappings(mapping_groups, options)
|
||||
|
||||
options = nvchad.load_override(options, "folke/which-key.nvim")
|
||||
|
||||
wk.setup(options)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue