Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'helix-term/src/commands/lsp.rs')
| -rw-r--r-- | helix-term/src/commands/lsp.rs | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/helix-term/src/commands/lsp.rs b/helix-term/src/commands/lsp.rs index cd041acd..6d6b9744 100644 --- a/helix-term/src/commands/lsp.rs +++ b/helix-term/src/commands/lsp.rs @@ -14,7 +14,8 @@ use tui::{text::Span, widgets::Row}; use super::{align_view, push_jump, Align, Context, Editor}; use helix_core::{ - syntax::LanguageServerFeature, text_annotations::InlineAnnotation, Selection, Uri, + diagnostic::DiagnosticProvider, syntax::LanguageServerFeature, + text_annotations::InlineAnnotation, Selection, Uri, }; use helix_stdx::path; use helix_view::{ @@ -31,13 +32,7 @@ use crate::{ ui::{self, overlay::overlaid, FileLocation, Picker, Popup, PromptEvent}, }; -use std::{ - cmp::Ordering, - collections::{BTreeMap, HashSet}, - fmt::Display, - future::Future, - path::Path, -}; +use std::{cmp::Ordering, collections::HashSet, fmt::Display, future::Future, path::Path}; /// Gets the first language server that is attached to a document which supports a specific feature. /// If there is no configured language server that supports the feature, this displays a status message. @@ -209,7 +204,7 @@ type DiagnosticsPicker = Picker<PickerDiagnostic, DiagnosticStyles>; fn diag_picker( cx: &Context, - diagnostics: BTreeMap<Uri, Vec<(lsp::Diagnostic, LanguageServerId)>>, + diagnostics: impl IntoIterator<Item = (Uri, Vec<(lsp::Diagnostic, DiagnosticProvider)>)>, format: DiagnosticsFormat, ) -> DiagnosticsPicker { // TODO: drop current_path comparison and instead use workspace: bool flag? @@ -219,8 +214,11 @@ fn diag_picker( for (uri, diags) in diagnostics { flat_diag.reserve(diags.len()); - for (diag, ls) in diags { - if let Some(ls) = cx.editor.language_server_by_id(ls) { + for (diag, provider) in diags { + if let Some(ls) = provider + .language_server_id() + .and_then(|id| cx.editor.language_server_by_id(id)) + { flat_diag.push(PickerDiagnostic { location: Location { uri: uri.clone(), @@ -560,11 +558,7 @@ pub fn diagnostics_picker(cx: &mut Context) { let doc = doc!(cx.editor); if let Some(uri) = doc.uri() { let diagnostics = cx.editor.diagnostics.get(&uri).cloned().unwrap_or_default(); - let picker = diag_picker( - cx, - [(uri, diagnostics)].into(), - DiagnosticsFormat::HideSourcePath, - ); + let picker = diag_picker(cx, [(uri, diagnostics)], DiagnosticsFormat::HideSourcePath); cx.push_layer(Box::new(overlaid(picker))); } } |