Merge branch 'master' into compute-lazy-assits
# Conflicts: # crates/rust-analyzer/src/main_loop/handlers.rs # crates/rust-analyzer/src/to_proto.rs
This commit is contained in:
@@ -12,14 +12,13 @@ use std::{ffi::OsString, path::PathBuf};
|
||||
use lsp_types::ClientCapabilities;
|
||||
use ra_flycheck::FlycheckConfig;
|
||||
use ra_ide::{AssistConfig, CompletionConfig, InlayHintsConfig};
|
||||
use ra_project_model::CargoConfig;
|
||||
use ra_project_model::{CargoConfig, JsonProject, ProjectManifest};
|
||||
use serde::Deserialize;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Config {
|
||||
pub client_caps: ClientCapsConfig,
|
||||
|
||||
pub with_sysroot: bool,
|
||||
pub publish_diagnostics: bool,
|
||||
pub lru_capacity: Option<usize>,
|
||||
pub proc_macro_srv: Option<(PathBuf, Vec<OsString>)>,
|
||||
@@ -35,6 +34,27 @@ pub struct Config {
|
||||
pub assist: AssistConfig,
|
||||
pub call_info_full: bool,
|
||||
pub lens: LensConfig,
|
||||
|
||||
pub with_sysroot: bool,
|
||||
pub linked_projects: Vec<LinkedProject>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum LinkedProject {
|
||||
ProjectManifest(ProjectManifest),
|
||||
JsonProject(JsonProject),
|
||||
}
|
||||
|
||||
impl From<ProjectManifest> for LinkedProject {
|
||||
fn from(v: ProjectManifest) -> Self {
|
||||
LinkedProject::ProjectManifest(v)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<JsonProject> for LinkedProject {
|
||||
fn from(v: JsonProject) -> Self {
|
||||
LinkedProject::JsonProject(v)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
@@ -142,6 +162,7 @@ impl Default for Config {
|
||||
assist: AssistConfig::default(),
|
||||
call_info_full: true,
|
||||
lens: LensConfig::default(),
|
||||
linked_projects: Vec::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -241,6 +262,22 @@ impl Config {
|
||||
self.lens = LensConfig::NO_LENS;
|
||||
}
|
||||
|
||||
if let Some(linked_projects) = get::<Vec<ManifestOrJsonProject>>(value, "/linkedProjects") {
|
||||
if !linked_projects.is_empty() {
|
||||
self.linked_projects.clear();
|
||||
for linked_project in linked_projects {
|
||||
let linked_project = match linked_project {
|
||||
ManifestOrJsonProject::Manifest(it) => match ProjectManifest::from_manifest_file(it) {
|
||||
Ok(it) => it.into(),
|
||||
Err(_) => continue,
|
||||
}
|
||||
ManifestOrJsonProject::JsonProject(it) => it.into(),
|
||||
};
|
||||
self.linked_projects.push(linked_project);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
log::info!("Config::update() = {:#?}", self);
|
||||
|
||||
fn get<'a, T: Deserialize<'a>>(value: &'a serde_json::Value, pointer: &str) -> Option<T> {
|
||||
@@ -308,3 +345,10 @@ impl Config {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[serde(untagged)]
|
||||
enum ManifestOrJsonProject {
|
||||
Manifest(PathBuf),
|
||||
JsonProject(JsonProject),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user