akinsho / akinsho/bufferline.nvim

[Bug]: the example Custom Area from the documentation can be improved

Abierto
#901 0 comentarios 0 reacciones 0 asignados Ver en GitHub
bug
Lenguaje dominante
Lua
Estrellas
4.4k
Forks
240
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

### Is there an existing issue for this?

- [X] I have searched the existing issues

### What happened?

I think [this](https://github.com/akinsho/bufferline.nvim/blob/main/doc/bufferline.txt#L1111) part of documentation which presents an example `custom_areas` definition could be improved.
Currently, this won't create a highlight group for every type of message (error, warning ...), but instead it will create the groups only for the existing entries. Meaning that if there is no error and few warnings, the first hl group will be for warnings. As a result, if the error appears later, it will try to overwrite the hl group of the warning as error and create new group for warning. I think the better approach would be to always return the same length of the section's table:
```lua
custom_areas = {
right = function()
local result = {}
local seve = vim.diagnostic.severity
local error = #vim.diagnostic.get(0, { severity = seve.ERROR })
local warn = #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 })

local error_text = ""
if error ~= 0 then
error_text = "  " .. error .. " "
end
table.insert(result, { text = error_text, fg = "#EC5241" })

local warn_text = ""
if warn ~= 0 then
warn_text = "  " .. warn .. " "
end
table.insert(result, { text = warn_text, fg = "#EFB839" })

local hint_text = ""
if hint ~= 0 then
hint_text = " 󱜸 " .. hint .. " "
end
table.insert(result, { text = hint_text , fg = "#A3BA5E" })


local info_text = ""
if info ~= 0 then
info_text = "  " .. info .. " "
end
table.insert(result, { text = info_text, fg = "#7EA9A7" })

return result
end,
}
```

### What did you expect to happen?

proper colors

### Config

.

### Additional Information

...

### commit

_No response_

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.