78 lines
2.2 KiB
Lua
78 lines
2.2 KiB
Lua
return {
|
|
|
|
-- add yaml specific modules to treesitter
|
|
{
|
|
"nvim-treesitter/nvim-treesitter",
|
|
opts = function(_, opts)
|
|
if type(opts.ensure_installed) == "table" then
|
|
vim.list_extend(opts.ensure_installed, { "yaml" })
|
|
end
|
|
end,
|
|
},
|
|
|
|
-- yaml schema support
|
|
{
|
|
"b0o/SchemaStore.nvim",
|
|
lazy = true,
|
|
version = false, -- last release is way too old
|
|
},
|
|
|
|
-- correctly setup lspconfig
|
|
{
|
|
"neovim/nvim-lspconfig",
|
|
opts = {
|
|
-- make sure mason installs the server
|
|
servers = {
|
|
yamlls = {
|
|
-- Have to add this for yamlls to understand that we support line folding
|
|
capabilities = {
|
|
textDocument = {
|
|
foldingRange = {
|
|
dynamicRegistration = false,
|
|
lineFoldingOnly = true,
|
|
},
|
|
},
|
|
},
|
|
-- lazy-load schemastore when needed
|
|
on_new_config = function(new_config)
|
|
new_config.settings.yaml.schemas = vim.tbl_deep_extend(
|
|
"force",
|
|
new_config.settings.yaml.schemas or {},
|
|
require("schemastore").yaml.schemas()
|
|
)
|
|
end,
|
|
settings = {
|
|
redhat = { telemetry = { enabled = false } },
|
|
yaml = {
|
|
keyOrdering = false,
|
|
format = {
|
|
enable = true,
|
|
},
|
|
validate = true,
|
|
schemaStore = {
|
|
-- Must disable built-in schemaStore support to use
|
|
-- schemas from SchemaStore.nvim plugin
|
|
enable = false,
|
|
-- Avoid TypeError: Cannot read properties of undefined (reading 'length')
|
|
url = "",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
setup = {
|
|
yamlls = function()
|
|
-- Neovim < 0.10 does not have dynamic registration for formatting
|
|
if vim.fn.has("nvim-0.10") == 0 then
|
|
require("lazyvim.util").lsp.on_attach(function(client, _)
|
|
if client.name == "yamlls" then
|
|
client.server_capabilities.documentFormattingProvider = true
|
|
end
|
|
end)
|
|
end
|
|
end,
|
|
},
|
|
},
|
|
},
|
|
}
|