From dc596526420539e44e0bd38db427b3b1a188db9e Mon Sep 17 00:00:00 2001 From: KITAGAWA Yasutaka Date: Sun, 9 Feb 2025 09:27:36 +0900 Subject: [PATCH 1/4] Allow delimiter variable option to be set from config.yaml --- docs/config_file_example.yaml | 1 + src/config/mod.rs | 4 ++++ src/config/yaml.rs | 2 ++ src/finder/structures.rs | 1 + 4 files changed, 8 insertions(+) diff --git a/docs/config_file_example.yaml b/docs/config_file_example.yaml index 8fa2f0c..ae2706f 100644 --- a/docs/config_file_example.yaml +++ b/docs/config_file_example.yaml @@ -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: diff --git a/src/config/mod.rs b/src/config/mod.rs index a5d1e4a..cc788da 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -99,6 +99,10 @@ impl Config { .or_else(|| self.yaml.finder.overrides_var.clone()) } + pub fn delimiter_var(&self) -> Option { + self.yaml.finder.delimiter_var.clone() + } + pub fn tealdeer(&self) -> bool { self.yaml.client.tealdeer } diff --git a/src/config/yaml.rs b/src/config/yaml.rs index 868411b..796d3f6 100644 --- a/src/config/yaml.rs +++ b/src/config/yaml.rs @@ -47,6 +47,7 @@ pub struct Finder { pub command: FinderChoice, pub overrides: Option, pub overrides_var: Option, + pub delimiter_var: Option, } fn finder_deserialize<'de, D>(deserializer: D) -> Result @@ -158,6 +159,7 @@ impl Default for Finder { command: FinderChoice::Fzf, overrides: None, overrides_var: None, + delimiter_var: None, } } } diff --git a/src/finder/structures.rs b/src/finder/structures.rs index a055194..4b6726b 100644 --- a/src/finder/structures.rs +++ b/src/finder/structures.rs @@ -66,6 +66,7 @@ impl Opts { overrides: CONFIG.fzf_overrides_var(), suggestion_type: SuggestionType::SingleRecommendation, prevent_select1: false, + delimiter: CONFIG.delimiter_var(), ..Default::default() } } From 2a87d5ec08e8a3f89b8fed807f62f696f2764205 Mon Sep 17 00:00:00 2001 From: alexis-opolka <53085471+alexis-opolka@users.noreply.github.com> Date: Sun, 9 Feb 2025 14:46:11 +0100 Subject: [PATCH 2/4] Update Navi's configuration documentation Signed-off-by: alexis-opolka <53085471+alexis-opolka@users.noreply.github.com> --- docs/navi_config.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/docs/navi_config.md b/docs/navi_config.md index 553c850..b8ee9ec 100644 --- a/docs/navi_config.md +++ b/docs/navi_config.md @@ -6,6 +6,8 @@ - [Changing colors](#changing-colors) - [Resizing columns](#resizing-columns) - [Overriding fzf options](#overriding-fzf-options) + - [Defining your own delimiter](#defining-your-own-delimiter) + # Paths and Environment Variables @@ -92,3 +94,19 @@ FZF_DEFAULT_OPTS="--height 3" navi ``` In addition, this can be set by properly configuring _navi_'s `config.yaml`. Please check `navi --help` for more instructions. + +## Defining your own delimiter + +Navi allows you to define your own delimiter to parse the selected result for a variable in your cheats.\ +It is equivalent to defining `--delimiter` used with `--column`. + +You can define it as such: + +```yaml +finder: + delimiter_var: +``` + +> [!CAUTION] +> Defining the delimiter via the configuration file means that Navi will use this delimiter by default for +> every variable using the `--column` instruction. From 08e96d00532a65ad2872a0cf5476fe8b2eb02897 Mon Sep 17 00:00:00 2001 From: alexis-opolka Date: Wed, 12 Feb 2025 12:18:26 +0000 Subject: [PATCH 3/4] Update documentation on how to override the delimiter_var configuration Signed-off-by: alexis-opolka --- docs/navi_config.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/docs/navi_config.md b/docs/navi_config.md index b8ee9ec..781777a 100644 --- a/docs/navi_config.md +++ b/docs/navi_config.md @@ -104,9 +104,20 @@ You can define it as such: ```yaml finder: - delimiter_var: + delimiter_var: ### By default the expression is \s\s ``` > [!CAUTION] > Defining the delimiter via the configuration file means that Navi will use this delimiter by default for > every variable using the `--column` instruction. + +You can override this configuration with the `--delimiter` instruction in the variable definition of your cheatsheet. + +It can be overriden like this: + +```yaml +echo + +$ image_id: ... --- --column 3 --header-lines 1 --delimiter '\s\s+' # <-- This variable uses \s\s+ as a delimiter +$ image_tag: ... --- --column 3 --header-lines 1 # <-- This variable uses the default delimiter +``` From 4fdd371f68ca18652c491c74a83779cc2a50d7c7 Mon Sep 17 00:00:00 2001 From: Alexis Opolka <53085471+alexis-opolka@users.noreply.github.com> Date: Thu, 13 Feb 2025 13:29:50 +0100 Subject: [PATCH 4/4] Update docs/navi_config.md Co-authored-by: KITAGAWA Yasutaka --- docs/navi_config.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/navi_config.md b/docs/navi_config.md index 781777a..dbbdac5 100644 --- a/docs/navi_config.md +++ b/docs/navi_config.md @@ -104,7 +104,7 @@ You can define it as such: ```yaml finder: - delimiter_var: ### By default the expression is \s\s + delimiter_var: ### By default the expression is \s\s+ ``` > [!CAUTION]