kosayoda / nvim-lightbulb

VSCode 💡 for neovim's built-in LSP.
MIT License
801 stars 30 forks source link

fix: avoid false positives due to gathering diagnostics from different buffer #68

Closed jonathan-elize closed 1 week ago

jonathan-elize commented 1 month ago

As I was trying out this plugin, I noticed that code actions kept being shown on lines even when actions weren't available:

Screenshot 2024-09-16 at 11 50 39 PM

I dug into this and it seems like the reason is because vim.lsp.diagnostic.get_line_diagnostics() without any arguments seems to get diagnostics across the entire workspace:

Screenshot 2024-09-16 at 11 51 03 PM

I opened this PR as a fix to this by including just the bufnr in the call in case it was on purpose to try and include diagnostics not just on that line. By just adding the buffer it'll include diagnostics across the whole buffer. If we wanted to tighten this more we could add the line number as well but I wanted to open this up for discussion.

kosayoda commented 1 week ago

Thanks for the report! This should be fixed in 34aa174 for 0.9.x and 0.10.x

jonathan-elize commented 1 week ago

Sounds good. Thanks for the plugin! @kosayoda