From b2df015fe6c76203d55ee1c916b4f3a27b327d67 Mon Sep 17 00:00:00 2001 From: David Barroso Date: Sat, 10 Dec 2022 14:05:44 +0100 Subject: [PATCH] when generating lsp config use RUST_SRC_PATH if set --- src/project.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/project.rs b/src/project.rs index 0df00b9..a6e3acf 100644 --- a/src/project.rs +++ b/src/project.rs @@ -1,5 +1,6 @@ use glob::glob; use serde::{Deserialize, Serialize}; +use std::env; use std::error::Error; use std::process::Command; @@ -64,6 +65,12 @@ impl RustAnalyzerProject { /// Use `rustc` to determine the default toolchain pub fn get_sysroot_src(&mut self) -> Result<(), Box> { + // check if RUST_SRC_PATH is set + if let Ok(path) = env::var("RUST_SRC_PATH") { + self.sysroot_src = path; + return Ok(()); + } + let toolchain = Command::new("rustc") .arg("--print") .arg("sysroot")