diff --git a/lua/plugins/configs/lspconfig.lua b/lua/plugins/configs/lspconfig.lua index e4593ee..8355385 100644 --- a/lua/plugins/configs/lspconfig.lua +++ b/lua/plugins/configs/lspconfig.lua @@ -22,60 +22,9 @@ M.on_attach = function(client, bufnr) client.resolved_capabilities.document_formatting = false client.resolved_capabilities.document_range_formatting = false - local options = { - - -- 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", - }, - }, - - icons = { - breadcrumb = "»", -- symbol used in the command line area that shows your active key combo - separator = "  ", -- symbol used between a key and it's label - group = "+", -- symbol prepended to a group - }, - - popup_mappings = { - scroll_down = "", -- binding to scroll down inside the popup - scroll_up = "", -- binding to scroll up inside the popup - }, - - window = { - border = "none", -- none/single/double/shadow - }, - - layout = { - spacing = 6, -- spacing between columns - }, - - hidden = { "", "", "", "", "call", "lua", "^:", "^ " }, - - triggers_blacklist = { - -- list of mode / prefixes that should never be hooked by WhichKey - i = { "j", "k" }, - v = { "j", "k" }, - }, - } - - options = nvchad.load_override(options, "folke/which-key.nvim") - + 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 diff --git a/lua/plugins/configs/whichkey.lua b/lua/plugins/configs/whichkey.lua index afcf40c..e113b3b 100644 --- a/lua/plugins/configs/whichkey.lua +++ b/lua/plugins/configs/whichkey.lua @@ -4,7 +4,9 @@ if not present then return end -local options = { +local M = {} + +M.options = { -- NOTE : this mode_opts table isnt in the default whichkey config -- Its added here so you could configure it in chadrc @@ -55,15 +57,19 @@ local options = { }, } -options = nvchad.load_override(options, "folke/which-key.nvim") +M.options = nvchad.load_override(M.options, "folke/which-key.nvim") -local mappings = nvchad.load_config().mappings -local mapping_groups = { groups = vim.deepcopy(mappings.groups) } +M.setup = function() + local mappings = nvchad.load_config().mappings + local mapping_groups = { groups = vim.deepcopy(mappings.groups) } -mappings.disabled = nil -mappings.groups = nil + mappings.disabled = nil + mappings.groups = nil -nvchad.whichKey_map(mappings, options) -nvchad.whichKey_map(mapping_groups, options) + nvchad.whichKey_map(mappings, M.options) + nvchad.whichKey_map(mapping_groups, M.options) -wk.setup(options) + wk.setup(M.options) +end + +return M diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 0c3d16d..f0c1867 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -206,7 +206,7 @@ local plugins = { nvchad.packer_lazy_load "which-key.nvim" end, config = function() - require "plugins.configs.whichkey" + require("plugins.configs.whichkey").setup() end, }, }