akinsho / akinsho/bufferline.nvim

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

オープン
#901 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
bug
主要言語
Lua
スター
4.4k
フォーク
240
PR マージ指標
30日以内にマージされた PR はありません

説明

### 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_

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。