diff --git a/lua/lazyvim/plugins/editor.lua b/lua/lazyvim/plugins/editor.lua index fa5d676e..5bdbcb12 100644 --- a/lua/lazyvim/plugins/editor.lua +++ b/lua/lazyvim/plugins/editor.lua @@ -162,32 +162,47 @@ return { { "folke/which-key.nvim", event = "VeryLazy", + opts_extend = { "spec" }, opts = { - plugins = { spelling = true }, - defaults = { - mode = { "n", "v" }, - ["g"] = { name = "+goto" }, - ["gs"] = { name = "+surround" }, - ["z"] = { name = "+fold" }, - ["]"] = { name = "+next" }, - ["["] = { name = "+prev" }, - [""] = { name = "+tabs" }, - ["b"] = { name = "+buffer" }, - ["c"] = { name = "+code" }, - ["f"] = { name = "+file/find" }, - ["g"] = { name = "+git" }, - ["gh"] = { name = "+hunks", ["_"] = "which_key_ignore" }, - ["q"] = { name = "+quit/session" }, - ["s"] = { name = "+search" }, - ["u"] = { name = "+ui" }, - ["w"] = { name = "+windows" }, - ["x"] = { name = "+diagnostics/quickfix" }, + defaults = {}, + spec = { + { + mode = { "n", "v" }, + { "", group = "tabs" }, + { "b", group = "buffer" }, + { "c", group = "code" }, + { "f", group = "file/find" }, + { "g", group = "git" }, + { "gh", group = "hunks" }, + { "q", group = "quit/session" }, + { "s", group = "search" }, + { "u", group = "ui" }, + { "w", group = "windows" }, + { "x", group = "diagnostics/quickfix" }, + { "[", group = "prev" }, + { "]", group = "next" }, + { "g", group = "goto" }, + { "gs", group = "surround" }, + { "z", group = "fold" }, + }, + }, + }, + keys = { + { + "?", + function() + require("which-key").show({ global = false }) + end, + desc = "Buffer Local Keymaps (which-key)", }, }, config = function(_, opts) local wk = require("which-key") wk.setup(opts) - wk.register(opts.defaults) + if not vim.tbl_isempty(opts.defaults) then + LazyVim.warn("which-key: opts.defaults is deprecated. Please use opts.spec instead.") + wk.register(opts.defaults) + end end, }, diff --git a/lua/lazyvim/plugins/extras/editor/overseer.lua b/lua/lazyvim/plugins/extras/editor/overseer.lua index 0ef281ae..373c0029 100644 --- a/lua/lazyvim/plugins/extras/editor/overseer.lua +++ b/lua/lazyvim/plugins/extras/editor/overseer.lua @@ -64,7 +64,9 @@ return { "folke/which-key.nvim", optional = true, opts = { - defaults = { ["o"] = { name = "+overseer" } }, + spec = { + { "o", group = "overseer" }, + }, }, }, { diff --git a/lua/lazyvim/plugins/extras/lang/markdown.lua b/lua/lazyvim/plugins/extras/lang/markdown.lua index c8424ea5..7d026b23 100644 --- a/lua/lazyvim/plugins/extras/lang/markdown.lua +++ b/lua/lazyvim/plugins/extras/lang/markdown.lua @@ -100,6 +100,7 @@ return { headline_highlights = {}, -- disable bullets for now. See https://github.com/lukas-reineke/headlines.nvim/issues/66 bullets = {}, + quote_string = false, } for i = 1, 6 do local hl = "Headline" .. i diff --git a/lua/lazyvim/plugins/extras/lang/r.lua b/lua/lazyvim/plugins/extras/lang/r.lua index e3dd3302..96e618b3 100644 --- a/lua/lazyvim/plugins/extras/lang/r.lua +++ b/lua/lazyvim/plugins/extras/lang/r.lua @@ -21,22 +21,19 @@ return { -- Increase the width of which-key to handle the longer r-nvim descriptions local wk = require("which-key") - -- Workaround from https://github.com/folke/which-key.nvim/issues/514#issuecomment-1987286901 - wk.register({ - [""] = { - a = { name = "+(a)ll", ["🚫"] = "which_key_ignore" }, - b = { name = "+(b)etween marks", ["🚫"] = "which_key_ignore" }, - c = { name = "+(c)hunks", ["🚫"] = "which_key_ignore" }, - f = { name = "+(f)unctions", ["🚫"] = "which_key_ignore" }, - g = { name = "+(g)oto", ["🚫"] = "which_key_ignore" }, - k = { name = "+(k)nit", ["🚫"] = "which_key_ignore" }, - p = { name = "+(p)aragraph", ["🚫"] = "which_key_ignore" }, - q = { name = "+(q)uarto", ["🚫"] = "which_key_ignore" }, - r = { name = "+(r) general", ["🚫"] = "which_key_ignore" }, - s = { name = "+(s)plit or (s)end", ["🚫"] = "which_key_ignore" }, - t = { name = "+(t)erminal", ["🚫"] = "which_key_ignore" }, - v = { name = "+(v)iew", ["🚫"] = "which_key_ignore" }, - }, + wk.add({ + { "a", group = "all" }, + { "b", group = "between marks" }, + { "c", group = "chunks" }, + { "f", group = "functions" }, + { "g", group = "goto" }, + { "k", group = "knit" }, + { "p", group = "paragraph" }, + { "q", group = "quarto" }, + { "r", group = "r general" }, + { "s", group = "split or send" }, + { "t", group = "terminal" }, + { "v", group = "view" }, }) end, }, diff --git a/lua/lazyvim/util/mini.lua b/lua/lazyvim/util/mini.lua index a0fe407b..a35999c4 100644 --- a/lua/lazyvim/util/mini.lua +++ b/lua/lazyvim/util/mini.lua @@ -61,52 +61,51 @@ end -- register all text objects with which-key function M.ai_whichkey() - ---@type table - local i = { - [" "] = "Whitespace", - ['"'] = 'Balanced "', - ["'"] = "Balanced '", - ["`"] = "Balanced `", - ["("] = "Balanced (", - [")"] = "Balanced ) including white-space", - [">"] = "Balanced > including white-space", - [""] = "Balanced <", - ["]"] = "Balanced ] including white-space", - ["["] = "Balanced [", - ["}"] = "Balanced } including white-space", - ["{"] = "Balanced {", - ["?"] = "User Prompt", - _ = "Underscore", - a = "Argument", - b = "Balanced ), ], }", - c = "Class", - d = "Digit(s)", - e = "Word in CamelCase & snake_case", - f = "Function", - g = "Entire file", - i = "Indent", - o = "Block, conditional, loop", - q = "Quote `, \", '", - t = "Tag", - u = "Use/call function & method", - U = "Use/call without dot in name", + local objects = { + { " ", desc = "whitespace" }, + { '"', desc = 'balanced "' }, + { "'", desc = "balanced '" }, + { "(", desc = "balanced (" }, + { ")", desc = "balanced ) including white-space" }, + { "<", desc = "balanced <" }, + { ">", desc = "balanced > including white-space" }, + { "?", desc = "user prompt" }, + { "U", desc = "use/call without dot in name" }, + { "[", desc = "balanced [" }, + { "]", desc = "balanced ] including white-space" }, + { "_", desc = "underscore" }, + { "`", desc = "balanced `" }, + { "a", desc = "argument" }, + { "b", desc = "balanced )]}" }, + { "c", desc = "class" }, + { "d", desc = "digit(s)" }, + { "e", desc = "word in CamelCase & snake_case" }, + { "f", desc = "function" }, + { "g", desc = "entire file" }, + { "i", desc = "indent" }, + { "o", desc = "block, conditional, loop" }, + { "q", desc = "quote `\"'" }, + { "t", desc = "tag" }, + { "u", desc = "use/call function & method" }, + { "{", desc = "balanced {" }, + { "}", desc = "balanced } including white-space" }, } - local a = vim.deepcopy(i) - for k, v in pairs(a) do - a[k] = v:gsub(" including.*", "") - end - local ic = vim.deepcopy(i) - local ac = vim.deepcopy(a) - for key, name in pairs({ n = "Next", l = "Last" }) do - i[key] = vim.tbl_extend("force", { name = "Inside " .. name .. " textobject" }, ic) - a[key] = vim.tbl_extend("force", { name = "Around " .. name .. " textobject" }, ac) + local ret = { mode = { "o", "x" } } + for prefix, name in pairs({ + i = "inside", + a = "around", + il = "last", + ["in"] = "next", + al = "last", + an = "next", + }) do + ret[#ret + 1] = { prefix, group = name } + for _, obj in ipairs(objects) do + ret[#ret + 1] = { prefix .. obj[1], desc = obj.desc } + end end - require("which-key").register({ - mode = { "o", "x" }, - i = i, - a = a, - }) + require("which-key").add(ret, { notify = false }) end ---@param opts {skip_next: string, skip_ts: string[], skip_unbalanced: boolean, markdown: boolean}