diff options
author | Aram Drevekenin <aram@poor.dev> | 2022-10-24 19:21:03 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-24 19:21:03 +0200 |
commit | 88647ae275df793403ce24e44d585ade934ee35a (patch) | |
tree | 42e58b376c1667061703b538052c965e71874d34 /zellij-utils | |
parent | 63cf3a6b01734b449c084d6da7b4022bbe6519ef (diff) |
fix(various): minor fixes before 32 (#1841)
* fix(layouts): point to layout documentation
* adjust shell completions
* comment about clear-defaults in the config
Diffstat (limited to 'zellij-utils')
20 files changed, 94 insertions, 89 deletions
diff --git a/zellij-utils/assets/completions/comp.bash b/zellij-utils/assets/completions/comp.bash index 210fd25da..867468090 100644 --- a/zellij-utils/assets/completions/comp.bash +++ b/zellij-utils/assets/completions/comp.bash @@ -1,4 +1,4 @@ -function zp () { zellij run --name "$*" -- bash -c "$*";} # zellij pane -function zpf () { zellij run --name "$*" --floating -- bash -c "$*";} # zellij pane floating -function zo () { zellij edit "$*";} # zellij open -function zof () { zellij edit --floating "$*";} # zellij open floating +function zr () { zellij run --name "$*" -- bash -ic "$*";} +function zrf () { zellij run --name "$*" --floating -- bash -ic "$*";} +function ze () { zellij edit "$*";} +function zef () { zellij edit --floating "$*";} diff --git a/zellij-utils/assets/completions/comp.fish b/zellij-utils/assets/completions/comp.fish index 286150b84..a46af36b6 100644 --- a/zellij-utils/assets/completions/comp.fish +++ b/zellij-utils/assets/completions/comp.fish @@ -6,19 +6,15 @@ complete -c zellij -n "__fish_seen_subcommand_from a" -f -a "(__fish_complete_se complete -c zellij -n "__fish_seen_subcommand_from kill-session" -f -a "(__fish_complete_sessions)" -d "Session" complete -c zellij -n "__fish_seen_subcommand_from k" -f -a "(__fish_complete_sessions)" -d "Session" complete -c zellij -n "__fish_seen_subcommand_from setup" -l "generate-completion" -x -a "bash elvish fish zsh powershell" -d "Shell" -function zp - # zellij pane +function zr command zellij run --name "$argv" -- fish -c "$argv" end -function zpf - # zellij pane floating +function zrf command zellij run --name "$argv" --floating -- fish -c "$argv" end -function zo - # zellij open +function ze command zellij edit $argv end -function zof - # zellij open floating +function zef command zellij edit --floating $argv end diff --git a/zellij-utils/assets/completions/comp.zsh b/zellij-utils/assets/completions/comp.zsh index 5c5c4af34..d9c737651 100644 --- a/zellij-utils/assets/completions/comp.zsh +++ b/zellij-utils/assets/completions/comp.zsh @@ -1,4 +1,4 @@ -function zp () { zellij run --name "$*" -- zsh -c "$*";} # zellij pane -function zpf () { zellij run --name "$*" --floating -- zsh -c "$*";} # zellij pane floating -function zo () { zellij edit "$*";} # zellij open -function zof () { zellij edit --floating "$*";} # zellij open floating +function zr () { zellij run --name "$*" -- zsh -ic "$*";} +function zrf () { zellij run --name "$*" --floating -- zsh -ic "$*";} +function ze () { zellij edit "$*";} +function zef () { zellij edit --floating "$*";} diff --git a/zellij-utils/assets/config/default.kdl b/zellij-utils/assets/config/default.kdl index 227dea433..9689be1ba 100644 --- a/zellij-utils/assets/config/default.kdl +++ b/zellij-utils/assets/config/default.kdl @@ -1,3 +1,4 @@ +// If you'd like to override the default keybindings completely, be sure to change "keybinds" to "keybinds clear-defaults=true" keybinds { normal { // uncomment this and adjust key if using copy_on_select=false diff --git a/zellij-utils/src/input/actions.rs b/zellij-utils/src/input/actions.rs index edfcd713e..a9ab37053 100644 --- a/zellij-utils/src/input/actions.rs +++ b/zellij-utils/src/input/actions.rs @@ -357,6 +357,7 @@ impl Action { src: Some(NamedSource::new(layout_path.as_path().as_os_str().to_string_lossy().to_string(), String::from(raw_layout))), offset: Some(kdl_error.span.offset()), len: Some(kdl_error.span.len()), + help_message: None, }; let report: Report = kdl_error.into(); format!("{:?}", report) diff --git a/zellij-utils/src/input/config.rs b/zellij-utils/src/input/config.rs index ca161c94b..5cdc509ff 100644 --- a/zellij-utils/src/input/config.rs +++ b/zellij-utils/src/input/config.rs @@ -36,17 +36,10 @@ pub struct KdlError { pub src: Option<NamedSource>, pub offset: Option<usize>, pub len: Option<usize>, + pub help_message: Option<String>, } impl KdlError { - pub fn new_with_location(error_message: String, offset: usize, len: usize) -> Self { - KdlError { - error_message, - src: None, - offset: Some(offset), - len: Some(len), - } - } pub fn add_src(mut self, src_name: String, src_input: String) -> Self { self.src = Some(NamedSource::new(src_name, src_input)); self @@ -68,8 +61,10 @@ impl Diagnostic for KdlError { } } fn help<'a>(&'a self) -> Option<Box<dyn Display + 'a>> { - // TODO: link to specific relevant sections - Some(Box::new(format!("For more information, please see our configuration guide: https://zellij.dev/documentation/configuration.html"))) + match &self.help_message { + Some(help_message) => Some(Box::new(help_message)), + None => Some(Box::new(format!("For more information, please see our configuration guide: https://zellij.dev/documentation/configuration.html"))) + } } fn labels(&self) -> Option<Box<dyn Iterator<Item = LabeledSpan> + '_>> { if let (Some(offset), Some(len)) = (self.offset, self.len) { @@ -113,6 +108,16 @@ impl ConfigError { src: None, offset: Some(offset), len: Some(len), + help_message: None, + }) + } + pub fn new_layout_kdl_error(error_message: String, offset: usize, len: usize) -> Self { + ConfigError::KdlError(KdlError { + error_message, + src: None, + offset: Some(offset), + len: Some(len), + help_message: Some(format!("For more information, please see our layout guide: https://zellij.dev/documentation/creating-a-layout.html")), }) } } @@ -204,6 +209,7 @@ impl Config { )), offset: Some(kdl_error.span.offset()), len: Some(kdl_error.span.len()), + help_message: None, }; Err(ConfigError::KdlError(kdl_error)) }, diff --git a/zellij-utils/src/input/layout.rs b/zellij-utils/src/input/layout.rs index e283b4455..8d0dc104d 100644 --- a/zellij-utils/src/input/layout.rs +++ b/zellij-utils/src/input/layout.rs @@ -284,7 +284,7 @@ impl LayoutParts { panes.insert(index, layout); Ok(()) }, - LayoutParts::Tabs(_tabs) => Err(ConfigError::new_kdl_error( + LayoutParts::Tabs(_tabs) => Err(ConfigError::new_layout_kdl_error( "Trying to insert a pane into a tab layout".into(), 0, 0, diff --git a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__keybinds__keybinds_test__error_received_on_unknown_input_mode.snap b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__keybinds__keybinds_test__error_received_on_unknown_input_mode.snap index eab0dc6f4..2b1b24f7c 100644 --- a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__keybinds__keybinds_test__error_received_on_unknown_input_mode.snap +++ b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__keybinds__keybinds_test__error_received_on_unknown_input_mode.snap @@ -1,6 +1,6 @@ --- source: zellij-utils/src/input/./unit/keybinds_test.rs -assertion_line: 476 +assertion_line: 529 expression: "format!(\"{:?}\", config_error)" --- -KdlError(KdlError { error_message: "Invalid mode: 'i_do_not_exist'", src: None, offset: Some(32), len: Some(14) }) +KdlError(KdlError { error_message: "Invalid mode: 'i_do_not_exist'", src: None, offset: Some(32), len: Some(14), help_message: None }) diff --git a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__keybinds__keybinds_test__error_received_on_unknown_key_instruction.snap b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__keybinds__keybinds_test__error_received_on_unknown_key_instruction.snap index cce4254ad..d6f867136 100644 --- a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__keybinds__keybinds_test__error_received_on_unknown_key_instruction.snap +++ b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__keybinds__keybinds_test__error_received_on_unknown_key_instruction.snap @@ -1,6 +1,6 @@ --- source: zellij-utils/src/input/./unit/keybinds_test.rs -assertion_line: 490 +assertion_line: 543 expression: "format!(\"{:?}\", config_error)" --- -KdlError(KdlError { error_message: "Unknown keybind instruction: 'i_am_not_bind_or_unbind'", src: None, offset: Some(55), len: Some(23) }) +KdlError(KdlError { error_message: "Unknown keybind instruction: 'i_am_not_bind_or_unbind'", src: None, offset: Some(55), len: Some(23), help_message: None }) diff --git a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__error_on_more_than_one_focused_tab.snap b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__error_on_more_than_one_focused_tab.snap index b640aa430..c730d0d7b 100644 --- a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__error_on_more_than_one_focused_tab.snap +++ b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__error_on_more_than_one_focused_tab.snap @@ -1,6 +1,6 @@ --- source: zellij-utils/src/input/./unit/layout_test.rs -assertion_line: 979 +assertion_line: 1015 expression: "format!(\"{:?}\", layout_error)" --- -KdlError(KdlError { error_message: "Only one tab can be focused", src: Some(NamedSource { name: "layout_file_name", source: "<redacted>"), offset: Some(0), len: Some(98) }) +KdlError(KdlError { error_message: "Only one tab can be focused", src: Some(NamedSource { name: "layout_file_name", source: "<redacted>"), offset: Some(0), len: Some(98), help_message: Some("For more information, please see our layout guide: https://zellij.dev/documentation/creating-a-layout.html") }) diff --git a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__error_on_multiple_layout_nodes_in_file.snap b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__error_on_multiple_layout_nodes_in_file.snap index 0c2811ec7..baa2e3ce8 100644 --- a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__error_on_multiple_layout_nodes_in_file.snap +++ b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__error_on_multiple_layout_nodes_in_file.snap @@ -1,6 +1,6 @@ --- source: zellij-utils/src/input/./unit/layout_test.rs -assertion_line: 879 +assertion_line: 901 expression: "format!(\"{:?}\", layout_error)" --- -KdlError(KdlError { error_message: "Only one layout node per file allowed", src: Some(NamedSource { name: "layout_file_name", source: "<redacted>"), offset: Some(0), len: Some(31) }) +KdlError(KdlError { error_message: "Only one layout node per file allowed", src: Some(NamedSource { name: "layout_file_name", source: "<redacted>"), offset: Some(0), len: Some(31), help_message: Some("For more information, please see our layout guide: https://zellij.dev/documentation/creating-a-layout.html") }) diff --git a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__error_on_pane_templates_without_a_name.snap b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__error_on_pane_templates_without_a_name.snap index cf7fc6923..6fa185bd5 100644 --- a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__error_on_pane_templates_without_a_name.snap +++ b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__error_on_pane_templates_without_a_name.snap @@ -1,6 +1,6 @@ --- source: zellij-utils/src/input/./unit/layout_test.rs -assertion_line: 951 +assertion_line: 985 expression: "format!(\"{:?}\", layout_error)" --- -KdlError(KdlError { error_message: "Pane templates must have a name", src: Some(NamedSource { name: "layout_file_name", source: "<redacted>"), offset: Some(30), len: Some(96) }) +KdlError(KdlError { error_message: "Pane templates must have a name", src: Some(NamedSource { name: "layout_file_name", source: "<redacted>"), offset: Some(30), len: Some(96), help_message: Some("For more information, please see our layout guide: https://zellij.dev/documentation/creating-a-layout.html") }) diff --git a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__error_on_tab_templates_without_a_name.snap b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__error_on_tab_templates_without_a_name.snap index c7b591f8e..c1cce5425 100644 --- a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__error_on_tab_templates_without_a_name.snap +++ b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__error_on_tab_templates_without_a_name.snap @@ -1,6 +1,6 @@ --- source: zellij-utils/src/input/./unit/layout_test.rs -assertion_line: 966 +assertion_line: 1002 expression: "format!(\"{:?}\", layout_error)" --- -KdlError(KdlError { error_message: "Tab templates must have a name", src: Some(NamedSource { name: "layout_file_name", source: "<redacted>"), offset: Some(30), len: Some(95) }) +KdlError(KdlError { error_message: "Tab templates must have a name", src: Some(NamedSource { name: "layout_file_name", source: "<redacted>"), offset: Some(30), len: Some(95), help_message: Some("For more information, please see our layout guide: https://zellij.dev/documentation/creating-a-layout.html") }) diff --git a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__error_on_unknown_layout_node.snap b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__error_on_unknown_layout_node.snap index b2b28ffef..845e41c68 100644 --- a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__error_on_unknown_layout_node.snap +++ b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__error_on_unknown_layout_node.snap @@ -1,6 +1,6 @@ --- source: zellij-utils/src/input/./unit/layout_test.rs -assertion_line: 892 +assertion_line: 916 expression: "format!(\"{:?}\", layout_error)" --- -KdlError(KdlError { error_message: "Unknown layout node: 'i_am_not_a_proper_node'", src: Some(NamedSource { name: "layout_file_name", source: "<redacted>"), offset: Some(47), len: Some(22) }) +KdlError(KdlError { error_message: "Unknown layout node: 'i_am_not_a_proper_node'", src: Some(NamedSource { name: "layout_file_name", source: "<redacted>"), offset: Some(47), len: Some(22), help_message: Some("For more information, please see our layout guide: https://zellij.dev/documentation/creating-a-layout.html") }) diff --git a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__error_on_unknown_layout_pane_property.snap b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__error_on_unknown_layout_pane_property.snap index 573ca75a1..35dfaf03e 100644 --- a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__error_on_unknown_layout_pane_property.snap +++ b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__error_on_unknown_layout_pane_property.snap @@ -1,6 +1,6 @@ --- source: zellij-utils/src/input/./unit/layout_test.rs -assertion_line: 926 +assertion_line: 929 expression: "format!(\"{:?}\", layout_error)" --- -KdlError(KdlError { error_message: "Unknown pane property: spit_size", src: Some(NamedSource { name: "layout_file_name", source: "<redacted>"), offset: Some(35), len: Some(11) }) +KdlError(KdlError { error_message: "Unknown pane property: spit_size", src: Some(NamedSource { name: "layout_file_name", source: "<redacted>"), offset: Some(35), len: Some(11), help_message: Some("For more information, please see our layout guide: https://zellij.dev/documentation/creating-a-layout.html") }) diff --git a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__error_on_unknown_layout_pane_template_property.snap b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__error_on_unknown_layout_pane_template_property.snap index 09701ebe4..a4a5f0852 100644 --- a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__error_on_unknown_layout_pane_template_property.snap +++ b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__error_on_unknown_layout_pane_template_property.snap @@ -1,6 +1,6 @@ --- source: zellij-utils/src/input/./unit/layout_test.rs -assertion_line: 939 +assertion_line: 942 expression: "format!(\"{:?}\", layout_error)" --- -KdlError(KdlError { error_message: "Unknown pane property: spit_size", src: Some(NamedSource { name: "layout_file_name", source: "<redacted>"), offset: Some(68), len: Some(11) }) +KdlError(KdlError { error_message: "Unknown pane property: spit_size", src: Some(NamedSource { name: "layout_file_name", source: "<redacted>"), offset: Some(68), len: Some(11), help_message: Some("For more information, please see our layout guide: https://zellij.dev/documentation/creating-a-layout.html") }) diff --git a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__error_on_unknown_layout_tab_property.snap b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__error_on_unknown_layout_tab_property.snap index bbe1769c4..09a86ca9d 100644 --- a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__error_on_unknown_layout_tab_property.snap +++ b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__error_on_unknown_layout_tab_property.snap @@ -1,6 +1,6 @@ --- source: zellij-utils/src/input/./unit/layout_test.rs -assertion_line: 925 +assertion_line: 955 expression: "format!(\"{:?}\", layout_error)" --- -KdlError(KdlError { error_message: "Invalid tab property 'spit_size'", src: Some(NamedSource { name: "layout_file_name", source: "<redacted>"), offset: Some(30), len: Some(15) }) +KdlError(KdlError { error_message: "Invalid tab property 'spit_size'", src: Some(NamedSource { name: "layout_file_name", source: "<redacted>"), offset: Some(30), len: Some(15), help_message: Some("For more information, please see our layout guide: https://zellij.dev/documentation/creating-a-layout.html") }) diff --git a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__error_on_unknown_layout_tab_template_property.snap b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__error_on_unknown_layout_tab_template_property.snap index 134970f7f..b75e4c91c 100644 --- a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__error_on_unknown_layout_tab_template_property.snap +++ b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__error_on_unknown_layout_tab_template_property.snap @@ -1,6 +1,6 @@ --- source: zellij-utils/src/input/./unit/layout_test.rs -assertion_line: 936 +assertion_line: 968 expression: "format!(\"{:?}\", layout_error)" --- -KdlError(KdlError { error_message: "Invalid tab property 'spit_size'", src: Some(NamedSource { name: "layout_file_name", source: "<redacted>"), offset: Some(30), len: Some(48) }) +KdlError(KdlError { error_message: "Invalid tab property 'spit_size'", src: Some(NamedSource { name: "layout_file_name", source: "<redacted>"), offset: Some(30), len: Some(48), help_message: Some("For more information, please see our layout guide: https://zellij.dev/documentation/creating-a-layout.html") }) diff --git a/zellij-utils/src/k |