yamlls

URL: https://github.com/redhat-developer/yaml-language-server

plugins.lsp.servers.yamlls.enable

Whether to enable https://github.com/redhat-developer/yaml-language-server

yaml-language-server can be installed via yarn:

yarn global add yaml-language-server

To use a schema for validation, there are two options:

  1. Add a modeline to the file. A modeline is a comment of the form:
<!-- -->
# yaml-language-server: $schema=<urlToTheSchema|relativeFilePath|absoluteFilePath}>

where the relative filepath is the path relative to the open yaml file, and the absolute filepath is the filepath relative to the filesystem root (‘/’ on unix systems)

  1. Associated a schema url, relative , or absolute (to root of project, not to filesystem root) path to the a glob pattern relative to the detected project root. Check :LspInfo to determine the resolved project root.
require('lspconfig').yamlls.setup {
  ... -- other configuration for setup {}
  settings = {
    yaml = {
      ... -- other settings. note this overrides the lspconfig defaults.
      schemas = {
        ["https://json.schemastore.org/github-workflow.json"] = "/.github/workflows/*",
        ["../path/relative/to/file.yml"] = "/.github/workflows/*",
        ["/path/from/root/of/project"] = "/.github/workflows/*",
      },
    },
  }
}

Currently, kubernetes is special-cased in yammls, see the following upstream issues: * #211. * #307.

To override a schema to use a specific k8s schema version (for example, to use 1.18):

require('lspconfig').yamlls.setup {
  ... -- other configuration for setup {}
  settings = {
    yaml = {
      ... -- other settings. note this overrides the lspconfig defaults.
      schemas = {
        ["https://raw.githubusercontent.com/yannh/kubernetes-json-schema/refs/heads/master/v1.32.1-standalone-strict/all.json"] = "/*.k8s.yaml",
        ... -- other schemas
      },
    },
  }
}

.

Type: boolean

Default: false

Example: true

Declared by:

plugins.lsp.servers.yamlls.package

The yamlls package to use.

Type: null or package

Default: pkgs.yaml-language-server

Declared by:

plugins.lsp.servers.yamlls.autostart

Controls if the FileType autocommand that launches a language server is created. If false, allows for deferring language servers until manually launched with :LspStart (|lspconfig-commands|).

Type: null or boolean or raw lua code

Default: null

Plugin default: true

Declared by:

plugins.lsp.servers.yamlls.cmd

A list where each entry corresponds to the blankspace delimited part of the command that launches the server.

The first entry is the binary used to run the language server. Additional entries are passed as arguments.

Type: null or (list of string)

Default: null when package is null, otherwise null

Declared by:

plugins.lsp.servers.yamlls.extraOptions

Extra options for the yamlls language server.

Type: attribute set of anything

Default: { }

Declared by:

plugins.lsp.servers.yamlls.filetypes

Set of filetypes for which to attempt to resolve {root_dir}. May be empty, or server may specify a default value.

Type: null or (list of string)

Default: null

Declared by:

plugins.lsp.servers.yamlls.rootMarkers

A list of files that mark the root of the project/workspace.

Vim’s LSP will try to share the same language server instance for all buffers matching filetypes within the same project.

A new server instance is only spawned when opening a buffer with a different project root.

See :h lsp-config and :h vim.fs.root().

Type: null or (list of (string or raw lua code)) or raw lua code

Default: null

Plugin default: null

Declared by:

plugins.lsp.servers.yamlls.settings

The settings for this LSP.

Type: attribute set of anything

Default: { }

Example:

{
  callback = {
    __raw = ''
      function()
        print('nixvim')
      end
    '';
  };
  foo_bar = 42;
  hostname = "localhost:8080";
}

Declared by: