diff --git a/after/ftplugin/go.lua b/after/ftplugin/go.lua index 329f3c0c..71bebf0b 100644 --- a/after/ftplugin/go.lua +++ b/after/ftplugin/go.lua @@ -2,3 +2,10 @@ local vo = vim.opt_local vo.tabstop = 4 vo.shiftwidth = 4 vo.softtabstop = 4 + +local wk = require("which-key") +wk.add({ + { "c", "", desc = "+Coding" }, + { "cl", "lua print('TODO')", desc = "Todo" }, + { "cc", "lua print('TODO')", desc = "Todo2" }, +}) diff --git a/after/ftplugin/lua.lua b/after/ftplugin/lua.lua index 327231cc..cbea57fc 100644 --- a/after/ftplugin/lua.lua +++ b/after/ftplugin/lua.lua @@ -1,20 +1,20 @@ local wk = require("which-key") -wk.register({ - c = { - name = "Coding", - r = { - function() - require("luapad.run").run() - end, - "Run buffer content", - }, - l = { - function() - require("luapad").init() - end, - "Luapad", - }, - t = { "lua MiniTest.run_file()", "MiniTest for current file" }, - s = { "lua MiniTest.run()", "Run MiniTest suite" }, +wk.add({ + { "c", "", desc = "+Coding" }, + { + "cr", + function() + require("luapad.run").run() + end, + desc = "Run buffer content", }, -}, { prefix = "", mode = "n" }) + { + "cl", + function() + require("luapad").init() + end, + desc = "Luapad", + }, + { "ct", "lua MiniTest.run_file()", desc = "MiniTest for current file" }, + { "cs", "lua MiniTest.run()", desc = "Run MiniTest suite" }, +}) diff --git a/after/ftplugin/python.lua b/after/ftplugin/python.lua index 329f3c0c..908c1789 100644 --- a/after/ftplugin/python.lua +++ b/after/ftplugin/python.lua @@ -2,3 +2,8 @@ local vo = vim.opt_local vo.tabstop = 4 vo.shiftwidth = 4 vo.softtabstop = 4 + +local wk = require("which-key") +wk.add({ + { "dp", "", desc = "+Python" }, +}) diff --git a/lua/core/plugins/dap.lua b/lua/core/plugins/dap.lua index 5510e5b7..36de915c 100644 --- a/lua/core/plugins/dap.lua +++ b/lua/core/plugins/dap.lua @@ -15,12 +15,9 @@ end -- stylua: ignore local default_config = { - groups = { - ["d"] = { "Debug" }, - ["dp"] = { "Python" }, - }, dap = { keys = { + {"d", "", desc = "+Debug" }, { "db", function() require("dap").toggle_breakpoint() end, desc = "Toggle Breakpoint" }, { "dc", function() require("dap").run_to_cursor() end, desc = "Continue" }, { "di", function() require("dap").step_into() end, desc = "Step Into" }, @@ -131,12 +128,4 @@ return { }, }, }, - -- which key integration - { - "folke/which-key.nvim", - optional = true, - opts = { - groups = config.groups, - }, - }, } diff --git a/lua/core/plugins/gitsigns.lua b/lua/core/plugins/gitsigns.lua index a3a74878..e74ccf97 100644 --- a/lua/core/plugins/gitsigns.lua +++ b/lua/core/plugins/gitsigns.lua @@ -2,6 +2,9 @@ local user_config = vim.g.config.plugins.gitsigns or {} local default_config = { enabled = true, + keys = { + { "g", "", desc = "+Git" }, + }, opts = { on_attach = function(buffer) local gs = package.loaded.gitsigns @@ -35,18 +38,9 @@ return { "nvim-lua/plenary.nvim", }, opts = config.opts, + keys = config.keys, config = function(_, opts) require("gitsigns").setup(opts) end, }, - -- which key integration - { - "folke/which-key.nvim", - optional = true, - opts = { - groups = { - ["g"] = { name = "Git" }, - }, - }, - }, } diff --git a/lua/core/plugins/gp.lua b/lua/core/plugins/gp.lua index afa8e13e..d31f76cc 100644 --- a/lua/core/plugins/gp.lua +++ b/lua/core/plugins/gp.lua @@ -2,10 +2,8 @@ local user_config = vim.g.config.plugins.gp or {} local default_config = { enabled = false, - groups = { - ["i"] = { name = "AI" }, - }, keys = { + { "i", "", desc = "+AI" }, { "iv", "GpChatNew vsplit", desc = "New Chat (vsplit)" }, { "it", "GpChatToggle", desc = "Toggle last chat" }, { "if", "GpChatFinder", desc = "Find chat" }, @@ -64,12 +62,4 @@ return { config.config_function(opts) end, }, - -- which key integration - { - "folke/which-key.nvim", - optional = true, - opts = { - groups = config.groups, - }, - }, } diff --git a/lua/core/plugins/lsp/keys.lua b/lua/core/plugins/lsp/keys.lua index ac59304c..272a8234 100644 --- a/lua/core/plugins/lsp/keys.lua +++ b/lua/core/plugins/lsp/keys.lua @@ -84,13 +84,6 @@ M._keys = { function M.on_attach(client, buffer) local Keys = require("lazy.core.handler.keys") local keymaps = {} - local wk = require("which-key") - - wk.register({ - l = { - w = { "Workspaces" }, - }, - }, { prefix = "", mode = "n" }) for _, value in ipairs(M._keys) do local keys = Keys.parse(value) diff --git a/lua/core/plugins/mini.lua b/lua/core/plugins/mini.lua index 9e364129..6fa59bf0 100644 --- a/lua/core/plugins/mini.lua +++ b/lua/core/plugins/mini.lua @@ -1,6 +1,6 @@ local utils = require("utils.functions") -return { +return { { "echasnovski/mini.comment", -- built-in in Neovim 10 @@ -26,17 +26,7 @@ return { ":normal saiW`", { desc = "Surround inner word with backticks", noremap = true } ) - local wk = require("which-key") - wk.register({ - sa = "Add surrounding", - sd = "Delete surrounding", - sh = "Highlight surrounding", - sn = "Surround update n lines", - sr = "Replace surrounding", - sF = "Find left surrounding", - sf = "Find right surrounding", - st = { "lua require('tsht').nodes()", "TS hint textobject" }, - }) + -- TODO which-key integration require("mini.surround").setup(opts) end, }, diff --git a/lua/core/plugins/noice.lua b/lua/core/plugins/noice.lua index a0d5784f..8a6c156b 100644 --- a/lua/core/plugins/noice.lua +++ b/lua/core/plugins/noice.lua @@ -24,10 +24,8 @@ local default_config = { -- { filter = { event = "msg_show", find = "written" }, opts = { skip = true } }, -- skip "write" message on save }, }, - groups = { - ["n"] = { name = "Noice" }, - }, keys = { + { "n", "", desc = "Noice" }, { "nd", "Noice dismiss", desc = "Dismiss all visible messages" }, { "nn", "Noice", desc = "Open Noice" }, { "ne", "Noice errors", desc = "Open Noice Errors" }, @@ -47,19 +45,11 @@ return { { "rcarriga/nvim-notify", opts = { - top_down = false, + top_down = true, }, }, }, keys = config.keys, opts = config.opts, }, - -- which key integration - { - "folke/which-key.nvim", - optional = true, - opts = { - groups = config.groups, - }, - }, } diff --git a/lua/core/plugins/spectre.lua b/lua/core/plugins/spectre.lua index ab7afa25..346fc2f9 100644 --- a/lua/core/plugins/spectre.lua +++ b/lua/core/plugins/spectre.lua @@ -6,6 +6,7 @@ return { }, enabled = vim.g.config.plugins.spectre.enable, keys = { + { "R", "", desc = "Replace" }, { "Rr", function() @@ -30,14 +31,4 @@ return { }, }, }, - -- which key integration - { - "folke/which-key.nvim", - optional = true, - opts = { - groups = { - ["R"] = { name = "Replace" }, - }, - }, - }, } diff --git a/lua/core/plugins/treesj.lua b/lua/core/plugins/treesj.lua index 5ef4064b..5f0cac60 100644 --- a/lua/core/plugins/treesj.lua +++ b/lua/core/plugins/treesj.lua @@ -2,6 +2,7 @@ return { { "Wansmer/treesj", keys = { + { "mS", "", desc = "TreeSJ" }, { "mSt", "TSJToggle", desc = "Toggle" }, { "mSj", "TSJJoin", desc = "Join" }, { "mSs", "TSJSplit", desc = "Split" }, @@ -12,14 +13,4 @@ return { }, config = true, }, - -- which key integration - { - "folke/which-key.nvim", - optional = true, - opts = { - groups = { - ["mS"] = { name = "TreeSJ" }, - }, - }, - }, } diff --git a/lua/core/plugins/trouble.lua b/lua/core/plugins/trouble.lua index a7262849..64f20b87 100644 --- a/lua/core/plugins/trouble.lua +++ b/lua/core/plugins/trouble.lua @@ -16,10 +16,8 @@ local default_config = { }, }, }, - groups = { - ["x"] = { name = "Trouble" }, - }, keys = { + { "x", "", desc = "Trouble" }, { "xl", "Trouble loclist toggle", @@ -43,12 +41,4 @@ return { opts = config.opts, keys = config.keys, }, - -- which key integration - { - "folke/which-key.nvim", - optional = true, - opts = { - groups = config.groups, - }, - }, } diff --git a/lua/core/plugins/which-key.lua b/lua/core/plugins/which-key.lua index 85c08e9c..5fe371ff 100644 --- a/lua/core/plugins/which-key.lua +++ b/lua/core/plugins/which-key.lua @@ -1,45 +1,45 @@ +local user_config = vim.g.config.plugins.which_key or {} local icons = require("utils.icons") -local M = { - "folke/which-key.nvim", - event = "VeryLazy", + +local default_config = { opts = { + preset = "modern", icons = { + rules = false, -- disable icons in keymaps breadcrumb = icons.arrows.DoubleArrowRight, -- symbol used in the command line area that shows your active key combo separator = icons.arrows.SmallArrowRight, -- symbol used between a key and it's label group = icons.ui.Plus, -- symbol prepended to a group }, - window = { - border = "none", -- none, single, double, shadow - position = "bottom", -- bottom, top - margin = { 0, 10, 3, 10 }, -- extra window margin [top, right, bottom, left] - padding = { 2, 2, 2, 2 }, -- extra window padding [top, right, bottom, left] - }, layout = { - height = { min = 3, max = 25 }, -- min and max height of the columns width = { min = 5, max = 50 }, -- min and max width of the columns spacing = 10, -- spacing between columns align = "center", -- align columns left, center or right }, - groups = { - mode = { "n", "v" }, - ["b"] = { name = "Buffers" }, - ["f"] = { name = "Files" }, - ["l"] = { name = "LSP" }, - ["m"] = { name = "Misc" }, - ["q"] = { name = "Quickfix" }, - ["R"] = { name = "Replace" }, - ["mS"] = { name = "TreeSJ" }, - ["s"] = { name = "Search" }, - ["t"] = { name = "Toggles" }, - ["w"] = { name = "Window" }, - ["z"] = { name = "Spelling" }, + spec = { + { "b", group = "Buffers" }, + { "f", group = "Files" }, + { "l", group = "LSP" }, + { "m", group = "Misc" }, + { "q", group = "Quickfix" }, + { "R", group = "Replace" }, + { "mS", group = "TreeSJ" }, + { "s", group = "Search" }, + { "t", group = "Toggles" }, + { "w", group = "Window" }, + { "z", group = "Spelling" }, }, }, +} + +local config = vim.tbl_deep_extend("force", default_config, user_config) + +return { + "folke/which-key.nvim", + event = "VeryLazy", + opts_extend = { "spec" }, + opts = config.opts, config = function(_, opts) local wk = require("which-key") wk.setup(opts) - wk.register(opts.groups) end, } - -return M