Allow styling of invalid diagnostics
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
parent
8d5e3fb159
commit
2664dad2bc
6 changed files with 52 additions and 29 deletions
|
@ -394,7 +394,7 @@ impl<'a> BlockMapWriter<'a> {
|
||||||
let id = BlockId(self.0.next_block_id.fetch_add(1, SeqCst));
|
let id = BlockId(self.0.next_block_id.fetch_add(1, SeqCst));
|
||||||
ids.push(id);
|
ids.push(id);
|
||||||
|
|
||||||
let position = buffer.anchor_before(block.position);
|
let position = buffer.anchor_after(block.position);
|
||||||
let point = position.to_point(buffer);
|
let point = position.to_point(buffer);
|
||||||
let start_row = wrap_snapshot
|
let start_row = wrap_snapshot
|
||||||
.from_point(Point::new(point.row, 0), Bias::Left)
|
.from_point(Point::new(point.row, 0), Bias::Left)
|
||||||
|
|
|
@ -613,7 +613,7 @@ impl EditorElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
let underline = if let Some(severity) = chunk.diagnostic {
|
let underline = if let Some(severity) = chunk.diagnostic {
|
||||||
Some(super::diagnostic_style(severity, style).text)
|
Some(super::diagnostic_style(severity, false, style).text)
|
||||||
} else {
|
} else {
|
||||||
highlight_style.underline
|
highlight_style.underline
|
||||||
};
|
};
|
||||||
|
|
|
@ -2284,7 +2284,7 @@ impl Editor {
|
||||||
let settings = build_settings.borrow()(cx);
|
let settings = build_settings.borrow()(cx);
|
||||||
vec![(
|
vec![(
|
||||||
message_len,
|
message_len,
|
||||||
diagnostic_style(severity, &settings.style)
|
diagnostic_style(severity, false, &settings.style)
|
||||||
.text
|
.text
|
||||||
.into(),
|
.into(),
|
||||||
)]
|
)]
|
||||||
|
@ -2294,7 +2294,7 @@ impl Editor {
|
||||||
let build_settings = build_settings.clone();
|
let build_settings = build_settings.clone();
|
||||||
move |cx| {
|
move |cx| {
|
||||||
let settings = build_settings.borrow()(cx);
|
let settings = build_settings.borrow()(cx);
|
||||||
diagnostic_style(severity, &settings.style).block
|
diagnostic_style(severity, false, &settings.style).block
|
||||||
}
|
}
|
||||||
})),
|
})),
|
||||||
disposition: BlockDisposition::Below,
|
disposition: BlockDisposition::Below,
|
||||||
|
@ -2919,10 +2919,14 @@ impl EditorSettings {
|
||||||
selection: Default::default(),
|
selection: Default::default(),
|
||||||
guest_selections: Default::default(),
|
guest_selections: Default::default(),
|
||||||
syntax: Default::default(),
|
syntax: Default::default(),
|
||||||
diagnostic_error: Default::default(),
|
error_diagnostic: Default::default(),
|
||||||
diagnostic_warning: Default::default(),
|
invalid_error_diagnostic: Default::default(),
|
||||||
diagnostic_information: Default::default(),
|
warning_diagnostic: Default::default(),
|
||||||
diagnostic_hint: Default::default(),
|
invalid_warning_diagnostic: Default::default(),
|
||||||
|
information_diagnostic: Default::default(),
|
||||||
|
invalid_information_diagnostic: Default::default(),
|
||||||
|
hint_diagnostic: Default::default(),
|
||||||
|
invalid_hint_diagnostic: Default::default(),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -3046,12 +3050,20 @@ impl SelectionExt for Selection<Point> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn diagnostic_style(severity: DiagnosticSeverity, style: &EditorStyle) -> DiagnosticStyle {
|
pub fn diagnostic_style(
|
||||||
match severity {
|
severity: DiagnosticSeverity,
|
||||||
DiagnosticSeverity::ERROR => style.diagnostic_error,
|
valid: bool,
|
||||||
DiagnosticSeverity::WARNING => style.diagnostic_warning,
|
style: &EditorStyle,
|
||||||
DiagnosticSeverity::INFORMATION => style.diagnostic_information,
|
) -> DiagnosticStyle {
|
||||||
DiagnosticSeverity::HINT => style.diagnostic_hint,
|
match (severity, valid) {
|
||||||
|
(DiagnosticSeverity::ERROR, true) => style.error_diagnostic,
|
||||||
|
(DiagnosticSeverity::ERROR, false) => style.invalid_error_diagnostic,
|
||||||
|
(DiagnosticSeverity::WARNING, true) => style.warning_diagnostic,
|
||||||
|
(DiagnosticSeverity::WARNING, false) => style.invalid_warning_diagnostic,
|
||||||
|
(DiagnosticSeverity::INFORMATION, true) => style.information_diagnostic,
|
||||||
|
(DiagnosticSeverity::INFORMATION, false) => style.invalid_information_diagnostic,
|
||||||
|
(DiagnosticSeverity::HINT, true) => style.hint_diagnostic,
|
||||||
|
(DiagnosticSeverity::HINT, false) => style.invalid_hint_diagnostic,
|
||||||
_ => Default::default(),
|
_ => Default::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,6 +136,7 @@ impl LanguageServer {
|
||||||
buffer.resize(message_len, 0);
|
buffer.resize(message_len, 0);
|
||||||
stdout.read_exact(&mut buffer).await?;
|
stdout.read_exact(&mut buffer).await?;
|
||||||
|
|
||||||
|
println!("{}", std::str::from_utf8(&buffer).unwrap());
|
||||||
if let Ok(AnyNotification { method, params }) =
|
if let Ok(AnyNotification { method, params }) =
|
||||||
serde_json::from_slice(&buffer)
|
serde_json::from_slice(&buffer)
|
||||||
{
|
{
|
||||||
|
|
|
@ -227,12 +227,14 @@ pub struct EditorStyle {
|
||||||
pub line_number_active: Color,
|
pub line_number_active: Color,
|
||||||
pub guest_selections: Vec<SelectionStyle>,
|
pub guest_selections: Vec<SelectionStyle>,
|
||||||
pub syntax: Arc<SyntaxTheme>,
|
pub syntax: Arc<SyntaxTheme>,
|
||||||
pub diagnostic_error: DiagnosticStyle,
|
pub error_diagnostic: DiagnosticStyle,
|
||||||
pub diagnostic_warning: DiagnosticStyle,
|
pub invalid_error_diagnostic: DiagnosticStyle,
|
||||||
#[serde(default)]
|
pub warning_diagnostic: DiagnosticStyle,
|
||||||
pub diagnostic_information: DiagnosticStyle,
|
pub invalid_warning_diagnostic: DiagnosticStyle,
|
||||||
#[serde(default)]
|
pub information_diagnostic: DiagnosticStyle,
|
||||||
pub diagnostic_hint: DiagnosticStyle,
|
pub invalid_information_diagnostic: DiagnosticStyle,
|
||||||
|
pub hint_diagnostic: DiagnosticStyle,
|
||||||
|
pub invalid_hint_diagnostic: DiagnosticStyle,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Deserialize, Default)]
|
#[derive(Copy, Clone, Deserialize, Default)]
|
||||||
|
@ -288,10 +290,14 @@ impl InputEditorStyle {
|
||||||
line_number_active: Default::default(),
|
line_number_active: Default::default(),
|
||||||
guest_selections: Default::default(),
|
guest_selections: Default::default(),
|
||||||
syntax: Default::default(),
|
syntax: Default::default(),
|
||||||
diagnostic_error: Default::default(),
|
error_diagnostic: Default::default(),
|
||||||
diagnostic_warning: Default::default(),
|
invalid_error_diagnostic: Default::default(),
|
||||||
diagnostic_information: Default::default(),
|
warning_diagnostic: Default::default(),
|
||||||
diagnostic_hint: Default::default(),
|
invalid_warning_diagnostic: Default::default(),
|
||||||
|
information_diagnostic: Default::default(),
|
||||||
|
invalid_information_diagnostic: Default::default(),
|
||||||
|
hint_diagnostic: Default::default(),
|
||||||
|
invalid_hint_diagnostic: Default::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,7 +173,7 @@ corner_radius = 6
|
||||||
|
|
||||||
[project_panel]
|
[project_panel]
|
||||||
extends = "$panel"
|
extends = "$panel"
|
||||||
padding.top = 6 # ($workspace.tab.height - $project_panel.entry.height) / 2
|
padding.top = 6 # ($workspace.tab.height - $project_panel.entry.height) / 2
|
||||||
|
|
||||||
[project_panel.entry]
|
[project_panel.entry]
|
||||||
text = "$text.1"
|
text = "$text.1"
|
||||||
|
@ -236,7 +236,11 @@ line_number_active = "$text.0.color"
|
||||||
selection = "$selection.host"
|
selection = "$selection.host"
|
||||||
guest_selections = "$selection.guests"
|
guest_selections = "$selection.guests"
|
||||||
error_color = "$status.bad"
|
error_color = "$status.bad"
|
||||||
diagnostic_error = { text = "$status.bad", border = "#ff0000", background = "#ffdddd" }
|
error_diagnostic = { text = "$status.bad" }
|
||||||
diagnostic_warning = { text = "$status.warn", border = "#ffff00", background = "#ffffdd" }
|
invalid_error_diagnostic = { text = "$text.3.color" }
|
||||||
diagnostic_info = { text = "$status.info" }
|
warning_diagnostic = { text = "$status.warn" }
|
||||||
diagnostic_hint = { text = "$status.info" }
|
invalid_warning_diagnostic = { text = "$text.3.color" }
|
||||||
|
information_diagnostic = { text = "$status.info" }
|
||||||
|
invalid_information_diagnostic = { text = "$text.3.color" }
|
||||||
|
hint_diagnostic = { text = "$status.info" }
|
||||||
|
invalid_hint_diagnostic = { text = "$text.3.color" }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue