scip: Allow customizing cargo config.
Re-use the LSP config json for simplicity.
This commit is contained in:
parent
b3f45745ea
commit
791e6c8b1b
@ -131,6 +131,9 @@ xflags::xflags! {
|
||||
|
||||
/// The output path where the SCIP file will be written to. Defaults to `index.scip`.
|
||||
optional --output path: PathBuf
|
||||
|
||||
/// A path to an json configuration file that can be used to customize cargo behavior.
|
||||
optional --config-path config_path: PathBuf
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -239,6 +242,7 @@ pub struct Scip {
|
||||
pub path: PathBuf,
|
||||
|
||||
pub output: Option<PathBuf>,
|
||||
pub config_path: Option<PathBuf>,
|
||||
}
|
||||
|
||||
impl RustAnalyzer {
|
||||
|
@ -12,7 +12,6 @@ use ide::{
|
||||
};
|
||||
use ide_db::LineIndexDatabase;
|
||||
use load_cargo::{load_workspace_at, LoadCargoConfig, ProcMacroServerChoice};
|
||||
use project_model::{CargoConfig, RustLibSource};
|
||||
use scip::types as scip_types;
|
||||
|
||||
use crate::{
|
||||
@ -24,8 +23,6 @@ impl flags::Scip {
|
||||
pub fn run(self) -> anyhow::Result<()> {
|
||||
eprintln!("Generating SCIP start...");
|
||||
let now = Instant::now();
|
||||
let mut cargo_config = CargoConfig::default();
|
||||
cargo_config.sysroot = Some(RustLibSource::Discover);
|
||||
|
||||
let no_progress = &|s| (eprintln!("rust-analyzer: Loading {s}"));
|
||||
let load_cargo_config = LoadCargoConfig {
|
||||
@ -34,6 +31,20 @@ impl flags::Scip {
|
||||
prefill_caches: true,
|
||||
};
|
||||
let root = vfs::AbsPathBuf::assert(std::env::current_dir()?.join(&self.path)).normalize();
|
||||
|
||||
let mut config = crate::config::Config::new(
|
||||
root.clone(),
|
||||
lsp_types::ClientCapabilities::default(),
|
||||
/* workspace_roots = */ vec![],
|
||||
/* is_visual_studio_code = */ false,
|
||||
);
|
||||
|
||||
if let Some(p) = self.config_path {
|
||||
let mut file = std::io::BufReader::new(std::fs::File::open(p)?);
|
||||
let json = serde_json::from_reader(&mut file)?;
|
||||
config.update(json)?;
|
||||
}
|
||||
let cargo_config = config.cargo();
|
||||
let (host, vfs, _) = load_workspace_at(
|
||||
root.as_path().as_ref(),
|
||||
&cargo_config,
|
||||
|
@ -766,6 +766,8 @@ impl fmt::Display for ConfigError {
|
||||
}
|
||||
}
|
||||
|
||||
impl std::error::Error for ConfigError {}
|
||||
|
||||
impl Config {
|
||||
pub fn new(
|
||||
root_path: AbsPathBuf,
|
||||
|
Loading…
x
Reference in New Issue
Block a user