Improved yaml behaviour in combination with kubernetes
This commit is contained in:
7
nvim/dot-config/nvim/lua/plugins/kubernetes.lua
Normal file
7
nvim/dot-config/nvim/lua/plugins/kubernetes.lua
Normal file
@@ -0,0 +1,7 @@
|
||||
return {
|
||||
"diogo464/kubernetes.nvim",
|
||||
opts = {
|
||||
schema_strict = true,
|
||||
schema_generate_always = false,
|
||||
},
|
||||
}
|
||||
@@ -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 = {
|
||||
|
||||
11
nvim/dot-config/nvim/lua/plugins/yaml-companion.lua
Normal file
11
nvim/dot-config/nvim/lua/plugins/yaml-companion.lua
Normal 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,
|
||||
}
|
||||
@@ -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 = {
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user