Skip to content

Autocomplete in your editor ​

You want your editor to suggest field names and allowed values, and to underline a mistake before you run alta lint.

Solution ​

Write the JSON Schemas into your project once:

Terminal
sh
alta schemas --out .alta/schemas

Then tell VS Code which schema goes with which file, in .vscode/settings.json:

.vscode/settings.json
json
{
  "json.schemas": [
    {
      "fileMatch": [
        "quests.json",
        "*.quests.json",
        "mission.json"
      ],
      "url": "./.alta/schemas/alta.quests.schema.json"
    },
    {
      "fileMatch": ["chart.json"],
      "url": "./.alta/schemas/alta.chart.schema.json"
    },
    {
      "fileMatch": ["onboarding.json"],
      "url": "./.alta/schemas/alta.onboarding.schema.json"
    },
    {
      "fileMatch": ["cinematics.json"],
      "url": "./.alta/schemas/alta.cinematics.schema.json"
    }
  ]
}

examples/recipes/vscode/settings.json

Open quests.json: typing "kind": " lists the step kinds, and a misspelled field is underlined.

How it works ​

alta schemas writes one JSON Schema per standard, the same ones alta lint and the SDK use. The json.schemas setting maps file names to these schemas, so you need nothing inside your content files. The schemas catch the shape of a file (names, types, closed lists); alta lint still does the rest, such as references between quests.

Variants ​

  • Other editors. JetBrains IDEs: Settings › Languages & Frameworks › Schemas and DTDs › JSON Schema Mappings, with the same files. Neovim and Helix: give the same mapping to the JSON language server.
  • Keep them current. Run alta schemas --out .alta/schemas again after you update alta; alta schemas --out .alta/schemas --check fails if they are out of date.
  • Other file names. Add your names to fileMatch, for example "*.quests.json".

What's next

Alta OS is open source (MIT).