Skip to main content

QuickOpenProvider

Trait QuickOpenProvider 

Source
pub trait QuickOpenProvider: Send + Sync {
    // Required methods
    fn prefix(&self) -> &str;
    fn name(&self) -> &str;
    fn hint(&self) -> &str;
    fn suggestions(
        &self,
        query: &str,
        context: &QuickOpenContext,
    ) -> Vec<Suggestion>;
    fn on_select(
        &self,
        selected_index: Option<usize>,
        query: &str,
        context: &QuickOpenContext,
    ) -> QuickOpenResult;

    // Provided method
    fn preview(
        &self,
        _selected_index: usize,
        _context: &QuickOpenContext,
    ) -> Option<(String, Option<usize>)> { ... }
}
Expand description

Trait for quick open providers

Each provider handles a specific prefix and provides suggestions for that domain (files, commands, buffers, etc.)

Required Methods§

Source

fn prefix(&self) -> &str

The prefix that triggers this provider (e.g., “>”, “#”, “:”) Empty string means this is the default provider (no prefix)

Source

fn name(&self) -> &str

Human-readable name for this provider

Source

fn hint(&self) -> &str

Short hint shown in the status bar (e.g., “> Commands”)

Source

fn suggestions( &self, query: &str, context: &QuickOpenContext, ) -> Vec<Suggestion>

Generate suggestions for the given query

The query has already had the prefix stripped.

Source

fn on_select( &self, selected_index: Option<usize>, query: &str, context: &QuickOpenContext, ) -> QuickOpenResult

Handle selection of a suggestion

selected_index is the index into the suggestions array returned by suggestions(). query is the original query (without prefix).

Provided Methods§

Source

fn preview( &self, _selected_index: usize, _context: &QuickOpenContext, ) -> Option<(String, Option<usize>)>

Optional: provide a preview for the selected suggestion Returns a file path and optional line number for preview

Implementors§