]> git.rmz.io Git - dotfiles.git/blob - nvim/lua/plugins/lang/yaml.lua
lazyvim: absorb all langs
[dotfiles.git] / nvim / lua / plugins / lang / yaml.lua
1 return {
2 -- yaml schema support
3 {
4 "b0o/SchemaStore.nvim",
5 lazy = true,
6 version = false, -- last release is way too old
7 },
8
9 -- correctly setup lspconfig
10 {
11 "neovim/nvim-lspconfig",
12 opts = {
13 -- make sure mason installs the server
14 servers = {
15 yamlls = {
16 -- Have to add this for yamlls to understand that we support line folding
17 capabilities = {
18 textDocument = {
19 foldingRange = {
20 dynamicRegistration = false,
21 lineFoldingOnly = true,
22 },
23 },
24 },
25 -- lazy-load schemastore when needed
26 on_new_config = function(new_config)
27 new_config.settings.yaml.schemas = vim.tbl_deep_extend(
28 "force",
29 new_config.settings.yaml.schemas or {},
30 require("schemastore").yaml.schemas()
31 )
32 end,
33 settings = {
34 redhat = { telemetry = { enabled = false } },
35 yaml = {
36 keyOrdering = false,
37 format = {
38 enable = true,
39 },
40 validate = true,
41 schemaStore = {
42 -- Must disable built-in schemaStore support to use
43 -- schemas from SchemaStore.nvim plugin
44 enable = false,
45 -- Avoid TypeError: Cannot read properties of undefined (reading 'length')
46 url = "",
47 },
48 },
49 },
50 },
51 },
52 setup = {
53 yamlls = function()
54 -- Neovim < 0.10 does not have dynamic registration for formatting
55 if vim.fn.has("nvim-0.10") == 0 then
56 rmz.lsp.on_attach(function(client, _)
57 client.server_capabilities.documentFormattingProvider = true
58 end, "yamlls")
59 end
60 end,
61 },
62 },
63 },
64 }