VS Code has support for schemastore which gives you autocomplete in YAML files.
But VS Code does not detect the schema if the filename is different.
For example, if I edit .golangci.yaml
the corresponding schema gets used. If I edit .golangci-foo.yaml
the schema is not detected.
How can I enable the schema for files where the filename is different?
CodePudding user response:
At least for JSON, you can do this using the json.schemas
setting. Like so:
"json.schemas": [
{
"fileMatch": [ "*tsconfig*.json" ],
"url": "http://json.schemastore.org/tsconfig",
},{
"fileMatch": [ "*cSpell.json" ],
"url": "https://raw.githubusercontent.com/streetsidesoftware/cspell/cspell4/cspell.schema.json",
},{
"fileMatch": [ "*.webmanifest" ],
"url": "http://json.schemastore.org/web-manifest",
},{
"fileMatch": [ "*package*.json" ],
"url": "https://json.schemastore.org/package",
}
],
I'm not sure if this same setting extends to YAML, but I don't see a yaml.schemas
setting.
Perhaps you can try something like this:
"json.schemas": [
{
"fileMatch": [ ".golangci*.yaml" ],
"url": "http://example.com/path/to/schema",
}
],