diff --git a/src/config/file.rs b/src/config/file.rs index 967ab79..a4f8d5c 100644 --- a/src/config/file.rs +++ b/src/config/file.rs @@ -4,11 +4,17 @@ use serde::{Deserialize, Serialize}; use crate::tui::Signal; +/// The `RON` representation of the config. This is the schema the config file +/// should follow. #[derive(Debug, Deserialize, Serialize)] pub struct RonConfig { + /// Directory of the `Filaments` directory. pub directory: PathBuf, + /// Keybinds to be used in every part of the TUI pub global_key_binds: HashMap, + /// Config for the `ZK` component of the TUI pub zk: ZkConfig, + /// Keybinds for the `TODO` component of the TUI pub todo: TodoConfig, } @@ -28,57 +34,13 @@ pub struct TodoConfig { pub struct ExplorerConfig { pub keybinds: HashMap, } + #[derive(Debug, Deserialize, Serialize)] pub struct InspectorConfig { pub keybinds: HashMap, } + #[derive(Debug, Deserialize, Serialize)] pub struct TaskListConfig { pub keybinds: HashMap, } - -#[cfg(test)] -mod tests { - - use super::*; - use std::{collections::HashMap, path::PathBuf}; - - #[test] - fn fucking_around_with_ron() { - let x = RonConfig { - directory: PathBuf::from("some/notes/dir"), - global_key_binds: HashMap::from([("".to_string(), Signal::Quit)]), - zk: ZkConfig { - keybinds: HashMap::from([ - ("".to_string(), Signal::OpenZettel), - ("".to_string(), Signal::MoveDown), - ]), - }, - todo: TodoConfig { - explorer: ExplorerConfig { - keybinds: HashMap::from([ - ("".to_string(), Signal::NewZettel), - ("".to_string(), Signal::MoveUp), - ]), - }, - inspector: InspectorConfig { - keybinds: HashMap::from([ - ("".to_string(), Signal::NewZettel), - ("".to_string(), Signal::MoveUp), - ]), - }, - tasklist: TaskListConfig { - keybinds: HashMap::from([ - ("".to_string(), Signal::NewZettel), - ("".to_string(), Signal::MoveUp), - ]), - }, - }, - }; - - let ron_string = ron::ser::to_string_pretty(&x, ron::ser::PrettyConfig::default()) - .expect("failed to serialize"); - - println!("{ron_string}"); - } -} diff --git a/src/config/keymap.rs b/src/config/keymap.rs index 08a7e4f..d0940a1 100644 --- a/src/config/keymap.rs +++ b/src/config/keymap.rs @@ -4,6 +4,7 @@ use std::{ collections::HashMap, ops::{Deref, DerefMut}, }; + use strum::IntoEnumIterator; use crossterm::event::KeyEvent; @@ -176,11 +177,6 @@ fn parse_key_code_with_modifiers( #[cfg(test)] mod test { - // use crossterm::event::{KeyEvent, KeyModifiers}; - // use kdl::KdlNode; - - // use crate::tui::{KeyMap, Region, Signal}; - use crossterm::event::{KeyEvent, KeyModifiers}; use crate::{ @@ -206,7 +202,7 @@ mod test { "tab": SwitchTo ( page: Todo(Explorer) ), - + }, ), todo: ( @@ -217,9 +213,9 @@ mod test { "tab": SwitchTo ( page: Zk ), - + }, - + ), tasklist: ( keybinds: { @@ -228,9 +224,9 @@ mod test { "tab": SwitchTo ( page: Zk ), - + }, - + ), explorer: ( keybinds: { @@ -239,9 +235,9 @@ mod test { "tab": SwitchTo ( page: Zk ), - + }, - + ), ), ) diff --git a/src/config/mod.rs b/src/config/mod.rs index cf51b4d..4b45b97 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -41,7 +41,7 @@ pub struct Config { } impl Config { - /// generates a new config with the provided `filaments_dir` + /// Generates a new config with the provided `filaments_dir` pub fn generate(fil_dir: &Path) -> Result { let mut default_conf: RonConfig = ron::from_str(DEFAULT_CONFIG) .expect("The default config must always be a valid RonConfig"); diff --git a/src/lsp/mod.rs b/src/lsp/mod.rs index 39368d3..64a43b1 100644 --- a/src/lsp/mod.rs +++ b/src/lsp/mod.rs @@ -175,8 +175,6 @@ impl LanguageServer for Backend { /// Returns the `` portion of a `[[ | ]]` wikilink if the /// cursor (0-based char index) falls anywhere inside the `[[ ... ]]` span. /// Also handles `[[<id>]]` (no pipe / title). -/// -// helper function written by claude. I was lowkey too lazy to write this logic xd fn extract_wikilink_id_at(line: &str, char_idx: usize) -> Option<&str> { let mut search_start = 0; @@ -196,9 +194,7 @@ fn extract_wikilink_id_at(line: &str, char_idx: usize) -> Option<&str> { let id = inner.split('|').next().unwrap_or(inner).trim(); return Some(id); } - search_start = close_abs + 2; // advance past this `]]` } - None }