summaryrefslogtreecommitdiff
path: root/src/config
diff options
context:
space:
mode:
authorNathan Reiner <nathan@nathanreiner.xyz>2024-08-01 22:07:04 +0200
committerNathan Reiner <nathan@nathanreiner.xyz>2024-08-01 22:07:04 +0200
commit1e1eb95926f556e666bc20355327abd24d264858 (patch)
treee40b68da80b984355baf68a36983d78bb2ec63dd /src/config
parent5d15bed762c4c699bebc9b5f5e302fa61785ed51 (diff)
minor cleanup
Diffstat (limited to 'src/config')
-rw-r--r--src/config/evalsto.rs9
-rw-r--r--src/config/mod.rs2
-rw-r--r--src/config/theme/mod.rs2
-rw-r--r--src/config/theme/sheetview.rs2
-rw-r--r--src/config/theme/style.rs6
5 files changed, 15 insertions, 6 deletions
diff --git a/src/config/evalsto.rs b/src/config/evalsto.rs
index 10b2dd1..eae9b2d 100644
--- a/src/config/evalsto.rs
+++ b/src/config/evalsto.rs
@@ -62,3 +62,12 @@ where
}
}
}
+
+impl<T, A> Default for EvalTo<T, A>
+where
+ T: Default,
+{
+ fn default() -> Self {
+ Self::Value(T::default())
+ }
+}
diff --git a/src/config/mod.rs b/src/config/mod.rs
index 6e88306..c5131a6 100644
--- a/src/config/mod.rs
+++ b/src/config/mod.rs
@@ -8,7 +8,7 @@ pub mod theme;
pub mod constants;
pub mod evalsto;
-#[derive(Debug)]
+#[derive(Debug, Default)]
pub struct GlobalConfig {
pub theme: Theme,
}
diff --git a/src/config/theme/mod.rs b/src/config/theme/mod.rs
index 35101c5..75f65a0 100644
--- a/src/config/theme/mod.rs
+++ b/src/config/theme/mod.rs
@@ -8,7 +8,7 @@ use super::DUMMY_CONFIG;
pub mod style;
pub mod sheetview;
-#[derive(Clone, Debug)]
+#[derive(Clone, Debug, Default)]
pub struct Theme {
pub sheetview: SheetViewTheme,
}
diff --git a/src/config/theme/sheetview.rs b/src/config/theme/sheetview.rs
index 30d801e..edc7cc3 100644
--- a/src/config/theme/sheetview.rs
+++ b/src/config/theme/sheetview.rs
@@ -8,7 +8,7 @@ use crate::{
use super::style::Style;
-#[derive(Debug, Clone)]
+#[derive(Debug, Clone, Default)]
pub struct SheetViewTheme {
pub cursor: EvalTo<Style, CellRef>,
pub selection: EvalTo<Style, CellRef>,
diff --git a/src/config/theme/style.rs b/src/config/theme/style.rs
index 6e8d161..87cd068 100644
--- a/src/config/theme/style.rs
+++ b/src/config/theme/style.rs
@@ -3,7 +3,7 @@ use std::str::FromStr;
use mlua::{FromLua, IntoLua};
use ratatui::style::{Color, Styled, Stylize};
-#[derive(Clone, Copy, Debug)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct Style {
pub fg: Option<Color>,
pub bg: Option<Color>,
@@ -102,7 +102,7 @@ impl<'lua> FromLua<'lua> for Style {
return Ok(style)
}
- return Err(mlua::Error::runtime("could not parse style"));
+ Err(mlua::Error::runtime("could not parse style"))
}
}
@@ -114,6 +114,6 @@ impl<'lua> IntoLua<'lua> for Style {
let table = lua.create_table()?;
table.set("fg", self.fg.map(|s| s.to_string()).into_lua(lua)?)?;
table.set("bg", self.bg.map(|s| s.to_string()).into_lua(lua)?)?;
- Ok(table.into_lua(lua)?)
+ table.into_lua(lua)
}
}