feat: give column data types a dedicated syntax-highlight colour

Both Node::Ident and Word carried a highlight_override field, and
both were dead — the walker driver discarded the Ident's and
walk_word hardcoded Keyword. So column types (int, serial, …)
rendered identically to table/column names.

Wire both overrides through, and add a dedicated HighlightClass::Type
with its own theme colour (tok_type), distinct from keyword-purple
and identifier-teal. The three type Ident slots opt in, so canonical
types and the advanced-mode single-word SQL aliases (float, varchar,
…) render as types; the two-word `double precision` alias opts in via
a new Word::type_keyword constructor. ADR-0022 Amendment 4.
This commit is contained in:
claude@clouddev1
2026-05-29 22:07:18 +00:00
parent 46a31284c5
commit d20f765325
10 changed files with 195 additions and 13 deletions
+11 -3
View File
@@ -180,7 +180,7 @@ fn walk_node_inner(
source: src,
role,
validator,
highlight_override: _,
highlight_override,
writes_table,
writes_column,
writes_user_listed_column,
@@ -193,6 +193,7 @@ fn walk_node_inner(
*src,
role,
*validator,
*highlight_override,
*writes_table,
*writes_column,
*writes_user_listed_column,
@@ -336,7 +337,10 @@ fn walk_word(
per_byte.push(ByteClass {
start,
end,
class: HighlightClass::Keyword,
// A keyword may opt into a non-default colour via
// `Word::type_keyword` (e.g. `double precision`, ADR-0022
// Amendment 4). Plain keywords leave it `None`.
class: word.highlight_override.unwrap_or(HighlightClass::Keyword),
});
NodeWalkResult::Matched { end, skipped: Vec::new() }
} else {
@@ -397,6 +401,7 @@ fn walk_ident(
src: crate::dsl::grammar::IdentSource,
role: &'static str,
validator: Option<crate::dsl::grammar::IdentValidator>,
highlight_override: Option<crate::dsl::grammar::HighlightClass>,
writes_table: bool,
writes_column: bool,
writes_user_listed_column: bool,
@@ -554,7 +559,10 @@ fn walk_ident(
per_byte.push(ByteClass {
start,
end,
class: HighlightClass::Identifier,
// A type slot (and any future slot that wants a non-default
// colour) overrides the otherwise-uniform Identifier class
// (issue #8 / ADR-0022 Amendment 4).
class: highlight_override.unwrap_or(HighlightClass::Identifier),
});
NodeWalkResult::Matched { end, skipped: Vec::new() }
}