Gathering detailed insights and metrics for yaml-language-server
Gathering detailed insights and metrics for yaml-language-server
Gathering detailed insights and metrics for yaml-language-server
Gathering detailed insights and metrics for yaml-language-server
npm install yaml-language-server
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
1,098 Stars
1,302 Commits
265 Forks
18 Watching
15 Branches
145 Contributors
Updated on 27 Nov 2024
TypeScript (99.78%)
JavaScript (0.2%)
Dockerfile (0.02%)
Cumulative downloads
Total Downloads
Last day
12.4%
31,336
Compared to previous day
Last week
4.8%
174,428
Compared to previous week
Last month
15.3%
700,003
Compared to previous month
Last year
144.3%
2,931,492
Compared to previous year
10
26
1
Supports JSON Schema 7 and below.
Starting from 1.0.0
the language server uses eemeli/yaml as the new YAML parser, which strictly enforces the specified YAML spec version. Default YAML spec version is 1.2
, it can be changed with yaml.yamlVersion
setting.
The following settings are supported:
yaml.yamlVersion
: Set default YAML spec version (1.2 or 1.1)yaml.format.enable
: Enable/disable default YAML formatter (requires restart)yaml.format.singleQuote
: Use single quotes instead of double quotesyaml.format.bracketSpacing
: Print spaces between brackets in objectsyaml.format.proseWrap
: Always: wrap prose if it exceeds the print width, Never: never wrap the prose, Preserve: wrap prose as-isyaml.format.printWidth
: Specify the line length that the printer will wrap onyaml.validate
: Enable/disable validation featureyaml.hover
: Enable/disable hoveryaml.completion
: Enable/disable autocompletionyaml.schemas
: Helps you associate schemas with files in a glob patternyaml.schemaStore.enable
: When set to true the YAML language server will pull in all available schemas from JSON Schema Storeyaml.schemaStore.url
: URL of a schema store catalog to use when downloading schemas.yaml.customTags
: Array of custom tags that the parser will validate against. It has two ways to be used. Either an item in the array is a custom tag such as "!Ref" and it will automatically map !Ref to scalar or you can specify the type of the object !Ref should be e.g. "!Ref sequence". The type of object can be either scalar (for strings and booleans), sequence (for arrays), map (for objects).yaml.maxItemsComputed
: The maximum number of outline symbols and folding regions computed (limited for performance reasons).[yaml].editor.tabSize
: the number of spaces to use when autocompleting. Takes priority over editor.tabSize.editor.tabSize
: the number of spaces to use when autocompleting. Default is 2.http.proxy
: The URL of the proxy server that will be used when attempting to download a schema. If it is not set or it is undefined no proxy server will be used.http.proxyStrictSSL
: If true the proxy server certificate should be verified against the list of supplied CAs. Default is false.[yaml].editor.formatOnType
: Enable/disable on type indent and auto formatting arrayyaml.disableDefaultProperties
: Disable adding not required properties with default values into completion textyaml.suggest.parentSkeletonSelectedFirst
: If true, the user must select some parent skeleton first before autocompletion starts to suggest the rest of the properties.\nWhen yaml object is not empty, autocompletion ignores this setting and returns all properties and skeletons.yaml.style.flowMapping
: Forbids flow style mappings if set to forbid
yaml.style.flowSequence
: Forbids flow style sequences if set to forbid
yaml.keyOrdering
: Enforces alphabetical ordering of keys in mappings when set to true
. Default is false
In order to 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, we can have the following custom tags:
1"yaml.customTags": [ 2 "!Scalar-example scalar", 3 "!Seq-example sequence", 4 "!Mapping-example mapping" 5]
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.
We can then use the newly defined custom tags inside our YAML file:
1some_key: !Scalar-example some_value 2some_sequence: !Seq-example 3 - some_seq_key_1: some_seq_value_1 4 - some_seq_key_2: some_seq_value_2 5some_mapping: !Mapping-example 6 some_mapping_key_1: some_mapping_value_1 7 some_mapping_key_2: some_mapping_value_2
yaml.schemas applies a schema to a file. In other words, the schema (placed on the left) is applied to the glob pattern on the right. Your schema can be local or online. Your schema path must be relative to the project root and not an absolute path to the schema.
For example: If you have project structure
myProject
   > myYamlFile.yaml
you can do
1yaml.schemas: { 2 "https://json.schemastore.org/composer": "/myYamlFile.yaml" 3}
and that will associate the composer schema with myYamlFile.yaml.
When associating a schema it should follow the format below
1yaml.schemas: { 2 "url": "globPattern", 3 "Kubernetes": "globPattern" 4}
e.g.
1yaml.schemas: { 2 "https://json.schemastore.org/composer": "/*" 3}
e.g.
1yaml.schemas: { 2 "kubernetes": "/myYamlFile.yaml" 3}
e.g.
1yaml.schemas: { 2 "https://json.schemastore.org/composer": "/*", 3 "kubernetes": "/myYamlFile.yaml" 4}
On Windows with full path:
1yaml.schemas: { 2 "C:\\Users\\user\\Documents\\custom_schema.json": "someFilePattern.yaml", 3}
On Mac/Linux with full path:
1yaml.schemas: { 2 "/home/user/custom_schema.json": "someFilePattern.yaml", 3}
Since 0.11.0
YAML Schemas can be used for validation:
1 "/home/user/custom_schema.yaml": "someFilePattern.yaml"
A schema can be associated with multiple globs using a json array, e.g.
1yaml.schemas: { 2 "kubernetes": ["filePattern1.yaml", "filePattern2.yaml"] 3}
e.g.
1"yaml.schemas": { 2 "http://json.schemastore.org/composer": ["/*"], 3 "file:///home/johnd/some-schema.json": ["some.yaml"], 4 "../relative/path/schema.json": ["/config*.yaml"], 5 "/Users/johnd/some-schema.json": ["some.yaml"], 6}
e.g.
1"yaml.schemas": { 2 "kubernetes": ["/myYamlFile.yaml"] 3}
e.g.
1"yaml.schemas": { 2 "http://json.schemastore.org/composer": ["/*"], 3 "kubernetes": ["/myYamlFile.yaml"] 4}
You can also use relative paths when working with multi root workspaces.
Suppose you have a multi root workspace that is laid out like:
1My_first_project: 2 test.yaml 3 my_schema.json 4My_second_project: 5 test2.yaml 6 my_schema2.json
You must then associate schemas relative to the root of the multi root workspace project.
1yaml.schemas: { 2 "My_first_project/my_schema.json": "test.yaml", 3 "My_second_project/my_schema2.json": "test2.yaml" 4}
yaml.schemas
allows you to specify json schemas that you want to validate against the yaml that you write. Kubernetes is an optional field. It does not require a url as the language server will provide that. You just need the keyword kubernetes and a glob pattern.
Suppose a file is meant to be a component of an existing schema (like a job.yaml
file in a circleci orb), but there isn't a standalone schema that you can reference. If there is a nested schema definition for this subcomponent, you can reference it using a url fragment, e.g.:
1yaml.schemas: { 2 "https://json.schemastore.org/circleciconfig#/definitions/jobs/additionalProperties": "/src/jobs/*.yaml", 3}
Note This will require reading your existing schema and understanding the schemastore structure a bit. (TODO: link to a documentation or blog post here?)
It is possible to specify a yaml schema using a modeline.
1# yaml-language-server: $schema=<urlToTheSchema>
Also it is possible to use relative path in a modeline:
1# yaml-language-server: $schema=../relative/path/to/schema
or absolute path:
1# yaml-language-server: $schema=/absolute/path/to/schema
The following is the priority of schema association in highest to lowest priority:
An image is provided for users who would like to use the YAML language server without having to install dependencies locally.
The image is located at quay.io/redhat-developer/yaml-language-server
To run the image you can use:
1docker run -it quay.io/redhat-developer/yaml-language-server:latest
yaml-language-server
use vscode-languageserver@7.0.0
which implements LSP 3.16
The support schema selection notification is sent from a client to the server to inform server that client supports JSON Schema selection.
Notification:
'yaml/supportSchemaSelection'
void
The schema store initialized notification is sent from the server to a client to inform client that server has finished initializing/loading schemas from schema store, and client now can ask for schemas.
Notification:
'yaml/schema/store/initialized'
void
The get all schemas request sent from a client to server to get all known schemas.
Request:
'yaml/get/all/jsonSchemas'
;Response:
JSONSchemaDescriptionExt[]
1interface JSONSchemaDescriptionExt { 2 /** 3 * Schema URI 4 */ 5 uri: string; 6 /** 7 * Schema name, from schema store 8 */ 9 name?: string; 10 /** 11 * Schema description, from schema store 12 */ 13 description?: string; 14 /** 15 * Is schema used for current document 16 */ 17 usedForCurrentFile: boolean; 18 /** 19 * Is schema from schema store 20 */ 21 fromStore: boolean; 22}
The request sent from a client to server to get schemas used for current document. Client can use this method to indicate in UI which schemas used for current YAML document.
Request:
'yaml/get/jsonSchema'
;Response:
JSONSchemaDescription[]
1interface JSONSchemaDescriptionExt { 2 /** 3 * Schema URI 4 */ 5 uri: string; 6 /** 7 * Schema name, from schema store 8 */ 9 name?: string; 10 /** 11 * Schema description, from schema store 12 */ 13 description?: string; 14}
This repository only contains the server implementation. Here are some known clients consuming this server:
1cd yaml-language-server 2$ yarn install
1$ yarn run build
1node (Yaml Language Server Location)/out/server/src/server.js [--stdio]
We have included the option to connect to the language server via stdio to help with integrating the language server into different clients.
Building the YAML Language Server produces CommonJS modules in the /out/server/src
directory. In addition, a build also produces UMD (Universal Module Definition) modules and ES Modules (ESM) in the /lib
directory. That gives you choices in using the YAML Language Server with different module loaders on the server side and in the browser with bundlers like webpack.
We use a GitHub Action to publish each change in the main
branch to npm registry with the next
tag.
You may use the next
version to adopt the latest changes into your project.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
packaging workflow detected
Details
Reason
Found 25/28 approved changesets -- score normalized to 8
Reason
dependency not pinned by hash detected -- score normalized to 5
Details
Reason
SAST tool is not run on all commits -- score normalized to 4
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
10 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn Morevolar-service-yaml
Integrate yaml-language-server into Volar
yaml-language-server-parser
This is a maintained fork of YAML-AST-PARSER specifically for the YAML Language server.
yaml-ast-parser-custom-tags
This is a custom maintained fork specifically for the YAML Language server.
@kie-tools/yaml-language-server
Esbuild package to wrap [YAML Language Server](https://github.com/redhat-developer/yaml-language-server) and allow the use in Webpack.