aboutsummaryrefslogtreecommitdiff
path: root/src/config.rs
diff options
context:
space:
mode:
authorlukeflo2025-10-13 15:45:53 +0200
committerlukeflo2025-10-13 15:57:42 +0200
commit467851007e1861834326deee3116aa88fe839f5a (patch)
tree7e1cb113d99c32ad5b434f7e87d851cd9c9be382 /src/config.rs
parent0a8805acfb6fbb3d3a8c22f4ccbaf692a73cddfb (diff)
downloadbibiman-467851007e1861834326deee3116aa88fe839f5a.tar.gz
bibiman-467851007e1861834326deee3116aa88fe839f5a.zip
Working proof of concept of citekey formatting
Diffstat (limited to 'src/config.rs')
-rw-r--r--src/config.rs69
1 files changed, 69 insertions, 0 deletions
diff --git a/src/config.rs b/src/config.rs
index b1c4b07..7c1a0f8 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -20,6 +20,7 @@ use std::{
io::{Write, stdin},
path::PathBuf,
str::FromStr,
+ sync::LazyLock,
};
use color_eyre::{eyre::Result, owo_colors::OwoColorize};
@@ -40,6 +41,31 @@ pub const IGNORED_SPECIAL_CHARS: [char; 33] = [
'&', '/', '`', '´', '#', '+', '*', '=', '|', '<', '>', '^', '°', '_', '"',
];
+pub static IGNORED_WORDS: LazyLock<Vec<String>> = LazyLock::new(|| {
+ vec![
+ String::from("the"),
+ String::from("a"),
+ String::from("an"),
+ String::from("of"),
+ String::from("for"),
+ String::from("in"),
+ String::from("at"),
+ String::from("to"),
+ String::from("and"),
+ String::from("der"),
+ String::from("die"),
+ String::from("das"),
+ String::from("ein"),
+ String::from("eine"),
+ String::from("eines"),
+ String::from("des"),
+ String::from("auf"),
+ String::from("und"),
+ String::from("für"),
+ String::from("vor"),
+ ]
+});
+
const DEFAULT_CONFIG: &str = r##"
# [general]
## Default files/dirs which are loaded on startup
@@ -118,6 +144,40 @@ const DEFAULT_CONFIG: &str = r##"
## Convert chars to specified case. Possible values:
## "upper", "uppercase", "lower", "lowercase"
# case = "lowercase"
+
+## Map all unicode chars to their pure ascii equivalent
+# ascii_only = true
+
+## List of special chars that'll be ignored when building citekeys.
+## A custom list will overwrite the default list
+# ignored_chars = [
+# "?", "!", "\\", "\'", ".", "-", "–", ":", ",", "[", "]", "(", ")", "{", "}", "§", "$", "%", "&", "/", "`", "´", "#", "+", "*", "=", "|", "<", ">", "^", "°", "_", """,
+# ]
+
+## List of words that'll be ignored when building citekeys.
+## A custom list will overwrite the default list
+# ignored_words = [
+# "the",
+# "a",
+# "an",
+# "of",
+# "for",
+# "in",
+# "at",
+# "to",
+# "and",
+# "der",
+# "die",
+# "das",
+# "ein",
+# "eine",
+# "eines",
+# "des",
+# "auf",
+# "und",
+# "für",
+# "vor",
+# ]
"##;
/// Main struct of the config file. Contains substructs/headings in toml
@@ -171,6 +231,9 @@ pub struct Colors {
pub struct CitekeyFormatter {
pub fields: Option<Vec<String>>,
pub case: Option<CitekeyCase>,
+ pub ascii_only: bool,
+ pub ignored_chars: Option<Vec<char>>,
+ pub ignored_words: Option<Vec<String>>,
}
impl Default for BibiConfig {
@@ -194,6 +257,9 @@ impl Default for BibiConfig {
citekey_formatter: CitekeyFormatter {
fields: None,
case: None,
+ ascii_only: true,
+ ignored_chars: None,
+ ignored_words: None,
},
}
}
@@ -224,6 +290,9 @@ impl BibiConfig {
citekey_formatter: CitekeyFormatter {
fields: None,
case: None,
+ ascii_only: true,
+ ignored_chars: None,
+ ignored_words: None,
},
}
}