diff --git a/lua/lazyvim/plugins/editor.lua b/lua/lazyvim/plugins/editor.lua index d03e88b5..6beaff20 100644 --- a/lua/lazyvim/plugins/editor.lua +++ b/lua/lazyvim/plugins/editor.lua @@ -218,11 +218,7 @@ return { event = "VeryLazy", opts = { plugins = { spelling = true }, - }, - config = function(_, opts) - local wk = require("which-key") - wk.setup(opts) - local keymaps = { + defaults = { mode = { "n", "v" }, ["g"] = { name = "+goto" }, ["gz"] = { name = "+surround" }, @@ -239,11 +235,12 @@ return { ["u"] = { name = "+ui" }, ["w"] = { name = "+windows" }, ["x"] = { name = "+diagnostics/quickfix" }, - } - if Util.has("noice.nvim") then - keymaps["sn"] = { name = "+noice" } - end - wk.register(keymaps) + }, + }, + config = function(_, opts) + local wk = require("which-key") + wk.setup(opts) + wk.register(opts.defaults) end, }, diff --git a/lua/lazyvim/plugins/ui.lua b/lua/lazyvim/plugins/ui.lua index 2c43cc0c..26e6e092 100644 --- a/lua/lazyvim/plugins/ui.lua +++ b/lua/lazyvim/plugins/ui.lua @@ -199,6 +199,17 @@ return { { "folke/noice.nvim", event = "VeryLazy", + dependencies = { + -- which key integration + { + "folke/which-key.nvim", + opts = function(_, opts) + if require("lazyvim.util").has("noice.nvim") then + opts.defaults["sn"] = { name = "+noice" } + end + end, + }, + }, opts = { lsp = { override = {