0

For background see How to make VS Code to treat other file extensions as certain language?

That question is concerned with how to define a file association manually. This question is about how to express that in the contributes section of the package.json file for a VS Code extension.

Basically I want VS Code to treat .mdbook as an alias for .json because it's a json file with a specific schema. It's not obvious to me which contribution point is relevant or how to express this.

Peter Wone
  • 17,965
  • 12
  • 82
  • 134

1 Answers1

1

It's straightforward, but the documentation only hints at it.

You "contribute" the language, but only the settings you're adding or changing. To use my own application as an example, we add a file type and a friendly-name for json like so:

    "languages": [
      {
        "id": "json",
        "extensions": [
          ".mdbook"
        ],
        "aliases": [
          "Markdown Book"
        ]
      }
    ],

Obviously the json language is already defined; these settings are merged.

Peter Wone
  • 17,965
  • 12
  • 82
  • 134