From 01a1b8e80db55963f281cf36674cf1c174e2f50e Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Tue, 18 Apr 2023 20:00:02 +0200 Subject: [PATCH] feat(diagnostics): added support for setting prefix = "icons". Check the docs on how to enable --- lua/lazyvim/plugins/lsp/init.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lua/lazyvim/plugins/lsp/init.lua b/lua/lazyvim/plugins/lsp/init.lua index 2f761754..aeb284bb 100644 --- a/lua/lazyvim/plugins/lsp/init.lua +++ b/lua/lazyvim/plugins/lsp/init.lua @@ -25,6 +25,9 @@ return { spacing = 4, source = "if_many", prefix = "●", + -- this will set set the prefix to a function that returns the diagnostics icon based on the severity + -- this only works on a recent 0.10.0 build. Will be set to "●" when not supported + -- prefix = "icons", }, severity_sort = true, }, @@ -83,6 +86,19 @@ return { name = "DiagnosticSign" .. name vim.fn.sign_define(name, { text = icon, texthl = name, numhl = "" }) end + + if opts.diagnostics.virtual_text.prefix == "icons" then + opts.diagnostics.virtual_text.prefix = vim.fn.has("nvim-0.10.0") == 0 and "●" + or function(diagnostic) + local icons = require("lazyvim.config").icons.diagnostics + for d, icon in pairs(icons) do + if diagnostic.severity == vim.diagnostic.severity[d:upper()] then + return icon + end + end + end + end + vim.diagnostic.config(opts.diagnostics) local servers = opts.servers