Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'helix-term/src/ui/editor.rs')
| -rw-r--r-- | helix-term/src/ui/editor.rs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index 9ffc3e87..c1d8205e 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -142,6 +142,11 @@ impl EditorView { Self::doc_diagnostics_highlights_into(doc, theme, &mut overlays); if is_focused { + if config.lsp.auto_document_highlight { + if let Some(overlay) = Self::doc_document_highlights(doc, view, theme) { + overlays.push(overlay); + } + } if let Some(tabstops) = Self::tabstop_highlights(doc, theme) { overlays.push(tabstops); } @@ -459,6 +464,27 @@ impl EditorView { ]); } + pub fn doc_document_highlights( + doc: &Document, + view: &View, + theme: &Theme, + ) -> Option<OverlayHighlights> { + let ranges = doc.document_highlights(view.id)?; + if ranges.is_empty() { + return None; + } + + let highlight = theme + .find_highlight_exact("ui.highlight") + .or_else(|| theme.find_highlight_exact("ui.selection")) + .or_else(|| theme.find_highlight_exact("ui.cursor"))?; + + Some(OverlayHighlights::Homogeneous { + highlight, + ranges: ranges.to_vec(), + }) + } + /// Get highlight spans for selections in a document view. pub fn doc_selection_highlights( mode: Mode, |