Skip to content

7 4 zed editor integration

TransCompilator edited this page Nov 26, 2026 · 1 revision

7.4 Zed Editor Integration

Source: https://deepwiki.com/PonvasanthPon/TransCompilator/7-4-zed-editor-integration

Zed Editor Integration

Relevant source files

The following files were used as context for generating this wiki page:

Purpose and Scope

This page details the Zed editor integration for TransCompilator English (.eng) files. The integration is engineered to be fully offline, zero-AI, and non-telemetric. It comprises the tc-eng-extension WebAssembly extension, the install_zed_config.sh automation script, custom semantic token rules for monochrome typographic highlighting, and book serif typography settings (Liberation Serif).

Sources: editors/zed/README.md:1-19


1. Extension Architecture and LSP Routing (tc-eng-extension)

The tc-eng-extension package provides the bridge between Zed and the TransCompilator language server (tc-lsp). It is written as a Zed extension exposing a WebAssembly library.

The extension structure is defined by editors/zed/tc-eng-extension/extension.toml, which registers the tc-lsp language server for the TransCompilator English language identifier.

id = "tc-eng"
name = "TransCompilator English (.eng)"
version = "0.1.0-alpha-preview"
schema_version = 1

[language_servers.tc-lsp]
name = "tc-lsp"
languages = ["TransCompilator English"]

Sources: editors/zed/tc-eng-extension/extension.toml:1-9

The core Rust logic resides in editors/zed/tc-eng-extension/src/lib.rs. It implements the zed::Extension trait via the TcEngExtension struct. The language_server_command method resolves the tc-lsp binary path from the active worktree and configures it to run over standard input/output (--stdio).

graph TD
    sub5["Zed Editor Workspace"] -->|"worktree.which(\"tc-lsp\")"| sub6["TcEngExtension::language_server_command"]
    sub6 -->|"Command { tc-lsp, --stdio }"| sub7["tc-lsp Binary"]
    sub7 -->|"JSON-RPC / stdio"| sub8["tc::lsp::analysis"]

    classDef default fill:#fff,stroke:#000,stroke-width:1px;
Loading

Figure 1: LSP command routing from Zed worktree to tc-lsp.

Sources: editors/zed/tc-eng-extension/src/lib.rs:1-30

Sources: editors/zed/tc-eng-extension/src/lib.rs:1-30, editors/zed/tc-eng-extension/extension.toml:1-9


2. Configuration Installation and Merging (install_zed_config.sh)

The helper script editors/zed/install_zed_config.sh automates the setup of binaries, local bin symlinks, settings merging, and task registration without destroying existing user configurations.

graph TD
    sub1["editors/zed/install_zed_config.sh"] -->|"cargo build --release"| sub2["Release Binaries (tc, tc-lsp, r1-editor)"]
    sub2 -->|"Symlink"| sub3["~/.local/bin/"]
    sub1 -->|"Python Merge Script"| sub4["~/.config/zed/settings.json"]
    sub1 -->|"Python Merge Tasks"| sub5["~/.config/zed/tasks.json"]

    classDef default fill:#fff,stroke:#000,stroke-width:1px;
Loading

Figure 2: Configuration installation pipeline in install_zed_config.sh.

The script performs the following actions:

  1. Builds release binaries (tc, tc-lsp, r1-editor) with CARGO_NET_OFFLINE=true constraints.
  2. Symlinks them into ~/.local/bin.
  3. Backs up existing Zed settings (~/.config/zed/settings.json) with a timestamped suffix.
  4. Deep-merges overlay settings from editors/zed/settings.json while purging stale font fallbacks and language-scoped font overrides.
  5. Merges custom tc: tasks from editors/zed/tasks.json into ~/.config/zed/tasks.json.

Sources: editors/zed/install_zed_config.sh:1-102


3. Monochrome Semantic Token Rules

TransCompilator English files utilize language-scoped LSP semantic tokens instead of traditional rainbow syntax highlighting. The rules are specified in editors/zed/tc-eng-extension/languages/eng/semantic_token_rules.json.

Token Type / Modifier Font Style / Weight Underline / Foreground Semantic Role in .eng Files
function Bold #1c1c1e Computational verbs and phrase heads
keyword Bold #1c1c1e Control words and flow markers
variable (readonly) Italic #1c1c1e Resolved ACE anaphors (it, its, their, them, the result)
variable Normal Underline: #c8c8cc Variables, multi-word names, fields, record targets
string Italic #1c1c1e String literals
number Normal #1c1c1e Numeric constants
comment Italic #7a7a7a Explicit comments and COMMENT_OMITTED narrative prose

English glue words (the, of, a, an, by, me, out) and punctuation remain unstyled in normal body ink.

[
  {
    "token_type": "variable",
    "token_modifiers": ["readonly"],
    "foreground_color": "#1c1c1e",
    "font_style": "italic"
  },
  {
    "token_type": "comment",
    "foreground_color": "#7a7a7a",
    "font_style": "italic"
  },
  {
    "token_type": "function",
    "foreground_color": "#1c1c1e",
    "font_weight": "bold"
  }
]

Sources: editors/zed/tc-eng-extension/languages/eng/semantic_token_rules.json:1-22, editors/zed/README.md:20-40

Sources: editors/zed/tc-eng-extension/languages/eng/semantic_token_rules.json:1-37, editors/zed/README.md:20-40


4. Serif Typography and Zero-AI Invariants

Zed enforces editor typography via top-level configuration keys in editors/zed/settings.json. Font keys nested under language blocks are ignored by Zed, so the repository maintains a clean top-level font family lock:

{
  "disable_ai": true,
  "telemetry": {
    "diagnostics": false,
    "metrics": false
  },
  "auto_update": false,
  "theme": "One Light",
  "buffer_font_family": "Liberation Serif",
  "buffer_font_size": 18,
  "buffer_line_height": "comfortable",
  "terminal": {
    "font_family": ".ZedMono",
    "font_size": 14
  }
}

Sources: editors/zed/settings.json:1-16

Zero-AI and Zero-Network Invariants

  • disable_ai is explicitly set to true.
  • Telemetry diagnostics and metrics are disabled.
  • Auto-update is disabled to prevent background network activity.
  • Liberation Serif is used for buffer text to provide crisp Regular, Bold, Italic, and underline renderings without falling back to font-fallback paths that might drop styled variants.
  • The integrated terminal is pinned separately to .ZedMono to maintain a monospace execution shell.

Sources: editors/zed/settings.json:1-42, editors/zed/README.md:41-82


5. Integrated Zed Tasks

Five core development tasks are provided in .zed/tasks.json and editors/zed/tasks.json, allowing direct execution of compiler subcommands from within the editor interface:

  1. tc: Run (.eng -> static ELF64): Executes tc run $ZED_FILE.
  2. tc: Run + Parity Check: Executes r1-editor --check $ZED_FILE.
  3. tc: Paraphrase: Executes tc paraphrase $ZED_FILE.
  4. tc: Trace (Link Grammar + WordNet/VerbNet): Executes tc trace $ZED_FILE.
  5. tc: Build Static ELF64: Executes tc build $ZED_FILE.

Sources: .zed/tasks.json:1-32, editors/zed/tasks.json:1-32


Clone this wiki locally