11use crate :: actions:: Action ;
22use crate :: plugin:: Plugin ;
3+ use eframe:: egui;
34use fuzzy_matcher:: skim:: SkimMatcherV2 ;
45use fuzzy_matcher:: FuzzyMatcher ;
56use serde:: { Deserialize , Serialize } ;
7+ use std:: sync:: atomic:: { AtomicBool , Ordering } ;
68
79pub const SHELL_CMDS_FILE : & str = "shell_cmds.json" ;
810
@@ -17,6 +19,25 @@ pub struct ShellCmdEntry {
1719 pub keep_open : bool ,
1820}
1921
22+ #[ derive( Serialize , Deserialize , Clone ) ]
23+ pub struct ShellPluginSettings {
24+ pub open_in_wezterm : bool ,
25+ }
26+
27+ impl Default for ShellPluginSettings {
28+ fn default ( ) -> Self {
29+ Self {
30+ open_in_wezterm : false ,
31+ }
32+ }
33+ }
34+
35+ static USE_WEZTERM : AtomicBool = AtomicBool :: new ( false ) ;
36+
37+ pub fn use_wezterm ( ) -> bool {
38+ USE_WEZTERM . load ( Ordering :: Relaxed )
39+ }
40+
2041fn default_autocomplete ( ) -> bool {
2142 true
2243}
@@ -220,4 +241,25 @@ impl Plugin for ShellPlugin {
220241 } ,
221242 ]
222243 }
244+
245+ fn default_settings ( & self ) -> Option < serde_json:: Value > {
246+ serde_json:: to_value ( ShellPluginSettings :: default ( ) ) . ok ( )
247+ }
248+
249+ fn apply_settings ( & mut self , value : & serde_json:: Value ) {
250+ if let Ok ( cfg) = serde_json:: from_value :: < ShellPluginSettings > ( value. clone ( ) ) {
251+ USE_WEZTERM . store ( cfg. open_in_wezterm , Ordering :: Relaxed ) ;
252+ }
253+ }
254+
255+ fn settings_ui ( & mut self , ui : & mut egui:: Ui , value : & mut serde_json:: Value ) {
256+ let mut cfg: ShellPluginSettings =
257+ serde_json:: from_value ( value. clone ( ) ) . unwrap_or_default ( ) ;
258+ ui. checkbox ( & mut cfg. open_in_wezterm , "Open commands in WezTerm" ) ;
259+ USE_WEZTERM . store ( cfg. open_in_wezterm , Ordering :: Relaxed ) ;
260+ match serde_json:: to_value ( & cfg) {
261+ Ok ( v) => * value = v,
262+ Err ( e) => tracing:: error!( "failed to serialize shell settings: {e}" ) ,
263+ }
264+ }
223265}
0 commit comments