Switch from yaml-companion to schema-companion
This commit is contained in:
parent
7d71427f28
commit
3f9ec6a29f
|
@ -33,6 +33,7 @@
|
||||||
"peek.nvim": { "branch": "master", "commit": "5820d937d5414baea5f586dc2a3d912a74636e5b" },
|
"peek.nvim": { "branch": "master", "commit": "5820d937d5414baea5f586dc2a3d912a74636e5b" },
|
||||||
"plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" },
|
"plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" },
|
||||||
"ros-nvim": { "branch": "main", "commit": "f0e16eebe68546025784593fa2355ca6749014a0" },
|
"ros-nvim": { "branch": "main", "commit": "f0e16eebe68546025784593fa2355ca6749014a0" },
|
||||||
|
"schema-companion.nvim": { "branch": "main", "commit": "7d662b6c1497fdd82e3e8836eb122f5c4b0d8277" },
|
||||||
"schemastore.nvim": { "branch": "main", "commit": "0098dde21296a454ae1426f9ac47340dd38c27ce" },
|
"schemastore.nvim": { "branch": "main", "commit": "0098dde21296a454ae1426f9ac47340dd38c27ce" },
|
||||||
"smart-splits.nvim": { "branch": "master", "commit": "5ef94ca23b28148187846fc46f10184aad4d17b0" },
|
"smart-splits.nvim": { "branch": "master", "commit": "5ef94ca23b28148187846fc46f10184aad4d17b0" },
|
||||||
"telescope-fzf-native.nvim": { "branch": "main", "commit": "1f08ed60cafc8f6168b72b80be2b2ea149813e55" },
|
"telescope-fzf-native.nvim": { "branch": "main", "commit": "1f08ed60cafc8f6168b72b80be2b2ea149813e55" },
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
-- https://github.com/nvim-lualine/lualine.nvim
|
-- https://github.com/nvim-lualine/lualine.nvim
|
||||||
|
|
||||||
local function get_schema()
|
local function get_schema()
|
||||||
local schema = require("yaml-companion").get_buf_schema(0)
|
local schema = require("schema-companion.context").get_buffer_schema()
|
||||||
if schema.result[1].name == "none" then
|
if schema.name == "none" then
|
||||||
return ""
|
return ""
|
||||||
end
|
end
|
||||||
return schema.result[1].name
|
return schema.name
|
||||||
end
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
63
nvim/dot-config/nvim/lua/plugins/schema-companion.lua
Normal file
63
nvim/dot-config/nvim/lua/plugins/schema-companion.lua
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
local kubernetes = {}
|
||||||
|
kubernetes.name = "Kubernetes"
|
||||||
|
|
||||||
|
---@type schema_companion.MatcherMatchFn
|
||||||
|
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
|
||||||
|
|
||||||
|
return {
|
||||||
|
"cenk1cenk2/schema-companion.nvim",
|
||||||
|
dependencies = {
|
||||||
|
"nvim-lua/plenary.nvim",
|
||||||
|
"nvim-telescope/telescope.nvim",
|
||||||
|
"diogo464/kubernetes.nvim",
|
||||||
|
},
|
||||||
|
config = function()
|
||||||
|
require("schema-companion").setup({
|
||||||
|
enable_telescope = true,
|
||||||
|
matchers = {
|
||||||
|
kubernetes,
|
||||||
|
},
|
||||||
|
schemas = {},
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.keymap.set(
|
||||||
|
"n",
|
||||||
|
"<leader>ss",
|
||||||
|
require("telescope").extensions.schema_companion.select_schema,
|
||||||
|
{ desc = "Select schema" }
|
||||||
|
)
|
||||||
|
|
||||||
|
vim.lsp.config(
|
||||||
|
"yamlls",
|
||||||
|
require("schema-companion").setup_client({
|
||||||
|
single_file_support = true,
|
||||||
|
settings = {
|
||||||
|
yaml = {},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
)
|
||||||
|
end,
|
||||||
|
}
|
|
@ -1,19 +0,0 @@
|
||||||
return {
|
|
||||||
"someone-stole-my-name/yaml-companion.nvim",
|
|
||||||
dependencies = {
|
|
||||||
"nvim-lua/plenary.nvim",
|
|
||||||
"nvim-telescope/telescope.nvim",
|
|
||||||
"nvim-telescope/telescope.nvim",
|
|
||||||
"diogo464/kubernetes.nvim",
|
|
||||||
},
|
|
||||||
config = function()
|
|
||||||
require("telescope").load_extension("yaml_schema")
|
|
||||||
|
|
||||||
vim.lsp.config("yamlls", require("yaml-companion").setup({
|
|
||||||
builtin_matchers = {
|
|
||||||
kubernetes = { enabled = false },
|
|
||||||
kubernetes_custom = { enabled = true },
|
|
||||||
},
|
|
||||||
}))
|
|
||||||
end,
|
|
||||||
}
|
|
|
@ -1,35 +0,0 @@
|
||||||
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