Skip to content

Commit

Permalink
fix: make serde error on unknown fields, make color scheme less eye-b…
Browse files Browse the repository at this point in the history
…leedy
  • Loading branch information
justinpombrio committed Apr 23, 2024
1 parent 725bb4e commit a8ce055
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/language/specs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use serde::{Deserialize, Serialize};

/// A kind of node that can appear in a document.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct ConstructSpec {
pub name: String,
pub arity: AritySpec,
Expand All @@ -15,10 +16,12 @@ pub struct ConstructSpec {

/// A set of constructs. Can both include and be included by other sorts.
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, Hash)]
#[serde(deny_unknown_fields)]
pub struct SortSpec(pub Vec<String>);

/// The sorts of children that a node is allowed to contain.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub enum AritySpec {
/// Designates a pure text node.
Texty,
Expand All @@ -33,6 +36,7 @@ pub enum AritySpec {
/// Describes the structure of a language, e.g. which constructs can appear
/// in which positions.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct GrammarSpec {
pub constructs: Vec<ConstructSpec>,
pub sorts: Vec<(String, SortSpec)>,
Expand All @@ -41,6 +45,7 @@ pub struct GrammarSpec {

/// Describes how to display every construct in a language.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct NotationSetSpec {
/// A unqiue name for this set of notations
pub name: String,
Expand All @@ -51,6 +56,7 @@ pub struct NotationSetSpec {
/// A single notation, with a grammar describing its structure and a notation describing how to
/// display it.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct LanguageSpec {
pub name: String,
pub grammar: GrammarSpec,
Expand Down
10 changes: 7 additions & 3 deletions src/style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ pub struct Style {
}

#[derive(Debug, Clone, Copy, Default, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub enum Priority {
#[default]
Low,
Expand All @@ -57,6 +58,7 @@ pub enum CursorHalf {
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub enum StyleLabel {
Open,
Close,
Expand All @@ -77,6 +79,7 @@ pub enum StyleLabel {

// TODO: doc
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub enum Condition {
IsEmptyText,
IsCommentOrWs,
Expand All @@ -95,6 +98,7 @@ pub struct Rgb {
}

#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub enum Base16Color {
/// Default Background
Base00,
Expand Down Expand Up @@ -232,9 +236,9 @@ impl ColorTheme {
/// The "default dark" Base16 colorscheme, by Chris Kempson (http://chriskempson.com)
pub fn default_dark() -> ColorTheme {
ColorTheme {
base00: Rgb::from_hex("#181818").bug(),
base01: Rgb::from_hex("#282828").bug(),
base02: Rgb::from_hex("#383838").bug(),
base00: Rgb::from_hex("#312121").bug(),
base01: Rgb::from_hex("#111111").bug(),
base02: Rgb::from_hex("#103030").bug(),
base03: Rgb::from_hex("#585858").bug(),
base04: Rgb::from_hex("#b8b8b8").bug(),
base05: Rgb::from_hex("#d8d8d8").bug(),
Expand Down

0 comments on commit a8ce055

Please sign in to comment.