reovim_plugin_profiles/
lib.rs1use {
9 reovim_core::{
10 command_line::ExCommandHandler,
11 event_bus::{
12 DynEvent, EventBus, EventResult,
13 core_events::{
14 ProfileListEvent, ProfileLoadEvent, ProfileSaveEvent, RegisterExCommand,
15 },
16 },
17 plugin::{Plugin, PluginContext, PluginId, PluginStateRegistry},
18 },
19 std::{collections::HashMap, sync::Arc},
20};
21
22pub struct ProfilesPlugin;
24
25impl Plugin for ProfilesPlugin {
26 fn id(&self) -> PluginId {
27 PluginId::new("core:profiles")
28 }
29
30 fn build(&self, _ctx: &mut PluginContext) {
31 }
33
34 fn subscribe(&self, bus: &EventBus, _state: Arc<PluginStateRegistry>) {
35 let mut subcommands = HashMap::new();
37
38 subcommands.insert(
40 "list".to_string(),
41 Box::new(ExCommandHandler::ZeroArg {
42 event_constructor: || DynEvent::new(ProfileListEvent),
43 description: "List all available profiles",
44 }),
45 );
46
47 subcommands.insert(
49 "load".to_string(),
50 Box::new(ExCommandHandler::SingleArg {
51 event_constructor: |name| DynEvent::new(ProfileLoadEvent { name }),
52 description: "Load a profile by name",
53 }),
54 );
55
56 subcommands.insert(
58 "save".to_string(),
59 Box::new(ExCommandHandler::SingleArg {
60 event_constructor: |name| DynEvent::new(ProfileSaveEvent { name }),
61 description: "Save current settings as a profile",
62 }),
63 );
64
65 bus.emit(RegisterExCommand::new(
67 "profile",
68 ExCommandHandler::Subcommand {
69 subcommands,
70 description: "Manage configuration profiles",
71 },
72 ));
73
74 tracing::debug!("ProfilesPlugin: Registered :profile command with subcommands");
75
76 bus.subscribe::<ProfileListEvent, _>(100, move |_event, ctx| {
79 tracing::info!("ProfileListEvent received - profile picker UI not yet implemented");
80 ctx.request_render();
82 EventResult::Handled
83 });
84
85 tracing::debug!("ProfilesPlugin: Subscribed to ProfileListEvent");
86 }
87}