Commit a190c21659
a190c2165941eb293ec3d83b3593faab91eb4be2
parent: 972ae5971d
Unregistered key
stevenpollack <stevenpollack@users.noreply.github.com> · 2026-07-30 02:30 UTC
committer: <noreply@github.com>
Add `default_split` tunable to control `<C-W>f` split direction (#620)
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Layout: unified · split
config.example.toml
+1
| @@ -7,6 +7,7 @@ url = "https://matrix.org" |
| 7 | 7 | |
| 8 | 8 | [settings] |
| 9 | 9 | default_room = "#iamb-users:0x.badd.cafe" |
| 10 | default_split = "vertical" |
| 10 | 11 | external_edit_file_suffix = ".md" |
| 11 | 12 | log_level = "warn" |
| 12 | 13 | message_shortcode_display = false |
docs/iamb.5
+10
| @@ -135,6 +135,16 @@ for more details. |
| 135 | 135 | The room to show by default instead of the |
| 136 | 136 | .Sy :welcome |
| 137 | 137 | window. |
| 138 | .It Sy default_split |
| 139 | Controls which direction |
| 140 | .Sy <C-W>f |
| 141 | and |
| 142 | .Sy <C-W><C-F> |
| 143 | open a new split when following a room identifier under the cursor. |
| 144 | Possible values are |
| 145 | .Dq Sy horizontal |
| 146 | (the default) and |
| 147 | .Dq Sy vertical . |
| 138 | 148 | .It Sy external_edit_file_suffix |
| 139 | 149 | Suffix to append to temporary file names when using the :editor command. Defaults to .md. |
| 140 | 150 | .It Sy image_preview |
src/config.rs
+12
| @@ -419,6 +419,14 @@ pub enum UserDisplayStyle { |
| 419 | 419 | DisplayName, |
| 420 | 420 | } |
| 421 | 421 | |
| 422 | #[derive(Clone, Copy, Debug, Default, Deserialize, Eq, PartialEq)] |
| 423 | #[serde(rename_all = "lowercase")] |
| 424 | pub enum SplitDirection { |
| 425 | #[default] |
| 426 | Horizontal, |
| 427 | Vertical, |
| 428 | } |
| 429 | |
| 422 | 430 | #[derive(Clone, Copy, Debug, Eq, PartialEq)] |
| 423 | 431 | pub struct NotifyVia { |
| 424 | 432 | /// Deliver notifications via terminal bell. |
| @@ -716,6 +724,7 @@ pub struct TunableValues { |
| 716 | 724 | pub user_gutter_width: usize, |
| 717 | 725 | pub external_edit_file_suffix: String, |
| 718 | 726 | pub tabstop: usize, |
| 727 | pub default_split: SplitDirection, |
| 719 | 728 | pub ssl_verify: bool, |
| 720 | 729 | } |
| 721 | 730 | |
| @@ -758,6 +767,7 @@ pub struct Tunables { |
| 758 | 767 | pub user_gutter_width: Option<usize>, |
| 759 | 768 | pub external_edit_file_suffix: Option<String>, |
| 760 | 769 | pub tabstop: Option<usize>, |
| 770 | pub default_split: Option<SplitDirection>, |
| 761 | 771 | pub ssl_verify: Option<bool>, |
| 762 | 772 | } |
| 763 | 773 | |
| @@ -797,6 +807,7 @@ impl Tunables { |
| 797 | 807 | .external_edit_file_suffix |
| 798 | 808 | .or(other.external_edit_file_suffix), |
| 799 | 809 | tabstop: self.tabstop.or(other.tabstop), |
| 810 | default_split: self.default_split.or(other.default_split), |
| 800 | 811 | ssl_verify: self.ssl_verify.or(other.ssl_verify), |
| 801 | 812 | } |
| 802 | 813 | } |
| @@ -832,6 +843,7 @@ impl Tunables { |
| 832 | 843 | .external_edit_file_suffix |
| 833 | 844 | .unwrap_or_else(|| ".md".to_string()), |
| 834 | 845 | tabstop: self.tabstop.unwrap_or(4), |
| 846 | default_split: self.default_split.unwrap_or_default(), |
| 835 | 847 | ssl_verify: self.ssl_verify.unwrap_or(true), |
| 836 | 848 | } |
| 837 | 849 | } |
src/keybindings.rs
+23 −1
| @@ -13,7 +13,7 @@ use modalkit::{ |
| 13 | 13 | }; |
| 14 | 14 | |
| 15 | 15 | use crate::base::{IambAction, IambInfo, Keybindings, MATRIX_ID_WORD}; |
| 16 | | use crate::config::{ApplicationSettings, Keys}; |
| 16 | use crate::config::{ApplicationSettings, Keys, SplitDirection}; |
| 17 | 17 | |
| 18 | 18 | pub type IambStep = InputStep<IambInfo>; |
| 19 | 19 | |
| @@ -85,5 +85,27 @@ impl InputBindings<TerminalKey, IambStep> for ApplicationSettings { |
| 85 | 85 | } |
| 86 | 86 | } |
| 87 | 87 | } |
| 88 | |
| 89 | if self.tunables.default_split == SplitDirection::Vertical { |
| 90 | let ctrl_w = "<C-W>".parse::<TerminalKey>().unwrap(); |
| 91 | let key_f = "f".parse::<TerminalKey>().unwrap(); |
| 92 | let ctrl_f = "<C-F>".parse::<TerminalKey>().unwrap(); |
| 93 | |
| 94 | let vsplit_open = IambStep::new() |
| 95 | .actions(vec![WindowAction::Split( |
| 96 | OpenTarget::Cursor(MATRIX_ID_WORD.clone()), |
| 97 | Axis::Vertical, |
| 98 | MoveDir1D::Next, |
| 99 | 1.into(), |
| 100 | ) |
| 101 | .into()]) |
| 102 | .goto(VimMode::Normal); |
| 103 | |
| 104 | let cwf = vec![once(&ctrl_w), once(&key_f)]; |
| 105 | let cwcf = vec![once(&ctrl_w), once(&ctrl_f)]; |
| 106 | |
| 107 | bindings.add_mapping(VimMode::Normal, &cwf, &vsplit_open); |
| 108 | bindings.add_mapping(VimMode::Normal, &cwcf, &vsplit_open); |
| 109 | } |
| 88 | 110 | } |
| 89 | 111 | } |
src/tests.rs
+1
| @@ -206,6 +206,7 @@ pub fn mock_tunables() -> TunableValues { |
| 206 | 206 | image_preview: None, |
| 207 | 207 | user_gutter_width: 30, |
| 208 | 208 | tabstop: 4, |
| 209 | default_split: Default::default(), |
| 209 | 210 | ssl_verify: true, |
| 210 | 211 | } |
| 211 | 212 | } |