在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):redhat-developer/vscode-yaml开源软件地址(OpenSource Url):https://github.com/redhat-developer/vscode-yaml开源编程语言(OpenSource Language):TypeScript 92.5%开源软件介绍(OpenSource Introduction):YAML Language Support by Red HatProvides comprehensive YAML Language support to Visual Studio Code, via the yaml-language-server, with built-in Kubernetes syntax support. Features
Auto completion and hover support are provided by the schema. Please refer to Language Server Settings to setup a schema YAML version supportStarting from Extension SettingsThe following settings are supported:
In to your settings. Adding custom tagsTo use the custom tags in your YAML file, you need to first specify the custom tags in the setting of your code editor. For example, you can have the following custom tags: "yaml.customTags": [
"!Scalar-example scalar",
"!Seq-example sequence",
"!Mapping-example mapping"
] The !Scalar-example would map to a scalar custom tag, the !Seq-example would map to a sequence custom tag, the !Mapping-example would map to a mapping custom tag. You can then use the newly defined custom tags inside the YAML file: some_key: !Scalar-example some_value
some_sequence: !Seq-example
- some_seq_key_1: some_seq_value_1
- some_seq_key_2: some_seq_value_2
some_mapping: !Mapping-example
some_mapping_key_1: some_mapping_value_1
some_mapping_key_2: some_mapping_value_2 Associating schemasYAML Language support uses JSON Schemas to understand the shape of a YAML file, including its value sets, defaults and descriptions. The schema support is shipped with JSON Schema Draft 7. We support schemas provided through JSON Schema Store. However, schemas can also be defined in a workspace. The association of a YAML file to a schema can be done either in the YAML file itself using a modeline or in the User or Workspace settings under the property Associating a schema in the YAML fileIt is possible to specify a yaml schema using a modeline. Schema url can be a relative path. If a relative path is specified, it is calculated from yaml file path, not from workspace root path # yaml-language-server: $schema=<urlToTheSchema> Associating a schema to a glob pattern via yaml.schemas:
When associating a schema it should follow the format below "yaml.schemas": {
"url": "globPattern",
"Kubernetes": "globPattern"
} e.g. yaml.schemas: {
"https://json.schemastore.org/composer": "/*"
} e.g. yaml.schemas: {
"kubernetes": "/myYamlFile.yaml"
} e.g. yaml.schemas: {
"https://json.schemastore.org/composer": "/*",
"kubernetes": "/myYamlFile.yaml"
} On Windows with full path: yaml.schemas: {
"C:\\Users\\user\\Documents\\custom_schema.json": "someFilePattern.yaml",
"file:///C:/Users/user/Documents/custom_schema.json": "someFilePattern.yaml",
} On Mac/Linux with full path: yaml.schemas: {
"/home/user/custom_schema.json": "someFilePattern.yaml",
} Since "/home/user/custom_schema.yaml": "someFilePattern.yaml" A schema can be associated with multiple globs using a json array, e.g. yaml.schemas: {
"kubernetes": ["filePattern1.yaml", "filePattern2.yaml"]
} e.g. "yaml.schemas": {
"http://json.schemastore.org/composer": ["/*"],
"file:///home/johnd/some-schema.json": ["some.yaml"],
"../relative/path/schema.json": ["/config*.yaml"],
"/Users/johnd/some-schema.json": ["some.yaml"],
} e.g. "yaml.schemas": {
"kubernetes": ["/myYamlFile.yaml"]
} e.g. "yaml.schemas": {
"http://json.schemastore.org/composer": ["/*"],
"kubernetes": ["/myYamlFile.yaml"]
} Multi root schema association:You can also use relative paths when working with multi-root workspaces. Suppose you have a multi-root workspace that is laid out like: My_first_project:
test.yaml
my_schema.json
My_second_project:
test2.yaml
my_schema2.json You must then associate schemas relative to the root of the multi root workspace project. yaml.schemas: {
"My_first_project/my_schema.json": "test.yaml",
"My_second_project/my_schema2.json": "test2.yaml"
}
Mapping a schema in an extension
{
"contributes": {
"yamlValidation": [
{
"fileMatch": "yourfile.yml",
"url": "./schema.json"
}
]
}
} Data and TelemetryThe How to contributeThe instructions are available in the contribution guide. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论