autozimu / LanguageClient-neovim

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

Rust: [LC] sending on a disconnected channel #1157

Closed alopatindev closed 3 years ago

alopatindev commented 3 years ago

Describe the bug

I often get these error messages when trying to use go to definition in a rust project.

Environment

call plug#begin('~/.config/nvim/plugged')
Plug 'autozimu/LanguageClient-neovim', {
    \ 'branch': 'next',
    \ 'do': 'bash install.sh',
    \ }
call plug#end()

let g:LanguageClient_serverCommands = {
\ 'rust': ['rust-analyzer'],
\ }
autocmd BufEnter *.rs map <C-\> :tab call LanguageClient#textDocument_definition({'gotoCmd': 'tab drop'})<CR>

To Reproduce

Steps to reproduce the behavior:

Additional context

13:10:58 INFO reader-None src/rpcclient.rs:191 <= None {"id": 13, "jsonrpc": "2.0", "method": "languageClient/findLocations", "params": {"bufnr": 6, "handle": true, "languageId": "rust", "gotoCmd": "tab drop", "method": "textDocument/definition", "position": {"character": 11, "line": 105}, "filename": "/some/project/file.rs"}}
13:10:58 INFO unnamed src/language_server_protocol.rs:2259 Begin textDocument/didChange
13:10:58 INFO writer-None src/rpcclient.rs:238 => None {"jsonrpc":"2.0","method":"LSP#text","params":["/some/project/file.rs"],"id":10246}
13:10:58 INFO reader-None src/rpcclient.rs:191 <= None {"id": 10246, "jsonrpc": "2.0", "result": ["some changes"]}
13:10:58 INFO unnamed src/language_server_protocol.rs:2279 Texts equal. Skipping didChange.
13:10:58 INFO unnamed src/language_server_protocol.rs:1363 Begin textDocument/definition
13:10:58 INFO writer-None src/rpcclient.rs:238 => None {"jsonrpc":"2.0","method":"eval","params":["expand('<cword>')"],"id":10247}
13:10:58 INFO reader-None src/rpcclient.rs:191 <= None {"id": 10247, "jsonrpc": "2.0", "result": "SomeIdentifier"}
13:10:58 ERROR unnamed src/rpchandler.rs:27 Error handling message: sending on a disconnected channel

Message: {"jsonrpc":"2.0","method":"languageClient/findLocations","params":{"bufnr":11,"filename":"/some/project/file.rs","gotoCmd":"tab drop","handle":true,"languageId":"rust","method":"textDocument/definition","position":{"character":47,"line":113}},"id":10}

Error: sending on a disconnected channel
13:10:58 INFO writer-None src/rpcclient.rs:238 => None {"jsonrpc":"2.0","error":{"code":-32603,"message":"sending on a disconnected channel"},"id":10}

rustc 1.48.0 (7eac88abb 2020-11-16) rust-analyzer cadf0e9

martskins commented 3 years ago

Can you share some more of the log? Also, have you tried updating rust-analyzer? I found a similar issue a few days ago but it was a specific commit that was broken and was fixed on the nightly release of the next day.

alopatindev commented 3 years ago

Thanks, it seems that updating rust-analyzer to ac30710 2020-11-30 solved the issue for me.