Improved yaml behaviour in combination with kubernetes
This commit is contained in:
parent
c8377cdcf3
commit
1df19a07cf
|
@ -15,6 +15,7 @@
|
|||
"guess-indent.nvim": { "branch": "main", "commit": "6cd61f7a600bb756e558627cd2e740302c58e32d" },
|
||||
"inc-rename.nvim": { "branch": "main", "commit": "f9b9e5b9a75074810f40881b7e254b5bbeaf122e" },
|
||||
"indent-blankline.nvim": { "branch": "master", "commit": "e10626f7fcd51ccd56d7ffc00883ba7e0aa28f78" },
|
||||
"kubernetes.nvim": { "branch": "main", "commit": "1a08abc6c0694f0d1f5d6725bfa7a88daf0f7246" },
|
||||
"lazy.nvim": { "branch": "main", "commit": "d8f26efd456190241afd1b0f5235fe6fdba13d4a" },
|
||||
"lazydev.nvim": { "branch": "main", "commit": "a1b78b2ac6f978c72e76ea90ae92a94edf380cfc" },
|
||||
"lsp_signature.nvim": { "branch": "master", "commit": "5b64964ed02098c85613ee3d20f96bed1dfb64cc" },
|
||||
|
@ -50,5 +51,6 @@
|
|||
"todo-comments.nvim": { "branch": "main", "commit": "f8bd47e4bc15e3aa7c784b12e68b6dd6e97caea2" },
|
||||
"trouble.nvim": { "branch": "main", "commit": "50481f414bd3c1a40122c1d759d7e424d5fafe84" },
|
||||
"undotree": { "branch": "master", "commit": "2556c6800b210b2096b55b66e74b4cc1d9ebbe4f" },
|
||||
"which-key.nvim": { "branch": "main", "commit": "6cebd86917df559a88de0f806b2989799c6e6423" }
|
||||
"which-key.nvim": { "branch": "main", "commit": "6cebd86917df559a88de0f806b2989799c6e6423" },
|
||||
"yaml-companion.nvim": { "branch": "main", "commit": "131b0d67bd2e0f1a02e0daf2f3460482221ce3c0" }
|
||||
}
|
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
|
Loading…
Reference in New Issue
Block a user