ZIm/docs/src/languages/yaml.md
Peter Tripp 2d06d5c906
Add YAML LSP initialization_options (#17479)
Makes YAML language server configurable under `lsp.yaml-language-server`:
- Add support for `initialization_options` 
- Add support for custom `bin` specification
2024-09-06 11:42:36 -04:00

1.7 KiB

YAML

YAML support is available natively in Zed.

Configuration

You can configure various yaml-language-server settings by adding them to your Zed settings.json in a yaml-language-server block under the lsp key. For example:

  "lsp": {
    "yaml-language-server": {
      "initialization_options": {
        "yaml": {
          "keyOrdering": true,
          "format": {
            "singleQuote": true
          },
          "schemas": {
              "http://json.schemastore.org/composer": ["/*"],
              "../relative/path/schema.json": ["/config*.yaml"]
          }
        }
      }
    }
  }

Note, settings keys must be nested, so yaml.keyOrdering becomes {"yaml": { "keyOrdering": true }}.

Schemas

By default yaml-language-server will attempt to determine the correct schema for a given yaml file and retrieve the appropriate JSON Schema from [Json Schema Store].

You can override this by [using an inlined schema] reference via a modeline comment at the top of your yaml file:

# yaml-language-server: $schema=https://json.schemastore.org/github-action.json
name: Issue Assignment
on:
  issues:
    types: [oppened]

You can disable this functionality entirely if desired:

  "lsp": {
    "yaml-language-server": {
      "initialization_options": {
        "yaml": {
          "schemaStore": {
            "enable": false
          }
        }
      }
    }
  }