Skip to content

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

Closed
@Yu-Leo

Description

@Yu-Leo

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions