aboutsummaryrefslogtreecommitdiffstats
path: root/default-plugins
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 /default-plugins
parentdocs(changelog): generate session names with custom words list (diff)
downloadsl0ppij-c95d0e769f31b21f5e2d4aaf6465468344f1bfd6.tar.gz
sl0ppij-c95d0e769f31b21f5e2d4aaf6465468344f1bfd6.tar.xz
sl0ppij-c95d0e769f31b21f5e2d4aaf6465468344f1bfd6.zip
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 'default-plugins')
-rw-r--r--default-plugins/compact-bar/src/main.rs3
-rw-r--r--default-plugins/fixture-plugin-for-tests/src/main.rs8
-rw-r--r--default-plugins/status-bar/src/main.rs8
-rw-r--r--default-plugins/strider/src/main.rs3
-rw-r--r--default-plugins/tab-bar/src/main.rs3
5 files changed, 19 insertions, 6 deletions
diff --git a/default-plugins/compact-bar/src/main.rs b/default-plugins/compact-bar/src/main.rs
index 40fa65f5..18c9f12b 100644
--- a/default-plugins/compact-bar/src/main.rs
+++ b/default-plugins/compact-bar/src/main.rs
@@ -2,6 +2,7 @@ mod line;
mod tab;
use std::cmp::{max, min};
+use std::collections::BTreeMap;
use std::convert::TryInto;
use tab::get_tab_to_focus;
@@ -30,7 +31,7 @@ static ARROW_SEPARATOR: &str = "";
register_plugin!(State);
impl ZellijPlugin for State {
- fn load(&mut self) {
+ fn load(&mut self, configuration: BTreeMap<String, String>) {
set_selectable(false);
subscribe(&[
EventType::TabUpdate,
diff --git a/default-plugins/fixture-plugin-for-tests/src/main.rs b/default-plugins/fixture-plugin-for-tests/src/main.rs
index 20457f13..074aa1a4 100644
--- a/default-plugins/fixture-plugin-for-tests/src/main.rs
+++ b/default-plugins/fixture-plugin-for-tests/src/main.rs
@@ -1,4 +1,5 @@
use serde::{Deserialize, Serialize};
+use std::collections::BTreeMap;
use zellij_tile::prelude::*;
// This is a fixture plugin used only for tests in Zellij
@@ -9,6 +10,7 @@ use zellij_tile::prelude::*;
struct State {
received_events: Vec<Event>,
received_payload: Option<String>,
+ configuration: BTreeMap<String, String>,
}
#[derive(Default, Serialize, Deserialize)]
@@ -35,7 +37,8 @@ register_plugin!(State);
register_worker!(TestWorker, test_worker, TEST_WORKER);
impl ZellijPlugin for State {
- fn load(&mut self) {
+ fn load(&mut self, configuration: BTreeMap<String, String>) {
+ self.configuration = configuration;
subscribe(&[
EventType::InputReceived,
EventType::Key,
@@ -210,6 +213,9 @@ impl ZellijPlugin for State {
Key::Ctrl('x') => {
rename_tab(1, "new tab name");
},
+ Key::Ctrl('z') => {
+ go_to_tab_name(&format!("{:?}", self.configuration));
+ },
_ => {},
},
Event::CustomMessage(message, payload) => {
diff --git a/default-plugins/status-bar/src/main.rs b/default-plugins/status-bar/src/main.rs
index ee14e45d..d768b35e 100644
--- a/default-plugins/status-bar/src/main.rs
+++ b/default-plugins/status-bar/src/main.rs
@@ -8,6 +8,7 @@ use ansi_term::{
Style,
};
+use std::collections::BTreeMap;
use std::fmt::{Display, Error, Formatter};
use zellij_tile::prelude::actions::Action;
use zellij_tile::prelude::*;
@@ -196,7 +197,7 @@ fn color_elements(palette: Palette, different_color_alternates: bool) -> Colored
}
impl ZellijPlugin for State {
- fn load(&mut self) {
+ fn load(&mut self, configuration: BTreeMap<String, String>) {
// TODO: Should be able to choose whether to use the cache through config.
self.tip_name = get_cached_tip_name();
set_selectable(false);
@@ -207,7 +208,10 @@ impl ZellijPlugin for State {
EventType::InputReceived,
EventType::SystemClipboardFailure,
]);
- self.supermode = false; // TODO: from config
+ self.supermode = configuration
+ .get("supermode")
+ .and_then(|s| s.trim().parse().ok())
+ .unwrap_or(false);
self.standby_mode = InputMode::Pane;
if self.supermode {
switch_to_input_mode(&InputMode::Locked); // supermode should start locked (TODO: only
diff --git a/default-plugins/strider/src/main.rs b/default-plugins/strider/src/main.rs
index 24d443d1..35ff92ea 100644
--- a/default-plugins/strider/src/main.rs
+++ b/default-plugins/strider/src/main.rs
@@ -6,6 +6,7 @@ use search::{FileContentsWorker, FileNameWorker, MessageToSearch, ResultsOfSearc
use serde::{Deserialize, Serialize};
use serde_json;
use state::{refresh_directory, FsEntry, State};
+use std::collections::BTreeMap;
use std::{cmp::min, time::Instant};
use zellij_tile::prelude::*;
@@ -18,7 +19,7 @@ register_worker!(
);
impl ZellijPlugin for State {
- fn load(&mut self) {
+ fn load(&mut self, configuration: BTreeMap<String, String>) {
refresh_directory(self);
self.search_state.loading = true;
subscribe(&[
diff --git a/default-plugins/tab-bar/src/main.rs b/default-plugins/tab-bar/src/main.rs
index 05fdd560..fc67ef91 100644
--- a/default-plugins/tab-bar/src/main.rs
+++ b/default-plugins/tab-bar/src/main.rs
@@ -2,6 +2,7 @@ mod line;
mod tab;
use std::cmp::{max, min};
+use std::collections::BTreeMap;
use std::convert::TryInto;
use tab::get_tab_to_focus;
@@ -30,7 +31,7 @@ static ARROW_SEPARATOR: &str = "";
register_plugin!(State);
impl ZellijPlugin for State {
- fn load(&mut self) {
+ fn load(&mut self, configuration: BTreeMap<String, String>) {
set_selectable(false);
subscribe(&[
EventType::TabUpdate,