From 2b4dca0131f4076fc860b2b367cde0732f876e54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9ana=20=E6=B1=9F?= Date: Tue, 8 Jul 2025 23:31:08 +0200 Subject: [PATCH] nvim: refactor diagnostic configuration --- .config/nvim/plugin/lsp.lua | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/.config/nvim/plugin/lsp.lua b/.config/nvim/plugin/lsp.lua index 4eed6980..8ee5d1d2 100644 --- a/.config/nvim/plugin/lsp.lua +++ b/.config/nvim/plugin/lsp.lua @@ -75,6 +75,23 @@ local servers = { ------------- -- Helpers -- ------------- +vim.diagnostic.config { + signs = { + text = { + [vim.diagnostic.severity.ERROR] = "E", + [vim.diagnostic.severity.WARN] = "W", + [vim.diagnostic.severity.INFO] = "H", + [vim.diagnostic.severity.HINT] = "·", + }, + }, + severity_sort = true, + underline = { + severity = { + vim.diagnostic.severity.ERROR, + vim.diagnostic.severity.WARN, + }, + }, +} -- Helix style border local border = { @@ -94,18 +111,9 @@ function vim.lsp.util.open_floating_preview(contents, syntax, opts, ...) return orig_util_open_floating_preview(contents, syntax, opts, ...) end --- Diagnostic display configuration -vim.diagnostic.config { virtual_text = false, severity_sort = true } - -- Set log level vim.lsp.set_log_level("off") --- Gutter symbols setup -vim.fn.sign_define("DiagnosticSignError", { text = "E", texthl = "DiagnosticSignError", numhl = "DiagnosticSignError" }) -vim.fn.sign_define("DiagnosticSignWarn", { text = "W", texthl = "DiagnosticSignWarn", numhl = "DiagnosticSignWarn" }) -vim.fn.sign_define("DiagnosticSignHint", { text = "H", texthl = "DiagnosticSignHint", numhl = "DiagnosticSignHint" }) -vim.fn.sign_define("DiagnosticSignInfo", { text = "·", texthl = "DiagnosticSignInfo", numhl = "DiagnosticSignInfo" }) - -- Capabilities local capabilities = vim.lsp.protocol.make_client_capabilities() capabilities = require("cmp_nvim_lsp").default_capabilities(capabilities) @@ -115,8 +123,7 @@ capabilities = require("cmp_nvim_lsp").default_capabilities(capabilities) ---------- require("fidget").setup() - -local mylsp = require('lsp') +local mylsp = require("lsp") for name, config in pairs(servers) do require("lspconfig")[name].setup {