neoclide / coc.nvim

Nodejs extension host for vim & neovim, load extensions like VSCode and host language servers.
Other
24.15k stars 953 forks source link

Repeated Diagnostic Messages with Verible Language Server #4984

Closed TBD9rain closed 2 months ago

TBD9rain commented 2 months ago

Result from CocInfo

## versions

vim version: VIM - Vi IMproved 9.0 9001897
node version: v20.7.0
coc.nvim version: 0.0.82-2f312370 2024-04-12 17:35:29 +0800
coc.nvim directory: C:\Program Files\Vim\vimfiles\plugged\coc.nvim
term: undefined
platform: win32

## Log of coc.nvim

2024-04-19T09:48:49.228 INFO (pid:17444) [plugin] - coc.nvim initialized with node: v20.7.0 after 185
2024-04-19T09:48:49.233 INFO (pid:17444) [services] - LanguageClient verible state change: stopped => starting
2024-04-19T09:48:49.277 INFO (pid:17444) [language-client-index] - Language server "languageserver.verible" started with 17988
2024-04-19T09:48:49.334 INFO (pid:17444) [services] - LanguageClient verible state change: starting => running
2024-04-19T09:48:49.337 INFO (pid:17444) [services] - service languageserver.verible started
2024-04-19T09:51:56.701 INFO (pid:17444) [attach] - receive notification: runCommand [ 'workspace.showOutput', 'languageserver.verible' ]
2024-04-19T09:52:01.960 INFO (pid:17444) [attach] - receive notification: showInfo []

Describe the bug

I'm using verible (v0.0-3638-ge3ef2a37) as a language server in my gvim (v9.0.1897) with coc.nvim (v0.0.82-84ce0312). It will display two duplicated messages to one warning.

The lsp log is as follows:

[Trace - 09:37:33.491] 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 - 09:37:33.540] Received response 'initialize - (0)' in 49ms.
[Trace - 09:37:33.540] Sending notification 'initialized'.
[Trace - 09:37:33.544] Sending notification 'workspace/didChangeConfiguration'.
[Trace - 09:37:33.544] Sending notification 'textDocument/didOpen'.
[Trace - 09:37:33.545] Sending request 'textDocument/diagnostic - (1)'.
[Trace - 09:37:33.545] Received notification 'textDocument/publishDiagnostics'.
[Trace - 09:37:33.546] Received response 'textDocument/diagnostic - (1)' in 1ms.
[Trace - 09:37:56.192] Sending notification 'textDocument/didChange'.
[Trace - 09:37:56.194] Sending request 'textDocument/diagnostic - (2)'.
[Trace - 09:37:56.194] Received notification 'textDocument/publishDiagnostics'.
[Trace - 09:37:56.195] Received response 'textDocument/diagnostic - (2)' in 1ms.
[Trace - 09:37:56.517] Sending notification 'textDocument/didChange'.
[Trace - 09:37:56.518] Sending request 'textDocument/diagnostic - (3)'.
[Trace - 09:37:56.518] Received notification 'textDocument/publishDiagnostics'.
[Trace - 09:37:56.519] Received response 'textDocument/diagnostic - (3)' in 1ms.

I tried to set disabledFeaturs: ["diagnostics"], and the diagnostic message was only displayed once. However, the lsp log is as identical.

It seems that the problem is the one more textDocument/diagnostic request.

Reproduce the bug

Screenshots (optional)

image

fannheyward commented 2 months ago

How do you set languageserver.verible?

fannheyward commented 2 months ago

textDocument/diagnostic request

Looks like you've enabled pullDiagnostic.onSave in your coc-settings.json, coc.nvim pulls diagnostics from server multiple times.

TBD9rain commented 2 months ago

My languageserver.verible configuration:

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

The pullDiagnostic.onSave is disabled as default.

fannheyward commented 2 months ago

Any other pluuDiagnostic settings in your coc-settings.json? textDocument/diagnostic request won't be sent if pull mode disabled.

TBD9rain commented 2 months ago

I didn't make any change of pullDiagnostic. And the other language server doesn't send the textDocument/diagnostic request.

Here is my coc-settings.json.

{
    //  coc setting
    "coc.preferences.extensionUpdateCheck": "weekly",
    "coc.preferences.maxFileSize": "2MB",

    //  completion setting
    "suggest.autoTrigger": "always",
    "suggest.noselect": false,
    "suggest.enablePreselect": true,
    "suggest.completionItemKindLabels": {
        "text":             "",    //  "v"
        "method":           "",    //  "f"
        "function":         "󰊕",    //  "f"
        "constructor":      "󰏖",    //  "f"
        "field":            "",    //  "m"
        "variable":         "󰫧",    //  "v"
        "class":            "",    //  "C"
        "interface":        "",    //  "I"
        "module":           "M",    //  "M"
        "property":         "",    //  "m"
        "unit":             "U",    //  "U"
        "value":            "󰎠",    //  "v"
        "enum":             "E",    //  "E"
        "keyword":          "",    //  "k"
        "snippet":          "",    //  "S"
        "color":            "",    //  "v"
        "file":             "",    //  "F"
        "reference":        "",    //  "r"
        "folder":           "",    //  "F"
        "enumMember":       "e",    //  "m"
        "constant":         "󰏿",    //  "v"
        "struct":           "",    //  "S"
        "event":            "",    //  "E"
        "operator":         "",    //  "O"
        "typeParameter":    "T",    //  "T"
        "default":          ""     //  ""
    },

    //  code diagnostic
    "diagnostic.enable": true,
    "diagnostic.enableMessage": "always",
    "diagnostic.refreshOnInsertMode": false,
    "diagnostic.checkCurrentLine": true,
    "diagnostic.virtualText": false,
    "diagnostic.errorSign": "",
    "diagnostic.warningSign": "",
    "diagnostic.infoSign": "",
    "diagnostic.hintSign": ">>",

    //  CodeLens
    "codeLens.enable": true,

    //  languae server
    "languageserver": {
        "verible":{
            "enable": true,
            "command": "verible-verilog-ls",
            "filetypes": ["verilog", "systemverilog"],
            "disabledFeatures": ["diagnostics"], //  fix output repeated identical messages
            "trace.server": "message"
        },
        "svls":{
            "enable": false,
            "command": "svls",
            "filetypes": ["verilog", "systemverilog"],
            "trace.server": "message"
        }
    }
}
fannheyward commented 2 months ago

The verible language server enabled pull mode capability.

The repeated diagnostics:

  1. one from publishDiagnostics, server pushed to client
  2. server enabled pull mode, the client requests to server and displays them

set disabledFeaturs: ["diagnostics"], and the diagnostic message was only displayed once.

This disabled the first one, client ignored the published diagnostics.

coc.nvim is a LSP client, the server should not use both push and pull diagnostics at the same time, or provide a configuration to disable one.