Skip to content

Code-grade editor: syntax highlighting + tree-based folding via Lezer (new @jsvision/lang) #102

Description

@blendsdk

Summary

Build the code-development-grade editor (line numbers, syntax highlighting, tree-based folding)
on top of the existing @jsvision/ui editor, using Lezer (@lezer/*) as the language engine.

This is the build follow-through for the closed epic #18 ("RD-08 Editor family: a
code-development-grade editor … in-house, no CodeMirror dep"). A 9-probe feasibility spike returned
GO; the spike branch/package were never committed, so the decision now lives in
codeops/features/code-editor/plans/feasibility-spike/decision-memo.md (reconstructed).

Reinterpreting #18's "no CodeMirror dep"

Still holds. Lezer is CodeMirror's incremental parser, not its editor view. We take the parser
(pure JS, headless — no DOM, no WASM, no native; passes check:deps) and reject CodeMirror's
view/language/commands and Monaco. The shipped @jsvision/ui editor is the view.

Architecture (settled)

Three moving parts:

  1. Extract the editor @jsvision/ui@jsvision/editor — tracked in Refactor: extract the editor into its own package (@jsvision/editor) #101, lands
    before this build. Coupling is real: the editor imports 9 ui subsystems + reaches
    controls/measure.js and dialog/message-box.js, and @jsvision/files depends on it.
  2. Seam types (Tokenizer / FoldProvider) in @jsvision/core — pure zero-dep declarations,
    so the Lezer package depends only on core + @lezer/* (never on ui/editor).
  3. Lezer engine in a new opt-in @jsvision/lang@lezer/* as regular deps.

core/ui keep {} runtime deps (mirrors @jsvision/formszod). The indent-based default
folder + gutter live in @jsvision/editor
(zero-dep), so basic folding works without Lezer.

Lezer only — no TextMate fallback. It is Lezer or we don't build this. Accepted consequence: the
supported-language set = languages that have (or for which we author) a Lezer grammar; a language
with no Lezer grammar is out of scope until one exists (no regex/TextMate second path).

Work

  • Land Refactor: extract the editor into its own package (@jsvision/editor) #101 (extract @jsvision/editor) — prerequisite.
  • Add Tokenizer / FoldProvider seam types to @jsvision/core.
  • Scaffold @jsvision/lang (@lezer/* deps); implement the (from,to,tag) Tokenizer +
    FoldProvider for one language end-to-end.
  • Gutter + indent-based default folder in @jsvision/editor (works without @jsvision/lang).
  • Bounded-chunk buffer → Lezer Input adapter; off-frame/time-budgeted parse for large files.
  • Per-language fold allow-lists (~8 node names/language).
  • make_requirements RD-08 with the decision-memo as settled evidence.
  • Kitchen-sink story + headless smoke test for the highlighted/foldable editor.
  • yarn verify + check:deps stays clean (core/ui remain zero-dep).

Not in scope / re-measure

Per-probe timings and exact @lezer/* versions from the original spike are unrecoverable (lost
with the uncommitted spike). Re-spike only if a specific number becomes load-bearing.

Related

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: frameworkLarger framework infrastructureeffort: XLExtra large — epic / requirements-firstenhancementNew feature or requestepicLarge multi-part feature; likely needs its own requirements/plan (CodeOps RD)priority: mediumValuable; schedule after the high tier

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions