A polyglot Go-template language toolkit (syntax highlighting, diagnostics, and completion) for Go templates embedded in any base language.
0

Configure Feed

Select the types of activity you want to include in your feed.

at main 3 files
README.md

scripts/#

Repo maintenance scripts for polytmpl. Each script is a small Node module with no external dependencies, wired into the pnpm workspace as polytmpl-scripts.

generate-zed-language#

Scaffolds a new per-flavour Zed language under zed/languages/<lang>-template/, following the inverted-injection pattern documented in docs/architecture.md: gotmpl is the host grammar, and the base language is injected by name into gotmpl's text regions.

Usage#

pnpm --filter polytmpl-scripts run generate-zed-language <lang-id> [display-name] [--force]

Arguments#

Argument Meaning
<lang-id> Lowercase language id matching /^[a-z][a-z0-9-]*$/. Examples: toml, sql, dockerfile.
[display-name] Optional. Defaults to <ID> Template for short acronym-style ids (≤4 letters) and Lang Template (title-cased) otherwise.

Flags#

Flag Meaning
--force Overwrite an existing zed/languages/<lang>-template/.
-h, --help Print usage and exit.

Examples#

# Short id → "TOML Template" by default.
pnpm --filter polytmpl-scripts run generate-zed-language toml

# Longer name with an explicit display label.
pnpm --filter polytmpl-scripts run generate-zed-language dockerfile "Dockerfile Template"

# Regenerate over an existing directory.
pnpm --filter polytmpl-scripts run generate-zed-language toml --force

# Print usage and exit.
pnpm --filter polytmpl-scripts run generate-zed-language --help

What it generates#

Three files under zed/languages/<lang-id>-template/:

File Role
config.toml name, grammar = "gotmpl", default path_suffixes = ["<lang-id>.tmpl"], gotmpl comment markers.
injections.scm (text) @injection.content (#set! injection.language "<lang-id>") (#set! injection.combined) — injects the base language into every non-template span.
highlights.scm Fresh copy of zed/languages/gotmpl/highlights.scm with a sync-note header so future drift is visible.

After generation#

The script prints three numbered next steps:

  1. Review config.toml — confirm the display name and add any extra path_suffixes (e.g. yml.tmpl, gohtml).
  2. Review injections.scm — confirm injection.language "<id>" resolves to a language Zed knows about (built-in or via a community extension).
  3. Reinstall the dev extension in Zed: Command Palette → zed: install dev extension → select zed/.

Constraints worth knowing#

  • Sync requirement. Every per-flavour language carries its own highlights.scm. If the canonical zed/languages/gotmpl/highlights.scm ever changes, regenerate each flavour with --force, or update each file by hand. The header comment in every generated file flags this.
  • Base-language availability. Injection resolves at runtime against Zed's language registry. If the chosen language id isn't registered (built-in or community extension), the non-template parts will appear unhighlighted but the gotmpl actions still colour correctly.