From df94a044ec656c456067b550531a62e80a5be420 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sun, 16 Apr 2023 21:33:55 +0200 Subject: [PATCH] feat(which-key): easier integration for which-key group names --- lua/lazyvim/plugins/editor.lua | 17 +++++++---------- lua/lazyvim/plugins/ui.lua | 11 +++++++++++ 2 files changed, 18 insertions(+), 10 deletions(-) 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 = {