lapce-rust icon indicating copy to clipboard operation
lapce-rust copied to clipboard

Not warning about the lack of rust-analyzer

Open Seven0492 opened this issue 2 years ago • 9 comments

Lapce Version

0.2.4

System information

Arch Linux kernel version: 5.15.81-1-lts

Describe the bug

Autosuggestion not working when dealing with some crates (In Rust)

Syntax highlighting just not showing in some cases

The problem?

I fixed it, it was that rust-analyzer was not installed.

The problem with that?

I only found out when I was trying to switch to Helix, and had to install rust-analyzer via rustup and do a symlink to a directory in PATH from the analyzer binary.

What I suggest?

Adding a prompt warning about the lack of rust-analyzer like other mainstream IDE's instead of just being silently faulty.

Or even installing it automatically.

I had no idea what was wrong with the Rust plugin, I thought the 'sub-par' (Used lightly) performance of its highlighting was 'normal', until I added the missing part by accident and made it work like a champ!

I can now use Lapce coding in Rust without reservation and have had a fantastic experience so far, keep it up! This is a wonderful project that was badly needed (The Rust plugin was needed too :P).

I just want other people coming to Lapce for a good Rust environment not be discouraged by its problem when it lacks rust-analyzer.

I made this issue since I think this is something that should me made aware to the user.

Seven0492 avatar Dec 07 '22 21:12 Seven0492

Duplicate of lapce/lapce #1763

Seven0492 avatar Dec 07 '22 21:12 Seven0492

I was wondering why code completion didn't seem to do anything. As stated above install rust-analyzer via rustup and create a symlink to ~/.cargo/bin fixed it:

rustup component add rust-analyzer
rustup which --toolchain stable rust-analyzer
cd ~/.cargo/bin
ln -s <PATH TO RUSTUP'S RUST-ANALYZER> rust-analyzer

bobajeff avatar Dec 10 '22 15:12 bobajeff

Oh, and to find the location of rust-analyzer without too much hassle:

# Prints the absolute path to the rust-analyzer binary
rustup which rust-analyzer

So, the new command to make a symlink to the binary would be:

ln -s $(rustup which rust-analyzer) ~/.cargo/bin/rust-analyzer

Seven0492 avatar Dec 13 '22 21:12 Seven0492

Typically the Rust extension installs RA itself, but the download can fail (faulty internet connection, or it being blocked). Typically, uninstalling then reinstalling the plugin would fix the issue for a faulty connection. It should alert the user if it fails, though.

MinusGix avatar Dec 14 '22 15:12 MinusGix

Hm, weird then, anyway, its fixed now with a simple solution, this issue will be available for anyone to mention if they had any other, similar problems, and how they solved it.

Not sure if I should close this issue, though.

Seven0492 avatar Dec 14 '22 21:12 Seven0492

I'm not sure where it failed. When I noticed it not working the first thing I did was open the folder where the extension is installed. In there I saw there was already a binary of rust-analyser; so I would assume it was meant to use that one. However, it clearly wasn't as things only started working after installing my own via rust-up and symlinking.

bobajeff avatar Dec 14 '22 21:12 bobajeff

I hadn't gone that far, but it is weird indeed, maybe the rust-analyzer version packaged with the extension is out of date?

This is the only reason I could think off which would generate this disconnect.

And even then, why would it silently fail? Question to ponder on, I guess.

Seven0492 avatar Dec 14 '22 21:12 Seven0492

I'm trying to use the Rust extension in Lapce on Windows. I had an old version from March 2022 and recently updated to Nightly (a93ffe0). The Rust extension sort of worked in the old Lapce version, but showed an empty tab with the name of the appropriate rust file when I did "Go to definition" on a symbol from an imported crate or from the same file. In nightly Lapce the extension is enabled but "Go to definition" does nothing. No error messages. I did rustup component add rust-analyzer and plugged the path to stable rust-analyzer.exe into "Server Path" in the Rust extension settings as recommended on lapce/lapce.docs#1 and no change. There is also a downloaded rust-analyzer in the extension folder. (No .exe but the file command on WSL says it's a PE32+ executable.) There are 0 warnings and errors in the left bottom corner; is there another place to see error messages from the extension?

Sorry, this may not be the right place to post this, as it doesn't seem to be about missing rust-analyzer.

Erutuon avatar Feb 01 '23 18:02 Erutuon

I currently have the same issue on Windows, without specifying a path I get proc macro losing failed errors (unsupported metadata version 7).

If I define a path in the plugin settings, I get server path "~.rustup\toolchains\stable-x86_64-pc-windows-msvc\bin\rust-analyzer.exe", could not be found.

Occuros avatar Sep 25 '23 10:09 Occuros