Skip to content

Commit

Permalink
feat: use TOML as default format for config
Browse files Browse the repository at this point in the history
  • Loading branch information
louis-thevenet committed Oct 23, 2024
1 parent a292bbd commit 3e25a6c
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 154 deletions.
116 changes: 0 additions & 116 deletions .config/config.json5

This file was deleted.

91 changes: 91 additions & 0 deletions .config/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
[keybindings.Explorer]
# App
"<q>" = "Quit"
"<Ctrl-c>" = "Quit"
"<Ctrl-z>" = "Suspend"
# Tabs
"<Shift-Right>" = "TabRight"
"<Shift-l>" = "TabRight"
"<Shift-Left>" = "TabLeft"
"<shift-h>" = "TabLeft"
# Navigation
"<j>" = "Down"
"<Down>" = "Down"
"<Tab>" = "Down"
"<k>" = "Up"
"<Up>" = "Up"
"<BackTab>" = "Up"
"<h>" = "Left"
"<Left>" = "Left"
"<l>" = "Right"
"<Right>" = "Right"
"<Enter>" = "Enter"
"<Backspace>" = "Cancel"
"<s>" = "Search"
"<Esc>" = "Escape"
"<o>" = "Open"
"<r>" = "ReloadVault"
# Scrolling
"<Ctrl-u>" = "ViewUp"
"<Ctrl-k>" = "ViewUp"
"<Ctrl-Up>" = "ViewUp"
"<PageUp>" = "ViewPageUp"
"<Ctrl-j>" = "ViewDown"
"<Ctrl-d>" = "ViewDown"
"<Ctrl-Down>" = "ViewDown"
"<PageDown>" = "ViewPageDown"
"<Ctrl-l>" = "ViewRight"
"<Ctrl-Right>" = "ViewRight"
"<Ctrl-h>" = "ViewLeft"
"<Ctrl-Left>" = "ViewLeft"

[keybindings.Filter]
# App
"<q>" = "Quit"
"<Ctrl-c>" = "Quit"
"<Ctrl-z>" = "Suspend"
# Tabs
"<Shift-Right>" = "TabRight"
"<Shift-l>" = "TabRight"
"<Shift-Left>" = "TabLeft"
"<shift-h>" = "TabLeft"
# Navigation
"<Enter>" = "Enter"
"<s>" = "Search"
"<Esc>" = "Escape"
"<r>" = "ReloadVault"
# Scrolling
"<Ctrl-u>" = "ViewUp"
"<Ctrl-k>" = "ViewUp"
"<Ctrl-Up>" = "ViewUp"
"<PageUp>" = "ViewPageUp"
"<Ctrl-d>" = "ViewDown"
"<Ctrl-j>" = "ViewDown"
"<Ctrl-Down>" = "ViewDown"
"<PageDown>" = "ViewPageDown"
"<Ctrl-l>" = "ViewRight"
"<Ctrl-Right>" = "ViewRight"
"<Ctrl-h>" = "ViewLeft"
"<Ctrl-Left>" = "ViewLeft"

[keybindings.Home]
# App
"<q>" = "Quit"
"<Ctrl-d>" = "Quit"
"<Ctrl-c>" = "Quit"
"<Ctrl-z>" = "Suspend"
# Tabs
"<Shift-Right>" = "TabRight"
"<Shift-l>" = "TabRight"
"<Shift-Left>" = "TabLeft"
"<Shift-h>" = "TabLeft"

[tasks_config]
use_american_format = true
indent_length = 2
parse_dot_files = false
file_tags_propagation = true
ignored = []
# vault_path= "./test-vault"
explorer_default_search_string = "- [ ] "
filter_default_search_string = ""
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

65 changes: 31 additions & 34 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,54 +1,58 @@
[package]
name = "vault-tasks"
version = "0.2.0"
edition = "2021"
repository = "https://github.com/louis-thevenet/vault-tasks"
authors = ["Louis Thevenet <louis.tvnt@gmail.com>"]
build = "build.rs"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[build-dependencies]
anyhow = "1.0.86"
vergen-gix = {version = "1.0.0", features = ["build", "cargo"]}

[dependencies]
better-panic = "0.3.0"
clap = { version = "4.4.5", features = [
"derive",
"cargo",
"wrap_help",
"unicode",
"string",
"unstable-styles",
] }
clap = {version = "4.4.5", features = [
"derive",
"cargo",
"wrap_help",
"unicode",
"string",
"unstable-styles"
]}
color-eyre = "0.6.3"
config = "0.14.0"
crossterm = { version = "0.28.1", features = ["serde", "event-stream"] }
crossterm = {version = "0.28.1", features = ["serde", "event-stream"]}
derive_deref = "1.1.1"
directories = "5.0.1"
futures = "0.3.30"
human-panic = "2.0.1"
json5 = "0.4.1"
lazy_static = "1.5.0"
libc = "0.2.158"
pretty_assertions = "1.4.0"
ratatui = { version = "0.28.1", features = ["serde", "macros"] }
serde = { version = "1.0.208", features = ["derive"] }
ratatui = {version = "0.28.1", features = ["serde", "macros"]}
serde = {version = "1.0.208", features = ["derive"]}
signal-hook = "0.3.17"
strip-ansi-escapes = "0.2.0"
strum = { version = "0.26.3", features = ["derive"] }
tokio = { version = "1.39.3", features = ["full"] }
strum = {version = "0.26.3", features = ["derive"]}
tokio = {version = "1.39.3", features = ["full"]}
tokio-util = "0.7.11"
tracing = "0.1.40"
tracing-error = "0.2.0"
tracing-subscriber = { version = "0.3.18", features = ["env-filter", "serde"] }
tracing-subscriber = {version = "0.3.18", features = ["env-filter", "serde"]}
chrono = "0.4.38"
winnow = "0.6.18"
tui-widget-list = "0.12.2"
tui-input = "0.10.1"
edit = "0.1.5"
tui-widgets = "0.3.1"
toml = "0.8.19"

[build-dependencies]
anyhow = "1.0.86"
vergen-gix = { version = "1.0.0", features = ["build", "cargo"] }
[dev-dependencies]
insta = {version = "1.40.0", features = ["yaml"]}

[package]
name = "vault-tasks"
version = "0.2.0"
edition = "2021"
repository = "https://github.com/louis-thevenet/vault-tasks"
authors = ["Louis Thevenet <louis.tvnt@gmail.com>"]
build = "build.rs"

[profile.dev.package]
insta.opt-level = 3

# The profile that 'cargo dist' will build with
[profile.dist]
Expand All @@ -68,10 +72,3 @@ targets = ["aarch64-apple-darwin", "x86_64-apple-darwin", "x86_64-unknown-linux-
# Publish jobs to run in CI
pr-run-mode = "plan"
install-updater = true

[dev-dependencies]
insta = { version = "1.40.0", features = ["yaml"] }

[profile.dev.package]
insta.opt-level = 3
similar.opt-level = 3
6 changes: 3 additions & 3 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use ratatui::style::{Color, Modifier, Style};
use serde::{de::Deserializer, Deserialize};
use tracing::{debug, info};

const CONFIG: &str = include_str!("../.config/config.json5");
const CONFIG: &str = include_str!("../.config/config.toml");

#[derive(Clone, Debug, Deserialize, Default)]
pub struct AppConfig {
Expand Down Expand Up @@ -74,7 +74,7 @@ lazy_static! {

impl Default for Config {
fn default() -> Self {
let mut config: Self = json5::from_str(CONFIG).unwrap();
let mut config: Self = toml::from_str(CONFIG).unwrap();
if cfg!(test) {
config.tasks_config.vault_path = PathBuf::from("./test-vault");
}
Expand Down Expand Up @@ -166,7 +166,7 @@ impl Config {

pub fn generate_config(path: Option<PathBuf>) -> Result<()> {
let config_dir = path.unwrap_or_else(get_config_dir);
let dest = config_dir.join("config.json5");
let dest = config_dir.join("config.toml");
if create_dir_all(config_dir).is_err() {
bail!("Failed to create config directory at {dest:?}".to_owned());
}
Expand Down

0 comments on commit 3e25a6c

Please # to comment.