Introduce a new include_warnings
setting under diagnostics
This commit is contained in:
parent
f603d682cd
commit
78908bc5cb
5 changed files with 43 additions and 1 deletions
3
Cargo.lock
generated
3
Cargo.lock
generated
|
@ -2210,6 +2210,9 @@ dependencies = [
|
||||||
"lsp",
|
"lsp",
|
||||||
"postage",
|
"postage",
|
||||||
"project",
|
"project",
|
||||||
|
"schemars",
|
||||||
|
"serde",
|
||||||
|
"serde_derive",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"settings",
|
"settings",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
|
|
|
@ -227,6 +227,11 @@
|
||||||
},
|
},
|
||||||
// Automatically update Zed
|
// Automatically update Zed
|
||||||
"auto_update": true,
|
"auto_update": true,
|
||||||
|
// Diagnostics configuration.
|
||||||
|
"diagnostics": {
|
||||||
|
// Whether to show warnings or not by default.
|
||||||
|
"include_warnings": true
|
||||||
|
},
|
||||||
// Git gutter behavior configuration.
|
// Git gutter behavior configuration.
|
||||||
"git": {
|
"git": {
|
||||||
// Control whether the git gutter is shown. May take 2 values:
|
// Control whether the git gutter is shown. May take 2 values:
|
||||||
|
|
|
@ -21,6 +21,9 @@ util = { path = "../util" }
|
||||||
workspace = { path = "../workspace" }
|
workspace = { path = "../workspace" }
|
||||||
|
|
||||||
anyhow.workspace = true
|
anyhow.workspace = true
|
||||||
|
schemars.workspace = true
|
||||||
|
serde.workspace = true
|
||||||
|
serde_derive.workspace = true
|
||||||
smallvec.workspace = true
|
smallvec.workspace = true
|
||||||
postage.workspace = true
|
postage.workspace = true
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
pub mod items;
|
pub mod items;
|
||||||
|
mod project_diagnostics_settings;
|
||||||
mod toolbar_controls;
|
mod toolbar_controls;
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
@ -20,6 +21,7 @@ use language::{
|
||||||
};
|
};
|
||||||
use lsp::LanguageServerId;
|
use lsp::LanguageServerId;
|
||||||
use project::{DiagnosticSummary, Project, ProjectPath};
|
use project::{DiagnosticSummary, Project, ProjectPath};
|
||||||
|
use project_diagnostics_settings::ProjectDiagnosticsSettings;
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use std::{
|
use std::{
|
||||||
|
@ -43,6 +45,7 @@ actions!(diagnostics, [Deploy, ToggleWarnings]);
|
||||||
const CONTEXT_LINE_COUNT: u32 = 1;
|
const CONTEXT_LINE_COUNT: u32 = 1;
|
||||||
|
|
||||||
pub fn init(cx: &mut AppContext) {
|
pub fn init(cx: &mut AppContext) {
|
||||||
|
settings::register::<ProjectDiagnosticsSettings>(cx);
|
||||||
cx.add_action(ProjectDiagnosticsEditor::deploy);
|
cx.add_action(ProjectDiagnosticsEditor::deploy);
|
||||||
cx.add_action(ProjectDiagnosticsEditor::toggle_warnings);
|
cx.add_action(ProjectDiagnosticsEditor::toggle_warnings);
|
||||||
items::init(cx);
|
items::init(cx);
|
||||||
|
@ -191,7 +194,7 @@ impl ProjectDiagnosticsEditor {
|
||||||
editor,
|
editor,
|
||||||
path_states: Default::default(),
|
path_states: Default::default(),
|
||||||
paths_to_update,
|
paths_to_update,
|
||||||
include_warnings: true,
|
include_warnings: settings::get::<ProjectDiagnosticsSettings>(cx).include_warnings,
|
||||||
};
|
};
|
||||||
this.update_excerpts(None, cx);
|
this.update_excerpts(None, cx);
|
||||||
this
|
this
|
||||||
|
|
28
crates/diagnostics/src/project_diagnostics_settings.rs
Normal file
28
crates/diagnostics/src/project_diagnostics_settings.rs
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
use schemars::JsonSchema;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Deserialize, Debug)]
|
||||||
|
pub struct ProjectDiagnosticsSettings {
|
||||||
|
pub include_warnings: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, Debug)]
|
||||||
|
pub struct ProjectDiagnosticsSettingsContent {
|
||||||
|
include_warnings: Option<bool>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl settings::Setting for ProjectDiagnosticsSettings {
|
||||||
|
const KEY: Option<&'static str> = Some("diagnostics");
|
||||||
|
type FileContent = ProjectDiagnosticsSettingsContent;
|
||||||
|
|
||||||
|
fn load(
|
||||||
|
default_value: &Self::FileContent,
|
||||||
|
user_values: &[&Self::FileContent],
|
||||||
|
_cx: &gpui::AppContext,
|
||||||
|
) -> anyhow::Result<Self>
|
||||||
|
where
|
||||||
|
Self: Sized,
|
||||||
|
{
|
||||||
|
Self::load_via_json_merge(default_value, user_values)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue