akinsho / akinsho/bufferline.nvim
[Bug]: the example Custom Area from the documentation can be improved
- Lingua principale
- Lua
- Stelle
- 4.4k
- Fork
- 240
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
### 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_
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Valutazione
Questa issue non è ancora stata valutata.