mirror of
https://github.com/dcarrillo/dotfiles.git
synced 2025-09-19 22:39:08 +00:00
[neovim] Replace yaml-companion with schemastore.nvim
This commit is contained in:
@@ -13,3 +13,7 @@ end, {})
|
|||||||
vim.api.nvim_create_user_command("RemoveTrailingSpaces", function()
|
vim.api.nvim_create_user_command("RemoveTrailingSpaces", function()
|
||||||
vim.cmd("% s/\\s\\+$//e")
|
vim.cmd("% s/\\s\\+$//e")
|
||||||
end, {})
|
end, {})
|
||||||
|
|
||||||
|
vim.api.nvim_create_user_command("SetSchema", function()
|
||||||
|
require("schema-companion").select_schema()
|
||||||
|
end, {})
|
||||||
|
@@ -178,27 +178,9 @@ require("lazy").setup({
|
|||||||
|
|
||||||
-- YAML
|
-- YAML
|
||||||
{
|
{
|
||||||
"someone-stole-my-name/yaml-companion.nvim",
|
"cenk1cenk2/schema-companion.nvim",
|
||||||
ft = { "yaml" },
|
config = function()
|
||||||
opts = {
|
require("schema-companion").setup({})
|
||||||
lspconfig = {
|
|
||||||
settings = {
|
|
||||||
redhat = {
|
|
||||||
telemetry = {
|
|
||||||
enabled = false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
-- yaml = {
|
|
||||||
-- schemas = {
|
|
||||||
-- ["https://custom/github-workflow.json"] = "/.github/workflows/*",
|
|
||||||
-- },
|
|
||||||
-- },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
config = function(_, opts)
|
|
||||||
local cfg = require("yaml-companion").setup(opts)
|
|
||||||
require("lspconfig")["yamlls"].setup(cfg)
|
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@@ -22,9 +22,9 @@ require("blink.cmp").setup({
|
|||||||
window = { border = "single" },
|
window = { border = "single" },
|
||||||
},
|
},
|
||||||
menu = {
|
menu = {
|
||||||
-- don't show completion menu automatically when searching
|
|
||||||
auto_show = function(ctx)
|
auto_show = function(ctx)
|
||||||
return ctx.mode ~= "cmdline" or not vim.tbl_contains({ "/", "?" }, vim.fn.getcmdtype())
|
return vim.fn.getcmdtype() == ":"
|
||||||
end,
|
end,
|
||||||
|
|
||||||
border = "single",
|
border = "single",
|
||||||
|
@@ -34,9 +34,8 @@ require("mason-lspconfig").setup({
|
|||||||
automatic_installation = true,
|
automatic_installation = true,
|
||||||
})
|
})
|
||||||
|
|
||||||
local lspconfig = require("lspconfig")
|
|
||||||
for _, server in pairs(servers) do
|
for _, server in pairs(servers) do
|
||||||
if server ~= "yamlls" then
|
if server ~= "ty" then
|
||||||
local opts = {
|
local opts = {
|
||||||
capabilities = require("blink.cmp").get_lsp_capabilities(),
|
capabilities = require("blink.cmp").get_lsp_capabilities(),
|
||||||
}
|
}
|
||||||
@@ -49,6 +48,6 @@ for _, server in pairs(servers) do
|
|||||||
opts = vim.tbl_deep_extend("force", conf_opts, opts)
|
opts = vim.tbl_deep_extend("force", conf_opts, opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
lspconfig[server].setup(opts)
|
vim.lsp.config(server, opts)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
28
.config/nvim/lua/plugins/lsp/settings/yamlls.lua
Normal file
28
.config/nvim/lua/plugins/lsp/settings/yamlls.lua
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
return require("schema-companion").setup_client(
|
||||||
|
require("schema-companion").adapters.yamlls.setup({
|
||||||
|
sources = {
|
||||||
|
require("schema-companion").sources.matchers.kubernetes.setup({ version = "master" }),
|
||||||
|
require("schema-companion").sources.lsp.setup(),
|
||||||
|
require("schema-companion").sources.schemas.setup({
|
||||||
|
{
|
||||||
|
name = "Kubernetes master",
|
||||||
|
uri = "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/master-standalone-strict/all.json",
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
{
|
||||||
|
-- Have to add this for yamlls to understand that we support line folding
|
||||||
|
capabilities = {
|
||||||
|
textDocument = {
|
||||||
|
foldingRange = {
|
||||||
|
dynamicRegistration = false,
|
||||||
|
lineFoldingOnly = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
settings = {
|
||||||
|
redhat = { telemetry = { enabled = false } },
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
@@ -53,12 +53,12 @@ local get_filetype = function()
|
|||||||
local ft = vim.bo.filetype or ""
|
local ft = vim.bo.filetype or ""
|
||||||
|
|
||||||
if ft == "yaml" then
|
if ft == "yaml" then
|
||||||
local schema = require("yaml-companion").get_buf_schema(0)
|
local schema = require("schema-companion").get_current_schemas() or ""
|
||||||
if not schema or not schema.result or not schema.result[1].name then
|
if schema == "" then
|
||||||
return ft
|
return ft
|
||||||
end
|
end
|
||||||
|
|
||||||
return ft .. " (" .. schema.result[1].name .. ")"
|
return ft .. " (" .. schema:sub(0, 50) .. ")"
|
||||||
else
|
else
|
||||||
return ft
|
return ft
|
||||||
end
|
end
|
||||||
|
@@ -39,4 +39,3 @@ telescope.setup({
|
|||||||
|
|
||||||
telescope.load_extension("fzf")
|
telescope.load_extension("fzf")
|
||||||
telescope.load_extension("ui-select")
|
telescope.load_extension("ui-select")
|
||||||
telescope.load_extension("yaml_schema")
|
|
||||||
|
Reference in New Issue
Block a user