Syntax highlighting for Salt state/pillar files (.sls) and Jinja
templates (.j2, .jinja) in Visual Studio Code.
Features
| File pattern | Language | Highlighting |
|---|---|---|
*.sls |
Salt SLS | YAML + Jinja |
*.j2, *.jinja (conf, env, systemd units, …) |
Jinja | Jinja highlighted, body plain text |
- Whitespace-control delimiters (
{%- ... -%}) are colored evenly on both ends. - Jinja is highlighted at every YAML nesting level.
- Plain
.yml/.yamlfiles are unaffected.
Highlighting *.yaml.j2 as Salt SLS
If you keep templated YAML in *.yaml.j2 files, map them to the sls language
in your project's .vscode/settings.json:
{
"files.associations": {
"*.yaml.j2": "sls"
}
}
Install
From the Marketplace: search for "Salt & Jinja Syntax Highlighting" in
the Extensions view (Ctrl+Shift+X), or install from the command line:
code --install-extension MycroftMind.salt-syntax
Then fully quit and reopen VS Code.
Known limitations
- Jinja nested deeply inside YAML block scalars gets best-effort scoping.
{% raw %} ... {% endraw %}content is not treated as fully literal.- For non-YAML templates (
.conf.j2,env.j2,service.j2), only the Jinja is highlighted; the underlying body (INI/env/systemd) stays plain text.
Building from source
The extension is pure JSON grammars — there's no compile step, only packaging
with vsce:
# Requires Node.js 18+
npx --yes @vscode/vsce package # produces salt-syntax-<version>.vsix
code --install-extension salt-syntax-<version>.vsix
License
MIT © Mycroft Mind, a.s.