summaryrefslogtreecommitdiffstats
path: root/zellij-utils/src
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2023-11-30 18:10:50 +0100
committerGitHub <noreply@github.com>2023-11-30 18:10:50 +0100
commitb0f36540fe3cb439fd0981cbb1ef5df6668ddbdf (patch)
tree6d1d7329361ad25506cc7e1cb7ea135b9434191b /zellij-utils/src
parent65bea269a45784d5b70bf4290bf55c2ddcd670e4 (diff)
feat(plugins): skip plugin cache flag (#2971)
* feat(plugins): allow explicitly skipping the plugin cache when loading * style(fmt): rustfmt * fix tests
Diffstat (limited to 'zellij-utils/src')
-rw-r--r--zellij-utils/src/cli.rs10
-rw-r--r--zellij-utils/src/input/actions.rs46
-rw-r--r--zellij-utils/src/kdl/mod.rs8
-rw-r--r--zellij-utils/src/plugin_api/action.proto2
-rw-r--r--zellij-utils/src/plugin_api/action.rs34
-rw-r--r--zellij-utils/src/snapshots/zellij_utils__setup__setup_test__default_config_with_no_cli_arguments.snap1
-rw-r--r--zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_env_vars_override_config_env_vars.snap1
-rw-r--r--zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_plugins_override_config_plugins.snap1
-rw-r--r--zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_themes_override_config_themes.snap1
-rw-r--r--zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_ui_config_overrides_config_ui_config.snap1
10 files changed, 89 insertions, 16 deletions
diff --git a/zellij-utils/src/cli.rs b/zellij-utils/src/cli.rs
index ee4024491..97a0cd778 100644
--- a/zellij-utils/src/cli.rs
+++ b/zellij-utils/src/cli.rs
@@ -242,6 +242,10 @@ pub enum Sessions {
conflicts_with("floating")
)]
in_place: bool,
+
+ /// Skip the memory and HD cache and force recompile of the plugin (good for development)
+ #[clap(short, long, value_parser, default_value("false"), takes_value(false))]
+ skip_plugin_cache: bool,
},
/// Edit file with default $EDITOR / $VISUAL
#[clap(visible_alias = "e")]
@@ -417,6 +421,8 @@ pub enum CliAction {
start_suspended: bool,
#[clap(long, value_parser)]
configuration: Option<PluginUserConfiguration>,
+ #[clap(short, long, value_parser)]
+ skip_plugin_cache: bool,
},
/// Open the specified file in a new zellij pane with your default EDITOR
Edit {
@@ -526,6 +532,8 @@ pub enum CliAction {
url: Url,
#[clap(short, long, value_parser)]
configuration: Option<PluginUserConfiguration>,
+ #[clap(short, long, value_parser)]
+ skip_plugin_cache: bool,
},
LaunchPlugin {
#[clap(short, long, value_parser)]
@@ -535,6 +543,8 @@ pub enum CliAction {
url: Url,
#[clap(short, long, value_parser)]
configuration: Option<PluginUserConfiguration>,
+ #[clap(short, long, value_parser)]
+ skip_plugin_cache: bool,
},
RenameSession {
name: String,
diff --git a/zellij-utils/src/input/actions.rs b/zellij-utils/src/input/actions.rs
index 8fe0a3285..8af5d28ee 100644
--- a/zellij-utils/src/input/actions.rs
+++ b/zellij-utils/src/input/actions.rs
@@ -209,10 +209,10 @@ pub enum Action {
LeftClick(Position),
RightClick(Position),
MiddleClick(Position),
- LaunchOrFocusPlugin(RunPlugin, bool, bool, bool), // bools => should float,
- // move_to_focused_tab, should_open_in_place
- LaunchPlugin(RunPlugin, bool, bool), // bools => should float,
- // should_open_in_place
+ LaunchOrFocusPlugin(RunPlugin, bool, bool, bool, bool), // bools => should float,
+ // move_to_focused_tab, should_open_in_place, skip_cache
+ LaunchPlugin(RunPlugin, bool, bool, bool), // bools => should float,
+ // should_open_in_place, skip_cache
LeftMouseRelease(Position),
RightMouseRelease(Position),
MiddleMouseRelease(Position),
@@ -238,9 +238,12 @@ pub enum Action {
/// Query all tab names
QueryTabNames,
/// Open a new tiled (embedded, non-floating) plugin pane
- NewTiledPluginPane(RunPlugin, Option<String>), // String is an optional name
- NewFloatingPluginPane(RunPlugin, Option<String>), // String is an optional name
- NewInPlacePluginPane(RunPlugin, Option<String>), // String is an optional name
+ NewTiledPluginPane(RunPlugin, Option<String>, bool), // String is an optional name, bool is
+ // skip_cache
+ NewFloatingPluginPane(RunPlugin, Option<String>, bool), // String is an optional name, bool is
+ // skip_cache
+ NewInPlacePluginPane(RunPlugin, Option<String>, bool), // String is an optional name, bool is
+ // skip_cache
StartOrReloadPlugin(RunPlugin),
CloseTerminalPane(u32),
ClosePluginPane(u32),
@@ -310,6 +313,7 @@ impl Action {
close_on_exit,
start_suspended,
configuration,
+ skip_plugin_cache,
} => {
let current_dir = get_current_dir();
let cwd = cwd
@@ -325,9 +329,17 @@ impl Action {
configuration: user_configuration,
};
if floating {
- Ok(vec![Action::NewFloatingPluginPane(plugin, name)])
+ Ok(vec![Action::NewFloatingPluginPane(
+ plugin,
+ name,
+ skip_plugin_cache,
+ )])
} else if in_place {
- Ok(vec![Action::NewInPlacePluginPane(plugin, name)])
+ Ok(vec![Action::NewInPlacePluginPane(
+ plugin,
+ name,
+ skip_plugin_cache,
+ )])
} else {
// it is intentional that a new tiled plugin pane cannot include a
// direction
@@ -337,7 +349,11 @@ impl Action {
// is being loaded
// this is not the case with terminal panes for historical reasons of
// backwards compatibility to a time before we had auto layouts
- Ok(vec![Action::NewTiledPluginPane(plugin, name)])
+ Ok(vec![Action::NewTiledPluginPane(
+ plugin,
+ name,
+ skip_plugin_cache,
+ )])
}
} else if !command.is_empty() {
let mut command = command.clone();
@@ -525,6 +541,7 @@ impl Action {
in_place,
move_to_focused_tab,
configuration,
+ skip_plugin_cache,
} => {
let current_dir = get_current_dir();
let run_plugin_location = RunPluginLocation::parse(url.as_str(), Some(current_dir))
@@ -539,6 +556,7 @@ impl Action {
floating,
move_to_focused_tab,
in_place,
+ skip_plugin_cache,
)])
},
CliAction::LaunchPlugin {
@@ -546,6 +564,7 @@ impl Action {
floating,
in_place,
configuration,
+ skip_plugin_cache,
} => {
let current_dir = get_current_dir();
let run_plugin_location = RunPluginLocation::parse(url.as_str(), Some(current_dir))
@@ -555,7 +574,12 @@ impl Action {
_allow_exec_host_cmd: false,
configuration: configuration.unwrap_or_default(),
};
- Ok(vec![Action::LaunchPlugin(run_plugin, floating, in_place)])
+ Ok(vec![Action::LaunchPlugin(
+ run_plugin,
+ floating,
+ in_place,
+ skip_plugin_cache,
+ )])
},
CliAction::RenameSession { name } => Ok(vec![Action::RenameSession(name)]),
}
diff --git a/zellij-utils/src/kdl/mod.rs b/zellij-utils/src/kdl/mod.rs
index 8353b6e74..71f48fc4f 100644
--- a/zellij-utils/src/kdl/mod.rs
+++ b/zellij-utils/src/kdl/mod.rs
@@ -938,6 +938,9 @@ impl TryFrom<(&KdlNode, &Options)> for Action {
let should_open_in_place = command_metadata
.and_then(|c_m| kdl_child_bool_value_for_entry(c_m, "in_place"))
.unwrap_or(false);
+ let skip_plugin_cache = command_metadata
+ .and_then(|c_m| kdl_child_bool_value_for_entry(c_m, "skip_plugin_cache"))
+ .unwrap_or(false);
let current_dir = std::env::current_dir().unwrap_or_else(|_| PathBuf::from("."));
let location = RunPluginLocation::parse(&plugin_path, Some(current_dir))?;
let configuration = KdlLayoutParser::parse_plugin_user_configuration(&kdl_action)?;
@@ -951,6 +954,7 @@ impl TryFrom<(&KdlNode, &Options)> for Action {
should_float,
move_to_focused_tab,
should_open_in_place,
+ skip_plugin_cache,
))
},
"LaunchPlugin" => {
@@ -972,6 +976,9 @@ impl TryFrom<(&KdlNode, &Options)> for Action {
let should_open_in_place = command_metadata
.and_then(|c_m| kdl_child_bool_value_for_entry(c_m, "in_place"))
.unwrap_or(false);
+ let skip_plugin_cache = command_metadata
+ .and_then(|c_m| kdl_child_bool_value_for_entry(c_m, "skip_plugin_cache"))
+ .unwrap_or(false);
let current_dir = std::env::current_dir().unwrap_or_else(|_| PathBuf::from("."));
let location = RunPluginLocation::parse(&plugin_path, Some(current_dir))?;
let configuration = KdlLayoutParser::parse_plugin_user_configuration(&kdl_action)?;
@@ -984,6 +991,7 @@ impl TryFrom<(&KdlNode, &Options)> for Action {
run_plugin,
should_float,
should_open_in_place,
+ skip_plugin_cache,
))
},
"PreviousSwapLayout" => Ok(Action::PreviousSwapLayout),
diff --git a/zellij-utils/src/plugin_api/action.proto b/zellij-utils/src/plugin_api/action.proto
index e9d2a293f..da10d82a8 100644
--- a/zellij-utils/src/plugin_api/action.proto
+++ b/zellij-utils/src/plugin_api/action.proto
@@ -69,6 +69,7 @@ message PaneIdAndShouldFloat {
message NewPluginPanePayload {
string plugin_url = 1;
optional string pane_name = 2;
+ bool skip_plugin_cache = 3;
}
enum SearchDirection {
@@ -88,6 +89,7 @@ message LaunchOrFocusPluginPayload {
optional PluginConfiguration plugin_configuration = 3;
bool move_to_focused_tab = 4;
bool should_open_in_place = 5;
+ bool skip_plugin_cache = 6;
}
message GoToTabNamePayload {
diff --git a/zellij-utils/src/plugin_api/action.rs b/zellij-utils/src/plugin_api/action.rs
index dc8c29380..71eaaa130 100644
--- a/zellij-utils/src/plugin_api/action.rs
+++ b/zellij-utils/src/plugin_api/action.rs
@@ -403,11 +403,13 @@ impl TryFrom<ProtobufAction> for Action {
let should_float = payload.should_float;
let move_to_focused_tab = payload.move_to_focused_tab;
let should_open_in_place = payload.should_open_in_place;
+ let skip_plugin_cache = payload.skip_plugin_cache;
Ok(Action::LaunchOrFocusPlugin(
run_plugin,
should_float,
move_to_focused_tab,
should_open_in_place,
+ skip_plugin_cache,
))
},
_ => Err("Wrong payload for Action::LaunchOrFocusPlugin"),
@@ -431,10 +433,12 @@ impl TryFrom<ProtobufAction> for Action {
let _move_to_focused_tab = payload.move_to_focused_tab; // not actually used in
// this action
let should_open_in_place = payload.should_open_in_place;
+ let skip_plugin_cache = payload.skip_plugin_cache;
Ok(Action::LaunchPlugin(
run_plugin,
should_float,
should_open_in_place,
+ skip_plugin_cache,
))
},
_ => Err("Wrong payload for Action::LaunchOrFocusPlugin"),
@@ -539,7 +543,12 @@ impl TryFrom<ProtobufAction> for Action {
configuration: PluginUserConfiguration::default(),
};
let pane_name = payload.pane_name;
- Ok(Action::NewTiledPluginPane(run_plugin, pane_name))
+ let skip_plugin_cache = payload.skip_plugin_cache;
+ Ok(Action::NewTiledPluginPane(
+ run_plugin,
+ pane_name,
+ skip_plugin_cache,
+ ))
},
_ => Err("Wrong payload for Action::NewTiledPluginPane"),
}
@@ -556,7 +565,12 @@ impl TryFrom<ProtobufAction> for Action {
configuration: PluginUserConfiguration::default(),
};
let pane_name = payload.pane_name;
- Ok(Action::NewFloatingPluginPane(run_plugin, pane_name))
+ let skip_plugin_cache = payload.skip_plugin_cache;
+ Ok(Action::NewFloatingPluginPane(
+ run_plugin,
+ pane_name,
+ skip_plugin_cache,
+ ))
},
_ => Err("Wrong payload for Action::MiddleClick"),
}
@@ -1007,6 +1021,7 @@ impl TryFrom<Action> for ProtobufAction {
should_float,
move_to_focused_tab,
should_open_in_place,
+ skip_plugin_cache,
) => {
let url: Url = Url::from(&run_plugin.location);
Ok(ProtobufAction {
@@ -1018,11 +1033,17 @@ impl TryFrom<Action> for ProtobufAction {
move_to_focused_tab,
should_open_in_place,
plugin_configuration: Some(run_plugin.configuration.try_into()?),
+ skip_plugin_cache,
},
)),
})
},
- Action::LaunchPlugin(run_plugin, should_float, should_open_in_place) => {
+ Action::LaunchPlugin(
+ run_plugin,
+ should_float,
+ should_open_in_place,
+ skip_plugin_cache,
+ ) => {
let url: Url = Url::from(&run_plugin.location);
Ok(ProtobufAction {
name: ProtobufActionName::LaunchPlugin as i32,
@@ -1033,6 +1054,7 @@ impl TryFrom<Action> for ProtobufAction {
move_to_focused_tab: false,
should_open_in_place,
plugin_configuration: Some(run_plugin.configuration.try_into()?),
+ skip_plugin_cache,
},
)),
})
@@ -1115,7 +1137,7 @@ impl TryFrom<Action> for ProtobufAction {
name: ProtobufActionName::QueryTabNames as i32,
optional_payload: None,
}),
- Action::NewTiledPluginPane(run_plugin, pane_name) => {
+ Action::NewTiledPluginPane(run_plugin, pane_name, skip_plugin_cache) => {
let plugin_url: Url = Url::from(&run_plugin.location);
Ok(ProtobufAction {
name: ProtobufActionName::NewTiledPluginPane as i32,
@@ -1123,11 +1145,12 @@ impl TryFrom<Action> for ProtobufAction {
NewPluginPanePayload {
plugin_url: plugin_url.into(),
pane_name,
+ skip_plugin_cache,
},
)),
})
},
- Action::NewFloatingPluginPane(run_plugin, pane_name) => {
+ Action::NewFloatingPluginPane(run_plugin, pane_name, skip_plugin_cache) => {
let plugin_url: Url = Url::from(&run_plugin.location);
Ok(ProtobufAction {
name: ProtobufActionName::NewFloatingPluginPane as i32,
@@ -1135,6 +1158,7 @@ impl TryFrom<Action> for ProtobufAction {
NewPluginPanePayload {
plugin_url: plugin_url.into(),
pane_name,
+ skip_plugin_cache,
},
)),
})
diff --git a/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__default_config_with_no_cli_arguments.snap b/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__default_config_with_no_cli_arguments.snap
index 7d5072a29..35aa55a40 100644
--- a/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__default_config_with_no_cli_arguments.snap
+++ b/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__default_config_with_no_cli_arguments.snap
@@ -2507,6 +2507,7 @@ Config {
true,
true,
false,
+ false,
),
SwitchToMode(
Normal,
diff --git a/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_env_vars_override_config_env_vars.snap b/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_env_vars_override_config_env_vars.snap
index 9c5e198e0..636b8d0d5 100644
--- a/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_env_vars_override_config_env_vars.snap
+++ b/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_env_vars_override_config_env_vars.snap
@@ -2507,6 +2507,7 @@ Config {
true,
true,
false,
+ false,
),
SwitchToMode(
Normal,
diff --git a/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_plugins_override_config_plugins.snap b/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_plugins_override_config_plugins.snap
index 31a921744..f183a0fa1 100644
--- a/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_plugins_override_config_plugins.snap
+++ b/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_plugins_override_config_plugins.snap
@@ -2507,6 +2507,7 @@ Config {
true,
true,
false,
+ false,
),
SwitchToMode(
Normal,
diff --git a/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_themes_override_config_themes.snap b/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_themes_override_config_themes.snap
index a6382c05e..f70502e6e 100644
--- a/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_themes_override_config_themes.snap
+++ b/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_themes_override_config_themes.snap
@@ -2507,6 +2507,7 @@ Config {
true,
true,
false,
+ false,
),
SwitchToMode(
Normal,
diff --git a/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_ui_config_overrides_config_ui_config.snap b/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_ui_config_overrides_config_ui_config.snap
index 9dc3f74e1..b0329b324 100644
--- a/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_ui_config_overrides_config_ui_config.snap
+++ b/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_ui_config_overrides_config_ui_config.snap
@@ -2507,6 +2507,7 @@ Config {
true,
true,
false,
+ false,
),
SwitchToMode(
Normal,