reovim_plugin_pickers/
lib.rs

1//! Built-in pickers plugin for reovim
2//!
3//! This plugin provides all built-in pickers for the Microscope fuzzy finder:
4//! - Files picker (find project files)
5//! - Buffers picker (switch between open buffers)
6//! - Grep picker (live grep with ripgrep)
7//! - Commands picker (command palette)
8//! - Recent picker (recently opened files)
9//! - Themes picker (colorscheme selector)
10//! - Help picker (help tags)
11//! - Keymaps picker (view keybindings)
12//! - Profiles picker (configuration profiles)
13//!
14//! These pickers are registered in the `PickerRegistry` when the plugin is loaded.
15
16mod buffers;
17mod commands;
18mod files;
19mod grep;
20mod help;
21mod keymaps;
22mod profiles;
23mod recent;
24mod syntax_helper;
25mod themes;
26
27use std::{any::TypeId, sync::Arc};
28
29use {
30    reovim_core::plugin::{Plugin, PluginContext, PluginId, PluginStateRegistry},
31    reovim_plugin_microscope::PickerRegistry,
32};
33
34// Re-export picker types
35pub use {
36    buffers::BuffersPicker,
37    commands::{CommandInfo, CommandsPicker},
38    files::FilesPicker,
39    grep::GrepPicker,
40    help::{HelpEntry, HelpPicker},
41    keymaps::{KeymapEntry, KeymapsPicker},
42    profiles::ProfilesPicker,
43    recent::RecentPicker,
44    themes::ThemesPicker,
45};
46
47/// Plugin that registers all built-in pickers
48pub struct PickersPlugin;
49
50impl Plugin for PickersPlugin {
51    fn id(&self) -> PluginId {
52        PluginId::new("reovim:pickers")
53    }
54
55    fn name(&self) -> &'static str {
56        "Built-in Pickers"
57    }
58
59    fn description(&self) -> &'static str {
60        "Files, buffers, grep, commands, and more pickers"
61    }
62
63    fn dependencies(&self) -> Vec<TypeId> {
64        // Depends on MicroscopePlugin for PickerRegistry
65        vec![TypeId::of::<reovim_plugin_microscope::MicroscopePlugin>()]
66    }
67
68    fn build(&self, _ctx: &mut PluginContext) {
69        // No commands to register - pickers are data providers
70    }
71
72    fn init_state(&self, registry: &PluginStateRegistry) {
73        // Ensure PickerRegistry exists (created by MicroscopePlugin, but register if not)
74        if !registry.contains::<PickerRegistry>() {
75            registry.register(PickerRegistry::new());
76        }
77
78        // Register all built-in pickers
79        registry.with_mut::<PickerRegistry, _, _>(|picker_registry| {
80            picker_registry.register(Arc::new(FilesPicker::new()));
81            picker_registry.register(Arc::new(BuffersPicker::new()));
82            picker_registry.register(Arc::new(GrepPicker::new()));
83            picker_registry.register(Arc::new(CommandsPicker::new()));
84            picker_registry.register(Arc::new(RecentPicker::new()));
85            picker_registry.register(Arc::new(ThemesPicker::new()));
86            picker_registry.register(Arc::new(HelpPicker::new()));
87            picker_registry.register(Arc::new(KeymapsPicker::new()));
88            picker_registry.register(Arc::new(ProfilesPicker::new()));
89        });
90    }
91}