chipsalliance / verible

Verible is a suite of SystemVerilog developer tools, including a parser, style-linter, formatter and language server
https://chipsalliance.github.io/verible/
Other
1.37k stars 210 forks source link

Repeated Diagnostic Messages in coc.nvim with Verible Language Server #2164

Open TBD9rain opened 6 months ago

TBD9rain commented 6 months ago

My IDE is as following:

Repeated Warning Messages

The verible-verilog-ls configurations are as following:

"languageserver": {
        "verible":{
            "enable": true,
            "command": "verible-verilog-ls",
            "filetypes": ["verilog", "systemverilog"],
            "trace.server":"messages"
        }
    }

When I created a new .v file and typed several spaces, repeated identical warning messages popped up:

1713450713248

I expect a single warning message per actual issue per file change or analysis trigger. After I configured the language server as following in coc.nvim, the second warning message dissapeared.

"languageserver": {
        "verible":{
            "enable": true,
            "command": "verible-verilog-ls",
            "filetypes": ["verilog", "systemverilog"],
            "disabledFeatures": ["diagnostics"], //  fix repeated identical messages bug
            "trace.server":"messages"
        }
    }

1713451208809

But I don't think this is an expected behavior or a long-term solution.

Log Messages

Logs of the preceeding different configurations are smilar except the message timestamps and durations.

[Trace - 22:45:20.639] Sending request 'initialize - (0)'.
Verible Verilog Language Server built at v0.0-3638-ge3ef2a37
commandline: C:/Program Files/Vim/vimfiles/languageserver/verible/verible-verilog-ls.exe 
[Trace - 22:45:20.647] Received response 'initialize - (0)' in 8ms.
[Trace - 22:45:20.647] Sending notification 'initialized'.
[Trace - 22:45:20.650] Sending notification 'workspace/didChangeConfiguration'.
[Trace - 22:45:20.650] Sending notification 'textDocument/didOpen'.
[Trace - 22:45:20.650] Sending request 'textDocument/diagnostic - (1)'.
[Trace - 22:45:20.651] Received notification 'textDocument/publishDiagnostics'.
[Trace - 22:45:20.651] Received response 'textDocument/diagnostic - (1)' in 1ms.
[Trace - 22:45:40.429] Sending notification 'textDocument/didChange'.
[Trace - 22:45:40.429] Sending request 'textDocument/diagnostic - (2)'.
[Trace - 22:45:40.429] Received notification 'textDocument/publishDiagnostics'.
[Trace - 22:45:40.430] Received response 'textDocument/diagnostic - (2)' in 1ms.
[Trace - 22:45:41.191] Sending notification 'textDocument/didChange'.
[Trace - 22:45:41.193] Sending request 'textDocument/diagnostic - (3)'.
[Trace - 22:45:41.194] Received notification 'textDocument/publishDiagnostics'.
[Trace - 22:45:41.195] Received response 'textDocument/diagnostic - (3)' in 2ms.

Verbose logs of the two configurations are also similar except the message timestamps and durations.

hzeller commented 6 months ago

On every change of the file, the diagnostics are updated. It seems like your editor does not coalesce these ?

There are also two mechanisms diagnostics can be received:

So things do look like they work as intended, just that the editor does not remove the duplicates.

I'll have a look if it is possible by the editor to request not auto-publishing diagnostics when it actually does the request by itself (maybe there is a setting the editor can send to the language server).

But you should probably also file an issue with your editors' language server implementation to make sure they coalesce the identical diagnostic messages properly or ignore diagnostic notifications when they already request

TBD9rain commented 6 months ago

The "disabledFeatures" configuration doesn't switch the explicit request off. I think it just diabled one of the messages from diaplaing.

I will file an issue with the language server implementation plugin as well.

fannheyward commented 6 months ago

Is the "disabledFeatures" configuration switching the explicit request off ?

The disabledFeatures made coc.nvim ignore publishDiagnostics one.

verible server files the capabilities with diagnosticProvider, coc.nvim will use pull mode to request to server for diagnostics.

I think the server shouldn't use both publishDiagnostics and diagnosticProvider at the same time, or use publishDiagnostics on document didOpen only, and pull mode for onSave and onChange.

benjamin051000 commented 3 months ago

Just chiming in that this is also an issue with https://github.com/neovim/nvim-lspconfig: image

It's very straightforward to enable:

-- ~/.config/nvim/after/plugin/lsp.lua
require'lspconfig'.verible.setup{}

I'm not sure what the differences are between the implementation of Verible and other language servers, but this is the only language server that outputs diagnostic messages twice for me.

hzeller commented 3 months ago

So maybe we need to change the language server to not auto-publish findings whenever the editor is in a mode where it actively pulls the diagnostics regardless if there was an auto-diagnostic already sent. I am having some vacation coming up, so I might have some time to look at it.