diff --git a/.config/config.ron b/.config/config.ron index e0de0cb..59f20c8 100644 --- a/.config/config.ron +++ b/.config/config.ron @@ -1,29 +1,27 @@ ( - directory: "./ZettelKasten", + directory: "/Users/suri/dev/projects/filaments/ZettelKasten", global_key_binds: { + "up": MoveUp, "ctrl-c": Quit, "ctrl-z": Suspend, - "up": MoveUp, "down": MoveDown, }, zk: ( keybinds: { - "": NewZettel, "enter": OpenZettel, - "tab": SwitchTo ( - region: Todo - ), - + "tab": SwitchTo( + region: Todo, + ), + "": NewZettel, }, ), todo: ( keybinds: { - "j": MoveDown, "k": MoveUp, - "tab": SwitchTo ( - region: Zk - ), - + "j": MoveDown, + "tab": SwitchTo( + region: Zk, + ), }, ), -) +) \ No newline at end of file diff --git a/.config/default_config.ron b/.config/default_config.ron new file mode 100644 index 0000000..a9265d6 --- /dev/null +++ b/.config/default_config.ron @@ -0,0 +1,27 @@ +( + directory: "{INSERT_ROOT_HERE}", + global_key_binds: { + "up": MoveUp, + "ctrl-c": Quit, + "ctrl-z": Suspend, + "down": MoveDown, + }, + zk: ( + keybinds: { + "enter": OpenZettel, + "tab": SwitchTo( + region: Todo, + ), + "": NewZettel, + }, + ), + todo: ( + keybinds: { + "k": MoveUp, + "j": MoveDown, + "tab": SwitchTo( + region: Zk, + ), + }, + ), +) diff --git a/src/cli/process.rs b/src/cli/process.rs index f9a1671..79d9989 100644 --- a/src/cli/process.rs +++ b/src/cli/process.rs @@ -44,7 +44,6 @@ impl Commands { Self::Zettel(zettel_sub_command) => { let conf = Config::parse()?; - // let ws = Workspace::instansiate(conf.fil_dir).await?; let mut kt = Kasten::instansiate(conf.fil_dir).await?; match zettel_sub_command { diff --git a/src/config/mod.rs b/src/config/mod.rs index 29126ed..a9ec0b7 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -7,6 +7,7 @@ use std::{ use color_eyre::eyre::Result; use directories::ProjectDirs; +use ron::ser::PrettyConfig; use crate::config::{file::RonConfig, keymap::KeyMap}; @@ -31,7 +32,7 @@ pub static CONFIG_DIRECTORY: LazyLock> = LazyLock::new(|| { .map(PathBuf::from) }); -const DEFAULT_CONFIG: &str = include_str!("../../.config/config.ron"); +const DEFAULT_CONFIG: &str = include_str!("../../.config/default_config.ron"); #[derive(Debug, Clone)] pub struct Config { @@ -47,7 +48,10 @@ impl Config { default_conf.directory = fil_dir.canonicalize()?; - Ok(ron::to_string(&default_conf)?) + Ok(ron::ser::to_string_pretty( + &default_conf, + PrettyConfig::default(), + )?) } /// Parse the config from `~/.config/filaments`, but will prioritize /// `FIL_CONFIG_DIR`. diff --git a/src/tui/components/zk/mod.rs b/src/tui/components/zk/mod.rs index 6d055d7..ef6921e 100644 --- a/src/tui/components/zk/mod.rs +++ b/src/tui/components/zk/mod.rs @@ -105,9 +105,6 @@ impl Zk<'_> { let preview = Preview::from(zettel.content(&kt.index).clone()); - // okay now that we have the zettel we need to construct the zettel out of this id - let zettel_view: ZettelView = zettel.into(); - drop(kt); Ok(Self { @@ -116,7 +113,7 @@ impl Zk<'_> { kh, layouts: Layouts::default(), zettel_list, - zettel_view, + zettel_view: zettel.into(), preview, }) } @@ -140,12 +137,11 @@ impl Zk<'_> { .await? .context("Unknown Behaviour, A selected zettel got deleted somehow.")?; - self.zettel_view = zettel.into(); - self.preview = zettel.content(&kh.index).clone().into(); - drop(kh); + self.zettel_view = zettel.into(); + Ok(()) } diff --git a/src/types/kasten.rs b/src/types/kasten.rs index 5190f10..3fe73bc 100644 --- a/src/types/kasten.rs +++ b/src/types/kasten.rs @@ -34,7 +34,6 @@ impl Kasten { /// at that path. pub async fn instansiate(root: impl Into) -> Result { let root = root.into(); - let db_conn_string = format!( "sqlite://{}", root.clone() diff --git a/src/types/zettel/id.rs b/src/types/zettel/id.rs index 9f02719..11ac921 100644 --- a/src/types/zettel/id.rs +++ b/src/types/zettel/id.rs @@ -96,5 +96,13 @@ mod tests { .expect("Should be able to parse the test path just file"); assert_eq!(id.0, "abcdef".into()); + + let path = PathBuf::from("/what/the/fuck/are/you/abcdef.md"); + + let id: ZettelId = path + .try_into() + .expect("Should be able to parse the test path just file"); + + assert_eq!(id.0, "abcdef".into()); } }