Breaking change for non-whichkey users | Refactor mapping functions

This commit is contained in:
siduck 2022-05-29 15:08:53 +05:30
parent c5bcf9d9a1
commit 0f013d4e7b
6 changed files with 85 additions and 192 deletions

View file

@ -22,14 +22,8 @@ M.on_attach = function(client, bufnr)
client.resolved_capabilities.document_formatting = false
client.resolved_capabilities.document_range_formatting = false
local options = require("plugins.configs.whichkey").options
local lsp_mappings = { nvchad.load_config().mappings.lspconfig }
lsp_mappings[1]["mode_opts"] = { buffer = bufnr }
if not nvchad.whichKey_map(lsp_mappings, options) then
nvchad.no_WhichKey_map(lsp_mappings)
end
local lsp_mappings = nvchad.load_config().mappings.lspconfig
nvchad.load_mappings({ lsp_mappings }, { buffer = bufnr })
end
local capabilities = vim.lsp.protocol.make_client_capabilities()

View file

@ -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)