Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'helix-view/src/editor.rs')
| -rw-r--r-- | helix-view/src/editor.rs | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index e6a585d6..31373630 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -45,6 +45,7 @@ use anyhow::{anyhow, bail, Error}; pub use helix_core::diagnostic::Severity; use helix_core::{ auto_pairs::AutoPairs, + diagnostic::DiagnosticProvider, syntax::{self, AutoPairConfig, IndentationHeuristic, LanguageServerFeature, SoftWrap}, Change, LineEnding, Position, Range, Selection, Uri, NATIVE_LINE_ENDING, }; @@ -1041,6 +1042,8 @@ pub struct Breakpoint { use futures_util::stream::{Flatten, Once}; +type Diagnostics = BTreeMap<Uri, Vec<(lsp::Diagnostic, DiagnosticProvider)>>; + pub struct Editor { /// Current editing mode. pub mode: Mode, @@ -1060,7 +1063,7 @@ pub struct Editor { pub macro_recording: Option<(char, Vec<KeyEvent>)>, pub macro_replaying: Vec<char>, pub language_servers: helix_lsp::Registry, - pub diagnostics: BTreeMap<Uri, Vec<(lsp::Diagnostic, LanguageServerId)>>, + pub diagnostics: Diagnostics, pub diff_providers: DiffProviderRegistry, pub debugger: Option<dap::Client>, @@ -1207,7 +1210,7 @@ impl Editor { macro_replaying: Vec::new(), theme: theme_loader.default(), language_servers, - diagnostics: BTreeMap::new(), + diagnostics: Diagnostics::new(), diff_providers: DiffProviderRegistry::default(), debugger: None, debugger_events: SelectAll::new(), @@ -2007,7 +2010,7 @@ impl Editor { /// Returns all supported diagnostics for the document pub fn doc_diagnostics<'a>( language_servers: &'a helix_lsp::Registry, - diagnostics: &'a BTreeMap<Uri, Vec<(lsp::Diagnostic, LanguageServerId)>>, + diagnostics: &'a Diagnostics, document: &Document, ) -> impl Iterator<Item = helix_core::Diagnostic> + 'a { Editor::doc_diagnostics_with_filter(language_servers, diagnostics, document, |_, _| true) @@ -2017,9 +2020,9 @@ impl Editor { /// filtered by `filter` which is invocated with the raw `lsp::Diagnostic` and the language server id it came from pub fn doc_diagnostics_with_filter<'a>( language_servers: &'a helix_lsp::Registry, - diagnostics: &'a BTreeMap<Uri, Vec<(lsp::Diagnostic, LanguageServerId)>>, + diagnostics: &'a Diagnostics, document: &Document, - filter: impl Fn(&lsp::Diagnostic, LanguageServerId) -> bool + 'a, + filter: impl Fn(&lsp::Diagnostic, &DiagnosticProvider) -> bool + 'a, ) -> impl Iterator<Item = helix_core::Diagnostic> + 'a { let text = document.text().clone(); let language_config = document.language.clone(); @@ -2027,8 +2030,9 @@ impl Editor { .uri() .and_then(|uri| diagnostics.get(&uri)) .map(|diags| { - diags.iter().filter_map(move |(diagnostic, lsp_id)| { - let ls = language_servers.get_by_id(*lsp_id)?; + diags.iter().filter_map(move |(diagnostic, provider)| { + let server_id = provider.language_server_id()?; + let ls = language_servers.get_by_id(server_id)?; language_config .as_ref() .and_then(|c| { @@ -2038,12 +2042,12 @@ impl Editor { }) }) .and_then(|_| { - if filter(diagnostic, *lsp_id) { + if filter(diagnostic, provider) { Document::lsp_diagnostic_to_diagnostic( &text, language_config.as_deref(), diagnostic, - *lsp_id, + provider.clone(), ls.offset_encoding(), ) } else { |