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"
77
88[settings]
99default_room = "#iamb-users:0x.badd.cafe"
10default_split = "vertical"
1011external_edit_file_suffix = ".md"
1112log_level = "warn"
1213message_shortcode_display = false
docs/iamb.5 +10
@@ -135,6 +135,16 @@ for more details.
135135The room to show by default instead of the
136136.Sy :welcome
137137window.
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 .
138148.It Sy external_edit_file_suffix
139149Suffix to append to temporary file names when using the :editor command. Defaults to .md.
140150.It Sy image_preview
src/config.rs +12
@@ -419,6 +419,14 @@ pub enum UserDisplayStyle {
419419 DisplayName,
420420}
421421
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
422430#[derive(Clone, Copy, Debug, Eq, PartialEq)]
423431pub struct NotifyVia {
424432 /// Deliver notifications via terminal bell.
@@ -716,6 +724,7 @@ pub struct TunableValues {
716724 pub user_gutter_width: usize,
717725 pub external_edit_file_suffix: String,
718726 pub tabstop: usize,
727 pub default_split: SplitDirection,
719728 pub ssl_verify: bool,
720729}
721730
@@ -758,6 +767,7 @@ pub struct Tunables {
758767 pub user_gutter_width: Option<usize>,
759768 pub external_edit_file_suffix: Option<String>,
760769 pub tabstop: Option<usize>,
770 pub default_split: Option<SplitDirection>,
761771 pub ssl_verify: Option<bool>,
762772}
763773
@@ -797,6 +807,7 @@ impl Tunables {
797807 .external_edit_file_suffix
798808 .or(other.external_edit_file_suffix),
799809 tabstop: self.tabstop.or(other.tabstop),
810 default_split: self.default_split.or(other.default_split),
800811 ssl_verify: self.ssl_verify.or(other.ssl_verify),
801812 }
802813 }
@@ -832,6 +843,7 @@ impl Tunables {
832843 .external_edit_file_suffix
833844 .unwrap_or_else(|| ".md".to_string()),
834845 tabstop: self.tabstop.unwrap_or(4),
846 default_split: self.default_split.unwrap_or_default(),
835847 ssl_verify: self.ssl_verify.unwrap_or(true),
836848 }
837849 }
src/keybindings.rs +23 −1
@@ -13,7 +13,7 @@ use modalkit::{
1313};
1414
1515use crate::base::{IambAction, IambInfo, Keybindings, MATRIX_ID_WORD};
16use crate::config::{ApplicationSettings, Keys};
16use crate::config::{ApplicationSettings, Keys, SplitDirection};
1717
1818pub type IambStep = InputStep<IambInfo>;
1919
@@ -85,5 +85,27 @@ impl InputBindings<TerminalKey, IambStep> for ApplicationSettings {
8585 }
8686 }
8787 }
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 }
88110 }
89111}
src/tests.rs +1
@@ -206,6 +206,7 @@ pub fn mock_tunables() -> TunableValues {
206206 image_preview: None,
207207 user_gutter_width: 30,
208208 tabstop: 4,
209 default_split: Default::default(),
209210 ssl_verify: true,
210211 }
211212}