chore: clippy + format

This commit is contained in:
Edward Langley
2026-04-04 12:34:50 -07:00
parent 35946afc91
commit c6c8ac2c69
4 changed files with 320 additions and 92 deletions

View File

@ -98,10 +98,7 @@ impl Keymap {
pub fn bind(&mut self, key: KeyCode, mods: KeyModifiers, name: &'static str) {
self.bindings.insert(
KeyPattern::Key(key, mods),
Binding::Cmd {
name,
args: vec![],
},
Binding::Cmd { name, args: vec![] },
);
}
@ -131,13 +128,8 @@ impl Keymap {
/// Bind a catch-all for any key at all.
pub fn bind_any(&mut self, name: &'static str) {
self.bindings.insert(
KeyPattern::Any,
Binding::Cmd {
name,
args: vec![],
},
);
self.bindings
.insert(KeyPattern::Any, Binding::Cmd { name, args: vec![] });
}
/// Look up the binding for a key.
@ -246,7 +238,12 @@ impl KeymapSet {
(KeyCode::Left, 0, -1),
(KeyCode::Right, 0, 1),
] {
normal.bind_args(key, none, "move-selection", vec![dr.to_string(), dc.to_string()]);
normal.bind_args(
key,
none,
"move-selection",
vec![dr.to_string(), dc.to_string()],
);
}
for (ch, dr, dc) in [('k', -1, 0), ('j', 1, 0), ('h', 0, -1), ('l', 0, 1)] {
normal.bind_args(
@ -333,7 +330,12 @@ impl KeymapSet {
normal.bind(KeyCode::Char('e'), ctrl, "enter-export-prompt");
// Search / category add
normal.bind_args(KeyCode::Char('n'), none, "search-navigate", vec!["forward".into()]);
normal.bind_args(
KeyCode::Char('n'),
none,
"search-navigate",
vec!["forward".into()],
);
normal.bind(KeyCode::Char('N'), shift, "search-or-category-add");
// Page navigation
@ -370,7 +372,12 @@ impl KeymapSet {
// ── Help mode ────────────────────────────────────────────────────
let mut help = Keymap::new();
help.bind_args(KeyCode::Esc, none, "enter-mode", vec!["normal".into()]);
help.bind_args(KeyCode::Char('q'), none, "enter-mode", vec!["normal".into()]);
help.bind_args(
KeyCode::Char('q'),
none,
"enter-mode",
vec!["normal".into()],
);
set.insert(ModeKey::Help, Arc::new(help));
// ── Formula panel ────────────────────────────────────────────────
@ -378,10 +385,20 @@ impl KeymapSet {
fp.bind_args(KeyCode::Esc, none, "enter-mode", vec!["normal".into()]);
fp.bind_args(KeyCode::Tab, none, "enter-mode", vec!["normal".into()]);
for key in [KeyCode::Up, KeyCode::Char('k')] {
fp.bind_args(key, none, "move-panel-cursor", vec!["formula".into(), "-1".into()]);
fp.bind_args(
key,
none,
"move-panel-cursor",
vec!["formula".into(), "-1".into()],
);
}
for key in [KeyCode::Down, KeyCode::Char('j')] {
fp.bind_args(key, none, "move-panel-cursor", vec!["formula".into(), "1".into()]);
fp.bind_args(
key,
none,
"move-panel-cursor",
vec!["formula".into(), "1".into()],
);
}
fp.bind(KeyCode::Char('a'), none, "enter-formula-edit");
fp.bind(KeyCode::Char('n'), none, "enter-formula-edit");
@ -395,10 +412,20 @@ impl KeymapSet {
cp.bind_args(KeyCode::Esc, none, "enter-mode", vec!["normal".into()]);
cp.bind_args(KeyCode::Tab, none, "enter-mode", vec!["normal".into()]);
for key in [KeyCode::Up, KeyCode::Char('k')] {
cp.bind_args(key, none, "move-panel-cursor", vec!["category".into(), "-1".into()]);
cp.bind_args(
key,
none,
"move-panel-cursor",
vec!["category".into(), "-1".into()],
);
}
for key in [KeyCode::Down, KeyCode::Char('j')] {
cp.bind_args(key, none, "move-panel-cursor", vec!["category".into(), "1".into()]);
cp.bind_args(
key,
none,
"move-panel-cursor",
vec!["category".into(), "1".into()],
);
}
cp.bind(KeyCode::Enter, none, "cycle-axis-at-cursor");
cp.bind(KeyCode::Char(' '), none, "cycle-axis-at-cursor");
@ -417,10 +444,20 @@ impl KeymapSet {
vp.bind_args(KeyCode::Esc, none, "enter-mode", vec!["normal".into()]);
vp.bind_args(KeyCode::Tab, none, "enter-mode", vec!["normal".into()]);
for key in [KeyCode::Up, KeyCode::Char('k')] {
vp.bind_args(key, none, "move-panel-cursor", vec!["view".into(), "-1".into()]);
vp.bind_args(
key,
none,
"move-panel-cursor",
vec!["view".into(), "-1".into()],
);
}
for key in [KeyCode::Down, KeyCode::Char('j')] {
vp.bind_args(key, none, "move-panel-cursor", vec!["view".into(), "1".into()]);
vp.bind_args(
key,
none,
"move-panel-cursor",
vec!["view".into(), "1".into()],
);
}
vp.bind(KeyCode::Enter, none, "switch-view-at-cursor");
vp.bind(KeyCode::Char('n'), none, "create-and-switch-view");
@ -434,15 +471,45 @@ impl KeymapSet {
ts.bind_args(KeyCode::Esc, none, "enter-mode", vec!["normal".into()]);
ts.bind_args(KeyCode::Tab, none, "enter-mode", vec!["normal".into()]);
ts.bind_args(KeyCode::Left, none, "move-tile-cursor", vec!["-1".into()]);
ts.bind_args(KeyCode::Char('h'), none, "move-tile-cursor", vec!["-1".into()]);
ts.bind_args(
KeyCode::Char('h'),
none,
"move-tile-cursor",
vec!["-1".into()],
);
ts.bind_args(KeyCode::Right, none, "move-tile-cursor", vec!["1".into()]);
ts.bind_args(KeyCode::Char('l'), none, "move-tile-cursor", vec!["1".into()]);
ts.bind_args(
KeyCode::Char('l'),
none,
"move-tile-cursor",
vec!["1".into()],
);
ts.bind(KeyCode::Enter, none, "cycle-axis-for-tile");
ts.bind(KeyCode::Char(' '), none, "cycle-axis-for-tile");
ts.bind_args(KeyCode::Char('r'), none, "set-axis-for-tile", vec!["row".into()]);
ts.bind_args(KeyCode::Char('c'), none, "set-axis-for-tile", vec!["column".into()]);
ts.bind_args(KeyCode::Char('p'), none, "set-axis-for-tile", vec!["page".into()]);
ts.bind_args(KeyCode::Char('n'), none, "set-axis-for-tile", vec!["none".into()]);
ts.bind_args(
KeyCode::Char('r'),
none,
"set-axis-for-tile",
vec!["row".into()],
);
ts.bind_args(
KeyCode::Char('c'),
none,
"set-axis-for-tile",
vec!["column".into()],
);
ts.bind_args(
KeyCode::Char('p'),
none,
"set-axis-for-tile",
vec!["page".into()],
);
ts.bind_args(
KeyCode::Char('n'),
none,
"set-axis-for-tile",
vec!["none".into()],
);
set.insert(ModeKey::TileSelect, Arc::new(ts));
// ── Editing mode ─────────────────────────────────────────────────
@ -455,7 +522,12 @@ impl KeymapSet {
// ── Formula edit ─────────────────────────────────────────────────
let mut fe = Keymap::new();
fe.bind_args(KeyCode::Esc, none, "enter-mode", vec!["formula-panel".into()]);
fe.bind_args(
KeyCode::Esc,
none,
"enter-mode",
vec!["formula-panel".into()],
);
fe.bind(KeyCode::Enter, none, "commit-formula");
fe.bind_args(KeyCode::Backspace, none, "pop-char", vec!["formula".into()]);
fe.bind_any_char("append-char", vec!["formula".into()]);
@ -463,16 +535,31 @@ impl KeymapSet {
// ── Category add ─────────────────────────────────────────────────
let mut ca = Keymap::new();
ca.bind_args(KeyCode::Esc, none, "enter-mode", vec!["category-panel".into()]);
ca.bind_args(
KeyCode::Esc,
none,
"enter-mode",
vec!["category-panel".into()],
);
ca.bind(KeyCode::Enter, none, "commit-category-add");
ca.bind(KeyCode::Tab, none, "commit-category-add");
ca.bind_args(KeyCode::Backspace, none, "pop-char", vec!["category".into()]);
ca.bind_args(
KeyCode::Backspace,
none,
"pop-char",
vec!["category".into()],
);
ca.bind_any_char("append-char", vec!["category".into()]);
set.insert(ModeKey::CategoryAdd, Arc::new(ca));
// ── Item add ─────────────────────────────────────────────────────
let mut ia = Keymap::new();
ia.bind_args(KeyCode::Esc, none, "enter-mode", vec!["category-panel".into()]);
ia.bind_args(
KeyCode::Esc,
none,
"enter-mode",
vec!["category-panel".into()],
);
ia.bind(KeyCode::Enter, none, "commit-item-add");
ia.bind(KeyCode::Tab, none, "commit-item-add");
ia.bind_args(KeyCode::Backspace, none, "pop-char", vec!["item".into()]);