autozimu / LanguageClient-neovim

Language Server Protocol (LSP) support for vim and neovim.
MIT License
3.55k stars 273 forks source link

Diagnostic signs are not displayed #1133

Closed 110y closed 3 years ago

110y commented 3 years ago

Describe the bug

A clear and concise description of what the bug is.

Environment

call plug#begin('~/.vim/plugged')
Plug 'autozimu/LanguageClient-neovim'
call plug#end()

augroup filetype_go
    autocmd!
    autocmd BufReadPost *.go setlocal filetype=go
augroup END

set signcolumn=yes

let g:LanguageClient_serverCommands = {
    \ 'go': ['gopls'],
    \ }
let g:LanguageClient_loggingLevel = 'DEBUG'
let g:LanguageClient_loggingFile  = expand('./log')
let g:LanguageClient_serverStderr = expand('~/stderr')

Go: gopls - v0.0.0-20201105220310-78b158585360 (latest master branch)

To Reproduce

Steps to reproduce the behavior:

package main

func main() {
    invalidtoken
}

Current behavior

No diagnostics signs are displayed.

Expected behavior

A diagnostics sign which complaints: undeclared name: invalidtoken, should be displayed like below:

image

This screenshot has been taken with LanguageClient-neovim version 8c779dd. So I think it should be work as expected at least with the commit.

Log

00:56:35 DEBUG reader-Some("go") src/rpcclient.rs:207 <= Some("go") {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///path/to/main.go","diagnostics":[{"range":{"start":{"line":3,"character":1},"end":{"line":3,"character":13}},"severity":1,"codeDescription":{"href":""},"source":"compiler","message":"undeclared name: invalidtoken"}]}}
00:56:35 INFO unnamed src/language_server_protocol.rs:2241 text_document_publish_diagnostics; params=Object({"diagnostics": Array([Object({"codeDescription": Object({"href": String("")}), "message": String("undeclared name: invalidtoken"), "range": Object({"end": Object({"character": Number(13), "line": Number(3)}), "start": Object({"character": Number(1), "line": Number(3)})}), "severity": Number(1), "source": String("compiler")})]), "uri": String("file:///path/to/main.go")})
00:56:35 ERROR unnamed src/rpchandler.rs:46 Error handling message: invalid value: string "", expected relative URL without a base

Message: {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[{"codeDescription":{"href":""},"message":"undeclared name: invalidtoken","range":{"end":{"character":13,"line":3},"start":{"character":1,"line":3}},"severity":1,"source":"compiler"}],"uri":"file:///path/to/main.go"}}

Error: invalid value: string "", expected relative URL without a base
martskins commented 3 years ago

This is an issue with gopls. The codeDescription field in the diagnostics should either not be present or contain an valid url in href, but you are getting "codeDescription":{"href":""} as per your log. I opened https://github.com/golang/go/issues/42314 a few days ago about this and it seems like it got fixed, so I presume that updating gopls (or using the latest release instead of master) should fix it for you.

This works for you in a previous version of LCN because the codeDescription field was added in version 0.83 of lsp-types, which we updated to after that commit you shared. But the issue is that that specific version of gopls you are running is not protocol compliant, so deserialization breaks on the client.

110y commented 3 years ago

Thank you so much! I've confirmed it.