akinsho / akinsho/bufferline.nvim

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

Đang mở
#901 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
bug
Ngôn ngữ chính
Lua
Star
4.4k
Fork
240
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.