◉ANTIGRAVITY LABJP
Articles/Editor View
⟐ Editor View/2026-07-12Intermediate

The Day My Own DSL Stayed Gray: Adding a Minimal TextMate Grammar to Antigravity

When a custom config file you use every day renders as flat gray text, misreads pile up. This walkthrough builds a minimal TextMate grammar and language-configuration so Antigravity highlights your own file type, with working code and the pitfalls that trip people up.

antigravity476editor36textmatesyntax highlightingextensionindie dev25

✦ Premium Article

One evening I opened a wallpaper-rules file from one of my own apps as an indie developer, and the screen looked oddly quiet. palette: sunset, @when season == winter, comments, strings, all the same shade of gray. Structure I could read at a glance in JavaScript or Python collapsed into flat text the moment the extension became my own .wprules. Every time my eyes tracked a line, I noticed I was redrawing the boundary between key and value in my head.

The cause was not the editor's capability. Antigravity simply does not know the .wprules extension, so it has no cue for where to apply color. The flip side is encouraging: hand it that cue, and the color comes back. Here we will assemble the smallest possible extension that highlights a custom file, using code that actually runs. No flashy features. The goal is the shortest path to "readable."

What Gray Really Means: Highlighting Maps Scopes to Colors

Syntax highlighting does not color text directly. First a grammar assigns each fragment of text a scope name such as keyword.control or string.quoted, and then the theme maps that scope name to a color. Two stages.

A custom file is gray because the first stage is missing. The theme has plenty of colors, but nothing has been tagged with a scope name to paint. So our job is not to pick colors. It is to write a grammar that assigns the right scope names to the text.

This design is not unique to Antigravity. It comes from TextMate and is widely adopted by VS Code-family editors. Antigravity follows the same mechanism, so a TextMate grammar (.tmLanguage.json) drops straight in.

The File We Are Targeting

We will bring color to a .wprules file like the one below. Think of it as a tiny DSL for declaring wallpaper-generation conditions.

# Winter dusk preset
@when season == winter
palette: sunset
brightness: 0.82
title: "Winter Glow"

There are four semantically distinct elements here: comments (#), directives (@when ...), keys (palette and friends), and values (numbers, booleans, strings). Assign a different scope to each of the four, and the reading cues return all at once.

✦

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
✦Why custom files render gray: there is no language registered, and a single TextMate grammar is enough to bring color back
✦Every file of a minimal extension (grammar, language-configuration, snippets) plus how to verify color with scope inspection
✦Three pitfalls: regex ordering, embedded languages, and theme-independent scope naming, each with a fix
Secure payment via Stripe · Cancel anytime
✦

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Antigravity Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • ✦Copy-paste ready implementation code
  • ✦New advanced guides published daily
  • ✦$5/mo or $10 for lifetime access
View Membership →

Related Articles

⟐ Editor View2026-11-13
Knowledge Work or Software Engineering: Choosing an Antigravity Layout by What the Task Changes
The Knowledge Work layout added in v2.30.0 hides code changes and developer tools. Here is how I decide between it and the Software Engineering layout, plus a short script to see what changed while the diffs were out of view.
⟐ Editor View2026-10-21
I Wondered Whether to Sort My Diffs by Machine, So I Ran It on 106 Commits. It Mattered for 8, and for One 1,776-File Change
I wrote a small script that orders a git diff by reading priority and ran it on 106 recent commits. It earned its place in 8 of them and one bulk change. Rules, full code, and the silent misclassification traps.
⟐ Editor View2026-10-18
Chat, Editor, Terminal: Which of the Three Panes to Watch on Day One
Antigravity opens with chat, editor, and terminal side by side. Where a non-coder should look in the first week, a cheat sheet for spotting risky terminal commands by their first word, how to judge a diff by its size, which permission preset to start with, and a triage table for day-one snags (as of November 2026).