From 66d933cbb3e8fd1f398e34ecae5cb01d8aa82fa3 Mon Sep 17 00:00:00 2001 From: Dreaded_X Date: Wed, 28 May 2025 17:58:57 +0200 Subject: [PATCH] Adjusted diagnostic config --- nvim/dot-config/nvim/lua/autocmds.lua | 21 +-------------------- nvim/dot-config/nvim/lua/options.lua | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 24 deletions(-) diff --git a/nvim/dot-config/nvim/lua/autocmds.lua b/nvim/dot-config/nvim/lua/autocmds.lua index 4126241..b70d6dc 100644 --- a/nvim/dot-config/nvim/lua/autocmds.lua +++ b/nvim/dot-config/nvim/lua/autocmds.lua @@ -64,19 +64,7 @@ vim.api.nvim_create_autocmd("LspAttach", { vim.keymap.set("n", "]d", function() vim.diagnostic.jump({ count = 1 }) end, { desc = "Go to next diagnostic message" }) - -- vim.keymap.set("n", "e", vim.diagnostic.open_float, { desc = "Open floating diagnostic message" }) - vim.keymap.set("n", "e", function() - if vim.diagnostic.config().virtual_lines then - vim.diagnostic.config({ virtual_lines = false }) - else - vim.diagnostic.config({ - virtual_lines = { - current_line = true, - format = vim.diagnostic.config().virtual_text.format, - }, - }) - end - end, { desc = "Show virtual diagnostic line" }) + vim.keymap.set("n", "e", vim.diagnostic.open_float, { desc = "Open floating diagnostic message" }) -- Helpers vim.keymap.set("n", "rn", function() @@ -132,10 +120,3 @@ vim.api.nvim_create_autocmd("LspAttach", { end end, }) - --- -vim.api.nvim_create_autocmd("CursorMoved", { - callback = function() - vim.diagnostic.config({ virtual_lines = false }) - end, -}) diff --git a/nvim/dot-config/nvim/lua/options.lua b/nvim/dot-config/nvim/lua/options.lua index 16457d7..cbc4551 100644 --- a/nvim/dot-config/nvim/lua/options.lua +++ b/nvim/dot-config/nvim/lua/options.lua @@ -82,10 +82,19 @@ vim.diagnostic.config({ [vim.diagnostic.severity.INFO] = diagnostic.info, }, }, - virtual_text = { - virt_text_pos = "eol_right_align", - format = function(d) - return ("%s [%s]"):format(d.message, d.source) + float = { + severity_sort = false, + header = "", + suffix = function(d) + local code = d.code and string.format(" (%s)", d.code) or "" + + return string.format("%s [%s]", code, d.source), "NormalFloat" end, }, + virtual_text = { + prefix = function(d) + return vim.diagnostic.config().signs.text[d.severity] + end, + virt_text_pos = "eol_right_align", + }, })