From 2c9d07663a7bd0cb01e7b053df0c763442a055c9 Mon Sep 17 00:00:00 2001 From: Thorsten Ball Date: Mon, 16 Sep 2024 18:45:11 +0200 Subject: [PATCH] rust: Lookup rust-analyzer on PATH by default (#17885) This is a highly and frequently requested change. Users are confused why rust-analyzer isn't used if it's on their `$PATH`. Previously I didn't enable this by default, because rust-analyzer would complain about an "Unknown binary", like this Unknown binary 'rust-analyzer' in official toolchain '1.81-aarch64-apple-darwin'.\n But turns out that only happens when you have installed rust-analyzer via the rustup toolchain, it's in your `$PATH`, and the `rust-toolchain.toml` of the repository doesn't mention it. The fix is to delete `~/.cargo/bin/rust-analyzer` and, if preferred, use `rust-analyzer` by installing the binary manually. Release Notes: - Changed rust-analyzer support to lookup `rust-analyzer` binaries by default in `$PATH`. That changes the default value to something users requested. --- crates/languages/src/rust.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/languages/src/rust.rs b/crates/languages/src/rust.rs index a32b4f55da..20e6c57574 100644 --- a/crates/languages/src/rust.rs +++ b/crates/languages/src/rust.rs @@ -57,12 +57,13 @@ impl LspAdapter for RustLspAdapter { } (Some(path.into()), None) } - (None, Some(true)) => { + (None, Some(true)) | (None, None) => { + // Try to lookup rust-analyzer in PATH by default. let path = delegate.which(Self::SERVER_NAME.as_ref()).await?; let env = delegate.shell_env().await; (Some(path), Some(env)) } - (None, Some(false)) | (None, None) => (None, None), + (None, Some(false)) => (None, None), }; path.map(|path| LanguageServerBinary { path,