mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-07-06 23:44:41 +02:00
feat: mini.pairs toggle
This commit is contained in:
parent
50b3050d30
commit
4d9407dc22
3 changed files with 16 additions and 14 deletions
|
@ -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,
|
||||
|
|
|
@ -121,6 +121,15 @@ end
|
|||
|
||||
---@param opts {skip_next: string, skip_ts: string[], skip_unbalanced: boolean, markdown: boolean}
|
||||
function M.pairs(opts)
|
||||
LazyVim.toggle.map("<leader>up", {
|
||||
name = "Mini Pairs",
|
||||
get = function()
|
||||
return not vim.g.minipairs_disable
|
||||
end,
|
||||
set = function(state)
|
||||
vim.g.minipairs_disable = not state
|
||||
end,
|
||||
})
|
||||
local pairs = require("mini.pairs")
|
||||
pairs.setup(opts)
|
||||
local open = pairs.open
|
||||
|
|
|
@ -21,6 +21,13 @@ function M.map(lhs, toggle)
|
|||
LazyVim.warn("Disabled " .. toggle.name, { title = toggle.name })
|
||||
end
|
||||
end, { desc = "Toggle" .. toggle.name })
|
||||
M.wk(lhs, toggle)
|
||||
end
|
||||
|
||||
function M.wk(lhs, toggle)
|
||||
if not LazyVim.has("which-key.nvim") then
|
||||
return
|
||||
end
|
||||
require("which-key").add({
|
||||
{
|
||||
lhs,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue