nvim: Update schema-companion and kubernetes matcher

This commit is contained in:
2025-09-12 02:08:50 +02:00
parent 54b1090984
commit e4d4be54c6
7 changed files with 101 additions and 54 deletions

View File

@@ -1,33 +1,6 @@
-- https://github.com/cenk1cenk2/schema-companion.nvim
--- @module "schema-companion"
--- @type schema_companion.Matcher
local kubernetes = {
name = "Kubernetes",
match = function(bufnr)
local lines = vim.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 {
name = "Kubernetes",
uri = require("kubernetes").yamlls_schema(),
}
end
end
return nil
end,
}
--- @module "lazy"
--- @type LazySpec
@@ -35,14 +8,13 @@ return {
"cenk1cenk2/schema-companion.nvim",
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-telescope/telescope.nvim",
"diogo464/kubernetes.nvim",
},
keys = {
{
"<leader>ys",
function()
require("telescope").extensions.schema_companion.select_schema()
require("schema-companion").select_schema()
end,
desc = "Yaml schema",
ft = "yaml",
@@ -50,11 +22,5 @@ return {
},
--- @module "schema-companion"
--- @type schema_companion.Config
opts = {
enable_telescope = true,
matchers = {
kubernetes,
},
schemas = {},
},
opts = {},
}