From a7a43192436c882d63572a91bdea63c8937b8f18 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Fri, 27 Jan 2023 23:31:22 +0100 Subject: [PATCH] beatiful lsp icons and messages --- lua/plugins/lspconfig.lua | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/lua/plugins/lspconfig.lua b/lua/plugins/lspconfig.lua index ad73bef..7cf94cf 100644 --- a/lua/plugins/lspconfig.lua +++ b/lua/plugins/lspconfig.lua @@ -41,6 +41,23 @@ return { ctermbg = 'red', bg = 'DarkRed' } ) + 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 @@ -270,7 +287,22 @@ return { capabilities = capabilities, }) - vim.diagnostic.config({ virtual_text = false }) + -- vim.diagnostic.config({ virtual_text = false }) + 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, + }, + }) end, event = 'VeryLazy' }