Breaking change for non-whichkey users | Refactor mapping functions
This commit is contained in:
parent
c5bcf9d9a1
commit
0f013d4e7b
6 changed files with 85 additions and 192 deletions
|
|
@ -1,27 +1,10 @@
|
|||
local M = {}
|
||||
local present, wk = pcall(require, "which-key")
|
||||
|
||||
M.options = {
|
||||
if not present then
|
||||
return
|
||||
end
|
||||
|
||||
-- NOTE : this mode_opts table isnt in the default whichkey config
|
||||
-- Its added here so you could configure it in chadrc
|
||||
|
||||
mode_opts = {
|
||||
n = {
|
||||
mode = "n",
|
||||
},
|
||||
|
||||
v = {
|
||||
mode = "v",
|
||||
},
|
||||
|
||||
i = {
|
||||
mode = "i",
|
||||
},
|
||||
|
||||
t = {
|
||||
mode = "t",
|
||||
},
|
||||
},
|
||||
local options = {
|
||||
|
||||
icons = {
|
||||
breadcrumb = "»", -- symbol used in the command line area that shows your active key combo
|
||||
|
|
@ -51,25 +34,15 @@ M.options = {
|
|||
},
|
||||
}
|
||||
|
||||
M.options = nvchad.load_override(M.options, "folke/which-key.nvim")
|
||||
options = nvchad.load_override(options, "folke/which-key.nvim")
|
||||
|
||||
M.setup = function()
|
||||
local present, wk = pcall(require, "which-key")
|
||||
local mappings = nvchad.load_config().mappings
|
||||
local mapping_groups = { groups = vim.deepcopy(mappings.groups) }
|
||||
|
||||
if not present then
|
||||
return
|
||||
end
|
||||
mappings.disabled = nil
|
||||
mappings.groups = nil
|
||||
|
||||
local mappings = nvchad.load_config().mappings
|
||||
local mapping_groups = { groups = vim.deepcopy(mappings.groups) }
|
||||
nvchad.load_mappings()
|
||||
nvchad.load_mappings(mapping_groups)
|
||||
|
||||
mappings.disabled = nil
|
||||
mappings.groups = nil
|
||||
|
||||
nvchad.whichKey_map(mappings, M.options)
|
||||
nvchad.whichKey_map(mapping_groups, M.options)
|
||||
|
||||
wk.setup(M.options)
|
||||
end
|
||||
|
||||
return M
|
||||
wk.setup(options)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue