Picker

Trait Picker 

Source
pub trait Picker: Send + Sync {
    // Required methods
    fn name(&self) -> &'static str;
    fn title(&self) -> &'static str;
    fn fetch(
        &self,
        ctx: &PickerContext,
    ) -> Pin<Box<dyn Future<Output = Vec<MicroscopeItem>> + Send + '_>>;
    fn on_select(&self, item: &MicroscopeItem) -> MicroscopeAction;

    // Provided methods
    fn prompt(&self) -> &'static str { ... }
    fn preview(
        &self,
        _item: &MicroscopeItem,
        _ctx: &PickerContext,
    ) -> Pin<Box<dyn Future<Output = Option<PreviewContent>> + Send + '_>> { ... }
    fn supports_live_filter(&self) -> bool { ... }
}
Expand description

Trait for implementing microscope pickers

Pickers are responsible for:

  • Fetching items (files, buffers, commands, etc.)
  • Determining actions when an item is selected
  • Optionally providing preview content

§Example

use reovim_plugin_microscope::{Picker, PickerContext, MicroscopeAction, MicroscopeItem};

pub struct MyPicker;

impl Picker for MyPicker {
    fn name(&self) -> &'static str { "my_picker" }
    fn title(&self) -> &'static str { "My Picker" }

    fn fetch(&self, ctx: &PickerContext) -> Pin<Box<dyn Future<Output = Vec<MicroscopeItem>> + Send + '_>> {
        Box::pin(async { vec![] })
    }

    fn on_select(&self, item: &MicroscopeItem) -> MicroscopeAction {
        MicroscopeAction::Nothing
    }
}

Required Methods§

Source

fn name(&self) -> &'static str

Unique identifier for this picker

Source

fn title(&self) -> &'static str

Human-readable title for the picker window

Source

fn fetch( &self, ctx: &PickerContext, ) -> Pin<Box<dyn Future<Output = Vec<MicroscopeItem>> + Send + '_>>

Fetch items asynchronously

Source

fn on_select(&self, item: &MicroscopeItem) -> MicroscopeAction

Handle selection of an item

Provided Methods§

Source

fn prompt(&self) -> &'static str

Prompt string (shown before input)

Source

fn preview( &self, _item: &MicroscopeItem, _ctx: &PickerContext, ) -> Pin<Box<dyn Future<Output = Option<PreviewContent>> + Send + '_>>

Optional: preview content for the selected item

Source

fn supports_live_filter(&self) -> bool

Whether this picker supports live filtering vs full re-fetch If true, the picker only needs to fetch once and nucleo handles filtering If false, the picker needs to re-fetch on each query change (e.g., live grep)

Implementors§