onivim / oni

Oni: Modern Modal Editing - powered by Neovim
https://www.onivim.io
MIT License
11.35k stars 301 forks source link

Rust Language Server support #1926

Open cetra3 opened 6 years ago

cetra3 commented 6 years ago

Duplicate of https://github.com/onivim/oni/issues/1712 but I have tested this against the wiki config:

Tested with the following config.js:

module.exports = {
    "language.rust.languageServer.command": "rls"
}

Does not work:

screen shot 2018-03-26 at 3 03 07 pm

rls is available on the path.

Also tested with absolute path:

module.exports = {
    "language.rust.languageServer.command": "/Users/cetra/.cargo/bin/rls"
}

We get a bit further, but it still does not work:

screen shot 2018-03-26 at 3 08 34 pm

oni-bot[bot] commented 6 years ago

Hello and welcome to the Oni repository! Thanks for opening your first issue here. To help us out, please make sure to include as much detail as possible - including screenshots and logs, if possible.

Drakulix commented 6 years ago

I am using the following settings with success:

// Language Support - Rust
"language.rust.languageServer.command": "rustup",
"language.rust.languageServer.arguments": ["run", "stable", "rls"],
"language.rust.languageServer.rootFiles": ["Cargo.toml"],

I mostly selected them because nightly rust rls was crashing at the time, but maybe this modifies the environment or something? Most language-server plugins for rust, I know of (atom and vscode), do use rustup to manage their rust installations, so I thought this might be of help.

cetra3 commented 6 years ago

I have tried that command but I get the following messages in the console along with a spinning wheel:

No grammar found for language: rust
Measure request fail
appelgriebsch commented 6 years ago

@Drakulix thanks for your snippets. Looks like Oni is trying to instantiate the RLS when using them, but still get the same problem as originally mentioned by the creator of the issue:

[Language Client] Notification textDocument/didOpen - P:\GH\rust\sample-rust\src\main.rs: start
bundle.js:1 [Language Client] Notification textDocument/didOpen - P:\GH\rust\sample-rust\src\main.rs: end
bundle.js:1 [LANGUAGE CLIENT - STDERR]: ERROR 2018-04-03T13:01:55Z: rls::server: dispatch error, Error { code: InvalidParams, message: "missing field `version`", data: None }

bundle.js:1 Received response message without id: Error is: 
{
    "code": -32602,
    "message": "missing field `version`"
}
Drakulix commented 6 years ago

@appelgriebsch I had the same issue in the beginning. I am trying to track down whats causing this and why I am currently not experiencing it anymore.

justgerd commented 6 years ago

I am getting the same error here, any fix?

Drakulix commented 6 years ago

Nope, sorry. I cannot reproduce, it just seems to work for me. No idea why.

wezm commented 6 years ago

@Drakulix if you run rustup run stable rls --version what do you get?

If I use rls from rust 1.25.0 I get the, "missing field `version`", error. If I use the 1.24.1 rls I don't get that error but I get the, "No grammar found for language: rust" error and no completions.

Drakulix commented 6 years ago

@wezm rls-preview 0.125.1-stable (cebf188 2018-03-19)

russoue commented 6 years ago

I am using the following:

// Language Support - Rust
"language.rust.languageServer.command": "rustup",
"language.rust.languageServer.arguments": ["run", "nightly", "rls"],
"language.rust.languageServer.rootFiles": ["Cargo.toml"],

But nothing happens to me. rls is in the path and works well with Atom. Is there anything else I need to do to active Rust support on Oni? Can it be that Oni is not recognizing the file name extension?

FredrikAleksander commented 6 years ago

I had this issue as well, but building from the master branch resolved it apparently. But now another issue has appared instead. After doing a couple of changes, the language service crashes with this error message [LANGUAGE CLIENT - STDERR]: thread 'main' panicked at 'Out of order or duplicate change', tools\rls\src\actions\mod.rs:272:13 note: Run with RUST_BACKTRACE=1 for a backtrace.

It might have to do with how the version of a text document is generated

EDIT: Running the nightly RLS, the error wont crash the language service, but diagnostics will sometimes be wrong. It is usable though

akinsho commented 6 years ago

@FredrikAleksander any luck successfully getting the rls to run without issue or is the above still happening?

FredrikAleksander commented 6 years ago

If I run the nightly version of RLS, it seems to work ok (sometimes diagnostics stops working temporarily, but it will start working again after a few changes). Looking at the RLS code, it was quite strict earlier and it would crash if any input was not what it expected (duplicate or out of sequence version numbers). In the nightly version it will just log a error instead

appelgriebsch commented 6 years ago

Hhmmm still not working. Even when trying the rls nightly option. Is there a way to increase logging of what's going on behind the scenes? Eventually there is an issue with the communication between rls and oni lsp client...

appelgriebsch commented 6 years ago

Interestingly I tested the Rust language server in a plain neovim environment with the LanguageClient-Neovim and this works quite well with the settings above (rustup run stable rls)...

akinsho commented 6 years ago

@appelgriebsch thanks for checking this with another client. I'm quite keen to get this working as well, I think our lsp client has some issues as it reports some errors with our current typescript client as well as our intended replacement theia-ide-language-server some clients seem to work well but others face issues as in #2448 I think we need to surface logs a bit more clearly and debug where what part of the client maybe causing the errors.

In your case can you get a screen shot of your dev console when the client fails to see what the error is?

dwagenk commented 6 years ago

I had similar problems, but after updating rls it now seems to work.

$ rustup run stable rls -V
rls-preview 0.127.0-stable (d2ade31 2018-05-08)

I'm a little confused, because it didn't work on the first try after updating, but only after the 4th or 5th reload of oni. I can't recall whether the error message was gone right after updating.

appelgriebsch commented 6 years ago

I did an update and install of rls and its dependencies as mentioned here: https://github.com/rust-lang-nursery/rls, which gives me that


λ rustup run stable rls -V
rls-preview 0.127.0-stable (d2ade31 2018-05-08)

It still shows me the same error mentioned above:

oni-rust-error

alasher commented 6 years ago

I'm also running into this issue, running oni release 0.3.6. Seeing similar issues as reported in this thread, and have rls working fine on Atom.

$ rustup run stable rls -V
rls-preview 0.127.0-stable (d2ade31 2018-05-08)
adamski commented 5 years ago

I'm just trying out Oni, and having some similar issues.

I have tried setting an absolute path for the rustup command.

Any ideas?

Screenshot 2019-06-03 at 15 47 07