When I open a Rust file in nvim, the following appears at the bottom of the window:
nvim-lspconfig.rust_analyzer has been setup.
This will likely lead to conflicts with the rustaceanvim LSP client.
See ':h rustaceanvim.mason'
Press ENTER or type command to continue
The command :h rustaceanvim.mason brings up help with snippets that I don't know how to use.
I'm obviously new to Neovim and have behaved like a magpie, taking little pieces from here and there.
theprimeagen's "0 to LSP" video to the LSP parts -- even some parts of this tutorial are apparently obsolete now, is that right?
rustaceanvim of course
rust-analyzer from Mason, maybe?
At some point my notes say it stopped complaining, then started again, but I may have forgotten to edit a Rust file.
Here's output from :checkhealth rustaceanvim
==============================================================================
rustaceanvim: require("rustaceanvim.health").check()
Checking for Lua dependencies ~
- OK [mfussenegger/nvim-dap](https://github.com/mfussenegger/nvim-dap) installed.
Checking external dependencies ~
- ERROR rust-analyzer: not found: Could not find an executable binary.
rustaceanvim requires [rust-analyzer](https://rust-analyzer.github.io/).
Required by the LSP client.
- OK Cargo: found cargo 1.78.0 (54d8815d0 2024-03-26)
- OK rustc: found rustc 1.78.0 (9b00956e5 2024-04-29)
- OK debug adapter: found codelldb
Checking config ~
- OK No errors found in config.
Checking for conflicting plugins ~
- ERROR nvim-lspconfig.rust_analyzer has been setup.
This will likely lead to conflicts with the rustaceanvim LSP client.
See ':help |rustaceanvim.mason'|
- OK No conflicting plugins detected.
Checking for tree-sitter parser ~
- OK tree-sitter parser for Rust detected.
At this point I have so much half-installed stuff I don't know which conflicting parts to wipe out and which parts to try to fix. I'd rather not do 0 to LSP again.
I'll reply with more detailed notes for any insomniacs reading this. Thanks.
This has been its own flavor of mess. I think I have too many of them installed.
I installed rust-tools, but it's superseded by rustaceanvim
I installed rust-analyzer (RA) in the Mason GUI
I probably installed it other times too?
In any case help rustaceanvim referred to nvim commands like :RustAnalyzer` which didn't exist for me.
Uninstalled rust-tools
Uninstalled rust-analyzer in Mason
Reinstalled rust-analyzer in Mason
Uninstalled rustaceanvim
Reinstalled rustaceanvim
Probably somewhere in there did some finagling in ~/.config/nvim/after/plugin/lsp.lua and/or ~/.config/nvim/lua/custom/packer.lua -- I wanted my RA to be independent of the above "helpful" plugins.
Still no :RustAnalyzer . So RTFM about rustaceanvim , not just the help screen[s]
TODO: I have a lot of links in here and it won't let me post them.... will post more once I get those extracted.
Yeah, it's right. Rustaceanvim doesn't need to work with nvim-lspconfig, mason.nvim or rust-tools.
The author of Rustaceanvim chooses his own way to build a LSP plugin as stated in the documentation/warning. It's kind of unfortunate to see Rustaceanvim doesn't work well with nvim-lspconfig IMHO.
There are some tricky cases from my experience. Like, Rustaceanvim uses directly the RA from your environment, which is quite good for pinned Rust toolchains because the version of RA is also pinned, and you don't need to configurate anything to make RA work. Sometimes I have to deal with really old toolchain with which latest RA just can't work properly in proc-macros expansion. But what if you have legacy RA environment from Mason to cause executable conflicts? In this case, I removed RA configuration totally from Mason, and deleted installed RA by Mason.
So my suggestion is to use Rustaceanvim independently, and have RA installed as is from rustup.
Thanks. Opinionated, normative guidance is exactly what I need right now. There are so many moving parts (nvim, Packer, Mason, and everything else you mentioned) that I just want to learn basic LSP editing. I'll figure out the tweaks later.
Tell it to me like I'm a precocious 5-year-old, but one weirdly fascinated with nvim.
So:
Maybe I don't need rustaceanvim for a "good" RA experience?
How can I get back to a intermediate state before the conflicting stuff but keep the other parts I've started configuring? E.g. can I use Packer to uninstall only the Rust bits?
From there -- how would you bring a newbie friend's nvim to fundamental Rust LSP goodness (presumably == RA) without the conflicts and distractions?
FWIW I'm experienced in coding other languages, beginner/intermediate in Rust, and obviously beginner in NeoVim. I use JetBrains editors and want to aim for an IDE-like nvim setup.
Personally, I ended up liking a lot AstroNvim. It makes the whole nvim experience very feature-rich already out of the box, but you can still configure and customize every bit of it.