diff options
| author | Aram Drevekenin <aram@poor.dev> | 2024-08-16 14:00:01 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-16 14:00:01 +0200 |
| commit | 056537d3eef06cddc60dc13b715a41766bb1fe9d (patch) | |
| tree | ff7e107e992e4c98ac60ac88da7215cb0beb668a /zellij-server/src/plugins/plugin_loader.rs | |
| parent | docs(changelog): CommandPaneReRun plugin event (diff) | |
| download | sl0ppij-056537d3eef06cddc60dc13b715a41766bb1fe9d.tar.gz sl0ppij-056537d3eef06cddc60dc13b715a41766bb1fe9d.tar.xz sl0ppij-056537d3eef06cddc60dc13b715a41766bb1fe9d.zip | |
feat(ux): first run setup-wizard (#3556)
* separate saved/runtime structure, kind of working
* serializing config
* work
* work
* save config through the configuration screen
* work
* startup wizard
* style(code): cleanups
* fix(session): reload config from disk when switching sessions
* style(fmt): rustfmt
* fix(config): propagate cli config options to screen
* style(fmt): rustfmt
Diffstat (limited to 'zellij-server/src/plugins/plugin_loader.rs')
| -rw-r--r-- | zellij-server/src/plugins/plugin_loader.rs | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/zellij-server/src/plugins/plugin_loader.rs b/zellij-server/src/plugins/plugin_loader.rs index 51ca3e16..7613da09 100644 --- a/zellij-server/src/plugins/plugin_loader.rs +++ b/zellij-server/src/plugins/plugin_loader.rs @@ -70,7 +70,7 @@ pub struct PluginLoader<'a> { default_layout: Box<Layout>, layout_dir: Option<PathBuf>, default_mode: InputMode, - keybinds: Option<Keybinds>, + keybinds: Keybinds, } impl<'a> PluginLoader<'a> { @@ -90,7 +90,7 @@ impl<'a> PluginLoader<'a> { default_shell: Option<TerminalAction>, default_layout: Box<Layout>, layout_dir: Option<PathBuf>, - default_mode: InputMode, + base_modes: &HashMap<ClientId, InputMode>, keybinds: &HashMap<ClientId, Keybinds>, ) -> Result<()> { let err_context = || format!("failed to reload plugin {plugin_id} from memory"); @@ -100,7 +100,11 @@ impl<'a> PluginLoader<'a> { return Err(anyhow!("No connected clients, cannot reload plugin")); } let first_client_id = connected_clients.remove(0); - let keybinds = keybinds.get(&first_client_id).cloned(); + let keybinds = keybinds.get(&first_client_id).cloned().unwrap_or_default(); + let default_mode = base_modes + .get(&first_client_id) + .cloned() + .unwrap_or_default(); let mut plugin_loader = PluginLoader::new_from_existing_plugin_attributes( &plugin_cache, @@ -157,7 +161,7 @@ impl<'a> PluginLoader<'a> { skip_cache: bool, layout_dir: Option<PathBuf>, default_mode: InputMode, - keybinds: Option<Keybinds>, + keybinds: Keybinds, ) -> Result<()> { let err_context = || format!("failed to start plugin {plugin_id} for client {client_id}"); let mut plugin_loader = PluginLoader::new( @@ -233,7 +237,7 @@ impl<'a> PluginLoader<'a> { default_layout: Box<Layout>, layout_dir: Option<PathBuf>, default_mode: InputMode, - keybinds: Option<Keybinds>, + keybinds: Keybinds, ) -> Result<()> { let mut new_plugins = HashSet::new(); for plugin_id in plugin_map.lock().unwrap().plugin_ids() { @@ -286,7 +290,7 @@ impl<'a> PluginLoader<'a> { default_shell: Option<TerminalAction>, default_layout: Box<Layout>, layout_dir: Option<PathBuf>, - default_mode: InputMode, + base_modes: &HashMap<ClientId, InputMode>, keybinds: &HashMap<ClientId, Keybinds>, ) -> Result<()> { let err_context = || format!("failed to reload plugin id {plugin_id}"); @@ -297,7 +301,11 @@ impl<'a> PluginLoader<'a> { return Err(anyhow!("No connected clients, cannot reload plugin")); } let first_client_id = connected_clients.remove(0); - let keybinds = keybinds.get(&first_client_id).cloned(); + let keybinds = keybinds.get(&first_client_id).cloned().unwrap_or_default(); + let default_mode = base_modes + .get(&first_client_id) + .cloned() + .unwrap_or_default(); let mut plugin_loader = PluginLoader::new_from_existing_plugin_attributes( &plugin_cache, @@ -350,7 +358,7 @@ impl<'a> PluginLoader<'a> { default_layout: Box<Layout>, layout_dir: Option<PathBuf>, default_mode: InputMode, - keybinds: Option<Keybinds>, + keybinds: Keybinds, ) -> Result<Self> { let plugin_own_data_dir = ZELLIJ_SESSION_CACHE_DIR .join(Url::from(&plugin.location).to_string()) @@ -399,7 +407,7 @@ impl<'a> PluginLoader<'a> { default_layout: Box<Layout>, layout_dir: Option<PathBuf>, default_mode: InputMode, - keybinds: Option<Keybinds>, + keybinds: Keybinds, ) -> Result<Self> { let err_context = || "Failed to find existing plugin"; let (running_plugin, _subscriptions, _workers) = { @@ -455,7 +463,7 @@ impl<'a> PluginLoader<'a> { default_layout: Box<Layout>, layout_dir: Option<PathBuf>, default_mode: InputMode, - keybinds: Option<Keybinds>, + keybinds: Keybinds, ) -> Result<Self> { let err_context = || "Failed to find existing plugin"; let running_plugin = { @@ -851,11 +859,7 @@ impl<'a> PluginLoader<'a> { layout_dir: self.layout_dir.clone(), default_mode: self.default_mode.clone(), subscriptions: Arc::new(Mutex::new(HashSet::new())), - keybinds: self - .keybinds - .as_ref() - .unwrap_or_else(|| &self.client_attributes.keybinds) - .clone(), + keybinds: self.keybinds.clone(), stdin_pipe, stdout_pipe, }; |
