Skip to main content

GrepPreviewHighlighter

Trait GrepPreviewHighlighter 

Source
pub trait GrepPreviewHighlighter: Send + Sync {
    // Required method
    fn highlight_line(&self, path: &Path, line: &str) -> Vec<DisplaySpan>;
}
Expand description

:picker grep <pattern>. Shells out to a configurable backend (rg, ag, grep, or auto-detected at invocation time) and walks its output line-by-line.

Sync subprocess for v1 (matches Files / Recent design – users invoke explicitly; brief wait is acceptable). The :picker grep ergonomic equivalent of vertico-buffer live-grep with prescient ranking ships once the async init seat path lands; until then this is the simplest path that respects the configurable-backend requirement.

Captures Arc<ConfigRegistry> at construction so the backend choice is read at every invocation (lets the user :set picker.grep.backend = "ag" mid-session and see it take effect on the next :picker grep). PH.3: off-thread syntax highlighter for grep preview lines. lattice-picker deliberately has NO lattice-syntax dependency (the structural off-thread guarantee — a source physically cannot parse on the render thread). The host injects a concrete impl that selects a grammar by the hit’s file extension and highlights the single preview line. Runs on the grep blocking task; returns display-relative DisplaySpans, empty when no grammar matches (→ plain preview). See docs/dev/architecture/picker-preview-highlight.md §7.

Required Methods§

Source

fn highlight_line(&self, path: &Path, line: &str) -> Vec<DisplaySpan>

Highlight line as source for the file at path. line is the exact text shown as the candidate display (already trimmed), so returned spans are display-relative and need no offset. Empty result ⇒ plain preview.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§