diff --git a/docs/editor-support.md b/docs/editor-support.md index c888063..c24288f 100644 --- a/docs/editor-support.md +++ b/docs/editor-support.md @@ -87,7 +87,9 @@ expression parsing, selector behavior, generated Rust facts, or build validation. Those remain with `hemx-build`, `hemx-lsp`, normal HTML tooling, and Rust tooling. Repo tests for highlighting should therefore be fixture/query tests for captures over these token classes; provider packaging or visual editor smoke -is a separate release slice and cannot become syntax authority. req: diagnostics/004 req: diagnostics/008 +is a separate release slice and cannot become syntax authority. The current +repo-owned fixture and golden capture contract live in +`docs/fixtures/hemplate-highlighting/`. req: diagnostics/004 req: diagnostics/008 ## VS Code and Cursor diff --git a/docs/fixtures/hemplate-highlighting/captures.tsv b/docs/fixtures/hemplate-highlighting/captures.tsv new file mode 100644 index 0000000..08db87c --- /dev/null +++ b/docs/fixtures/hemplate-highlighting/captures.tsv @@ -0,0 +1,17 @@ +capture literal +@attribute.hemx data-hemx-root +@attribute.hemx data-hemx-form +@attribute.hemx data-hemx-handle +@attribute.hemx data-hemx-slot +@attribute.dynamic.hemplate +class +@keyword.control.hemplate h-if +@keyword.control.hemplate h-for +@keyword.control.hemplate h-key +@keyword.control.hemplate h-match +@keyword.control.hemplate h-case +@punctuation.special.hemplate.escaped.open {+ +@punctuation.special.hemplate.escaped.close +} +@punctuation.special.hemplate.trusted.open {+= +@punctuation.special.hemplate.trusted.close =+} +@embedded.rust.hemplate result.title +@embedded.rust.hemplate result.summary_html diff --git a/docs/fixtures/hemplate-highlighting/hemplate.heml b/docs/fixtures/hemplate-highlighting/hemplate.heml new file mode 100644 index 0000000..1506b1d --- /dev/null +++ b/docs/fixtures/hemplate-highlighting/hemplate.heml @@ -0,0 +1,18 @@ + + + + + + + + + {+ result.title +} + {+= result.summary_html =+} + + + + + + No results + + diff --git a/hemx-lsp/src/main.rs b/hemx-lsp/src/main.rs index ba95755..fd32ee2 100644 --- a/hemx-lsp/src/main.rs +++ b/hemx-lsp/src/main.rs @@ -903,6 +903,44 @@ mod tests { assert!(value.contains("docs/hemplate-syntax.md")); } + #[test] + fn hemplate_highlighting_fixture_covers_documented_overlay_tokens() { + // req: diagnostics/004 req: diagnostics/008 + let fixture = include_str!("../../docs/fixtures/hemplate-highlighting/hemplate.heml"); + let captures = include_str!("../../docs/fixtures/hemplate-highlighting/captures.tsv"); + let allowed_captures = [ + "@attribute.hemx", + "@attribute.dynamic.hemplate", + "@keyword.control.hemplate", + "@punctuation.special.hemplate.escaped.open", + "@punctuation.special.hemplate.escaped.close", + "@punctuation.special.hemplate.trusted.open", + "@punctuation.special.hemplate.trusted.close", + "@embedded.rust.hemplate", + ] + .into_iter() + .collect::>(); + let mut seen = std::collections::BTreeSet::new(); + for (index, line) in captures.lines().enumerate().skip(1) { + let (capture, literal) = line + .split_once('\t') + .unwrap_or_else(|| panic!("capture row {index} must be TSV")); + assert!( + allowed_captures.contains(capture), + "unexpected capture `{capture}` in row {index}" + ); + assert!( + fixture.contains(literal), + "highlight fixture missing literal `{literal}` for capture `{capture}`" + ); + seen.insert(capture); + } + assert_eq!( + seen, allowed_captures, + "highlight fixture should exercise every documented overlay capture class" + ); + } + #[test] fn workout_template_fields_are_available_from_repo_facts() { // req: diagnostics/006 diff --git a/work/slices/SLICE-0011-highlight-fixtures.md b/work/slices/SLICE-0011-highlight-fixtures.md index 6fedf0d..c5a4737 100644 --- a/work/slices/SLICE-0011-highlight-fixtures.md +++ b/work/slices/SLICE-0011-highlight-fixtures.md @@ -1,7 +1,7 @@ --- id: SLICE-0011 type: slice -status: ready +status: done parent: NS-0003 title: Add hemplate highlighting fixtures and query tests refs: @@ -26,8 +26,8 @@ Create repo-owned highlighting fixtures that prove documented hemplate syntax re ## Verification -- Preferred future command: a repo-owned tree-sitter/query fixture test, once the crate/tool location is chosen. -- Until then, manual proof must name the exact editor/query runner and fixture. +- `cargo test -p hemx-lsp` +- `workledger check` ## Non-goals @@ -36,4 +36,4 @@ Create repo-owned highlighting fixtures that prove documented hemplate syntax re ## Evidence -The fixture list maps directly to the documented syntax surface. +Done at commit `34327d6` follow-up and verified with `cargo test -p hemx-lsp`: `docs/fixtures/hemplate-highlighting/hemplate.heml` covers the documented overlay token classes and `captures.tsv` records the golden capture names without requiring editor package publishing or a second parser.
No results