My personal-knowledge-system, with deeply integrated task tracking and long term goal planning capabilities.
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: move from kdl to ron for config file format

+287 -240
+22
.config/config.ron
··· 1 + ( 2 + directory: "./ZettelKasten", 3 + global_key_binds: { 4 + "ctrl-c": Quit, 5 + "ctrl-z": Suspend, 6 + "up": MoveUp, 7 + "down": MoveDown, 8 + }, 9 + zk: ( 10 + keybinds: { 11 + "<Ctrl-n>": NewZettel, 12 + "enter": OpenZettel, 13 + }, 14 + ), 15 + todo: ( 16 + keybinds: { 17 + "j": MoveDown, 18 + "k": MoveUp, 19 + // "<ctrl-d>": HalfPageDown, 20 + }, 21 + ), 22 + )
+3 -2
Cargo.lock
··· 2309 2309 "ratatui", 2310 2310 "ratatui-textarea", 2311 2311 "rayon", 2312 + "ron", 2312 2313 "serde", 2313 2314 "signal-hook 0.4.3", 2314 2315 "strum 0.28.0", ··· 6018 6019 6019 6020 [[package]] 6020 6021 name = "ron" 6021 - version = "0.12.0" 6022 + version = "0.12.1" 6022 6023 source = "registry+https://github.com/rust-lang/crates.io-index" 6023 - checksum = "fd490c5b18261893f14449cbd28cb9c0b637aebf161cd77900bfdedaff21ec32" 6024 + checksum = "4147b952f3f819eca0e99527022f7d6a8d05f111aeb0a62960c74eb283bec8fc" 6024 6025 dependencies = [ 6025 6026 "bitflags 2.11.0", 6026 6027 "once_cell",
+1
Cargo.toml
··· 81 81 pulldown-cmark = { version = "0.13.3", features = ["simd"] } 82 82 ratatui-textarea = "0.8.0" 83 83 nucleo-matcher = "0.3.1" 84 + ron = "0.12.1" 84 85 85 86 [build-dependencies] 86 87 anyhow = "1.0.102"
+1 -3
crates/dto/tests/zettel.rs
··· 2 2 ActiveModelTrait, ActiveValue::Set, ColorDTO, TagActiveModel, TagEntity, TagModel, 3 3 ZettelActiveModel, ZettelEntity, ZettelModel, 4 4 }; 5 - use sea_orm::{IntoActiveModel, QueryOrder}; 5 + use sea_orm::IntoActiveModel; 6 6 7 7 mod common; 8 8 ··· 56 56 let zettels_for_tag = TagEntity::load() 57 57 .filter_by_nano_id(tag.nano_id.clone()) 58 58 .with(ZettelEntity) 59 - 60 59 .all(&db) 61 - 62 60 .await 63 61 .unwrap(); 64 62
+6 -6
flake.lock
··· 8 8 "rust-analyzer-src": "rust-analyzer-src" 9 9 }, 10 10 "locked": { 11 - "lastModified": 1775115015, 12 - "narHash": "sha256-XO7jmyFupI82Sr1M2tLfsSxslIJwUOjzhFqeffaWyNw=", 11 + "lastModified": 1775287186, 12 + "narHash": "sha256-hYntDpbh8MuiYRmBf/6uHMpDOP2m7L7bXQXboWPg6WM=", 13 13 "owner": "nix-community", 14 14 "repo": "fenix", 15 - "rev": "45f82ed61800d52e27390b70823426045d982c84", 15 + "rev": "2517c7fb1eafc7259bb631267f1e1f813cf5f3bc", 16 16 "type": "github" 17 17 }, 18 18 "original": { ··· 44 44 "rust-analyzer-src": { 45 45 "flake": false, 46 46 "locked": { 47 - "lastModified": 1775045117, 48 - "narHash": "sha256-PLZYhcg3HUZ+lUMUV+JbXs9ExOAYpZC0PAtOVHCgYss=", 47 + "lastModified": 1775228522, 48 + "narHash": "sha256-+6eTD6EAabjow5gdjWRP6aI2UUwOZJEjzzsvvbVu8f8=", 49 49 "owner": "rust-lang", 50 50 "repo": "rust-analyzer", 51 - "rev": "e599ad4fc8861e0401906e4d730f74bfcc530e07", 51 + "rev": "f4b77dc99d9925667246e2887783b79bdc46a50d", 52 52 "type": "github" 53 53 }, 54 54 "original": {
+3
flake.nix
··· 124 124 # Set any environment variables for your dev shell 125 125 env = { 126 126 RUST_SRC_PATH = "${pkgs.rustToolchain}/lib/rustlib/src/rust/library"; 127 + 128 + # project specific vars 127 129 FIL_CONFIG = "./.config"; 128 130 FIL_DATA = "./.data"; 131 + FIL_LOG_LEVEL = "DEBUG"; 129 132 }; 130 133 131 134 # Add any shell logic you want executed any time the environment is activated
+4 -4
src/cli/process.rs
··· 24 24 Workspace::initialize(dir.clone()).await?; 25 25 26 26 // write config that sets the filaments directory to current dir! 27 - let config_kdl = dbg! {Config::generate(&dir)}; 27 + let config_str = dbg! {Config::generate(&dir)}?; 28 28 29 29 // create the config dir 30 30 let config_dir = get_config_dir(); 31 31 32 32 create_dir_all(config_dir).expect("creating the config dir should not error"); 33 33 34 - let mut config_file = File::create(get_config_dir().join("config.kdl")) 34 + let mut config_file = File::create(get_config_dir().join("config.ron")) 35 35 .context("Failed to create config file")?; 36 36 37 - write!(config_file, "{config_kdl}")?; 37 + write!(config_file, "{config_str}")?; 38 38 39 39 println!("wrote config to {config_file:#?}"); 40 40 ··· 44 44 45 45 Self::Zettel(zettel_sub_command) => { 46 46 let conf = Config::parse()?; 47 - let ws = Workspace::instansiate(conf.app_config.workspace).await?; 47 + let ws = Workspace::instansiate(conf.fil_dir).await?; 48 48 49 49 match zettel_sub_command { 50 50 ZettelSubcommand::New { title } => {
-152
src/config.rs
··· 1 - use color_eyre::eyre::Context; 2 - use directories::ProjectDirs; 3 - use kdl::KdlDocument; 4 - use serde::Deserialize; 5 - use std::{ 6 - env::{self, home_dir}, 7 - fmt::Debug, 8 - fs::File, 9 - io::Read, 10 - path::{Path, PathBuf}, 11 - sync::LazyLock, 12 - }; 13 - 14 - use crate::tui::KeyMap; 15 - 16 - /// Project Name: Filaments 17 - pub static PROJECT_NAME: LazyLock<String> = 18 - LazyLock::new(|| env!("CARGO_CRATE_NAME").to_uppercase()); 19 - 20 - /// The OS-agnostic data directory for the project. 21 - pub static DATA_DIRECTORY: LazyLock<Option<PathBuf>> = LazyLock::new(|| { 22 - env::var(format!("{}_DATA", PROJECT_NAME.clone())) 23 - .ok() 24 - .map(PathBuf::from) 25 - }); 26 - 27 - /// The OS-agnostic config directory for the project. 28 - pub static CONFIG_DIRECTORY: LazyLock<Option<PathBuf>> = LazyLock::new(|| { 29 - env::var(format!("{}_CONFIG", PROJECT_NAME.clone())) 30 - .ok() 31 - .map(PathBuf::from) 32 - }); 33 - 34 - const DEFAULT_CONFIG: &str = include_str!("../.config/config.kdl"); 35 - 36 - /// The App Config and Data locations. 37 - #[derive(Clone, Debug, Deserialize, Default)] 38 - #[expect(dead_code)] 39 - pub struct AppConfig { 40 - /// The directory where the single instance of the filaments exists. 41 - pub workspace: PathBuf, 42 - #[serde(default)] 43 - pub data: PathBuf, 44 - #[serde(default)] 45 - pub config: PathBuf, 46 - } 47 - 48 - /// Configuration for the App 49 - #[derive(Debug, Clone)] 50 - pub struct Config { 51 - pub app_config: AppConfig, 52 - pub keymap: KeyMap, 53 - // pub styles: Styles, 54 - } 55 - 56 - impl Config { 57 - /// generates a new config with the provided `filaments_dir` 58 - pub fn generate(filaments_dir: &Path) -> KdlDocument { 59 - 60 - 61 - let mut default_config: KdlDocument = DEFAULT_CONFIG 62 - .parse() 63 - .expect("Default config should always be a valid KDL document."); 64 - 65 - if let Some(node) = default_config 66 - .nodes_mut() 67 - .iter_mut() 68 - .find(|n| n.name().value() == "filaments_dir") 69 - && let Some(entry) = node.entries_mut().get_mut(0) 70 - { 71 - *entry.value_mut() = kdl::KdlValue::String(filaments_dir.to_string_lossy().to_string()); 72 - entry.clear_format(); 73 - } 74 - 75 - default_config 76 - } 77 - 78 - /// Parse the config from `~/.config/filametns` 79 - /// 80 - /// # Errors 81 - /// 82 - /// Will error if the config doesn't exist or if there 83 - /// is a problem parsing it. 84 - pub fn parse() -> color_eyre::Result<Self> { 85 - let config: KdlDocument = { 86 - let file_path = get_config_dir().join("config.kdl"); 87 - 88 - let mut file = File::open(file_path).context("Failed to find file!")?; 89 - 90 - let mut str = String::new(); 91 - 92 - file.read_to_string(&mut str) 93 - .context("Failed to read file!")?; 94 - 95 - str.parse().context("Expected to be valid kdl")? 96 - }; 97 - 98 - let keymap = KeyMap::try_from( 99 - config 100 - .get("keymap") 101 - .expect("Keymap must exist in the config"), 102 - ) 103 - .context("Keymap is not valid!")?; 104 - 105 - let filaments_dir_str = config 106 - .get("filaments_dir") 107 - .expect("config should always have this specified") 108 - .get(0) 109 - .and_then(|arg| arg.as_string()) 110 - .expect("filaments_dir must be a string"); 111 - 112 - let filaments_dir = PathBuf::from(filaments_dir_str) 113 - .canonicalize() 114 - .context("Filaments directory does not exist!")?; 115 - 116 - Ok(Self { 117 - app_config: AppConfig { 118 - workspace: filaments_dir, 119 - data: get_data_dir(), 120 - config: get_config_dir(), 121 - }, 122 - keymap, 123 - }) 124 - } 125 - } 126 - 127 - /// Returns the path to the OS-agnostic data directory. 128 - pub fn get_data_dir() -> PathBuf { 129 - DATA_DIRECTORY.clone().unwrap_or_else(|| { 130 - project_directory().map_or_else( 131 - || PathBuf::from(".").join(".data"), 132 - |proj_dirs| proj_dirs.data_local_dir().to_path_buf(), 133 - ) 134 - }) 135 - } 136 - 137 - /// Returns the path to the OS-agnostic config directory. 138 - pub fn get_config_dir() -> PathBuf { 139 - CONFIG_DIRECTORY.clone().unwrap_or_else(|| { 140 - home_dir().map_or_else( 141 - || PathBuf::from(".").join(".config"), 142 - |mut path| { 143 - path.push(".config"); 144 - path.push("filaments"); 145 - path 146 - }, 147 - ) 148 - }) 149 - } 150 - fn project_directory() -> Option<ProjectDirs> { 151 - ProjectDirs::from("com", "suri-codes", env!("CARGO_PKG_NAME")) 152 - }
+56
src/config/file.rs
··· 1 + use std::{collections::HashMap, path::PathBuf}; 2 + 3 + use serde::{Deserialize, Serialize}; 4 + 5 + use crate::tui::Signal; 6 + 7 + #[derive(Debug, Deserialize, Serialize)] 8 + pub struct RonConfig { 9 + pub directory: PathBuf, 10 + pub global_key_binds: HashMap<String, Signal>, 11 + pub zk: ZkConfig, 12 + pub todo: TodoConfig, 13 + } 14 + 15 + #[derive(Debug, Deserialize, Serialize)] 16 + pub struct ZkConfig { 17 + pub keybinds: HashMap<String, Signal>, 18 + } 19 + 20 + #[derive(Debug, Deserialize, Serialize)] 21 + pub struct TodoConfig { 22 + pub keybinds: HashMap<String, Signal>, 23 + } 24 + 25 + #[cfg(test)] 26 + mod tests { 27 + 28 + use super::*; 29 + use std::{collections::HashMap, path::PathBuf}; 30 + 31 + #[test] 32 + fn fucking_around_with_ron() { 33 + let x = RonConfig { 34 + directory: PathBuf::from("some/notes/dir"), 35 + global_key_binds: HashMap::from([("<Ctrl-C>".to_string(), Signal::Quit)]), 36 + zk: ZkConfig { 37 + keybinds: HashMap::from([ 38 + ("<Enter>".to_string(), Signal::OpenZettel), 39 + ("<Esc>".to_string(), Signal::MoveDown), 40 + ]), 41 + }, 42 + todo: TodoConfig { 43 + keybinds: HashMap::from([ 44 + ("<Space>".to_string(), Signal::NewZettel), 45 + ("<Esc>".to_string(), Signal::MoveUp), 46 + ]), 47 + }, 48 + }; 49 + 50 + let ron_string = ron::ser::to_string_pretty(&x, ron::ser::PrettyConfig::default()) 51 + .expect("failed to serialize"); 52 + 53 + println!("{ron_string}"); 54 + panic!() 55 + } 56 + }
+100
src/config/mod.rs
··· 1 + use std::{ 2 + env::{self, home_dir}, 3 + fs::read_to_string, 4 + path::{Path, PathBuf}, 5 + sync::LazyLock, 6 + }; 7 + 8 + use color_eyre::eyre::Result; 9 + use directories::ProjectDirs; 10 + 11 + use crate::config::{file::RonConfig, keymap::KeyMap}; 12 + 13 + mod file; 14 + mod keymap; 15 + 16 + /// Project Name: Filaments 17 + pub static PROJECT_NAME: LazyLock<String> = 18 + LazyLock::new(|| env!("CARGO_CRATE_NAME").to_uppercase()); 19 + 20 + /// The OS-agnostic data directory for the project. 21 + pub static DATA_DIRECTORY: LazyLock<Option<PathBuf>> = LazyLock::new(|| { 22 + env::var(format!("{}_DATA", PROJECT_NAME.clone())) 23 + .ok() 24 + .map(PathBuf::from) 25 + }); 26 + 27 + /// The OS-agnostic config directory for the project. 28 + pub static CONFIG_DIRECTORY: LazyLock<Option<PathBuf>> = LazyLock::new(|| { 29 + env::var(format!("{}_CONFIG", PROJECT_NAME.clone())) 30 + .ok() 31 + .map(PathBuf::from) 32 + }); 33 + 34 + const DEFAULT_CONFIG: &str = include_str!("../../.config/config.ron"); 35 + 36 + #[derive(Debug, Clone)] 37 + pub struct Config { 38 + pub fil_dir: PathBuf, 39 + pub keymap: KeyMap, 40 + } 41 + 42 + impl Config { 43 + /// generates a new config with the provided `filaments_dir` 44 + pub fn generate(fil_dir: &Path) -> Result<String> { 45 + let mut default_conf: RonConfig = ron::from_str(DEFAULT_CONFIG) 46 + .expect("The default config must always be a valid RonConfig"); 47 + 48 + default_conf.directory = fil_dir.canonicalize()?; 49 + 50 + Ok(ron::to_string(&default_conf)?) 51 + } 52 + /// Parse the config from `~/.config/filaments`, but will prioritize 53 + /// `FIL_CONFIG_DIR`. 54 + /// 55 + /// # Errors 56 + /// 57 + /// Will error if the config doesn't exist or if there 58 + /// is a problem parsing it. 59 + pub fn parse() -> Result<Self> { 60 + let ron: RonConfig = { 61 + let file_path = get_config_dir().join("config.ron"); 62 + ron::from_str(&read_to_string(file_path)?)? 63 + }; 64 + 65 + let keymap = KeyMap::try_from(&ron)?; 66 + 67 + Ok(Self { 68 + fil_dir: ron.directory.canonicalize()?, 69 + keymap, 70 + }) 71 + } 72 + } 73 + 74 + /// Returns the path to the OS-agnostic data directory. 75 + pub fn get_data_dir() -> PathBuf { 76 + DATA_DIRECTORY.clone().unwrap_or_else(|| { 77 + project_directory().map_or_else( 78 + || PathBuf::from(".").join(".data"), 79 + |proj_dirs| proj_dirs.data_local_dir().to_path_buf(), 80 + ) 81 + }) 82 + } 83 + 84 + /// Returns the path to the OS-agnostic config directory. 85 + pub fn get_config_dir() -> PathBuf { 86 + CONFIG_DIRECTORY.clone().unwrap_or_else(|| { 87 + home_dir().map_or_else( 88 + || PathBuf::from(".").join(".config"), 89 + |mut path| { 90 + path.push(".config"); 91 + path.push("filaments"); 92 + path 93 + }, 94 + ) 95 + }) 96 + } 97 + 98 + fn project_directory() -> Option<ProjectDirs> { 99 + ProjectDirs::from("com", "suri-codes", env!("CARGO_PKG_NAME")) 100 + }
+3 -3
src/main.rs
··· 13 13 }; 14 14 use clap::Parser; 15 15 use tokio::sync::RwLock; 16 - use tracing::debug; 16 + use tracing::info; 17 17 18 18 mod cli; 19 19 mod gui; ··· 41 41 // create the kasten handle 42 42 let kh: KastenHandle = rt.block_on(async { 43 43 let cfg = Config::parse()?; 44 - let ws = Workspace::instansiate(cfg.app_config.workspace).await?; 44 + let ws = Workspace::instansiate(cfg.fil_dir).await?; 45 45 Ok::<KastenHandle, color_eyre::Report>(Arc::new(RwLock::new(Kasten::index(ws).await?))) 46 46 })?; 47 47 48 - debug!("{kh:#?}"); 48 + info!("{kh:#?}"); 49 49 50 50 // then we spawn the tui on its own thread 51 51 let tui_handle = std::thread::spawn({
+1 -4
src/tui/app.rs
··· 10 10 11 11 use crate::{ 12 12 config::Config, 13 - tui::{ 14 - Event, Tui, 15 - components::{Viewport, Zk}, 16 - }, 13 + tui::{Event, Tui, components::Viewport}, 17 14 types::KastenHandle, 18 15 }; 19 16
+3 -1
src/tui/components/todo/mod.rs
··· 12 12 types::KastenHandle, 13 13 }; 14 14 15 + #[expect(dead_code)] 15 16 pub struct Todo { 16 17 signal_tx: Option<UnboundedSender<Signal>>, 17 18 kh: KastenHandle, ··· 28 29 } 29 30 } 30 31 32 + #[expect(dead_code)] 31 33 struct Layouts { 32 34 main: Layout, 33 35 } ··· 42 44 43 45 #[async_trait] 44 46 impl Component for Todo { 45 - async fn update(&mut self, signal: Signal) -> color_eyre::Result<Option<Signal>> { 47 + async fn update(&mut self, _signal: Signal) -> color_eyre::Result<Option<Signal>> { 46 48 Ok(None) 47 49 } 48 50
+3 -3
src/tui/components/viewport/mod.rs
··· 4 4 use ratatui::{ 5 5 Frame, 6 6 layout::{Constraint, Layout, Rect}, 7 - style::{Color, Stylize}, 8 - widgets::Block, 9 7 }; 10 8 use tokio::sync::mpsc::UnboundedSender; 11 9 ··· 20 18 21 19 pub struct Viewport<'text> { 22 20 signal_tx: Option<UnboundedSender<Signal>>, 21 + #[expect(dead_code)] 23 22 kh: KastenHandle, 24 23 layouts: Layouts, 25 24 switcher: Switcher<'text>, ··· 84 83 } 85 84 86 85 fn draw(&mut self, frame: &mut Frame, area: Rect) -> color_eyre::Result<()> { 87 - let (main_layout, switcher_layout) = { 86 + // figure out how we are to do this after 87 + let (main_layout, _switcher_layout) = { 88 88 let rects = self.layouts.main_switcher.split(area); 89 89 (rects[0], rects[1]) 90 90 };
+4 -1
src/tui/components/zk/mod.rs
··· 100 100 101 101 let kt = kh.read().await; 102 102 103 + info!("{selected_zettel:#?}"); 104 + info!("{kt:#?}"); 105 + 103 106 let zettel = kt 104 107 .get_node_by_zettel_id(selected_zettel) 105 - .expect("") 108 + .expect("kasten should have the selected zettel") 106 109 .payload(); 107 110 108 111 let preview = Preview::from(
+1 -1
src/tui/components/zk/preview.rs
··· 1 - use ratatui::{style::Style, text::Text, widgets::Widget}; 1 + use ratatui::{text::Text, widgets::Widget}; 2 2 3 3 #[derive(Debug, Clone)] 4 4 pub struct Preview<'text> {
+58 -55
src/tui/keymap.rs src/config/keymap.rs
··· 1 + use color_eyre::eyre::{Result, eyre}; 2 + use crossterm::event::{KeyCode, KeyModifiers}; 1 3 use std::{ 2 4 collections::HashMap, 3 5 ops::{Deref, DerefMut}, 4 6 }; 5 - 6 - use crossterm::event::{KeyCode, KeyEvent, KeyModifiers}; 7 - use kdl::KdlNode; 8 7 use strum::IntoEnumIterator; 9 8 10 - use crate::tui::{Signal, app::Region}; 9 + use crossterm::event::KeyEvent; 11 10 11 + use crate::{ 12 + config::file::RonConfig, 13 + tui::{Region, Signal}, 14 + }; 12 15 #[derive(Debug, Clone)] 13 16 pub struct KeyMap(pub HashMap<Region, HashMap<Vec<KeyEvent>, Signal>>); 14 17 15 - impl TryFrom<&KdlNode> for KeyMap { 18 + impl TryFrom<&RonConfig> for KeyMap { 16 19 type Error = color_eyre::Report; 17 20 18 - fn try_from(value: &KdlNode) -> std::result::Result<Self, Self::Error> { 19 - let mut all_binds = HashMap::new(); 21 + fn try_from(value: &RonConfig) -> Result<Self, Self::Error> { 22 + let mut binds = HashMap::new(); 20 23 21 24 for region in Region::iter() { 22 25 let mut region_binds = HashMap::new(); 23 - let Some(binds) = value 24 - .children() 25 - .expect("Keymap must have children.") 26 - .get(&region.to_string()) 27 - else { 28 - continue; 26 + 27 + let mut parse_and_insert = |str: &str, bind: &Signal| -> Result<()> { 28 + let key_seq = parse_key_sequence(str).map_err(|e| { 29 + eyre!(format!( 30 + "Failed to parse the following keybind as valid keybind: {e}" 31 + )) 32 + })?; 33 + 34 + region_binds.insert(key_seq, bind.clone()); 35 + Ok(()) 29 36 }; 30 37 31 - // now we iter through the things children 32 - for child in binds.iter_children() { 33 - let key_combo_str = child.name().to_string(); 34 - let key_combo_str = key_combo_str.trim(); 38 + // first thing we have to do is insert the global binds for this region 35 39 36 - let signal_str = child 37 - .entries() 38 - .first() 39 - .expect("A bind must map to an entry") 40 - .to_string(); 41 - let signal_str = signal_str.trim(); 42 - 43 - let signal: Signal = signal_str.parse().expect("Must be a \"bindable\" Signal"); 44 - let key_combo = parse_key_sequence(key_combo_str).unwrap(); 40 + for (str, bind) in &value.global_key_binds { 41 + parse_and_insert(str, bind)?; 42 + } 45 43 46 - let _ = region_binds.insert(key_combo, signal); 44 + // now we insert the region specific binds 45 + for (str, bind) in match region { 46 + Region::Zk => value.zk.keybinds.iter(), 47 + Region::Todo => value.todo.keybinds.iter(), 48 + } { 49 + parse_and_insert(str, bind)?; 47 50 } 48 51 49 - let _ = all_binds.insert(region, region_binds); 52 + binds.insert(region, region_binds); 50 53 } 51 54 52 - Ok(Self(all_binds)) 55 + Ok(Self(binds)) 53 56 } 54 57 } 55 58 ··· 170 173 171 174 #[cfg(test)] 172 175 mod test { 173 - use crossterm::event::{KeyEvent, KeyModifiers}; 174 - use kdl::KdlNode; 176 + // use crossterm::event::{KeyEvent, KeyModifiers}; 177 + // use kdl::KdlNode; 175 178 176 - use crate::tui::{KeyMap, Signal, app::Region}; 179 + // use crate::tui::{KeyMap, Region, Signal}; 177 180 178 181 #[test] 179 182 fn test_quit_in_home_region() { 180 - let keymap_str = " 181 - keymap { 182 - Todo { 183 - q Quit 184 - <Ctrl-C> Quit 185 - } 186 - } 187 - "; 183 + // let keymap_str = " 184 + // keymap { 185 + // Todo { 186 + // q Quit 187 + // <Ctrl-C> Quit 188 + // } 189 + // } 190 + // "; 188 191 189 - let kdl: &KdlNode = &keymap_str 190 - .parse() 191 - .expect("Keymap_str should be a valid KDL document"); 192 + // let kdl: &KdlNode = &keymap_str 193 + // .parse() 194 + // .expect("Keymap_str should be a valid KDL document"); 192 195 193 - let keymap: KeyMap = kdl.try_into().expect("Must be a valid keymap"); 196 + // let keymap: KeyMap = kdl.try_into().expect("Must be a valid keymap"); 194 197 195 - let map = keymap 196 - .get(&Region::Todo) 197 - .expect("Home region must exist in keymap"); 198 + // let map = keymap 199 + // .get(&Region::Todo) 200 + // .expect("Home region must exist in keymap"); 198 201 199 - let signal = map 200 - .get(&vec![KeyEvent::new_with_kind( 201 - crossterm::event::KeyCode::Char('q'), 202 - KeyModifiers::empty(), 203 - crossterm::event::KeyEventKind::Press, 204 - )]) 205 - .expect("Must resolve to a signal"); 202 + // let signal = map 203 + // .get(&vec![KeyEvent::new_with_kind( 204 + // crossterm::event::KeyCode::Char('q'), 205 + // KeyModifiers::empty(), 206 + // crossterm::event::KeyEventKind::Press, 207 + // )]) 208 + // .expect("Must resolve to a signal"); 206 209 207 - assert_eq!(*signal, Signal::Quit); 210 + // assert_eq!(*signal, Signal::Quit); 208 211 } 209 212 }
+1 -4
src/tui/mod.rs
··· 1 1 /// The tui app 2 2 mod app; 3 3 pub use app::App as TuiApp; 4 + pub use app::Region; 4 5 5 6 /// Tui components 6 7 mod components; ··· 9 10 mod raw_tui; 10 11 pub use raw_tui::Event; 11 12 pub use raw_tui::Tui; 12 - 13 - /// Keymap for mapping keybinds to regions 14 - mod keymap; 15 - pub use keymap::KeyMap; 16 13 17 14 /// Singals for commands needing to be processed 18 15 mod signal;
+17 -1
src/types/kasten.rs
··· 9 9 use rayon::iter::{ParallelBridge as _, ParallelIterator as _}; 10 10 use std::{cmp::max, collections::HashMap, path::Path, sync::Arc}; 11 11 use tokio::sync::RwLock; 12 + use tracing::{error, info}; 12 13 13 14 use crate::types::Workspace; 14 15 ··· 56 57 .map(|entry| entry.path()) 57 58 .collect::<Vec<_>>(); 58 59 60 + info!( 61 + "indexing the following paths {paths:#?} at root {:#?}", 62 + ws.root 63 + ); 64 + 59 65 let zettel_tasks = paths 60 66 .into_iter() 61 67 .map(|path| { ··· 68 74 let zettels = futures::future::join_all(zettel_tasks) 69 75 .await 70 76 .into_iter() 71 - .filter_map(|result| result.ok()?.ok()) 77 + .filter_map(|result| { 78 + result 79 + .inspect_err(|e| error!("Failed to join on zettel task parsing: {e:#?}")) 80 + .ok()? 81 + .inspect_err(|e| error!("Failed to parse file into zettel: {e:#?}")) 82 + .ok() 83 + }) 72 84 .collect::<Vec<Zettel>>(); 85 + 86 + info!("zettels: {zettels:#?}"); 73 87 74 88 // capacity! 75 89 let mut graph: ZkGraph = ZkGraph::from(&StableGraph::with_capacity( ··· 96 110 graph.add_edge(*src, *dst, link.clone()); 97 111 } 98 112 } 113 + 114 + info!("parsed graph: {graph:#?}"); 99 115 100 116 Ok(Self { 101 117 _private: (),