aboutsummaryrefslogtreecommitdiffstats
path: root/crates/turtle/src/command/client
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2026-06-13 00:58:32 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2026-06-13 00:58:32 +0200
commit9352a0f7cfdd5f5fc102a25d8a93218bc3dbe462 (patch)
treeb998430c307c10defb79d91abe5d30471c5c4f12 /crates/turtle/src/command/client
parentchore(treewide): Remove `cargo` warnings to 0 (diff)
downloadatuin-9352a0f7cfdd5f5fc102a25d8a93218bc3dbe462.zip
chore(treewide): Fix some of `clippy`'s error
Just a run of `cargo clippy --fix`
Diffstat (limited to 'crates/turtle/src/command/client')
-rw-r--r--crates/turtle/src/command/client/search/engines/daemon.rs2
-rw-r--r--crates/turtle/src/command/client/search/engines/skim.rs2
-rw-r--r--crates/turtle/src/command/client/search/keybindings/actions.rs214
-rw-r--r--crates/turtle/src/command/client/search/keybindings/conditions.rs98
-rw-r--r--crates/turtle/src/command/client/search/keybindings/defaults.rs2
-rw-r--r--crates/turtle/src/command/client/search/keybindings/keymap.rs12
-rw-r--r--crates/turtle/src/command/client/server.rs4
-rw-r--r--crates/turtle/src/command/client/sync/status.rs2
8 files changed, 168 insertions, 168 deletions
diff --git a/crates/turtle/src/command/client/search/engines/daemon.rs b/crates/turtle/src/command/client/search/engines/daemon.rs
index 55b3c6f2..cb0fdf7d 100644
--- a/crates/turtle/src/command/client/search/engines/daemon.rs
+++ b/crates/turtle/src/command/client/search/engines/daemon.rs
@@ -26,7 +26,7 @@ pub(crate) struct Search {
impl Search {
pub(crate) fn new(settings: &Settings) -> Self {
- Search {
+ Self {
client: None,
query_id: 0,
settings: settings.clone(),
diff --git a/crates/turtle/src/command/client/search/engines/skim.rs b/crates/turtle/src/command/client/search/engines/skim.rs
index 739e790b..e090e40d 100644
--- a/crates/turtle/src/command/client/search/engines/skim.rs
+++ b/crates/turtle/src/command/client/search/engines/skim.rs
@@ -18,7 +18,7 @@ pub(crate) struct Search {
impl Search {
pub(crate) fn new() -> Self {
- Search {
+ Self {
all_history: vec![],
engine: SkimMatcherV2::default(),
}
diff --git a/crates/turtle/src/command/client/search/keybindings/actions.rs b/crates/turtle/src/command/client/search/keybindings/actions.rs
index 341b030c..e9b654c5 100644
--- a/crates/turtle/src/command/client/search/keybindings/actions.rs
+++ b/crates/turtle/src/command/client/search/keybindings/actions.rs
@@ -83,73 +83,73 @@ impl Action {
&& let Ok(n) = rest.parse::<u8>()
&& (1..=9).contains(&n)
{
- return Ok(Action::AcceptNth(n));
+ return Ok(Self::AcceptNth(n));
}
if let Some(rest) = s.strip_prefix("return-selection-")
&& let Ok(n) = rest.parse::<u8>()
&& (1..=9).contains(&n)
{
- return Ok(Action::ReturnSelectionNth(n));
+ return Ok(Self::ReturnSelectionNth(n));
}
match s {
- "cursor-left" => Ok(Action::CursorLeft),
- "cursor-right" => Ok(Action::CursorRight),
- "cursor-word-left" => Ok(Action::CursorWordLeft),
- "cursor-word-right" => Ok(Action::CursorWordRight),
- "cursor-word-end" => Ok(Action::CursorWordEnd),
- "cursor-start" => Ok(Action::CursorStart),
- "cursor-end" => Ok(Action::CursorEnd),
+ "cursor-left" => Ok(Self::CursorLeft),
+ "cursor-right" => Ok(Self::CursorRight),
+ "cursor-word-left" => Ok(Self::CursorWordLeft),
+ "cursor-word-right" => Ok(Self::CursorWordRight),
+ "cursor-word-end" => Ok(Self::CursorWordEnd),
+ "cursor-start" => Ok(Self::CursorStart),
+ "cursor-end" => Ok(Self::CursorEnd),
- "delete-char-before" => Ok(Action::DeleteCharBefore),
- "delete-char-after" => Ok(Action::DeleteCharAfter),
- "delete-word-before" => Ok(Action::DeleteWordBefore),
- "delete-word-after" => Ok(Action::DeleteWordAfter),
- "delete-to-word-boundary" => Ok(Action::DeleteToWordBoundary),
- "clear-line" => Ok(Action::ClearLine),
- "clear-to-start" => Ok(Action::ClearToStart),
- "clear-to-end" => Ok(Action::ClearToEnd),
+ "delete-char-before" => Ok(Self::DeleteCharBefore),
+ "delete-char-after" => Ok(Self::DeleteCharAfter),
+ "delete-word-before" => Ok(Self::DeleteWordBefore),
+ "delete-word-after" => Ok(Self::DeleteWordAfter),
+ "delete-to-word-boundary" => Ok(Self::DeleteToWordBoundary),
+ "clear-line" => Ok(Self::ClearLine),
+ "clear-to-start" => Ok(Self::ClearToStart),
+ "clear-to-end" => Ok(Self::ClearToEnd),
- "select-next" => Ok(Action::SelectNext),
- "select-previous" => Ok(Action::SelectPrevious),
- "scroll-half-page-up" => Ok(Action::ScrollHalfPageUp),
- "scroll-half-page-down" => Ok(Action::ScrollHalfPageDown),
- "scroll-page-up" => Ok(Action::ScrollPageUp),
- "scroll-page-down" => Ok(Action::ScrollPageDown),
- "scroll-to-top" => Ok(Action::ScrollToTop),
- "scroll-to-bottom" => Ok(Action::ScrollToBottom),
- "scroll-to-screen-top" => Ok(Action::ScrollToScreenTop),
- "scroll-to-screen-middle" => Ok(Action::ScrollToScreenMiddle),
- "scroll-to-screen-bottom" => Ok(Action::ScrollToScreenBottom),
+ "select-next" => Ok(Self::SelectNext),
+ "select-previous" => Ok(Self::SelectPrevious),
+ "scroll-half-page-up" => Ok(Self::ScrollHalfPageUp),
+ "scroll-half-page-down" => Ok(Self::ScrollHalfPageDown),
+ "scroll-page-up" => Ok(Self::ScrollPageUp),
+ "scroll-page-down" => Ok(Self::ScrollPageDown),
+ "scroll-to-top" => Ok(Self::ScrollToTop),
+ "scroll-to-bottom" => Ok(Self::ScrollToBottom),
+ "scroll-to-screen-top" => Ok(Self::ScrollToScreenTop),
+ "scroll-to-screen-middle" => Ok(Self::ScrollToScreenMiddle),
+ "scroll-to-screen-bottom" => Ok(Self::ScrollToScreenBottom),
- "accept" => Ok(Action::Accept),
- "return-selection" => Ok(Action::ReturnSelection),
- "copy" => Ok(Action::Copy),
- "delete" => Ok(Action::Delete),
- "delete-all" => Ok(Action::DeleteAll),
- "return-original" => Ok(Action::ReturnOriginal),
- "return-query" => Ok(Action::ReturnQuery),
- "exit" => Ok(Action::Exit),
- "redraw" => Ok(Action::Redraw),
- "cycle-filter-mode" => Ok(Action::CycleFilterMode),
- "cycle-search-mode" => Ok(Action::CycleSearchMode),
- "switch-context" => Ok(Action::SwitchContext),
- "clear-context" => Ok(Action::ClearContext),
- "toggle-tab" => Ok(Action::ToggleTab),
+ "accept" => Ok(Self::Accept),
+ "return-selection" => Ok(Self::ReturnSelection),
+ "copy" => Ok(Self::Copy),
+ "delete" => Ok(Self::Delete),
+ "delete-all" => Ok(Self::DeleteAll),
+ "return-original" => Ok(Self::ReturnOriginal),
+ "return-query" => Ok(Self::ReturnQuery),
+ "exit" => Ok(Self::Exit),
+ "redraw" => Ok(Self::Redraw),
+ "cycle-filter-mode" => Ok(Self::CycleFilterMode),
+ "cycle-search-mode" => Ok(Self::CycleSearchMode),
+ "switch-context" => Ok(Self::SwitchContext),
+ "clear-context" => Ok(Self::ClearContext),
+ "toggle-tab" => Ok(Self::ToggleTab),
- "vim-enter-normal" => Ok(Action::VimEnterNormal),
- "vim-enter-insert" => Ok(Action::VimEnterInsert),
- "vim-enter-insert-after" => Ok(Action::VimEnterInsertAfter),
- "vim-enter-insert-at-start" => Ok(Action::VimEnterInsertAtStart),
- "vim-enter-insert-at-end" => Ok(Action::VimEnterInsertAtEnd),
- "vim-search-insert" => Ok(Action::VimSearchInsert),
- "vim-change-to-end" => Ok(Action::VimChangeToEnd),
- "enter-prefix-mode" => Ok(Action::EnterPrefixMode),
+ "vim-enter-normal" => Ok(Self::VimEnterNormal),
+ "vim-enter-insert" => Ok(Self::VimEnterInsert),
+ "vim-enter-insert-after" => Ok(Self::VimEnterInsertAfter),
+ "vim-enter-insert-at-start" => Ok(Self::VimEnterInsertAtStart),
+ "vim-enter-insert-at-end" => Ok(Self::VimEnterInsertAtEnd),
+ "vim-search-insert" => Ok(Self::VimSearchInsert),
+ "vim-change-to-end" => Ok(Self::VimChangeToEnd),
+ "enter-prefix-mode" => Ok(Self::EnterPrefixMode),
- "inspect-previous" => Ok(Action::InspectPrevious),
- "inspect-next" => Ok(Action::InspectNext),
+ "inspect-previous" => Ok(Self::InspectPrevious),
+ "inspect-next" => Ok(Self::InspectNext),
- "noop" => Ok(Action::Noop),
+ "noop" => Ok(Self::Noop),
_ => Err(format!("unknown action: {s}")),
}
@@ -158,65 +158,65 @@ impl Action {
/// Convert to a kebab-case string.
pub(crate) fn as_str(&self) -> String {
match self {
- Action::CursorLeft => "cursor-left".to_string(),
- Action::CursorRight => "cursor-right".to_string(),
- Action::CursorWordLeft => "cursor-word-left".to_string(),
- Action::CursorWordRight => "cursor-word-right".to_string(),
- Action::CursorWordEnd => "cursor-word-end".to_string(),
- Action::CursorStart => "cursor-start".to_string(),
- Action::CursorEnd => "cursor-end".to_string(),
+ Self::CursorLeft => "cursor-left".to_string(),
+ Self::CursorRight => "cursor-right".to_string(),
+ Self::CursorWordLeft => "cursor-word-left".to_string(),
+ Self::CursorWordRight => "cursor-word-right".to_string(),
+ Self::CursorWordEnd => "cursor-word-end".to_string(),
+ Self::CursorStart => "cursor-start".to_string(),
+ Self::CursorEnd => "cursor-end".to_string(),
- Action::DeleteCharBefore => "delete-char-before".to_string(),
- Action::DeleteCharAfter => "delete-char-after".to_string(),
- Action::DeleteWordBefore => "delete-word-before".to_string(),
- Action::DeleteWordAfter => "delete-word-after".to_string(),
- Action::DeleteToWordBoundary => "delete-to-word-boundary".to_string(),
- Action::ClearLine => "clear-line".to_string(),
- Action::ClearToStart => "clear-to-start".to_string(),
- Action::ClearToEnd => "clear-to-end".to_string(),
+ Self::DeleteCharBefore => "delete-char-before".to_string(),
+ Self::DeleteCharAfter => "delete-char-after".to_string(),
+ Self::DeleteWordBefore => "delete-word-before".to_string(),
+ Self::DeleteWordAfter => "delete-word-after".to_string(),
+ Self::DeleteToWordBoundary => "delete-to-word-boundary".to_string(),
+ Self::ClearLine => "clear-line".to_string(),
+ Self::ClearToStart => "clear-to-start".to_string(),
+ Self::ClearToEnd => "clear-to-end".to_string(),
- Action::SelectNext => "select-next".to_string(),
- Action::SelectPrevious => "select-previous".to_string(),
- Action::ScrollHalfPageUp => "scroll-half-page-up".to_string(),
- Action::ScrollHalfPageDown => "scroll-half-page-down".to_string(),
- Action::ScrollPageUp => "scroll-page-up".to_string(),
- Action::ScrollPageDown => "scroll-page-down".to_string(),
- Action::ScrollToTop => "scroll-to-top".to_string(),
- Action::ScrollToBottom => "scroll-to-bottom".to_string(),
- Action::ScrollToScreenTop => "scroll-to-screen-top".to_string(),
- Action::ScrollToScreenMiddle => "scroll-to-screen-middle".to_string(),
- Action::ScrollToScreenBottom => "scroll-to-screen-bottom".to_string(),
+ Self::SelectNext => "select-next".to_string(),
+ Self::SelectPrevious => "select-previous".to_string(),
+ Self::ScrollHalfPageUp => "scroll-half-page-up".to_string(),
+ Self::ScrollHalfPageDown => "scroll-half-page-down".to_string(),
+ Self::ScrollPageUp => "scroll-page-up".to_string(),
+ Self::ScrollPageDown => "scroll-page-down".to_string(),
+ Self::ScrollToTop => "scroll-to-top".to_string(),
+ Self::ScrollToBottom => "scroll-to-bottom".to_string(),
+ Self::ScrollToScreenTop => "scroll-to-screen-top".to_string(),
+ Self::ScrollToScreenMiddle => "scroll-to-screen-middle".to_string(),
+ Self::ScrollToScreenBottom => "scroll-to-screen-bottom".to_string(),
- Action::Accept => "accept".to_string(),
- Action::AcceptNth(n) => format!("accept-{n}"),
- Action::ReturnSelection => "return-selection".to_string(),
- Action::ReturnSelectionNth(n) => format!("return-selection-{n}"),
- Action::Copy => "copy".to_string(),
- Action::Delete => "delete".to_string(),
- Action::DeleteAll => "delete-all".to_string(),
- Action::ReturnOriginal => "return-original".to_string(),
- Action::ReturnQuery => "return-query".to_string(),
- Action::Exit => "exit".to_string(),
- Action::Redraw => "redraw".to_string(),
- Action::CycleFilterMode => "cycle-filter-mode".to_string(),
- Action::CycleSearchMode => "cycle-search-mode".to_string(),
- Action::SwitchContext => "switch-context".to_string(),
- Action::ClearContext => "clear-context".to_string(),
- Action::ToggleTab => "toggle-tab".to_string(),
+ Self::Accept => "accept".to_string(),
+ Self::AcceptNth(n) => format!("accept-{n}"),
+ Self::ReturnSelection => "return-selection".to_string(),
+ Self::ReturnSelectionNth(n) => format!("return-selection-{n}"),
+ Self::Copy => "copy".to_string(),
+ Self::Delete => "delete".to_string(),
+ Self::DeleteAll => "delete-all".to_string(),
+ Self::ReturnOriginal => "return-original".to_string(),
+ Self::ReturnQuery => "return-query".to_string(),
+ Self::Exit => "exit".to_string(),
+ Self::Redraw => "redraw".to_string(),
+ Self::CycleFilterMode => "cycle-filter-mode".to_string(),
+ Self::CycleSearchMode => "cycle-search-mode".to_string(),
+ Self::SwitchContext => "switch-context".to_string(),
+ Self::ClearContext => "clear-context".to_string(),
+ Self::ToggleTab => "toggle-tab".to_string(),
- Action::VimEnterNormal => "vim-enter-normal".to_string(),
- Action::VimEnterInsert => "vim-enter-insert".to_string(),
- Action::VimEnterInsertAfter => "vim-enter-insert-after".to_string(),
- Action::VimEnterInsertAtStart => "vim-enter-insert-at-start".to_string(),
- Action::VimEnterInsertAtEnd => "vim-enter-insert-at-end".to_string(),
- Action::VimSearchInsert => "vim-search-insert".to_string(),
- Action::VimChangeToEnd => "vim-change-to-end".to_string(),
- Action::EnterPrefixMode => "enter-prefix-mode".to_string(),
+ Self::VimEnterNormal => "vim-enter-normal".to_string(),
+ Self::VimEnterInsert => "vim-enter-insert".to_string(),
+ Self::VimEnterInsertAfter => "vim-enter-insert-after".to_string(),
+ Self::VimEnterInsertAtStart => "vim-enter-insert-at-start".to_string(),
+ Self::VimEnterInsertAtEnd => "vim-enter-insert-at-end".to_string(),
+ Self::VimSearchInsert => "vim-search-insert".to_string(),
+ Self::VimChangeToEnd => "vim-change-to-end".to_string(),
+ Self::EnterPrefixMode => "enter-prefix-mode".to_string(),
- Action::InspectPrevious => "inspect-previous".to_string(),
- Action::InspectNext => "inspect-next".to_string(),
+ Self::InspectPrevious => "inspect-previous".to_string(),
+ Self::InspectNext => "inspect-next".to_string(),
- Action::Noop => "noop".to_string(),
+ Self::Noop => "noop".to_string(),
}
}
}
@@ -236,7 +236,7 @@ impl Serialize for Action {
impl<'de> Deserialize<'de> for Action {
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
let s = String::deserialize(deserializer)?;
- Action::from_str(&s).map_err(serde::de::Error::custom)
+ Self::from_str(&s).map_err(serde::de::Error::custom)
}
}
diff --git a/crates/turtle/src/command/client/search/keybindings/conditions.rs b/crates/turtle/src/command/client/search/keybindings/conditions.rs
index f870d9a0..e52e4864 100644
--- a/crates/turtle/src/command/client/search/keybindings/conditions.rs
+++ b/crates/turtle/src/command/client/search/keybindings/conditions.rs
@@ -30,9 +30,9 @@ pub(crate) enum ConditionAtom {
#[derive(Debug, Clone, PartialEq, Eq)]
pub(crate) enum ConditionExpr {
Atom(ConditionAtom),
- Not(Box<ConditionExpr>),
- And(Box<ConditionExpr>, Box<ConditionExpr>),
- Or(Box<ConditionExpr>, Box<ConditionExpr>),
+ Not(Box<Self>),
+ And(Box<Self>, Box<Self>),
+ Or(Box<Self>, Box<Self>),
}
/// Context needed to evaluate conditions. This is a pure snapshot of state —
@@ -62,32 +62,32 @@ impl ConditionAtom {
/// Evaluate this atom against the given context.
pub(crate) fn evaluate(&self, ctx: &EvalContext) -> bool {
match self {
- ConditionAtom::CursorAtStart => ctx.cursor_position == 0,
- ConditionAtom::CursorAtEnd => ctx.cursor_position == ctx.input_width,
- ConditionAtom::InputEmpty => ctx.input_byte_len == 0,
- ConditionAtom::OriginalInputEmpty => ctx.original_input_empty,
- ConditionAtom::ListAtEnd => {
+ Self::CursorAtStart => ctx.cursor_position == 0,
+ Self::CursorAtEnd => ctx.cursor_position == ctx.input_width,
+ Self::InputEmpty => ctx.input_byte_len == 0,
+ Self::OriginalInputEmpty => ctx.original_input_empty,
+ Self::ListAtEnd => {
ctx.results_len == 0 || ctx.selected_index >= ctx.results_len.saturating_sub(1)
}
- ConditionAtom::ListAtStart => ctx.results_len == 0 || ctx.selected_index == 0,
- ConditionAtom::NoResults => ctx.results_len == 0,
- ConditionAtom::HasResults => ctx.results_len > 0,
- ConditionAtom::HasContext => ctx.has_context,
+ Self::ListAtStart => ctx.results_len == 0 || ctx.selected_index == 0,
+ Self::NoResults => ctx.results_len == 0,
+ Self::HasResults => ctx.results_len > 0,
+ Self::HasContext => ctx.has_context,
}
}
/// Parse from a kebab-case string.
pub(crate) fn from_str(s: &str) -> Result<Self, String> {
match s {
- "cursor-at-start" => Ok(ConditionAtom::CursorAtStart),
- "cursor-at-end" => Ok(ConditionAtom::CursorAtEnd),
- "input-empty" => Ok(ConditionAtom::InputEmpty),
- "original-input-empty" => Ok(ConditionAtom::OriginalInputEmpty),
- "list-at-end" => Ok(ConditionAtom::ListAtEnd),
- "list-at-start" => Ok(ConditionAtom::ListAtStart),
- "no-results" => Ok(ConditionAtom::NoResults),
- "has-results" => Ok(ConditionAtom::HasResults),
- "has-context" => Ok(ConditionAtom::HasContext),
+ "cursor-at-start" => Ok(Self::CursorAtStart),
+ "cursor-at-end" => Ok(Self::CursorAtEnd),
+ "input-empty" => Ok(Self::InputEmpty),
+ "original-input-empty" => Ok(Self::OriginalInputEmpty),
+ "list-at-end" => Ok(Self::ListAtEnd),
+ "list-at-start" => Ok(Self::ListAtStart),
+ "no-results" => Ok(Self::NoResults),
+ "has-results" => Ok(Self::HasResults),
+ "has-context" => Ok(Self::HasContext),
_ => Err(format!("unknown condition: {s}")),
}
}
@@ -95,15 +95,15 @@ impl ConditionAtom {
/// Convert to a kebab-case string.
pub(crate) fn as_str(&self) -> &'static str {
match self {
- ConditionAtom::CursorAtStart => "cursor-at-start",
- ConditionAtom::CursorAtEnd => "cursor-at-end",
- ConditionAtom::InputEmpty => "input-empty",
- ConditionAtom::OriginalInputEmpty => "original-input-empty",
- ConditionAtom::ListAtEnd => "list-at-end",
- ConditionAtom::ListAtStart => "list-at-start",
- ConditionAtom::NoResults => "no-results",
- ConditionAtom::HasResults => "has-results",
- ConditionAtom::HasContext => "has-context",
+ Self::CursorAtStart => "cursor-at-start",
+ Self::CursorAtEnd => "cursor-at-end",
+ Self::InputEmpty => "input-empty",
+ Self::OriginalInputEmpty => "original-input-empty",
+ Self::ListAtEnd => "list-at-end",
+ Self::ListAtStart => "list-at-start",
+ Self::NoResults => "no-results",
+ Self::HasResults => "has-results",
+ Self::HasContext => "has-context",
}
}
}
@@ -122,10 +122,10 @@ impl ConditionExpr {
/// Evaluate this expression against the given context.
pub(crate) fn evaluate(&self, ctx: &EvalContext) -> bool {
match self {
- ConditionExpr::Atom(atom) => atom.evaluate(ctx),
- ConditionExpr::Not(inner) => !inner.evaluate(ctx),
- ConditionExpr::And(lhs, rhs) => lhs.evaluate(ctx) && rhs.evaluate(ctx),
- ConditionExpr::Or(lhs, rhs) => lhs.evaluate(ctx) || rhs.evaluate(ctx),
+ Self::Atom(atom) => atom.evaluate(ctx),
+ Self::Not(inner) => !inner.evaluate(ctx),
+ Self::And(lhs, rhs) => lhs.evaluate(ctx) && rhs.evaluate(ctx),
+ Self::Or(lhs, rhs) => lhs.evaluate(ctx) || rhs.evaluate(ctx),
}
}
}
@@ -136,7 +136,7 @@ impl ConditionExpr {
impl From<ConditionAtom> for ConditionExpr {
fn from(atom: ConditionAtom) -> Self {
- ConditionExpr::Atom(atom)
+ Self::Atom(atom)
}
}
@@ -144,17 +144,17 @@ impl From<ConditionAtom> for ConditionExpr {
impl ConditionExpr {
/// Negate this expression: `!self`.
pub(crate) fn not(self) -> Self {
- ConditionExpr::Not(Box::new(self))
+ Self::Not(Box::new(self))
}
/// Conjoin with another expression: `self && other`.
- pub(crate) fn and(self, other: ConditionExpr) -> Self {
- ConditionExpr::And(Box::new(self), Box::new(other))
+ pub(crate) fn and(self, other: Self) -> Self {
+ Self::And(Box::new(self), Box::new(other))
}
/// Disjoin with another expression: `self || other`.
- pub(crate) fn or(self, other: ConditionExpr) -> Self {
- ConditionExpr::Or(Box::new(self), Box::new(other))
+ pub(crate) fn or(self, other: Self) -> Self {
+ Self::Or(Box::new(self), Box::new(other))
}
}
@@ -308,10 +308,10 @@ enum Prec {
impl ConditionExpr {
fn prec(&self) -> Prec {
match self {
- ConditionExpr::Or(..) => Prec::Or,
- ConditionExpr::And(..) => Prec::And,
- ConditionExpr::Not(..) => Prec::Not,
- ConditionExpr::Atom(..) => Prec::Atom,
+ Self::Or(..) => Prec::Or,
+ Self::And(..) => Prec::And,
+ Self::Not(..) => Prec::Not,
+ Self::Atom(..) => Prec::Atom,
}
}
@@ -321,17 +321,17 @@ impl ConditionExpr {
write!(f, "(")?;
}
match self {
- ConditionExpr::Atom(atom) => write!(f, "{atom}")?,
- ConditionExpr::Not(inner) => {
+ Self::Atom(atom) => write!(f, "{atom}")?,
+ Self::Not(inner) => {
write!(f, "!")?;
inner.fmt_with_prec(f, Prec::Not)?;
}
- ConditionExpr::And(lhs, rhs) => {
+ Self::And(lhs, rhs) => {
lhs.fmt_with_prec(f, Prec::And)?;
write!(f, " && ")?;
rhs.fmt_with_prec(f, Prec::And)?;
}
- ConditionExpr::Or(lhs, rhs) => {
+ Self::Or(lhs, rhs) => {
lhs.fmt_with_prec(f, Prec::Or)?;
write!(f, " || ")?;
rhs.fmt_with_prec(f, Prec::Or)?;
@@ -363,7 +363,7 @@ impl Serialize for ConditionExpr {
impl<'de> Deserialize<'de> for ConditionExpr {
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
let s = String::deserialize(deserializer)?;
- ConditionExpr::parse(&s).map_err(serde::de::Error::custom)
+ Self::parse(&s).map_err(serde::de::Error::custom)
}
}
diff --git a/crates/turtle/src/command/client/search/keybindings/defaults.rs b/crates/turtle/src/command/client/search/keybindings/defaults.rs
index 82219b33..4d00b475 100644
--- a/crates/turtle/src/command/client/search/keybindings/defaults.rs
+++ b/crates/turtle/src/command/client/search/keybindings/defaults.rs
@@ -477,7 +477,7 @@ fn apply_config_to_keymap(keymap: &mut Keymap, overrides: &HashMap<String, KeyBi
impl KeymapSet {
/// Build the complete set of default keymaps from settings.
pub(crate) fn defaults(settings: &Settings) -> Self {
- KeymapSet {
+ Self {
emacs: default_emacs_keymap(settings),
vim_normal: default_vim_normal_keymap(settings),
vim_insert: default_vim_insert_keymap(settings),
diff --git a/crates/turtle/src/command/client/search/keybindings/keymap.rs b/crates/turtle/src/command/client/search/keybindings/keymap.rs
index c3b93b59..00678b20 100644
--- a/crates/turtle/src/command/client/search/keybindings/keymap.rs
+++ b/crates/turtle/src/command/client/search/keybindings/keymap.rs
@@ -28,7 +28,7 @@ pub(crate) struct Keymap {
impl KeyRule {
/// Create an unconditional rule.
pub(crate) fn always(action: Action) -> Self {
- KeyRule {
+ Self {
condition: None,
action,
}
@@ -37,7 +37,7 @@ impl KeyRule {
/// Create a conditional rule. Accepts any type convertible to `ConditionExpr`,
/// including bare `ConditionAtom` values.
pub(crate) fn when(condition: impl Into<ConditionExpr>, action: Action) -> Self {
- KeyRule {
+ Self {
condition: Some(condition.into()),
action,
}
@@ -47,21 +47,21 @@ impl KeyRule {
impl KeyBinding {
/// Create a simple (unconditional) binding.
pub(crate) fn simple(action: Action) -> Self {
- KeyBinding {
+ Self {
rules: vec![KeyRule::always(action)],
}
}
/// Create a conditional binding from a list of rules.
pub(crate) fn conditional(rules: Vec<KeyRule>) -> Self {
- KeyBinding { rules }
+ Self { rules }
}
}
impl Keymap {
/// Create an empty keymap.
pub(crate) fn new() -> Self {
- Keymap {
+ Self {
bindings: HashMap::new(),
}
}
@@ -101,7 +101,7 @@ impl Keymap {
/// Merge another keymap into this one. Keys from `other` override keys in `self`.
#[expect(dead_code)]
- pub(crate) fn merge(&mut self, other: &Keymap) {
+ pub(crate) fn merge(&mut self, other: &Self) {
for (key, binding) in &other.bindings {
self.bindings.insert(key.clone(), binding.clone());
}
diff --git a/crates/turtle/src/command/client/server.rs b/crates/turtle/src/command/client/server.rs
index d821d6f8..88b12a7a 100644
--- a/crates/turtle/src/command/client/server.rs
+++ b/crates/turtle/src/command/client/server.rs
@@ -26,7 +26,7 @@ pub(crate) enum Cmd {
impl Cmd {
pub(crate) async fn run(self) -> Result<()> {
match self {
- Cmd::Start { host, port } => {
+ Self::Start { host, port } => {
let settings = Settings::new().wrap_err("could not load server settings")?;
let host = host.as_ref().unwrap_or(&settings.host).clone();
let port = port.unwrap_or(settings.port);
@@ -46,7 +46,7 @@ impl Cmd {
}
}
}
- Cmd::DefaultConfig => {
+ Self::DefaultConfig => {
// TODO(@bpeetz): Add this back <2026-06-11>
println!("TODO");
Ok(())
diff --git a/crates/turtle/src/command/client/sync/status.rs b/crates/turtle/src/command/client/sync/status.rs
index e75171eb..caf3b90f 100644
--- a/crates/turtle/src/command/client/sync/status.rs
+++ b/crates/turtle/src/command/client/sync/status.rs
@@ -16,7 +16,7 @@ pub(crate) async fn run(settings: &Settings) -> Result<()> {
println!("{}", "[Remote]".green());
println!("Address: {}", settings.sync.address);
- println!("User id: {}", me);
+ println!("User id: {me}");
} else {
bail!("You are not logged in to a sync server - cannot show sync status");
}