Align diagnostics config with the rest of rust-analyzer
This commit is contained in:
@@ -7,24 +7,25 @@
|
||||
//! configure the server itself, feature flags are passed into analysis, and
|
||||
//! tweak things like automatic insertion of `()` in completions.
|
||||
|
||||
use std::{collections::HashSet, ffi::OsString, path::PathBuf};
|
||||
use std::{ffi::OsString, path::PathBuf};
|
||||
|
||||
use flycheck::FlycheckConfig;
|
||||
use ide::{AssistConfig, CompletionConfig, HoverConfig, InlayHintsConfig};
|
||||
use ide::{AssistConfig, CompletionConfig, DiagnosticsConfig, HoverConfig, InlayHintsConfig};
|
||||
use lsp_types::ClientCapabilities;
|
||||
use project_model::{CargoConfig, ProjectJson, ProjectJsonData, ProjectManifest};
|
||||
use rustc_hash::FxHashSet;
|
||||
use serde::Deserialize;
|
||||
use vfs::AbsPathBuf;
|
||||
|
||||
use crate::diagnostics::DiagnosticsConfig;
|
||||
use crate::diagnostics::DiagnosticsMapConfig;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Config {
|
||||
pub client_caps: ClientCapsConfig,
|
||||
|
||||
pub publish_diagnostics: bool,
|
||||
pub experimental_diagnostics: bool,
|
||||
pub diagnostics: DiagnosticsConfig,
|
||||
pub diagnostics_map: DiagnosticsMapConfig,
|
||||
pub lru_capacity: Option<usize>,
|
||||
pub proc_macro_srv: Option<(PathBuf, Vec<OsString>)>,
|
||||
pub files: FilesConfig,
|
||||
@@ -45,14 +46,6 @@ pub struct Config {
|
||||
pub with_sysroot: bool,
|
||||
pub linked_projects: Vec<LinkedProject>,
|
||||
pub root_path: AbsPathBuf,
|
||||
|
||||
pub analysis: AnalysisConfig,
|
||||
}
|
||||
|
||||
/// Configuration parameters for the analysis run.
|
||||
#[derive(Debug, Default, Clone)]
|
||||
pub struct AnalysisConfig {
|
||||
pub disabled_diagnostics: HashSet<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Eq, PartialEq)]
|
||||
@@ -146,8 +139,8 @@ impl Config {
|
||||
|
||||
with_sysroot: true,
|
||||
publish_diagnostics: true,
|
||||
experimental_diagnostics: true,
|
||||
diagnostics: DiagnosticsConfig::default(),
|
||||
diagnostics_map: DiagnosticsMapConfig::default(),
|
||||
lru_capacity: None,
|
||||
proc_macro_srv: None,
|
||||
files: FilesConfig { watcher: FilesWatcher::Notify, exclude: Vec::new() },
|
||||
@@ -184,8 +177,6 @@ impl Config {
|
||||
hover: HoverConfig::default(),
|
||||
linked_projects: Vec::new(),
|
||||
root_path,
|
||||
|
||||
analysis: AnalysisConfig::default(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,8 +191,11 @@ impl Config {
|
||||
|
||||
self.with_sysroot = data.withSysroot;
|
||||
self.publish_diagnostics = data.diagnostics_enable;
|
||||
self.experimental_diagnostics = data.diagnostics_enableExperimental;
|
||||
self.diagnostics = DiagnosticsConfig {
|
||||
disable_experimental: !data.diagnostics_enableExperimental,
|
||||
disabled: data.diagnostics_disabled,
|
||||
};
|
||||
self.diagnostics_map = DiagnosticsMapConfig {
|
||||
warnings_as_info: data.diagnostics_warningsAsInfo,
|
||||
warnings_as_hint: data.diagnostics_warningsAsHint,
|
||||
};
|
||||
@@ -303,8 +297,6 @@ impl Config {
|
||||
goto_type_def: data.hoverActions_enable && data.hoverActions_gotoTypeDef,
|
||||
};
|
||||
|
||||
self.analysis = AnalysisConfig { disabled_diagnostics: data.analysis_disabledDiagnostics };
|
||||
|
||||
log::info!("Config::update() = {:#?}", self);
|
||||
}
|
||||
|
||||
@@ -369,14 +361,6 @@ impl Config {
|
||||
self.client_caps.status_notification = get_bool("statusNotification");
|
||||
}
|
||||
}
|
||||
|
||||
pub fn disabled_diagnostics(&self) -> Option<HashSet<String>> {
|
||||
if self.analysis.disabled_diagnostics.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(self.analysis.disabled_diagnostics.clone())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
@@ -434,6 +418,7 @@ config_data! {
|
||||
|
||||
diagnostics_enable: bool = true,
|
||||
diagnostics_enableExperimental: bool = true,
|
||||
diagnostics_disabled: FxHashSet<String> = FxHashSet::default(),
|
||||
diagnostics_warningsAsHint: Vec<String> = Vec::new(),
|
||||
diagnostics_warningsAsInfo: Vec<String> = Vec::new(),
|
||||
|
||||
@@ -464,7 +449,5 @@ config_data! {
|
||||
rustfmt_overrideCommand: Option<Vec<String>> = None,
|
||||
|
||||
withSysroot: bool = true,
|
||||
|
||||
analysis_disabledDiagnostics: HashSet<String> = HashSet::new(),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user