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§
Sourcefn fetch(
&self,
ctx: &PickerContext,
) -> Pin<Box<dyn Future<Output = Vec<MicroscopeItem>> + Send + '_>>
fn fetch( &self, ctx: &PickerContext, ) -> Pin<Box<dyn Future<Output = Vec<MicroscopeItem>> + Send + '_>>
Fetch items asynchronously
Sourcefn on_select(&self, item: &MicroscopeItem) -> MicroscopeAction
fn on_select(&self, item: &MicroscopeItem) -> MicroscopeAction
Handle selection of an item
Provided Methods§
Sourcefn preview(
&self,
_item: &MicroscopeItem,
_ctx: &PickerContext,
) -> Pin<Box<dyn Future<Output = Option<PreviewContent>> + Send + '_>>
fn preview( &self, _item: &MicroscopeItem, _ctx: &PickerContext, ) -> Pin<Box<dyn Future<Output = Option<PreviewContent>> + Send + '_>>
Optional: preview content for the selected item
Sourcefn supports_live_filter(&self) -> bool
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)