Colours the messages of the
Curly Message Format in VS Code: the
placeholders {{...}} with their keys, modifiers and options, and the escape
sequences, in a file of their own, in the strings of a JSON document and in
the scalars of a YAML catalogue.
It colours and nothing else. It has no code that runs, so it reports nothing
about a message, and a message it cannot read is drawn as text. The colours
come from a TextMate grammar, which is an approximation with stated edges:
see What it does not draw below.
Installing
Every version before 1.0.0 is a pre-release. In the Extensions view, search
for curly-message.curly-message-format and choose Install Pre-Release,
or from a terminal:
code --install-extension curly-message.curly-message-format --pre-release
A version with an odd minor (0.1.0, 1.1.0) is a pre-release and one with
an even minor (1.0.0, 1.2.0) a release. The extension needs VS Code 1.97
or later, the first whose own YAML grammar is the one a YAML catalogue is
coloured through.
What it colours
A message of its own
The language curly-message (Curly Message in the language picker) is for
a file whose whole text is one message. No file extension is claimed for it:
choose it in the language picker, or name the files in files.associations.
JSON
Every string value of every JSON document is read as a message, a property
name never. That is every document VS Code colours with its JSON grammars: JSON, JSON with
Comments, JSON Lines and snippets, a package.json and a settings.json
among them. Nothing in a JSON document says whether it is a catalogue, so a
{{...}} in any string value is drawn as a placeholder, whatever wrote it.
The extension has no setting that narrows this; disabling it for a workspace
turns it off there.
A message is read as JSON decodes it: "{{name}}" is the placeholder it
decodes to, and "{{a\nb}}", which decodes to braces around a line feed, is
the text it is.
YAML
{{ is not the format's alone in YAML: a GitHub Actions workflow, a Helm
chart and an Ansible playbook each write it for something else. So no YAML
document is coloured until a project says which of its files are catalogues,
by opening them in the language curly-message-yaml (Curly Message (YAML))
through files.associations, in .vscode/settings.json:
{
"files.associations": {
"**/locales/**/*.yaml": "curly-message-yaml"
}
}
Commit that file with a .vscode/extensions.json beside it that recommends
the extension, since without the extension VS Code does not know the language
and opens such a file as plain text:
{
"recommendations": ["curly-message.curly-message-format"]
}
A file opened this way is coloured by VS Code's own YAML grammar with the
messages in its scalars drawn over it, and gets the language configuration
and the editor settings VS Code gives a YAML document. It is no longer of the
language yaml, which is the cost: an extension that offers its features to
yaml documents alone (a YAML language server, with its validation against a
schema, its completion and its formatter) does not offer them to this file,
and a setting under [yaml] does not reach it.
Messages are read in the scalars that are values: a double-quoted, a
single-quoted and a block scalar, and a plain scalar of a block collection.
A plain scalar cannot open on a brace, so k: {{name}} is a flow mapping to
YAML and is not drawn; quote it.
Scopes
A theme colours a message through these scopes. Every one ends in
.curly-message, left out here. The names are not yet frozen: they
freeze with version 1.0.0, and until then a theme that selects one may have
to follow a rename.
| Scope |
What it covers |
text |
the message, in the language curly-message |
meta.placeholder |
a placeholder, from {{ to }} |
punctuation.definition.placeholder.begin, punctuation.definition.placeholder.end |
{{ and }} |
punctuation.separator |
the : before a modifier or an option's value, and the ; before an option |
variable.other.key |
the key |
support.function.modifier |
the modifier |
constant.other.option-key |
an option's key |
string.unquoted.option-value |
an option's value, the placeholders it holds included |
constant.character.escape |
a backslash and the character it cancels |
meta.escape.inert |
a backslash and a character it has nothing to cancel in |
meta.padding |
the whitespace the format trims around a part |
The grammar of the language curly-message-yaml is named
source.yaml.curly-message, and every scope under it is VS Code's own for
YAML but for those above.
What it does not draw
The grammar reads a line at a time with regular expressions, and says where
that falls short of a parser (grammar/README.md,
Divergences):
- a placeholder that holds placeholders more than 8 deep is drawn as text;
- a backslash that ends a message is drawn as an escape sequence;
- in a YAML scalar written over several lines, a placeholder or an escape
sequence that a line break of the document runs through is drawn as text.
VS Code tokenises no line past 20,000 characters by default
(editor.maxTokenizationLineLength), so a longer message written on one line
is not coloured at all.
Development
The grammar is built, not written: grammar/ holds its builder,
and npm run build writes the grammars the manifest registers into
syntaxes/ and packs the .vsix into dist/. Neither is committed. Node 22
or later builds and tests it; the extension itself ships no JavaScript.
| Command |
What it does |
npm ci |
install from the lockfile |
npm test |
build, lint, then the suite against the source and against the unpacked .vsix |
npm run smoke |
build, then open documents in a VS Code it downloads, with the .vsix installed, and read back the scopes it gives them |
npm run bench |
build, then the benchmark (bench/rows.mjs) |
npm run bench -- --compare <dir> |
the same, beside the package checked out and built at <dir> |
npm run lint:fix |
fix what the formatting contract reports |
Issues are filed in the family's shared tracker,
curly-message/spec.
License
MIT. The language configuration of curly-message-yaml is VS
Code's own for YAML, under the terms
THIRD-PARTY-NOTICES.md gives.