README: add two rust-analyzer configuration examples for Neovim users#9939
README: add two rust-analyzer configuration examples for Neovim users#9939sruggier wants to merge 3 commits intooxidecomputer:mainfrom
Conversation
|
For context, this is a side effect of me trying to tackle #9804. It looks like the most reasonable potential reviewers for this happen to be the set of people who work on this repo that are also named David (@davepacheco and @david-crespo). Specifically, the top editor of the README file: and the person who added the example block this PR expands: |
| .Neovim (using rustaceanvim) | ||
| [source, lua] | ||
| ---- | ||
| vim.g.rustaceanvim = { | ||
| server = { | ||
| default_settings = { | ||
| ['rust-analyzer'] = { | ||
| cargo = { | ||
| targetDir = true, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| } | ||
| ---- | ||
| .Neovim (using LazyVim): merge the following into custom.lua | ||
| [source, lua] | ||
| ---- | ||
| { | ||
| "mrcjkb/rustaceanvim", | ||
| opts = { | ||
| server = { | ||
| default_settings = { | ||
| ["rust-analyzer"] = { | ||
| cargo = { | ||
| targetDir = true, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| ---- |
There was a problem hiding this comment.
Thanks for doing this.
Unfortunately my understanding is that this will cause each neovim instance to spawn an r-a process which can cause the system to run out of RAM rather quickly (r-a on Omicron routinely takes 12+ GB).
I wrote up a small tool which integrates lspmux with r-a to solve this issue:
https://github.com/sunshowers/lspmux-rust-analyzer. (We also have an internal variant of lspmux which isn't open source, and which I didn't realize existed before I wrote this.)
All of this is to say that I'm concerned about recommending something which makes it too easy for people to shoot themselves in the foot. Maybe one of us should work on productionizing some kind of lspmux + r-a thing, whether the FOSS version + my scripts or our integration.
There was a problem hiding this comment.
Thanks, also, for your response 🙂
To be fair, these snippets merely set cargo.targetDir in rust-analyzer's config, whereas the behaviour of spawning r-a processes is triggered by installing the rustaceanvim plugin, or bootstrapping a LazyVim config and installing lang.rust from :LazyExtras.
Still, that can be a lot of memory usage, and the added concurrency enabled by setting targetDir would increase the risk of thrashing somewhat. Not that I have any strong feelings about getting this merged, but I pushed a commit that adds a warning about the memory usage, with links to both of those repositories. It seemed like a relatively uncontroversial next step, but that's not to say I want to discourage any other feedback about it.
I didn't attempt to mention the internal variant of lspmux: you can probably do a better job of that than I can, having some knowledge of where it lives. It's kind of funny, though, that you went from duplicate rust-analyzer processes to duplicate lspmux repositories.
There was a problem hiding this comment.
So, is there some kind of prize if I manage to beat the high score? I started loosely paying attention to rust-analyzer's memory usage after you mentioned it, and it's now above 17 GB on my system 😂
There was a problem hiding this comment.
Another funny addendum here: the omicron codebase has made a Helix user out of me. The experience of navigating clippy diagnostics, at least in my Neovim setup, was too slow to incorporate into a development workflow, and it turns out Helix implements that in a much more useful way.
Edit: I'll add that based on my own experience using the two, I think it would even be reasonable to suggest to Neovim users interested in working with this codebase that they should consider switching to Helix.
They were separated by commit 07ef231, but the flow is a bit clearer when the cargo.targetDir example block isn't in between.
012a6d6 to
4b2f0fa
Compare
460235d to
9e46438
Compare
There are multiple different ways one can integrate rust-analyzer into Neovim, each configured slightly differently. Even for Neovim users who aren't covered, though, these examples should help simplify the process of figuring it out.