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[settings] 8[settings]
9default_room = "#iamb-users:0x.badd.cafe" 9default_room = "#iamb-users:0x.badd.cafe"
10default_split = "vertical"
10external_edit_file_suffix = ".md" 11external_edit_file_suffix = ".md"
11log_level = "warn" 12log_level = "warn"
12message_shortcode_display = false 13message_shortcode_display = false
docs/iamb.5 +10
@@ -135,6 +135,16 @@ for more details.
135The room to show by default instead of the 135The room to show by default instead of the
136.Sy :welcome 136.Sy :welcome
137window. 137window.
138.It Sy default_split
139Controls which direction
140.Sy <C-W>f
141and
142.Sy <C-W><C-F>
143open a new split when following a room identifier under the cursor.
144Possible values are
145.Dq Sy horizontal
146(the default) and
147.Dq Sy vertical .
138.It Sy external_edit_file_suffix 148.It Sy external_edit_file_suffix
139Suffix to append to temporary file names when using the :editor command. Defaults to .md. 149Suffix to append to temporary file names when using the :editor command. Defaults to .md.
140.It Sy image_preview 150.It Sy image_preview
src/config.rs +12
@@ -419,6 +419,14 @@ pub enum UserDisplayStyle {
419 DisplayName, 419 DisplayName,
420} 420}
421 421
422#[derive(Clone, Copy, Debug, Default, Deserialize, Eq, PartialEq)]
423#[serde(rename_all = "lowercase")]
424pub enum SplitDirection {
425 #[default]
426 Horizontal,
427 Vertical,
428}
429
422#[derive(Clone, Copy, Debug, Eq, PartialEq)] 430#[derive(Clone, Copy, Debug, Eq, PartialEq)]
423pub struct NotifyVia { 431pub struct NotifyVia {
424 /// Deliver notifications via terminal bell. 432 /// Deliver notifications via terminal bell.
@@ -716,6 +724,7 @@ pub struct TunableValues {
716 pub user_gutter_width: usize, 724 pub user_gutter_width: usize,
717 pub external_edit_file_suffix: String, 725 pub external_edit_file_suffix: String,
718 pub tabstop: usize, 726 pub tabstop: usize,
727 pub default_split: SplitDirection,
719 pub ssl_verify: bool, 728 pub ssl_verify: bool,
720} 729}
721 730
@@ -758,6 +767,7 @@ pub struct Tunables {
758 pub user_gutter_width: Option<usize>, 767 pub user_gutter_width: Option<usize>,
759 pub external_edit_file_suffix: Option<String>, 768 pub external_edit_file_suffix: Option<String>,
760 pub tabstop: Option<usize>, 769 pub tabstop: Option<usize>,
770 pub default_split: Option<SplitDirection>,
761 pub ssl_verify: Option<bool>, 771 pub ssl_verify: Option<bool>,
762} 772}
763 773
@@ -797,6 +807,7 @@ impl Tunables {
797 .external_edit_file_suffix 807 .external_edit_file_suffix
798 .or(other.external_edit_file_suffix), 808 .or(other.external_edit_file_suffix),
799 tabstop: self.tabstop.or(other.tabstop), 809 tabstop: self.tabstop.or(other.tabstop),
810 default_split: self.default_split.or(other.default_split),
800 ssl_verify: self.ssl_verify.or(other.ssl_verify), 811 ssl_verify: self.ssl_verify.or(other.ssl_verify),
801 } 812 }
802 } 813 }
@@ -832,6 +843,7 @@ impl Tunables {
832 .external_edit_file_suffix 843 .external_edit_file_suffix
833 .unwrap_or_else(|| ".md".to_string()), 844 .unwrap_or_else(|| ".md".to_string()),
834 tabstop: self.tabstop.unwrap_or(4), 845 tabstop: self.tabstop.unwrap_or(4),
846 default_split: self.default_split.unwrap_or_default(),
835 ssl_verify: self.ssl_verify.unwrap_or(true), 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
15use crate::base::{IambAction, IambInfo, Keybindings, MATRIX_ID_WORD}; 15use crate::base::{IambAction, IambInfo, Keybindings, MATRIX_ID_WORD};
16use crate::config::{ApplicationSettings, Keys}; 16use crate::config::{ApplicationSettings, Keys, SplitDirection};
17 17
18pub type IambStep = InputStep<IambInfo>; 18pub 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 image_preview: None, 206 image_preview: None,
207 user_gutter_width: 30, 207 user_gutter_width: 30,
208 tabstop: 4, 208 tabstop: 4,
209 default_split: Default::default(),
209 ssl_verify: true, 210 ssl_verify: true,
210 } 211 }
211} 212}