akinsho / bufferline.nvim

A snazzy bufferline for Neovim
GNU General Public License v3.0
3.29k stars 193 forks source link

[Bug]: diagnostics can easily get out of date #923

Open gepbird opened 3 weeks ago

gepbird commented 3 weeks ago

Is there an existing issue for this?

What happened?

Bufferline doesn't update when diagnostics change, it can say there are errors when there aren't or vice versa. This is very annoying when using an lsp formatter to fix style errors and seeing that bufferline reports there are still errors (are those actual errors or those errors are outdated? I have to update bufferline to find it out).

With this minimal config, when I delete the erroneous line with dd, bufferline still shows the warning until I update it with :.

https://github.com/akinsho/bufferline.nvim/assets/29818440/72abd30e-c4e5-4837-89de-8fc0b26faa3a

What did you expect to happen?

Bufferline also updates when diagnostics changes.

Config

require 'lspconfig'.lua_ls.setup {}
require 'bufferline'.setup {
  options = {
    diagnostics = 'nvim_lsp',
  },
}

Additional Information

Setting options.diagnostics_update_in_insert = true for bufferline doesn't solve this issue.

After debugging this issue, I found out that neovim doesn't refresh the tabline when diagnostics change. Bufferline could refresh it, see :h diagnostic-handlers. This would make diagnostic_update_in_insert deprecated if it was trying to fix this kind of issue. But if diagnostic_update_in_insert was introduced to allow reducing tabline redraws, we could introduce an option like diagnostic_update_on_change. Please let me know which solution we should go with, I'd be happy to make a PR!

commit

https://github.com/akinsho/bufferline.nvim/commit/99337f63f0a3c3ab9519f3d1da7618ca4f91cffe

akinsho commented 1 week ago

Hi @gepbird just got round to this. I'd be up for an optional change to redraw the tabline when using diagnostic handlers. Personally I've never had an issue with this but seems valuable as an option

gepbird commented 1 week ago

Thanks for your response! I'll submit a PR soon with an option called diagnostic_update_on_event. I used a hacked-in version of the proposed change since I opened this issue and had no problems with it.