Allow delimiter variable option to be set from config.yaml

This commit is contained in:
KITAGAWA Yasutaka 2025-02-09 09:27:36 +09:00
parent 5515367dc8
commit dc59652642
No known key found for this signature in database
GPG key ID: EF503E87E8731A87
4 changed files with 8 additions and 0 deletions

View file

@ -17,6 +17,7 @@ finder:
command: fzf # equivalent to the --finder option
# overrides: --tac # equivalent to the --fzf-overrides option
# overrides_var: --tac # equivalent to the --fzf-overrides-var option
# delimiter_var: \s\s+ # equivalent to the --delimiter option that is used with --column option when you extract a column from the selected result for a variable
# cheats:
# paths:

View file

@ -99,6 +99,10 @@ impl Config {
.or_else(|| self.yaml.finder.overrides_var.clone())
}
pub fn delimiter_var(&self) -> Option<String> {
self.yaml.finder.delimiter_var.clone()
}
pub fn tealdeer(&self) -> bool {
self.yaml.client.tealdeer
}

View file

@ -47,6 +47,7 @@ pub struct Finder {
pub command: FinderChoice,
pub overrides: Option<String>,
pub overrides_var: Option<String>,
pub delimiter_var: Option<String>,
}
fn finder_deserialize<'de, D>(deserializer: D) -> Result<FinderChoice, D::Error>
@ -158,6 +159,7 @@ impl Default for Finder {
command: FinderChoice::Fzf,
overrides: None,
overrides_var: None,
delimiter_var: None,
}
}
}

View file

@ -66,6 +66,7 @@ impl Opts {
overrides: CONFIG.fzf_overrides_var(),
suggestion_type: SuggestionType::SingleRecommendation,
prevent_select1: false,
delimiter: CONFIG.delimiter_var(),
..Default::default()
}
}