Crate: editors/code. Opens any File{Text} node; lowest priority so specialised editors (markdown WYSIWYG, flow) win for their kinds, with “Open with…” to override.

Replacement requirements and the current CodeMirror feature/interface survey: Code Editor Requirements. Rust replacement milestones: Rust Code Editor Roadmap. M1 code and verification record: Rust Code Editor Implementation.

Architecture

  • Document in Rust: ropey::Rope + version + undo stack. Edits become core patches (ADR-0009 Patches not snapshots).
  • Backend options: CodeMirror 6 remains the default via JS Interop Boundary. The opt-in RustCodeEditorPanel in packages/code-view has live LSP/context acceptance, bounded accessibility context and tested backend migration. See Rust Code Editor Implementation and Rust Code Editor Accessibility and Cutover for its contract and remaining physical-desktop/Android gates. The default is prepared but unflipped.
  • Decorations are data: Highlight, Fold, Diagnostic, InlayHint, Gutter produced by Indexing (tree-sitter) and LSP and Terminal, consumed by any backend. The CodeMirror bundle therefore ships no language packages.

Languages (initial)

LanguageGrammarLSPWhy first
Rusttree-sitter-rustrust-analyzerdogfooding
Juliatree-sitter-juliaLanguageServer.jlhost of Flow Editor targets (Lux.jl, MTK)
Gotree-sitter-gogoplsmature, simple
Unisoncommunity grammar (verify)ucmdatabase-backed codebase = a natural Source
Lean 4tree-sitter-lean (verify)lake serveinfoview as an extra panel

Each is a LanguageContribution in editors/code/src/languages/, proving the contribution point works (Example - Language).

Features by phase

  1. Open/edit/save, highlighting from tree-sitter, folding, search.
  2. LSP: diagnostics, hover, completion, go-to-definition (which is a graph edge!), references.
  3. Semantic tokens, inlay hints, code actions, format.
  4. “Show AST”, “show call graph of this function” → open a GraphView in the Graph View.

Big cases

Backend chosen by measured size — see Case Selector (design).

Unicode input

\name → symbol with a dropdown, in this editor and every other input: Unicode Input (design, not built).

Unison note

Unison stores code in a codebase DB, not files. A UnisonSource extension (definitions as nodes, dependency edges) would make Moonkale one of the few editors that shows Unison the way Unison thinks. Good showcase; later phase.

Designs not built yet

Removed from editors/code/src as comment-only files in Milestone 18 phase 1:

  • Decorations (decorations.rs) in a neutral form — Highlight { range, token }, Fold, Diagnostic, InlayHint, Gutter — produced by the index/LSP and consumed by any backend. Today diagnostics and wiki-link marks go to CodeMirror in their own messages, and highlighting is the bundle’s (P-093).
  • Document (document.rs): rope + version + undo stack + node id, turning backend edits into core patches and applying incoming changes (external change → reconcile or prompt). Today ext-api::Document holds a String; the Rust editor shares revisioned undo history through Workspace.
  • A Rust-native backend (backend/native.rs): a virtualised Dioxus text view or a wgpu text renderer over the same rope and decorations. The opt-in Rust extension now uses editor-core and a virtualized Dioxus view in code-view; neutral decorations and feature parity remain unfinished.

CodeMirror’s find/replace controls use the shell theme tokens and the current English, German or Chinese locale (P-219, 2026-10-22). codemirror-search opens the real search panel in German, checks its styles, and selects a match.

Density and chrome (WP-63, 2026-10-28)

Text panels use shared density-aware actions: Save is primary in Simple, with wrap, reload, editor switching and settings in ⋯. Detailed expands the same actions. Optional Rust-editor chrome follows its extension choice.