mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-06-24 09:48:59 +02:00
feat(keymaps): added toggle for diagnostics and conceal
This commit is contained in:
parent
8174821b71
commit
77672ba3fd
2 changed files with 29 additions and 1 deletions
|
@ -75,6 +75,9 @@ vim.keymap.set("n", "<leader>tf", require("lazyvim.plugins.lsp.format").toggle,
|
|||
vim.keymap.set("n", "<leader>ts", function() util.toggle("spell") end, { desc = "Spelling" })
|
||||
vim.keymap.set("n", "<leader>tw", function() util.toggle("wrap") end, { desc = "Word Wrap" })
|
||||
vim.keymap.set("n", "<leader>tn", function() util.toggle("relativenumber", true) util.toggle("number") end, { desc = "Line Numbers" })
|
||||
vim.keymap.set("n", "<leader>td", util.toggle_diagnostics, { desc = "Diagnostics" })
|
||||
local conceallevel = vim.o.conceallevel > 0 and vim.o.conceallevel or 3
|
||||
vim.keymap.set("n", "<leader>tc", function() util.toggle("conceallevel", false, {0, conceallevel}) end, { desc = "Conceal" })
|
||||
|
||||
-- lazygit
|
||||
vim.keymap.set("n", "<leader>gg", function() require("lazyvim.util").float_term({ "lazygit" }) end, { desc = "Lazygit (cwd)" })
|
||||
|
|
|
@ -71,7 +71,20 @@ function M.float_term(cmd, opts)
|
|||
end
|
||||
|
||||
---@param silent boolean?
|
||||
function M.toggle(option, silent)
|
||||
---@param values? {[1]:any, [2]:any}
|
||||
function M.toggle(option, silent, values)
|
||||
if values then
|
||||
if vim.opt_local[option]:get() == values[1] then
|
||||
vim.opt_local[option] = values[2]
|
||||
else
|
||||
vim.opt_local[option] = values[1]
|
||||
end
|
||||
return vim.notify(
|
||||
"Set " .. option .. " to " .. vim.opt_local[option]:get(),
|
||||
vim.log.levels.INFO,
|
||||
{ title = "Option" }
|
||||
)
|
||||
end
|
||||
vim.opt_local[option] = not vim.opt_local[option]:get()
|
||||
if not silent then
|
||||
vim.notify(
|
||||
|
@ -82,4 +95,16 @@ function M.toggle(option, silent)
|
|||
end
|
||||
end
|
||||
|
||||
local enabled = true
|
||||
function M.toggle_diagnostics()
|
||||
enabled = not enabled
|
||||
if enabled then
|
||||
vim.diagnostic.enable()
|
||||
vim.notify("Enabled diagnostics", vim.log.levels.INFO, { title = "Diagnostics" })
|
||||
else
|
||||
vim.diagnostic.disable()
|
||||
vim.notify("Disabled diagnostics", vim.log.levels.INFO, { title = "Diagnostics" })
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue