summaryrefslogtreecommitdiffstats
path: root/zellij-tile
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2023-07-25 10:04:12 +0200
committerGitHub <noreply@github.com>2023-07-25 10:04:12 +0200
commitc95d0e769f31b21f5e2d4aaf6465468344f1bfd6 (patch)
tree9589f0875b91b73460b807e90817907bf3d7d8c6 /zellij-tile
parent6cf795a7df6c83b65a4535b6af0338b4a0b1742f (diff)
feat(plugins): make plugins configurable (#2646)
* work * make every plugin entry point configurable * make integration tests pass * make e2e tests pass * add test for plugin configuration * add test snapshot * add plugin config parsing test * cleanups * style(fmt): rustfmt * style(comment): remove commented code
Diffstat (limited to 'zellij-tile')
-rw-r--r--zellij-tile/src/lib.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/zellij-tile/src/lib.rs b/zellij-tile/src/lib.rs
index 98f141942..7bcaf4738 100644
--- a/zellij-tile/src/lib.rs
+++ b/zellij-tile/src/lib.rs
@@ -19,6 +19,7 @@ pub mod prelude;
pub mod shim;
use serde::{Deserialize, Serialize};
+use std::collections::BTreeMap;
use zellij_utils::data::Event;
/// This trait should be implemented - once per plugin - on a struct (normally representing the
@@ -27,7 +28,7 @@ use zellij_utils::data::Event;
#[allow(unused_variables)]
pub trait ZellijPlugin: Default {
/// Will be called when the plugin is loaded, this is a good place to [`subscribe`](shim::subscribe) to events that are interesting for this plugin.
- fn load(&mut self) {}
+ fn load(&mut self, configuration: BTreeMap<String, String>) {}
/// Will be called with an [`Event`](prelude::Event) if the plugin is subscribed to said event.
/// If the plugin returns `true` from this function, Zellij will know it should be rendered and call its `render` function.
fn update(&mut self, event: Event) -> bool {
@@ -103,7 +104,11 @@ macro_rules! register_plugin {
#[no_mangle]
fn load() {
STATE.with(|state| {
- state.borrow_mut().load();
+ let configuration = $crate::shim::object_from_stdin()
+ .context($crate::PLUGIN_MISMATCH)
+ .to_stdout()
+ .unwrap();
+ state.borrow_mut().load(configuration);
});
}