mirror of
https://codeberg.org/leana8959/.files.git
synced 2025-12-06 14:49:14 +00:00
nvim/diagnostic: cycle diagnostic layout
credit: mrcjkb
This commit is contained in:
parent
6fc31978fc
commit
c51141de08
1 changed files with 34 additions and 0 deletions
|
|
@ -44,6 +44,40 @@ vim.diagnostic.config {
|
|||
},
|
||||
}
|
||||
|
||||
do
|
||||
local index = 1
|
||||
|
||||
---@type vim.diagnostic.Opts[]
|
||||
local modes = {
|
||||
{ virtual_text = false, virtual_lines = false },
|
||||
{
|
||||
virtual_text = false,
|
||||
virtual_lines = {
|
||||
current_line = true,
|
||||
severity = {
|
||||
vim.diagnostic.severity.ERROR,
|
||||
vim.diagnostic.severity.WARN,
|
||||
},
|
||||
},
|
||||
},
|
||||
{ virtual_text = true, virtual_lines = false },
|
||||
}
|
||||
|
||||
---@param direction 'forward' | 'backward'
|
||||
local function cycle_diagnostic_modes(direction)
|
||||
if direction == "forward" then
|
||||
index = (index % #modes) + 1
|
||||
else
|
||||
index = (index - 2 + #modes) % #modes + 1
|
||||
end
|
||||
|
||||
vim.diagnostic.config(modes[index])
|
||||
end
|
||||
|
||||
vim.keymap.set("n", "]d", function() cycle_diagnostic_modes("forward") end)
|
||||
vim.keymap.set("n", "[d", function() cycle_diagnostic_modes("backward") end)
|
||||
end
|
||||
|
||||
-- Helix style border
|
||||
local orig_util_open_floating_preview = vim.lsp.util.open_floating_preview
|
||||
function vim.lsp.util.open_floating_preview(contents, syntax, opts, ...)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue