mirror of
https://github.com/helix-editor/helix.git
synced 2024-09-11 18:58:00 +03:00
Support LSP diagnostic tags (#9780)
This commit is contained in:
parent
1d6db30acf
commit
5ca6a448e9
@ -333,5 +333,7 @@ #### Interface
|
|||||||
| `diagnostic.info` | Diagnostics info (editing area) |
|
| `diagnostic.info` | Diagnostics info (editing area) |
|
||||||
| `diagnostic.warning` | Diagnostics warning (editing area) |
|
| `diagnostic.warning` | Diagnostics warning (editing area) |
|
||||||
| `diagnostic.error` | Diagnostics error (editing area) |
|
| `diagnostic.error` | Diagnostics error (editing area) |
|
||||||
|
| `diagnostic.unnecessary` | Diagnostics with unnecessary tag (editing area) |
|
||||||
|
| `diagnostic.deprecated` | Diagnostics with deprecated tag (editing area) |
|
||||||
|
|
||||||
[editor-section]: ./configuration.md#editor-section
|
[editor-section]: ./configuration.md#editor-section
|
||||||
|
@ -631,6 +631,12 @@ pub(crate) async fn initialize(&self, enable_snippets: bool) -> Result<lsp::Init
|
|||||||
}),
|
}),
|
||||||
publish_diagnostics: Some(lsp::PublishDiagnosticsClientCapabilities {
|
publish_diagnostics: Some(lsp::PublishDiagnosticsClientCapabilities {
|
||||||
version_support: Some(true),
|
version_support: Some(true),
|
||||||
|
tag_support: Some(lsp::TagSupport {
|
||||||
|
value_set: vec![
|
||||||
|
lsp::DiagnosticTag::UNNECESSARY,
|
||||||
|
lsp::DiagnosticTag::DEPRECATED,
|
||||||
|
],
|
||||||
|
}),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}),
|
}),
|
||||||
inlay_hint: Some(lsp::InlayHintClientCapabilities {
|
inlay_hint: Some(lsp::InlayHintClientCapabilities {
|
||||||
|
@ -360,7 +360,7 @@ pub fn doc_diagnostics_highlights(
|
|||||||
doc: &Document,
|
doc: &Document,
|
||||||
theme: &Theme,
|
theme: &Theme,
|
||||||
) -> [Vec<(usize, std::ops::Range<usize>)>; 5] {
|
) -> [Vec<(usize, std::ops::Range<usize>)>; 5] {
|
||||||
use helix_core::diagnostic::Severity;
|
use helix_core::diagnostic::{DiagnosticTag, Severity};
|
||||||
let get_scope_of = |scope| {
|
let get_scope_of = |scope| {
|
||||||
theme
|
theme
|
||||||
.find_scope_index_exact(scope)
|
.find_scope_index_exact(scope)
|
||||||
@ -380,6 +380,10 @@ pub fn doc_diagnostics_highlights(
|
|||||||
let error = get_scope_of("diagnostic.error");
|
let error = get_scope_of("diagnostic.error");
|
||||||
let r#default = get_scope_of("diagnostic"); // this is a bit redundant but should be fine
|
let r#default = get_scope_of("diagnostic"); // this is a bit redundant but should be fine
|
||||||
|
|
||||||
|
// Diagnostic tags
|
||||||
|
let unnecessary = theme.find_scope_index_exact("diagnostic.unnecessary");
|
||||||
|
let deprecated = theme.find_scope_index_exact("diagnostic.deprecated");
|
||||||
|
|
||||||
let mut default_vec: Vec<(usize, std::ops::Range<usize>)> = Vec::new();
|
let mut default_vec: Vec<(usize, std::ops::Range<usize>)> = Vec::new();
|
||||||
let mut info_vec = Vec::new();
|
let mut info_vec = Vec::new();
|
||||||
let mut hint_vec = Vec::new();
|
let mut hint_vec = Vec::new();
|
||||||
@ -396,6 +400,15 @@ pub fn doc_diagnostics_highlights(
|
|||||||
_ => (&mut default_vec, r#default),
|
_ => (&mut default_vec, r#default),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let scope = diagnostic
|
||||||
|
.tags
|
||||||
|
.first()
|
||||||
|
.and_then(|tag| match tag {
|
||||||
|
DiagnosticTag::Unnecessary => unnecessary,
|
||||||
|
DiagnosticTag::Deprecated => deprecated,
|
||||||
|
})
|
||||||
|
.unwrap_or(scope);
|
||||||
|
|
||||||
// If any diagnostic overlaps ranges with the prior diagnostic,
|
// If any diagnostic overlaps ranges with the prior diagnostic,
|
||||||
// merge the two together. Otherwise push a new span.
|
// merge the two together. Otherwise push a new span.
|
||||||
match vec.last_mut() {
|
match vec.last_mut() {
|
||||||
|
@ -80,6 +80,8 @@ label = "honey"
|
|||||||
"diagnostic.info" = { underline = { color = "delta", style = "curl" } }
|
"diagnostic.info" = { underline = { color = "delta", style = "curl" } }
|
||||||
"diagnostic.warning" = { underline = { color = "lightning", style = "curl" } }
|
"diagnostic.warning" = { underline = { color = "lightning", style = "curl" } }
|
||||||
"diagnostic.error" = { underline = { color = "apricot", style = "curl" } }
|
"diagnostic.error" = { underline = { color = "apricot", style = "curl" } }
|
||||||
|
"diagnostic.unnecessary" = { modifiers = ["dim"] }
|
||||||
|
"diagnostic.deprecated" = { modifiers = ["crossed_out"] }
|
||||||
|
|
||||||
warning = "lightning"
|
warning = "lightning"
|
||||||
error = "apricot"
|
error = "apricot"
|
||||||
|
Loading…
Reference in New Issue
Block a user