From 394d39942c960abc4eda20aa9055b6fe80bf56c3 Mon Sep 17 00:00:00 2001 From: Levi Neuwirth Date: Thu, 23 Jul 2026 15:04:10 -0400 Subject: [PATCH] feat(web): bundle HTML + CSS grammars + HTML injections MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Register `html` (.html/.htm/.xhtml) and `css` (.css) entries in BUILTIN_LANGUAGES, backed by the official tree-sitter-html 0.23 and tree-sitter-css 0.25 grammars over the tree-sitter-language shim (ABI-fine, no overlay — both export their query constants). The single `extensions` field wires detection ahead of the LSP filetype map. HTML's crate-exported INJECTIONS_QUERY lights up — `let` (JS keyword) at col 8. + let src = b"\n\n"; + let mut buf = Buffer::new(BufferId::next(), "page.html"); + buf.apply_edit(EditOp::Insert { pos: 0, bytes: src }) + .unwrap(); + let view = ParseView::new(&buf, language, "html".to_owned()); + let handle = view.handle(); + let _vid = buf.attach_view(Box::new(view)); + let mut req = handle.make_request(); + req.injection_aliases = reg.injection_alias_snapshot(); + let bundle = crate::syntax::run_parse(req).expect("html parse"); + handle.install(reg.resolve_layer_queries(&bundle)); + + let mut hv = SyntaxHighlightView::new(handle, reg.theme()); + let (rows, cols) = (2usize, 60usize); + let mut backing: Vec = vec![Cell::default(); rows * cols]; + let mut grid = CellGrid { + cells: &mut backing, + stride: cols as u32, + size: CellSize::new(rows as u32, cols as u32), + }; + let viewport = Viewport { + buffer_start: 0, + buffer_end: u64::MAX, + cell_origin: CellCoord::new(0, 0), + cell_size: CellSize::new(rows as u32, cols as u32), + gutter_w: 0, + }; + let registry = buf; + hv.render(®istry, viewport, &mut grid); + + // Inside