use serde::{Deserialize, Serialize};
use tatara_lisp::DeriveTataraDomain;
#[derive(DeriveTataraDomain, Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
#[tatara(keyword = "defhighlight")]
pub struct HighlightSpec {
pub group: String,
#[serde(default)]
pub fg: String,
#[serde(default)]
pub bg: String,
#[serde(default)]
pub bold: bool,
#[serde(default)]
pub italic: bool,
#[serde(default)]
pub underline: bool,
#[serde(default)]
pub undercurl: bool,
#[serde(default)]
pub strikethrough: bool,
#[serde(default)]
pub reverse: bool,
#[serde(default)]
pub link: String,
}
impl HighlightSpec {
#[must_use]
pub fn is_link(&self) -> bool {
!self.link.is_empty()
}
#[must_use]
pub fn has_attrs(&self) -> bool {
self.bold
|| self.italic
|| self.underline
|| self.undercurl
|| self.strikethrough
|| self.reverse
}
}
pub const CANONICAL_GROUPS: &[&str] = &[
"Normal",
"Comment",
"String",
"Number",
"Boolean",
"Function",
"Keyword",
"Statement",
"Conditional",
"Repeat",
"Operator",
"Type",
"Structure",
"Identifier",
"Constant",
"PreProc",
"Macro",
"Special",
"CursorLine",
"CursorColumn",
"LineNr",
"SignColumn",
"Visual",
"VisualNOS",
"Search",
"IncSearch",
"MatchParen",
"StatusLine",
"StatusLineNC",
"TabLine",
"TabLineFill",
"TabLineSel",
"VertSplit",
"Pmenu",
"PmenuSel",
"PmenuSbar",
"PmenuThumb",
"NormalFloat",
"FloatBorder",
"DiagnosticError",
"DiagnosticWarn",
"DiagnosticInfo",
"DiagnosticHint",
"GitSignsAdd",
"GitSignsChange",
"GitSignsDelete",
"DiffAdd",
"DiffChange",
"DiffDelete",
"DiffText",
];
#[must_use]
pub fn is_canonical_group(name: &str) -> bool {
CANONICAL_GROUPS.iter().any(|g| *g == name)
}