From 0dbf952a9ae080258e46463815c03ef762aaf935 Mon Sep 17 00:00:00 2001 From: Charles Danesi Date: Tue, 19 Nov 2024 12:27:14 -0500 Subject: [PATCH] add lsp diagnostics to bufferline --- .config/nvim/lua/plugins/bufferline.lua | 27 +++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/.config/nvim/lua/plugins/bufferline.lua b/.config/nvim/lua/plugins/bufferline.lua index 843b873..cc90baf 100644 --- a/.config/nvim/lua/plugins/bufferline.lua +++ b/.config/nvim/lua/plugins/bufferline.lua @@ -33,6 +33,33 @@ return { separator = true, }, }, + custom_areas = { + right = function() + local result = {} + local seve = vim.diagnostic.severity + local error = #vim.diagnostic.get(0, { severity = seve.ERROR }) + local warning = #vim.diagnostic.get(0, { severity = seve.WARN }) + local info = #vim.diagnostic.get(0, { severity = seve.INFO }) + local hint = #vim.diagnostic.get(0, { severity = seve.HINT }) + + if error ~= 0 then + table.insert(result, { text = "  " .. error, link = "DiagnosticError" }) + end + + if warning ~= 0 then + table.insert(result, { text = "  " .. warning, link = "DiagnosticWarn" }) + end + + if hint ~= 0 then + table.insert(result, { text = "  " .. hint, link = "DiagnosticHint" }) + end + + if info ~= 0 then + table.insert(result, { text = "  " .. info, link = "DiagnosticInfo" }) + end + return result + end, + }, }, }, }