akinsho / akinsho/bufferline.nvim

[Feature Request]: Separate highlight groups for each diagnostic icon

Abierto
#952 1 comentario 0 reacciones 0 asignados Ver en GitHub
enhancement
Lenguaje dominante
Lua
Estrellas
4.4k
Forks
240
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

### What?

I'm looking for a way to distinguish each icon with its own highlight group. For example in the diagnostics_indicator option, where the user can formulate a function that returns a string for the diagnostics icons. Maybe it can return a table of tables each containing 1. a string text ( what it currently returns ) plus a string text member for a corresponding highlight group.

Basically treating each of the 4 possible severity icons as their own little components which could be derived from their existing highlight groups or custom HL groups that get passed back, error_diagnostic_selected or warn_diagnostic_selected etc. Instead of one single string that uses the highest severity.

I did a little digging and it seems like the diagnostics.lua where this callback function is called, has access to the parsed highlight group and it gets set based on highest severity. I'm wondering if it won't be too much work / won't affect performance to implement it, I could try doing PR but I'm an absolute newbie at nvim plugins.

```
diagnostics_indicator = function(count, level, diagnostics_dict, context)
local s = ""
for e, n in pairs(diagnostics_dict) do
local sym = e == "error" and " "
or (e == "warning" and " " or " ")
s = s .. sym .. n
end
return s
end
```

I'm assuming for my idea to work, each icon will have to be treated as a separate component in diagnostics.lua before it's used in UI.lua?

```
. . .
local highlights = context.current_highlights
local element = context.tab
local diagnostics = element.diagnostics
if not diagnostics or not diagnostics.count or diagnostics.count < 1 then return end

local indicator = ""
if user_indicator and type(user_indicator) == "function" then
local ctx = { buffer = element, tab = element }
indicator = user_indicator(diagnostics.count, diagnostics.level, diagnostics.errors, ctx)
elseif indicator == nil then
indicator = fmt(" (%s)", diagnostics.count)
end

local highlight = highlights[diagnostics.level] or ""
local diag_highlight = highlights[diagnostics.level .. "_diagnostic"] or highlights.diagnostic or ""
return {
text = indicator,
highlight = diag_highlight,
attr = {
extends = {
{ id = ui.components.id.name, highlight = highlight },
{ id = ui.components.id.groups, highlight = highlight },
},
},
}
```

### Why?

These are just personal observations but I think it would look a lot more aesthetically pleasing.
I also think a different color for each icon would help parse them out at a glance and help with the "mental triage" of which files need the most attention or what progress is being made.
Having a single error upgrade the severity of all the other icons intuitively feels wrong to look at.

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.