Repository navigation
7 4 zed editor integration
Source: https://deepwiki.com/PonvasanthPon/TransCompilator/7-4-zed-editor-integration
Relevant source files
The following files were used as context for generating this wiki page:
- .zed/tasks.json
- editors/zed/README.md
- editors/zed/install_zed_config.sh
- editors/zed/settings.json
- editors/zed/tasks.json
- editors/zed/tc-eng-extension/Cargo.toml
- editors/zed/tc-eng-extension/extension.toml
- editors/zed/tc-eng-extension/languages/eng/config.toml
- editors/zed/tc-eng-extension/languages/eng/semantic_token_rules.json
- editors/zed/tc-eng-extension/src/lib.rs
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
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;
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
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;
Figure 2: Configuration installation pipeline in install_zed_config.sh.
The script performs the following actions:
- Builds release binaries (
tc,tc-lsp,r1-editor) withCARGO_NET_OFFLINE=trueconstraints. - Symlinks them into
~/.local/bin. - Backs up existing Zed settings (
~/.config/zed/settings.json) with a timestamped suffix. - Deep-merges overlay settings from
editors/zed/settings.jsonwhile purging stale font fallbacks and language-scoped font overrides. - Merges custom
tc:tasks fromeditors/zed/tasks.jsoninto~/.config/zed/tasks.json.
Sources: editors/zed/install_zed_config.sh:1-102
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
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
-
disable_aiis explicitly set totrue. - Telemetry diagnostics and metrics are disabled.
- Auto-update is disabled to prevent background network activity.
-
Liberation Serifis 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
.ZedMonoto maintain a monospace execution shell.
Sources: editors/zed/settings.json:1-42, editors/zed/README.md:41-82
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:
-
tc: Run (.eng -> static ELF64): Executestc run $ZED_FILE. -
tc: Run + Parity Check: Executesr1-editor --check $ZED_FILE. -
tc: Paraphrase: Executestc paraphrase $ZED_FILE. -
tc: Trace (Link Grammar + WordNet/VerbNet): Executestc trace $ZED_FILE. -
tc: Build Static ELF64: Executestc build $ZED_FILE.
Sources: .zed/tasks.json:1-32, editors/zed/tasks.json:1-32
The TransCompilator Project