Improved yaml behaviour in combination with kubernetes

This commit is contained in:
2025-02-19 00:45:57 +01:00
parent c8377cdcf3
commit 1df19a07cf
6 changed files with 72 additions and 12 deletions

View File

@@ -0,0 +1,7 @@
return {
"diogo464/kubernetes.nvim",
opts = {
schema_strict = true,
schema_generate_always = false,
},
}

View File

@@ -1,4 +1,13 @@
-- https://github.com/nvim-lualine/lualine.nvim
local function get_schema()
local schema = require("yaml-companion").get_buf_schema(0)
if schema.result[1].name == "none" then
return ""
end
return schema.result[1].name
end
return {
"nvim-lualine/lualine.nvim",
opts = {
@@ -28,6 +37,7 @@ return {
"encoding",
{ "fileformat", icons_enabled = false },
"filetype",
get_schema,
},
},
inactive_sections = {

View File

@@ -0,0 +1,11 @@
return {
"someone-stole-my-name/yaml-companion.nvim",
dependencies = {
"neovim/nvim-lspconfig",
"nvim-lua/plenary.nvim",
"nvim-telescope/telescope.nvim",
},
config = function()
require("telescope").load_extension("yaml_schema")
end,
}

View File

@@ -34,17 +34,12 @@ tools.servers = function()
},
},
},
yamlls = {
settings = {
yaml = {
schemaStore = {
enable = false,
url = "",
},
schemas = require("schemastore").yaml.schemas(),
},
yamlls = require("yaml-companion").setup({
builtin_matchers = {
kubernetes = { enabled = false },
kubernetes_custom = { enabled = true },
},
},
}),
taplo = {},
neocmake = {},
nil_ls = {

View File

@@ -0,0 +1,35 @@
local M = {}
local api = vim.api
local uri = require("kubernetes").yamlls_schema()
local schema = {
name = "Kubernetes",
uri = uri,
}
M.match = function(bufnr)
local lines = api.nvim_buf_get_lines(bufnr, 0, -1, false)
local kind = false
local api_version = false
for _, line in ipairs(lines) do
if kind or vim.regex("^kind: .*$"):match_str(line) then
kind = true
end
if api_version or vim.regex("^apiVersion: .*$"):match_str(line) then
api_version = true
end
if kind and api_version then
return schema
end
end
end
M.handles = function()
return { schema }
end
return M