{"id":13588577,"url":"https://github.com/redhat-developer/yaml-language-server","last_synced_at":"2025-05-12T15:17:30.100Z","repository":{"id":37430870,"uuid":"98066217","full_name":"redhat-developer/yaml-language-server","owner":"redhat-developer","description":"Language Server for YAML Files","archived":false,"fork":false,"pushed_at":"2025-03-20T13:03:30.000Z","size":32747,"stargazers_count":1189,"open_issues_count":188,"forks_count":277,"subscribers_count":17,"default_branch":"main","last_synced_at":"2025-03-30T14:35:45.892Z","etag":null,"topics":["language-server","yaml","yaml-support"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/redhat-developer.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-07-23T00:52:41.000Z","updated_at":"2025-03-29T15:43:52.000Z","dependencies_parsed_at":"2024-06-06T15:39:22.015Z","dependency_job_id":"ab0b0c24-bfd7-483c-afbf-c810c22528c7","html_url":"https://github.com/redhat-developer/yaml-language-server","commit_stats":{"total_commits":1032,"total_committers":82,"mean_commits":"12.585365853658537","dds":0.7248062015503876,"last_synced_commit":"f039273ee5b6974db5ad34b03bb24cfe09b64447"},"previous_names":[],"tags_count":104,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redhat-developer%2Fyaml-language-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redhat-developer%2Fyaml-language-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redhat-developer%2Fyaml-language-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redhat-developer%2Fyaml-language-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/redhat-developer","download_url":"https://codeload.github.com/redhat-developer/yaml-language-server/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250477810,"owners_count":21437049,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["language-server","yaml","yaml-support"],"created_at":"2024-08-01T15:06:47.940Z","updated_at":"2025-04-23T17:11:35.752Z","avatar_url":"https://github.com/redhat-developer.png","language":"TypeScript","funding_links":[],"categories":["TypeScript","Formats","HarmonyOS","yaml"],"sub_categories":["Windows Manager"],"readme":"![CI](https://github.com/redhat-developer/yaml-language-server/workflows/CI/badge.svg) [![version](https://img.shields.io/npm/v/yaml-language-server.svg)](https://www.npmjs.com/package/yaml-language-server) [![Coverage Status](https://coveralls.io/repos/github/redhat-developer/yaml-language-server/badge.svg?branch=main)](https://coveralls.io/github/redhat-developer/yaml-language-server?branch=main)\n\n# YAML Language Server\n\nSupports JSON Schema 7 and below.\nStarting from `1.0.0` the language server uses [eemeli/yaml](https://github.com/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.\n\n## Features\n\n1. YAML validation:\n   - Detects whether the entire file is valid yaml\n2. Validation:\n   - Detects errors such as:\n     - Node is not found\n     - Node has an invalid key node type\n     - Node has an invalid type\n     - Node is not a valid child node\n   - Detects warnings such as:\n     - Node is an additional property of parent\n3. Auto completion:\n   - Auto completes on all commands\n   - Scalar nodes autocomplete to schema's defaults if they exist\n4. Hover support:\n   - Hovering over a node shows description _if available_\n5. Document outlining:\n   - Shows a complete document outline of all nodes in the document\n\n## Language Server Settings\n\nThe following settings are supported:\n\n- `yaml.yamlVersion`: Set default YAML spec version (1.2 or 1.1)\n- `yaml.format.enable`: Enable/disable default YAML formatter (requires restart)\n- `yaml.format.singleQuote`: Use single quotes instead of double quotes\n- `yaml.format.bracketSpacing`: Print spaces between brackets in objects\n- `yaml.format.proseWrap`: Always: wrap prose if it exceeds the print width, Never: never wrap the prose, Preserve: wrap prose as-is\n- `yaml.format.printWidth`: Specify the line length that the printer will wrap on\n- `yaml.validate`: Enable/disable validation feature\n- `yaml.hover`: Enable/disable hover\n- `yaml.completion`: Enable/disable autocompletion\n- `yaml.schemas`: Helps you associate schemas with files in a glob pattern\n- `yaml.schemaStore.enable`: When set to true the YAML language server will pull in all available schemas from [JSON Schema Store](https://www.schemastore.org/json/)\n- `yaml.schemaStore.url`: URL of a schema store catalog to use when downloading schemas.\n- `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).\n- `yaml.maxItemsComputed`: The maximum number of outline symbols and folding regions computed (limited for performance reasons).\n- `[yaml].editor.tabSize`: the number of spaces to use when autocompleting. Takes priority over editor.tabSize.\n- `editor.tabSize`: the number of spaces to use when autocompleting. Default is 2.\n- `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.\n- `http.proxyStrictSSL`: If true the proxy server certificate should be verified against the list of supplied CAs. Default is false.\n- `[yaml].editor.formatOnType`: Enable/disable on type indent and auto formatting array\n- `yaml.disableDefaultProperties`: Disable adding not required properties with default values into completion text\n- `yaml.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.\n- `yaml.style.flowMapping` : Forbids flow style mappings if set to `forbid` \n- `yaml.style.flowSequence` : Forbids flow style sequences if set to `forbid`\n- `yaml.keyOrdering` : Enforces alphabetical ordering of keys in mappings when set to `true`. Default is `false`\n\n##### Adding custom tags\n\nIn 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:\n\n```yaml\n\"yaml.customTags\": [\n    \"!Scalar-example scalar\",\n    \"!Seq-example sequence\",\n    \"!Mapping-example mapping\"\n]\n```\n\nThe !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.\n\nWe can then use the newly defined custom tags inside our YAML file:\n\n```yaml\nsome_key: !Scalar-example some_value\nsome_sequence: !Seq-example\n  - some_seq_key_1: some_seq_value_1\n  - some_seq_key_2: some_seq_value_2\nsome_mapping: !Mapping-example\n  some_mapping_key_1: some_mapping_value_1\n  some_mapping_key_2: some_mapping_value_2\n```\n\n##### Associating a schema to a glob pattern via yaml.schemas:\n\nyaml.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.\n\nFor example:\nIf you have project structure\n\nmyProject\n\n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u003e myYamlFile.yaml\n\nyou can do\n\n```yaml\nyaml.schemas: {\n    \"https://json.schemastore.org/composer\": \"/myYamlFile.yaml\"\n}\n```\n\nand that will associate the composer schema with myYamlFile.yaml.\n\n## More examples of schema association:\n\n### Using yaml.schemas settings\n\n#### Single root schema association:\n\nWhen associating a schema it should follow the format below\n\n```yaml\nyaml.schemas: {\n    \"url\": \"globPattern\",\n    \"Kubernetes\": \"globPattern\"\n}\n```\n\ne.g.\n\n```yaml\nyaml.schemas: {\n    \"https://json.schemastore.org/composer\": \"/*\"\n}\n```\n\ne.g.\n\n```yaml\nyaml.schemas: {\n    \"kubernetes\": \"/myYamlFile.yaml\"\n}\n```\n\ne.g.\n\n```yaml\nyaml.schemas: {\n    \"https://json.schemastore.org/composer\": \"/*\",\n    \"kubernetes\": \"/myYamlFile.yaml\"\n}\n```\n\nOn Windows with full path:\n\n```yaml\nyaml.schemas: {\n    \"C:\\\\Users\\\\user\\\\Documents\\\\custom_schema.json\": \"someFilePattern.yaml\",\n}\n```\n\nOn Mac/Linux with full path:\n\n```yaml\nyaml.schemas: {\n    \"/home/user/custom_schema.json\": \"someFilePattern.yaml\",\n}\n```\n\nSince `0.11.0` YAML Schemas can be used for validation:\n\n```yaml\n \"/home/user/custom_schema.yaml\": \"someFilePattern.yaml\"\n```\n\nA schema can be associated with multiple globs using a json array, e.g.\n\n```yaml\nyaml.schemas: {\n    \"kubernetes\": [\"filePattern1.yaml\", \"filePattern2.yaml\"]\n}\n```\n\ne.g.\n\n```yaml\n\"yaml.schemas\": {\n    \"http://json.schemastore.org/composer\": [\"/*\"],\n    \"file:///home/johnd/some-schema.json\": [\"some.yaml\"],\n    \"../relative/path/schema.json\": [\"/config*.yaml\"],\n    \"/Users/johnd/some-schema.json\": [\"some.yaml\"],\n}\n```\n\ne.g.\n\n```yaml\n\"yaml.schemas\": {\n    \"kubernetes\": [\"/myYamlFile.yaml\"]\n}\n```\n\ne.g.\n\n```yaml\n\"yaml.schemas\": {\n    \"http://json.schemastore.org/composer\": [\"/*\"],\n    \"kubernetes\": [\"/myYamlFile.yaml\"]\n}\n```\n\n#### Multi root schema association:\n\nYou can also use relative paths when working with multi root workspaces.\n\nSuppose you have a multi root workspace that is laid out like:\n\n```yaml\nMy_first_project:\n   test.yaml\n   my_schema.json\nMy_second_project:\n   test2.yaml\n   my_schema2.json\n```\n\nYou must then associate schemas relative to the root of the multi root workspace project.\n\n```yaml\nyaml.schemas: {\n    \"My_first_project/my_schema.json\": \"test.yaml\",\n    \"My_second_project/my_schema2.json\": \"test2.yaml\"\n}\n```\n\n`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.\n\n### Nested Schema References\n\nSuppose 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.:\n\n```yaml\nyaml.schemas: {\n    \"https://json.schemastore.org/circleciconfig#/definitions/jobs/additionalProperties\": \"/src/jobs/*.yaml\",\n}\n```\n\n\u003e **Note**\n\u003e This will require reading your existing schema and understanding the schemastore structure a bit. (TODO: link to a documentation or blog post here?)\n\n### Using inlined schema\n\nIt is possible to specify a yaml schema using a modeline.\n\n```yaml\n# yaml-language-server: $schema=\u003curlToTheSchema\u003e\n```\n\nAlso it is possible to use relative path in a modeline:\n\n```yaml\n# yaml-language-server: $schema=../relative/path/to/schema\n```\n\nor absolute path:\n\n```yaml\n# yaml-language-server: $schema=/absolute/path/to/schema\n```\n\n### Schema priority\n\nThe following is the priority of schema association in highest to lowest priority:\n1. Modeline\n2. CustomSchemaProvider API\n3. yaml.settings\n4. Schema association notification\n5. Schema Store\n\n## Containerized Language Server\n\nAn image is provided for users who would like to use the YAML language server without having to install dependencies locally.\n\nThe image is located at `quay.io/redhat-developer/yaml-language-server`\n\nTo run the image you can use:\n\n```sh\ndocker run -it quay.io/redhat-developer/yaml-language-server:latest\n```\n\n## Language Server Protocol version\n\n`yaml-language-server` use `vscode-languageserver@7.0.0` which implements [LSP 3.16](https://github.com/Microsoft/language-server-protocol/blob/gh-pages/_specifications/specification-3-16.md)\n\n## Language Server Protocol extensions\n\n### SchemaSelectionRequests\n\n#### SupportSchemaSelection Notification\n\nThe support schema selection notification is sent from a client to the server to inform server that client supports JSON Schema selection.\n\n_Notification:_\n\n- method: `'yaml/supportSchemaSelection'`\n- params: `void`\n\n#### SchemaStoreInitialized Notification\n\nThe 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.\n\n_Notification:_\n\n- method: `'yaml/schema/store/initialized'`\n- params: `void`\n\n#### GetAllSchemas Request\n\nThe get all schemas request sent from a client to server to get all known schemas.\n\n_Request:_\n\n- method: `'yaml/get/all/jsonSchemas'`;\n- params: the document uri, server will mark used schema for document\n\n_Response:_\n\n- result: `JSONSchemaDescriptionExt[]`\n\n```typescript\ninterface JSONSchemaDescriptionExt {\n  /**\n   * Schema URI\n   */\n  uri: string;\n  /**\n   * Schema name, from schema store\n   */\n  name?: string;\n  /**\n   * Schema description, from schema store\n   */\n  description?: string;\n  /**\n   * Is schema used for current document\n   */\n  usedForCurrentFile: boolean;\n  /**\n   * Is schema from schema store\n   */\n  fromStore: boolean;\n}\n```\n\n#### GetSchemas Request\n\nThe 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.\n\n_Request:_\n\n- method: `'yaml/get/jsonSchema'`;\n- params: the document uri to get used schemas\n\n_Response:_\n\n- result: `JSONSchemaDescription[]`\n\n```typescript\ninterface JSONSchemaDescriptionExt {\n  /**\n   * Schema URI\n   */\n  uri: string;\n  /**\n   * Schema name, from schema store\n   */\n  name?: string;\n  /**\n   * Schema description, from schema store\n   */\n  description?: string;\n}\n```\n\n## Clients\n\nThis repository only contains the server implementation. Here are some known clients consuming this server:\n\n- [Eclipse Che](https://www.eclipse.org/che/)\n- [vscode-yaml](https://marketplace.visualstudio.com/items?itemName=redhat.vscode-yaml) for VSCode\n- [coc-yaml](https://github.com/neoclide/coc-yaml) for [coc.nvim](https://github.com/neoclide/coc.nvim)\n- [Eclipse Wild Web Developer](https://marketplace.eclipse.org/content/eclipse-wild-web-developer-web-development-eclipse-ide) for Eclipse IDE\n- [lsp-mode](https://github.com/emacs-lsp/lsp-mode) for Emacs\n- [vim-lsp](https://github.com/prabirshrestha/vim-lsp) for Vim\n- [LSP-yaml](https://packagecontrol.io/packages/LSP-yaml) for Sublime Text\n- [monaco-yaml](https://monaco-yaml.js.org) for Monaco editor\n- [Vim-EasyComplete](https://github.com/jayli/vim-easycomplete) for Vim/NeoVim\n- [nova-yaml](https://github.com/robb-j/nova-yaml/) for Nova\n- [volar-service-yaml](https://github.com/volarjs/services/tree/master/packages/yaml) for Volar\n\n## Developer Support\n\n### Getting started\n\n1. Install prerequisites:\n   - latest [Visual Studio Code](https://code.visualstudio.com/)\n   - [Node.js](https://nodejs.org/) v12.0.0 or higher\n2. Fork and clone this repository\n3. Install the dependencies\n   ```bash\n   cd yaml-language-server\n   $ yarn install\n   ```\n4. Build the language server\n   ```bash\n   $ yarn run build\n   ```\n5. The new built server is now located in ./out/server/src/server.js.\n   ```bash\n   node (Yaml Language Server Location)/out/server/src/server.js [--stdio]\n   ```\n\n### Connecting to the language server via stdio\n\nWe have included the option to connect to the language server via [stdio](https://github.com/redhat-developer/yaml-language-server/blob/681985b5a059c2cb55c8171235b07e1651b6c546/src/server.ts#L46-L51) to help with integrating the language server into different clients.\n\n### ESM and UMD Modules\n\nBuilding the YAML Language Server produces [CommonJS](http://www.commonjs.org/) modules in the `/out/server/src` directory. In addition, a build also produces [UMD](https://github.com/umdjs/umd) (Universal Module Definition) modules and [ES Modules](https://tc39.es/ecma262/#sec-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.\n\n### CI\n\nWe use a GitHub Action to publish each change in the `main` branch to [npm registry](https://www.npmjs.com/package/yaml-language-server) with the `next` tag.\nYou may use the `next` version to adopt the latest changes into your project.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fredhat-developer%2Fyaml-language-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fredhat-developer%2Fyaml-language-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fredhat-developer%2Fyaml-language-server/lists"}