Stream: t-compiler/wg-rls-2.0

Topic: vim support


Andrew Chin (Jul 05 2019 at 18:20, on Zulip):

Hello all! I have a question about rust-analyzer with coc.vim. I've got it setup and working correctly as far as I can see (things like tab completion and go-to definition are working well), but I'm stuck trying to get it to report errors. Does anyone know if this is supported at the moment, and if so, is any special config needed?

matklad (Jul 05 2019 at 18:24, on Zulip):

We just don't report a ton of errors at the moment: only syntax errors and some semnatic errors, like a missing field in a struct literal

matklad (Jul 05 2019 at 18:25, on Zulip):

the best way to get the full set of errors is using cargo watch

Andrew Chin (Jul 05 2019 at 18:26, on Zulip):

ahh, ok. well that answers my question then. thanks!

matklad (Jul 05 2019 at 18:33, on Zulip):

Do you get syntax errors though?

Andrew Chin (Jul 05 2019 at 18:37, on Zulip):

no, i didn't seem to get those either

Andrew Chin (Jul 05 2019 at 18:40, on Zulip):

hmm, well now that i try it again, i do see syntax errors reported

Andrew Chin (Jul 05 2019 at 18:42, on Zulip):

and i confirm that i do see errors on missing struct fields.

Andrew Chin (Jul 05 2019 at 18:43, on Zulip):

so it seems like it's all working correctly

Andrew Chin (Jul 05 2019 at 18:44, on Zulip):

this is pretty cool!

Ihor Antonov (Jul 10 2019 at 00:41, on Zulip):

Hi guys, I am trying to look into https://github.com/autozimu/LanguageClient-neovim/issues/848 but the first problem I encountered is that I don't know how to setup all the moving bits and pieces together for productive debugging. Let me explain a bit : it is a complicated setup of editor (nvim), language client plugin, and language server. Problems can potentially happen in any of the three main components. It is not clear for me what is the most effective way of monitoring the communication between server and client? Does anybody have experience of setting dev environment for fast and efficient dev-test cycles with rust analyzer? Any advice, even most general, is appreciated!

matklad (Jul 10 2019 at 08:52, on Zulip):

For VS Code, the thing that really helps is client-side logging. VS Code shows the trace of all LSP messages, as well as any additional stderr from the server

matklad (Jul 10 2019 at 08:52, on Zulip):

I think setting up something like this for VIM would be wise

Ihor Antonov (Jul 10 2019 at 18:56, on Zulip):

@matklad

We just don't report a ton of errors at the moment: only syntax errors and some semantic errors, like a missing field in a struct literal

I have noticed that RLS reports a lot of errors (I'd say everything that cargo shows). Is that because RLS has cargo "embedded"? For obvious reasons running cargo watch on the side is not super convenient. Is there a plan for ra to report all errors and what is the planned architecture?

qmx (Jul 12 2019 at 01:43, on Zulip):

Hello all! I have a question about rust-analyzer with coc.vim. I've got it setup and working correctly as far as I can see (things like tab completion and go-to definition are working well), but I'm stuck trying to get it to report errors. Does anyone know if this is supported at the moment, and if so, is any special config needed?

do you get a freeze and further 30s timeout after using jump to definition?

qmx (Jul 12 2019 at 01:45, on Zulip):

@matklad what's the policy for things like vim-integration problems? Should we file gh issues too? Just discuss them here?

matklad (Jul 12 2019 at 07:23, on Zulip):

It probably makes sense to file issues, yeah. Looking into the problems would also help ;) Neither me nor Florian are using vim :(

matklad (Jul 12 2019 at 07:25, on Zulip):

For obvious reasons running cargo watch on the side is not super convenient. Is there a plan for ra to report all errors and what is the planned architecture?

@Ihor Antonov For starters, we plan to just run cargo watch: that's simple and is actually faster than RLS. Currently this is implemented in VS Code on the client side. We plan to move cargo watch management to the language server

Ihor Antonov (Jul 12 2019 at 11:21, on Zulip):

@matklad

For obvious reasons running cargo watch on the side is not super convenient. Is there a plan for ra to report all errors and what is the planned architecture?

Ihor Antonov For starters, we plan to just run cargo watch: that's simple and is actually faster than RLS. Currently this is implemented in VS Code on the client side. We plan to move cargo watch management to the language server

So does this mean that RA will run cargo watch as a child process and then bubble up errors to the editor in form of LSP diagnostics?

matklad (Jul 12 2019 at 11:22, on Zulip):

More or less yes. Most likely though, we will be calling cargo as a subprocess, not cargo watch, and that we might also ask it to produce save-analysis data, in addition to just diagnostics

matklad (Jul 12 2019 at 11:23, on Zulip):

to clarify, the end game here is absolutely to just produce all errors on the fly from withing rust-analyze itself, using a salsa-based incremental compiler. We are very far from that at the moment though, so leveraging cargo check seems like a good idea in the meantime

Ihor Antonov (Jul 12 2019 at 11:37, on Zulip):

I agree and I like it, it follows Unix philosophy

Ihor Antonov (Jul 12 2019 at 11:37, on Zulip):

Thanks for the clarifications

Jane Lusby (Aug 17 2019 at 20:09, on Zulip):

I'm having some trouble figuring out how to enable cargo watch integration with rust-analyzer. This is already available right? I'm using coc.nvim and tried

```{
"languageserver": {
"rust": {
"command": "ra_lsp_server",
"filetypes": ["rust"],
"rootPatterns": ["Cargo.toml"]
}
},
"rust-analyzer.enableCargoWatchOnStartup": "ask"
}


Jane Lusby (Aug 17 2019 at 20:09, on Zulip):

but nothing seems to happen, I've tried using vscode and it will give me a prompt to enable cargo watch, but after clicking yes nothing visibly happens

Jane Lusby (Aug 17 2019 at 20:10, on Zulip):

running cargo watch independently seems to work wel

Jane Lusby (Aug 17 2019 at 20:27, on Zulip):

I've also tried "enabled" instead of "ask"

Pascal (Aug 17 2019 at 21:19, on Zulip):

i think the settings listed on https://github.com/rust-analyzer/rust-analyzer/blob/2bac1bdf174a053f0727e982f0f92d068ef3c208/docs/user/README.md#settings are only for the vscode ext. from what i can tell cargo-watch run completely separate to ra_lsp_server

Jane Lusby (Aug 17 2019 at 21:35, on Zulip):

Ooh, sad face

Pascal (Aug 18 2019 at 16:57, on Zulip):

maybe you can make a cargo-watch vim extension based on this impl? https://github.com/rust-analyzer/rust-analyzer/tree/2bac1bdf174a053f0727e982f0f92d068ef3c208/editors/code/src/utils/diagnostics

Jane Lusby (Aug 19 2019 at 17:47, on Zulip):

I was going to set up ale-vim to just run cargo for me on save because that composes well with coc.nvim + rust-analyzer

Jane Lusby (Aug 19 2019 at 17:48, on Zulip):

a vim extension for cargo watch would eventually be deprecated anyways right? My understanding is that ra-lsp will eventually have an incremental compiler built in

Last update: Nov 19 2019 at 17:40UTC