From 028ca26b085e197e1a4029d60a6ec424a9f20253 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Wed, 26 Mar 2025 21:06:48 +0100 Subject: [PATCH] deprecated function --- lua/config/options.lua | 36 +++++++++++++++++++++++++++++------- lua/plugins/lspconfig.lua | 16 ---------------- 2 files changed, 29 insertions(+), 23 deletions(-) diff --git a/lua/config/options.lua b/lua/config/options.lua index 395ec15..388990b 100644 --- a/lua/config/options.lua +++ b/lua/config/options.lua @@ -109,14 +109,36 @@ opt.foldexpr = 'nvim_treesitter#foldexpr()' opt.foldexpr = 'nvim_treesitter#foldexpr()' vim.diagnostic.config({ - virtual_text = false, - signs = true, - float = { - border = 'single', - format = function(diagnostic) - return string.format('%s (%s) [%s]', diagnostic.message, diagnostic.source, diagnostic.code or diagnostic.user_data.lsp.code) - end, + signs = { + text = { + [vim.diagnostic.severity.ERROR] = '', -- Nerd Font Error Icon + [vim.diagnostic.severity.WARN] = '', -- Nerd Font Warning Icon + [vim.diagnostic.severity.INFO] = '', -- Nerd Font Info Icon + [vim.diagnostic.severity.HINT] = '', -- Nerd Font Hint Icon (example) + }, + -- Define the highlight group to use for the sign text for each severity + texthl = { + [vim.diagnostic.severity.ERROR] = 'DiagnosticSignError', + [vim.diagnostic.severity.WARN] = 'DiagnosticSignWarn', + [vim.diagnostic.severity.INFO] = 'DiagnosticSignInfo', + [vim.diagnostic.severity.HINT] = 'DiagnosticSignHint', + }, + -- Optional: Highlight the line number column + numhl = { + [vim.diagnostic.severity.ERROR] = 'DiagnosticLineNrError', + -- Add others for WARN, INFO, HINT if desired + }, + -- Optional: Highlight the whole line + linehl = { + -- Define highlight groups like 'DiagnosticLineError', 'DiagnosticLineWarn', etc. + [vim.diagnostic.severity.ERROR] = 'DiagnosticLineError', + }, }, + -- Other diagnostic configurations (optional examples) + virtual_text = false, -- Disable virtual text (inline messages) + underline = true, -- Enable underlining diagnostics + update_in_insert = false, -- Don't update diagnostics in insert mode + severity_sort = true, -- Sort diagnostics by severity }) -- Window border for floating windows diff --git a/lua/plugins/lspconfig.lua b/lua/plugins/lspconfig.lua index bdce254..0c85aac 100644 --- a/lua/plugins/lspconfig.lua +++ b/lua/plugins/lspconfig.lua @@ -116,23 +116,7 @@ return { }, } - local diagnostics = { - Error = ' ', - Warning = ' ', - Information = ' ', - Question = ' ', - Hint = ' ', - } - local signs = { - { name = 'DiagnosticSignError', text = diagnostics.Error }, - { name = 'DiagnosticSignWarn', text = diagnostics.Warning }, - { name = 'DiagnosticSignHint', text = diagnostics.Hint }, - { name = 'DiagnosticSignInfo', text = diagnostics.Information }, - } - for _, sign in ipairs(signs) do - vim.fn.sign_define(sign.name, { texthl = sign.name, text = sign.text, numhl = sign.name }) - end OpenDiagFloat = function() for _, winid in pairs(vim.api.nvim_tabpage_list_wins(0)) do