How to maintain editor syntax definitions for Dang. Use when adding or removing keywords, tokens, or language constructs.
Installation
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
How to maintain editor syntax definitions for Dang. Use when adding or removing keywords, tokens, or language constructs.
Editor Syntax Maintenance
Dang has syntax definitions for three editors. When the language grammar
changes (keywords added/removed, tokens renamed, new constructs), all
three must be updated in sync.
Submodule pointing to https://github.com/vito/dang.nvim
Commit inside the submodule first, then update the submodule pointer
in the parent repo
Tree-sitter highlights (Zed + Neovim)
The two .scm files are nearly identical but use different capture
names (Zed uses @keyword.control, @variable.special, etc.; Neovim
uses @keyword, @variable.builtin, etc.). Edit both when making
changes.
Keywords are listed as (foo_token) nodes inside [ ... ] @keyword
blocks. To add or remove a keyword, add or remove the corresponding
(foo_token) line in both files.
TextMate grammar (VSCode)
Keywords live in the keyword-control repository entry as a single
regex. To add or remove a keyword, edit the \b(...)\b alternation.
Committing
Since Zed and Neovim are submodules:
# 1. Commit in each submodulecd editors/zed && git add -A && git commit -m "..." && cd ../..
cd editors/nvim && git add -A && git commit -m "..." && cd ../..
# 2. Commit submodule pointers + VSCode changes in parent
git add editors/zed editors/nvim editors/vscode/syntaxes/dang.tmLanguage.json
git commit -m "chore(editors): ..."
Embedded highlight query (REPL)
The REPL highlights its input with the same Zed highlights.scm, embedded
into the binary at pkg/dang/highlights.scm (a generated copy, since
go:embed can't follow the treesitter/queries/highlights.scm symlink into
the submodule). ./hack/generate (via go generate ./...) refreshes it with
cp, so it tracks the query automatically — just re-run generation after
editing the Zed query. New capture names also need a case in captureClass
in pkg/dang/highlight_common.go (kept in lockstep with
docs/go/highlight.go).
Stale-parser gotcha (cgo build cache)
pkg/dang/danglang binds the generated parser by #include-ing
treesitter/src/parser.c across package directories, and Go's build cache
does not track that file. After ./hack/generate regenerates the
grammar, cached builds keep linking the old parser; the first symptom is
the embedded highlight query failing to compile ("Invalid node type
<new_token>") and the REPL silently rendering plain text
(TestHighlightCodeStylesAndPreservesText fails). Force one rebuild:
go test -a ./pkg/dang/ -run TestHighlight
(-a recomputes the cache entry; subsequent normal builds are fine.)
Re-run ./hack/generate to refresh the embedded pkg/dang/highlights.scm
Force-rebuild the cgo parser binding (see gotcha above)
Add/refresh treesitter/test/corpus/ and editors/highlights/corpus/
cases for the new construct (tree-sitter test --update,
go test ./editors/ -run TestNeovimHighlights -update)