Closed wbthomason closed 5 years ago
Try add "rust-client.channel": "stable",
in your coc-settings.json
, don't know why nightly is broken for me.
Hmm, unfortunately that changes nothing. Explicitly setting nightly
also has no effect (though that's more expected).
I'm testing this using a new project (e.g. cargo new coc-rls-test
) and editing src/main.rs
. I'm on Arch Linux; rls --version
is "rls-preview 1.33.0 (9f3c906 2019-01-20)".
Don't know what happened, consider check out output channel of rust.
In the process of constructing
use std::thread;
use std::collections::HashMap;
fn main() {
println!("Hello, world!");
}
from the main.rs
created by cargo new
, I get the following output:
## Output channel: rust
error: expected identifier, found keyword `fn`
--> <racer-file>:2:1
|
2 | fn main() {
| ^^ expected identifier, found keyword
error: expected one of `::`, `;`, or `as`, found `main`
--> <racer-file>:2:4
|
2 | fn main() {
| ^^^^ expected one of `::`, `;`, or `as` here
error: expected one of `::`, `;`, or `as`, found `fn`
--> <racer-file>:2:1
|
1 | use s
| - expected one of `::`, `;`, or `as` here
2 | fn main() {
| ^^ unexpected token
error: expected one of `::`, `;`, or `as`, found `fn`
--> <racer-file>:2:1
|
1 | use std
| - expected one of `::`, `;`, or `as` here
2 | fn main() {
| ^^ unexpected token
error: expected one of `::`, `;`, or `as`, found `:`
--> <racer-file>:1:8
|
1 | use std:
| ^ expected one of `::`, `;`, or `as` here
error: expected identifier, found keyword `fn`
--> <racer-file>:2:1
|
2 | fn main() {
| ^^ expected identifier, found keyword
error: expected one of `::`, `;`, or `as`, found `main`
--> <racer-file>:2:4
|
2 | fn main() {
| ^^^^ expected one of `::`, `;`, or `as` here
error: expected one of `::`, `;`, or `as`, found `fn`
--> <racer-file>:2:1
|
1 | use std::t
| - expected one of `::`, `;`, or `as` here
2 | fn main() {
| ^^ unexpected token
error: expected one of `::`, `;`, or `as`, found `fn`
--> <racer-file>:2:1
|
1 | use std::thr
| - expected one of `::`, `;`, or `as` here
2 | fn main() {
| ^^ unexpected token
error: expected one of `::`, `;`, or `as`, found `fn`
--> <racer-file>:2:1
|
1 | use std::threa
| - expected one of `::`, `;`, or `as` here
2 | fn main() {
| ^^ unexpected token
error: expected one of `::`, `;`, or `as`, found `fn`
--> <racer-file>:3:1
|
1 | use s
| - expected one of `::`, `;`, or `as` here
2 |
3 | fn main() {
| ^^ unexpected token
error: expected one of `::`, `;`, or `as`, found `fn`
--> <racer-file>:3:1
|
1 | use std
| - expected one of `::`, `;`, or `as` here
2 |
3 | fn main() {
| ^^ unexpected token
error: expected one of `::`, `;`, or `as`, found `:`
--> <racer-file>:1:8
|
1 | use std:
| ^ expected one of `::`, `;`, or `as` here
error: expected one of `::`, `;`, or `as`, found `:`
--> <racer-file>:1:8
|
1 | use std:
| ^ expected one of `::`, `;`, or `as` here
error: expected identifier, found keyword `fn`
--> <racer-file>:3:1
|
3 | fn main() {
| ^^ expected identifier, found keyword
error: expected one of `::`, `;`, or `as`, found `main`
--> <racer-file>:3:4
|
3 | fn main() {
| ^^^^ expected one of `::`, `;`, or `as` here
error: expected one of `::`, `;`, or `as`, found `fn`
--> <racer-file>:3:1
|
1 | use std::c
| - expected one of `::`, `;`, or `as` here
2 |
3 | fn main() {
| ^^ unexpected token
error: expected one of `::`, `;`, or `as`, found `fn`
--> <racer-file>:3:1
|
1 | use std::col
| - expected one of `::`, `;`, or `as` here
2 |
3 | fn main() {
| ^^ unexpected token
error: expected one of `::`, `;`, or `as`, found `fn`
--> <racer-file>:3:1
|
1 | use std::colle
| - expected one of `::`, `;`, or `as` here
2 |
3 | fn main() {
| ^^ unexpected token
error: expected one of `::`, `;`, or `as`, found `fn`
--> <racer-file>:3:1
|
1 | use std::collect
| - expected one of `::`, `;`, or `as` here
2 |
3 | fn main() {
| ^^ unexpected token
error: expected one of `::`, `;`, or `as`, found `fn`
--> <racer-file>:3:1
|
1 | use std::collection
| - expected one of `::`, `;`, or `as` here
2 |
3 | fn main() {
| ^^ unexpected token
error: expected one of `::`, `;`, or `as`, found `:`
--> <racer-file>:1:21
|
1 | use std::collections:
| ^ expected one of `::`, `;`, or `as` here
error: expected identifier, found keyword `fn`
--> <racer-file>:3:1
|
3 | fn main() {
| ^^ expected identifier, found keyword
error: expected one of `::`, `;`, or `as`, found `main`
--> <racer-file>:3:4
|
3 | fn main() {
| ^^^^ expected one of `::`, `;`, or `as` here
error: expected one of `::`, `;`, or `as`, found `fn`
--> <racer-file>:3:1
|
1 | use std::collections::H
| - expected one of `::`, `;`, or `as` here
2 |
3 | fn main() {
| ^^ unexpected token
error: expected one of `::`, `;`, or `as`, found `fn`
--> <racer-file>:3:1
|
1 | use std::collections::Hash
| - expected one of `::`, `;`, or `as` here
2 |
3 | fn main() {
| ^^ unexpected token
error: expected one of `::`, `;`, or `as`, found `fn`
--> <racer-file>:3:1
|
1 | use std::collections::HashMa
| - expected one of `::`, `;`, or `as` here
2 |
3 | fn main() {
| ^^ unexpected token
It seems like RLS is failing to parse the file, maybe? Though this doesn't happen in VSCode, so I don't think it's a RLS error.
The relevant part of my VS Code config is:
"rust.all_features": true,
"rust.rustup": {
"toolchain": "stable-x86_64-unknown-linux-gnu",
"nightlyToolchain": "nightly-x86_64-unknown-linux-gnu"
},
"rust.mode": "rls",
"rust.rls": {
"useRustfmt": true
}
@chemzqm: Just to confirm, you do get completion in the example I gave? And your rls
version and coc config is the same as what I listed?
Sure, I only have those
"rust.trace.server": "verbose",
"rust-client.channel": "stable",
for coc-rls in my settings file.
Looks like the server have trouble parsing your file, so it doesn't provide any completion.
That is bizarre. With the exact same file you're editing and the example config from the coc.nvim
README (with the rust-related settings you mention above added), I get nothing for completions on items in std
, but do with VS Code (also using RLS).
Looking at the verbose server output, as above there are lots of errors about failing to parse the file, and the result of completion requests is always []
. But only for completion requests on std
items; items from 3rd party libraries succeed correctly. I'm very confused by this...
What does rls --version
output for you? What Neovim version are you using?
Hmm. I just tried the same example using LCN and ncm2, and have the same symptoms. Although I've still no idea what's causing this bug, that seems to imply it isn't a problem with coc-rls
, at least? As such, I'll close this issue. Thanks for the help!
I fixed this; it was indeed not a problem with coc or coc-rls. Turns out an old script was being sourced that set RUST_SRC_PATH
to an invalid value; apparently VS Code ignores this variable or handles it being incorrect. Sorry for the trouble and thank you for the help!
With the default configuration, I get no completion for crates/items in
std
. For example, completion at the following points fails withcoc-rls
but succeeds in VS Code.[cursor]
marks the cursor position when completion should trigger:In the VS Code extension, I had to select my toolchain, etc. Is that required for
coc-rls
? Is there any other configuration required to get proper completions? I do get completion for 3rd-party crates and instances of types from 3rd party crates, sococ-rls
is working to some extent...