◉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.

antigravity461editor33textmatesyntax highlightingextensionindie dev19

✦ 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 $15 for lifetime access
View Membership →

Related Articles

⟐ Editor View2026-10-08
Undo That Rewinds Only the Conversation, and Messaging a Subagent Directly: Three Moments I Hesitated
Antigravity 2.19.1 adds undo for the conversation only, and direct messages to a subagent. Here is what the changelog says, where I draw my own lines, and how to check both safely.
⟐ Editor View2026-08-14
I Stopped Eyeballing Agent Diffs, and the 2.8.0 View Limits Are Why
Version 2.8.0 caps how much of a file and how much of a large history diff you can view. Losing the ability to scroll to the end forced a better split: let a script decide what machines can catch, and spend human attention only on what they cannot. Includes a working script and the defects it found in a real repository.
⟐ Editor View2026-05-03
Gemini CLI vs Antigravity: When to Use Which (2026 Field-Tested Verdict)
The verdict: split by task granularity, not by loyalty. Where Gemini CLI, Gemini Code Assist, and Antigravity sit relative to your editor, the decision tree six months of parallel use produced, and how proxies and DevContainers change the answer.
📚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