Skip to content

Commit

Permalink
feat(marks): update the default sign to indicate mark time type
Browse files Browse the repository at this point in the history
  • Loading branch information
myypo committed Aug 17, 2024
1 parent 5f4e8b6 commit aae283a
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 15 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,12 @@ Default configuration:
},

-- Which signs to use for different mark types relatively to the current position
-- You can find more Unicode options online, and, if using a patched nerdfont, here: https://www.nerdfonts.com/cheat-sheet
signs = {
past = "",
close_past = "",
future = "",
close_future = "",
past = "",
close_past = "",
future = "",
close_future = "",
},
},

Expand Down
12 changes: 6 additions & 6 deletions compass/src/config/common/sign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ use serde::Deserialize;
#[derive(Debug, Deserialize)]
pub struct SignText(String);

impl Default for SignText {
fn default() -> Self {
Self("●".to_owned())
}
}

impl From<SignText> for String {
fn from(value: SignText) -> String {
value.0
}
}

impl From<String> for SignText {
fn from(value: String) -> SignText {
SignText(value)
}
}

impl Deref for SignText {
type Target = str;

Expand Down
29 changes: 24 additions & 5 deletions compass/src/config/marks/signs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,34 @@ use crate::config::SignText;

use serde::Deserialize;

#[derive(Debug, Default, Deserialize)]
#[derive(Debug, Deserialize)]
pub struct Signs {
#[serde(default)]
#[serde(default = "default_past")]
pub past: SignText,
#[serde(default)]
#[serde(default = "default_past")]
pub close_past: SignText,

#[serde(default)]
#[serde(default = "default_future")]
pub future: SignText,
#[serde(default)]
#[serde(default = "default_future")]
pub close_future: SignText,
}

fn default_past() -> SignText {
"◀".to_owned().into()
}

fn default_future() -> SignText {
"▶".to_owned().into()
}

impl Default for Signs {
fn default() -> Self {
Self {
past: default_past(),
close_past: default_past(),
future: default_future(),
close_future: default_future(),
}
}
}

0 comments on commit aae283a

Please sign in to comment.