Skip to content

Evaluate Monogram for generated TSRX editor grammars #1304

Description

@aleclarson

Monogram defines one executable grammar and derives TextMate, tree-sitter, and Monarch artifacts from it. Since TSRX currently maintains separate editor grammars, it may be worth evaluating whether a tsrx.ts Monogram grammar could reduce drift and improve highlighting correctness.

A first integration would likely target generated editor artifacts only:

  • VS Code TextMate grammar for source.tsrx
  • tree-sitter grammar/parser for Neovim and other editors
  • potentially Monarch for playground/docs use

Known unknowns:

  • TSRX's code/template mode switching, especially cases where TypeScript setup statements and rendered output share one scope.
  • Compatibility between generated TextMate scopes and the current VS Code grammar/theme behavior.
  • Compatibility between generated tree-sitter node shapes and the current Neovim queries.
  • Amount of custom scanner or generator code needed outside the grammar.
  • How cleanly TSRX-only forms like @{}, control-flow directives, lazy destructuring, dynamic tags, and <style> fit into Monogram's TSX base.
  • The exact test corpus needed to judge the prototype across parser behavior, highlighting, and editor integrations.

Suggested first experiment: prototype a minimal tsrx.ts Monogram grammar extending typescriptreact.ts, covering statement containers, control-flow directives, lazy destructuring, dynamic tags, and <style> embedding, then compare generated highlighting against the current tsrx.tmLanguage.json and tree-sitter parser on existing TSRX fixtures.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions