use serde::{Deserialize, Serialize};
use crate::text::Span;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
#[serde(rename_all = "kebab-case")]
pub enum HighlightKind {
Keyword,
String,
Comment,
Number,
Type,
Function,
Macro,
Attribute,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub struct Highlight {
pub span: Span,
pub kind: HighlightKind,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct HighlightRule {
pub node: &'static str,
pub under: Option<&'static str>,
pub kind: HighlightKind,
}
impl HighlightRule {
pub const fn new(node: &'static str, kind: HighlightKind) -> Self {
Self {
node,
under: None,
kind,
}
}
pub const fn under(mut self, parent: &'static str) -> Self {
self.under = Some(parent);
self
}
}