feat(keymaps): dynamic which-key icons/descriptions for toggles (#4050)

## Description

<!-- Describe the big picture of your changes to communicate to the
maintainers
  why we should accept this pull request. -->

## Related Issue(s)

- [ ] Closes #4025

## Screenshots


![image](https://github.com/user-attachments/assets/8453c23c-d560-490c-9f96-a22ea88f45fd)

## Checklist

- [ ] I've read the
[CONTRIBUTING](https://github.com/LazyVim/LazyVim/blob/main/CONTRIBUTING.md)
guidelines.
This commit is contained in:
Folke Lemaitre 2024-07-15 15:47:44 +02:00 committed by GitHub
parent 706ec4b6b6
commit 78cf0320bf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 217 additions and 131 deletions

View file

@ -140,20 +140,6 @@ return {
-- better deal with markdown code blocks
markdown = true,
},
keys = {
{
"<leader>up",
function()
vim.g.minipairs_disable = not vim.g.minipairs_disable
if vim.g.minipairs_disable then
LazyVim.warn("Disabled auto pairs", { title = "Option" })
else
LazyVim.info("Enabled auto pairs", { title = "Option" })
end
end,
desc = "Toggle Auto Pairs",
},
},
config = function(_, opts)
LazyVim.mini.pairs(opts)
end,

View file

@ -176,9 +176,9 @@ return {
{ "<leader>gh", group = "hunks" },
{ "<leader>q", group = "quit/session" },
{ "<leader>s", group = "search" },
{ "<leader>u", group = "ui" },
{ "<leader>u", group = "ui", icon = { icon = "󰙵 ", color = "cyan" } },
{ "<leader>w", group = "windows" },
{ "<leader>x", group = "diagnostics/quickfix" },
{ "<leader>x", group = "diagnostics/quickfix", icon = { icon = "󱖫 ", color = "green" } },
{ "[", group = "prev" },
{ "]", group = "next" },
{ "g", group = "goto" },
@ -193,7 +193,7 @@ return {
function()
require("which-key").show({ global = false })
end,
desc = "Buffer Local Keymaps (which-key)",
desc = "Buffer Keymaps (which-key)",
},
},
config = function(_, opts)

View file

@ -14,6 +14,16 @@ return {
end, { expr = true })
end
LazyVim.toggle.map("<leader>ua", {
name = "Mini Animate",
get = function()
return not vim.g.minianimate_disable
end,
set = function(state)
vim.g.minianimate_disable = not state
end,
})
local animate = require("mini.animate")
return {
resize = {

View file

@ -7,9 +7,9 @@ return {
"mason.nvim",
{ "williamboman/mason-lspconfig.nvim", config = function() end },
},
---@class PluginLspOpts
opts = function()
return {
---@class PluginLspOpts
local ret = {
-- options for vim.diagnostic.config()
---@type vim.diagnostic.Opts
diagnostics = {
@ -114,6 +114,7 @@ return {
-- ["*"] = function(server, opts) end,
},
}
return ret
end,
---@param opts PluginLspOpts
config = function(_, opts)
@ -150,7 +151,7 @@ return {
and vim.bo[buffer].buftype == ""
and not vim.tbl_contains(opts.inlay_hints.exclude, vim.bo[buffer].filetype)
then
LazyVim.toggle.inlay_hints(buffer, true)
vim.lsp.inlay_hint.enable(true, { bufnr = buffer })
end
end)
end

View file

@ -1,4 +1,14 @@
return {
{
"folke/which-key.nvim",
opts = {
spec = {
{ "<BS>", desc = "Decrement Selection", mode = "x" },
{ "<c-space>", desc = "Increment Selection", mode = { "x", "n" } },
},
},
},
-- Treesitter is a new parser generator tool that we can
-- use in Neovim to power faster and more accurate
-- syntax highlighting.