akinsho / akinsho/bufferline.nvim
[Bug]: Diagnostics count doesn't clear from 1 to 0
- 主要語言
- Lua
- 星號
- 4.4k
- 分支
- 240
- PR 合併指標
- 30 天內沒有已合併 PR
描述
### Is there an existing issue for this?
- [X] I have searched the existing issues
### What happened?
When I open a cpp file with no errors or warnings and then add a
```
#warning this is a test
```
directive, the count goes up to 1 as expected. However when I then remove the directive, the count doesn't go away and the name stays highlighted for warnings. The same is true for errors.
Curiously though, if one thing causes multiple errors or warnings that then get resolved all at the same time, for example placing a random `;` in the middle of an identifier and then removing it, the diagnostics do get cleared properly, although it sometimes takes quite a while (10 seconds are not uncommon). When going from 1 to 0, it doesn't clear, even after 10 minutes.
I also use nvim-tree's diagnostic markers, and theirs updates fine and instantly, as does coc itself.
I am using this setting
```lua
diagnostics = "coc",
-- ignore unused parameter
-- luacheck: push ignore 212
diagnostics_indicator = function(count, level, diagnostics_dict, context)
-- luacheck: pop
if (count == 0) then
return ""
end
local icon = '' .. ' ' .. level
if level:match("error") then
icon = ''
elseif level:match("warning") then
icon = ''
elseif level:match("info") or level:match("hint") then
icon = ''
end
-- kitty scales down the icon if there is no space on the right
return icon .. " " .. count
end,
```
### What did you expect to happen?
The diagnostics highlighting and count should clear once there are none left.
### Config
This is the full configuration I use
```lua
local bufferline = require("bufferline")
-- background color definitions
-- same as normal background
local background = '#121212'
local backgroundterm = 233
-- not selected, not visible
local normal = '#262626'
local normalterm = 235
-- visible, not selected
local visible = '#444444'
local visibleterm = 238
-- selected
local selected = '#808080'
local selectedterm = 8
-- foreground colors from Coc for hint, info, warning and error
local hintcolor = '#008080'
local hintcolorterm = 6
local infocolor = '#0000FF'
local infocolorterm = 12
local warningcolor = '#FFFF00'
local warningcolorterm = 11
local errorcolor = '#FF0000'
local errorcolorterm = 9
-- :help bufferline-configuration
bufferline.setup(
{
options = {
mode = "buffers",
separator_style = "slant",
--[[
style_preset = {
bufferline.style_preset.no_italic,
bufferline.style_preset.no_bold
},
]]--
numbers = function(opts)
return string.format('%s|%s', opts.raise(opts.ordinal), opts.raise(opts.id))
end,
indicator = {
style = "underline"
},
diagnostics = "coc",
-- ignore unused parameter
-- luacheck: push ignore 212
diagnostics_indicator = function(count, level, diagnostics_dict, context)
-- luacheck: pop
if (count == 0) then
return ""
end
--[[
if context.buffer:current() then
return ""
end
]]--
local icon = '' .. ' ' .. level
if level:match("error") then
icon = ''
elseif level:match("warning") then
icon = ''
elseif level:match("info") or level:match("hint") then
icon = ''
end
-- kitty scales down the icon if there is no space on the right
return icon .. " " .. count
end,
hover= {
enabled = true,
delay = 0,
reveal = {"close"}
},
close_icon = '',
buffer_close_icon = '',
show_tab_indicators = true,
show_duplicate_prefix = true,
always_show_bufferline = true,
name_formatter = function(buf)
if (buf.buffers == nil) then
-- it's a buffer
return buf.name
end
-- it's a tab
local count = 0
for _ in pairs(buf.buffers) do count = count + 1 end
return string.format('%d %d ', vim.api.nvim_tabpage_get_number(buf.tabnr), count)
end,
offsets = {
{
filetype = "NvimTree",
text = function()
return vim.fn.getcwd()
end,
highlight = "Directory",
text_align = "left"
}
},
themable = true,
}, -- end options
highlights = { -- help bufferline-highlights
fill = {
bg = background,
ctermbg = backgroundterm
},
tab = { -- non selected tab
bg = normal,
ctermbg = normalterm,
fg = '#808080',
ctermfg = 8
},
tab_separator = { -- non selected tab separators
bg = normal, -- this is inside the "tab"
ctermbg = normalterm,
fg = background, -- actual corner piece, blends into background
ctermfg = backgroundterm
},
tab_selected = { -- selected tab
bg = selected,
ctermbg = selectedterm,
fg = '#FFFFFF',
ctermfg = 15
},
tab_separator_selected = { -- selected tab separators
bg = selected,
ctermbg = selectedterm,
fg = background,
ctermfg = backgroundterm
},
background = { -- non visible, non selected buffers
bg =normal,
ctermbg = normalterm
},
separator = {
bg = normal,
ctermbg = normalterm,
fg = background,
ctermfg = backgroundterm
},
buffer_visible = { -- buffer visible, but not selected
bg = visible,
ctermbg = visibleterm
},
separator_visible = {
bg = visible,
ctermbg = visibleterm,
fg = background,
ctermfg = backgroundterm
},
buffer_selected = {
bg = selected,
ctermbg = selectedterm
},
separator_selected = {
bg = selected,
ctermbg = selectedterm,
fg = background,
ctermfg = backgroundterm
},
modified = {
bg = normal,
ctermfg = normalterm
},
modified_visible = {
bg = visible,
ctermbg = visibleterm
},
modified_selected = {
bg = selected,
ctermbg = selectedterm
},
duplicate = {
strikethrough = true
},
duplicate_visible =
{
strikethrough = true
},
duplicate_selected = {
strikethrough = true
},
diagnostic = {
bg = normal,
ctermbg = normalterm
},
diagnostic_visible = {
bg = visible,
ctermbg = visibleterm
},
diagnostic_selected = {
bg = selected,
ctermbg = selectedterm
},
modified = {
bg = normal,
ctermbg = normalterm
},
modified_visible = {
bg = visible,
ctermbg = visibleterm
},
modified_selected = {
bg = selected,
ctermbg = selectedterm
},
close_button = {
bg = normal,
ctermbg = normalterm
},
close_button_visible = {
bg = visible,
ctermbg = visibleterm
},
close_button_selected = {
bg = selected,
ctermbg = selectedterm
},
numbers = {
bg = normal,
ctermbg = normalterm
},
numbers_visible = {
bg = visible,
ctermbg = visibleterm
},
numbers_selected = {
bg = selected,
ctermbg = selectedterm
},
hint = {
bg = normal,
ctermbg = normalterm,
sp = hintcolor,
undercurl = true
},
hint_visible = {
bg = visible,
ctermbg = visibleterm,
sp = hintcolor,
undercurl = true
},
hint_selected = {
bg = selected,
ctermbg = selectedterm,
sp = hintcolor,
undercurl = true
},
hint_diagnostic = {
bg = normal,
ctermbg = normalterm,
fg = hintcolor,
ctermfg = hintcolorterm
},
hint_diagnostic_visible = {
bg = visible,
ctermbg = visibleterm,
fg = hintcolor,
ctermfg = hintcolorterm
},
hint_diagnostic_selected = {
bg = selected,
ctermbg = selectedterm,
fg = hintcolor,
ctermfg = hintcolorterm
},
info = {
bg = normal,
ctermbg = normalterm,
sp = infocolor,
undercurl = true
},
info_visible = {
bg = visible,
ctermbg = visibleterm,
sp = infocolor,
undercurl = true
},
info_selected = {
bg = selected,
ctermbg = selectedterm,
sp = infocolor,
undercurl = true
},
info_diagnostic = {
bg = normal,
ctermbg = normalterm,
fg = infocolor,
ctermfg = infocolorterm
},
info_diagnostic_visible = {
bg = visible,
ctermbg = visibleterm,
fg = infocolor,
ctermfg = infocolorterm
},
info_diagnostic_selected = {
bg = selected,
ctermbg = selectedterm,
fg = infocolor,
ctermfg = infocolorterm
},
warning = {
bg = normal,
ctermbg = normalterm,
sp = warningcolor,
undercurl = true
},
warning_visible = {
bg = visible,
ctermbg = visibleterm,
sp = warningcolor,
undercurl = true
},
warning_selected = {
bg = selected,
ctermbg = selectedterm,
sp = warningcolor,
undercurl = true
},
warning_diagnostic = {
bg = normal,
ctermbg = normalterm,
fg = warningcolor,
ctermfg = warningcolorterm
},
warning_diagnostic_visible = {
bg = visible,
ctermbg = visibleterm,
fg = warningcolor,
ctermfg = warningcolorterm
},
warning_diagnostic_selected = {
bg = selected,
ctermbg = selectedterm,
fg = warningcolor,
ctermfg = warningcolorterm
},
error = {
bg = normal,
ctermbg = normalterm,
sp = errorcolor,
undercurl = true
},
error_visible = {
bg = visible,
ctermbg = visibleterm,
sp = errorcolor,
undercurl = true
},
error_selected = {
bg = selected,
ctermbg = selectedterm,
sp = errorcolor,
undercurl = true
},
error_diagnostic = {
bg = normal,
ctermbg = normalterm,
fg = errorcolor,
ctermfg = errorcolorterm
},
error_diagnostic_visible = {
bg = visible,
ctermbg = visibleterm,
fg = errorcolor,
ctermfg = errorcolorterm
},
error_diagnostic_selected = {
bg = selected,
ctermbg = selectedterm,
fg = errorcolor,
ctermfg = errorcolorterm
},
}
})
```
### Additional Information
Versions:
- nvim: v0.10.0-dev-5ceb2238d
- luaJIT: 2.1.0-beta
- bufferline: 4.2.0
- coc: latest from [release branch](https://github.com/neoclide/coc.nvim/commit/b7375d5f8415929800397a059679bfda5ff8a25e)
### commit
no clue
貢獻指南
這個儲存庫沒有索引到貢獻指南
評估
這個 Issue 還沒有評估資料。