Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Diagnostic indicators are based only on messages from the "DiagnosticChanged" event, not from the entire buffer #3041

Closed
Yu-Leo opened this issue Jan 2, 2025 · 0 comments · Fixed by #3042
Labels
bug Something isn't working

Comments

@Yu-Leo
Copy link
Contributor

Yu-Leo commented Jan 2, 2025

Description

Diagnostic indicators are based only on messages from the "DiagnosticChanged" event, not from the entire buffer

I use nvim for Go (GoLang) development. I set up the lsp and linter using https://github.com/mfussenegger/nvim-lint.

I created my own autocmd: when saving the buffer (BufWritePost event) using the plugin https://github.com/mfussenegger/nvim-lint the linter is started, and its messages are added to diagnostics for the current buffer with the warning level.

In my case, it works like this:

  1. I save the current buffer
  2. LSP adds diagnostics
  3. The linter is triggered
  4. The linter adds diagnostics

When updating diagnostics, nvim-tree processes only those diagnoses that are contained in the "DiagnosticChanged" event. This is a problem for me because the "DiagnosticChanged" event occurs two times: in step 2 and in step 4.

If the diagnostics added by the linter will not contain diagnostic with the error level, and in the nvim-tree settings I will specify:

severity = {
  min = vim.diagnostic.severity.ERROR,
  max = vim.diagnostic.severity.ERROR,
}

then the diagnostics will not be displayed at all for the file in the nvim-tree.

I think it's more correct to analyze the entire diagnostics list for the buffer, which can be obtained using the vim.diagnostic.get function.

Neovim version

NVIM v0.10.2
Build type: RelWithDebInfo
LuaJIT 2.1.1731601260

Operating system and version

Linux 5.15.173-1-MANJARO

Windows variant

No response

nvim-tree version

master

Clean room replication

Not provided

Steps to reproduce

Not provided

Expected behavior

No response

Actual behavior

No response

@Yu-Leo Yu-Leo added the bug Something isn't working label Jan 2, 2025
Yu-Leo added a commit to Yu-Leo/nvim-tree.lua that referenced this issue Jan 2, 2025
alex-courtis added a commit to Yu-Leo/nvim-tree.lua that referenced this issue Jan 13, 2025
alex-courtis added a commit that referenced this issue Jan 13, 2025
* fix(#3041): use vim.diagnostic.get for updating diagnostics

* fix(#3041): remove unnecessary @type

---------

Co-authored-by: Alexander Courtis <alex@courtis.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant