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.

antigravity430editor31textmatesyntax highlightingextensionindie dev18

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-06-28
The Day My Own Skill Stopped Firing — When the Built-in Guide Skill Collides With Yours
Since the built-in Guide skill arrived, custom skills started getting skipped or double-fired. Here is how to observe which skill is chosen, and how to settle the conflict through descriptions and naming.
Editor View2026-06-15
Supervising Multiple Agents at Once on the Antigravity 2.0 Desktop: Screen Layout and Interruption Design
Now that Antigravity 2.0 has been recast as an agent control tower, here is how I lay out the screen, decide when to interrupt, and surface state when running several agents in parallel.
Editor View2026-05-27
Three Weeks with Antigravity Settings Sync Across Two Macs — A Sync Design for Solo App Development
Notes from three weeks of running Antigravity Settings Sync between a home Mac mini and a portable MacBook Air, written from the perspective of a solo developer working across multiple devices.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links
See all →