[neovim] Fix yaml-companion

This commit is contained in:
Daniel Carrillo 2023-11-03 18:48:15 +01:00
parent d5c9273e44
commit fb9748c38d
Signed by: dcarrillo
GPG Key ID: E4CD5C09DAED6E16
4 changed files with 47 additions and 42 deletions

View File

@ -179,7 +179,6 @@ require("lazy").setup({
{ "folke/trouble.nvim", cmd = { "TroubleToggle", "Trouble" } }, { "folke/trouble.nvim", cmd = { "TroubleToggle", "Trouble" } },
{ "glepnir/lspsaga.nvim", event = "BufRead" }, { "glepnir/lspsaga.nvim", event = "BufRead" },
{ "arkav/lualine-lsp-progress" }, { "arkav/lualine-lsp-progress" },
{ "someone-stole-my-name/yaml-companion.nvim", event = "BufRead" },
-- Telescope -- Telescope
{ "nvim-telescope/telescope.nvim", cmd = "Telescope" }, { "nvim-telescope/telescope.nvim", cmd = "Telescope" },
@ -191,6 +190,32 @@ require("lazy").setup({
{ "sindrets/diffview.nvim" }, { "sindrets/diffview.nvim" },
{ "f-person/git-blame.nvim" }, { "f-person/git-blame.nvim" },
-- YAML
{
"someone-stole-my-name/yaml-companion.nvim",
ft = { "yaml" },
opts = {
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,
},
-- DAP -- DAP
{ "mfussenegger/nvim-dap", event = "VeryLazy", version = "0.*" }, { "mfussenegger/nvim-dap", event = "VeryLazy", version = "0.*" },
{ "rcarriga/nvim-dap-ui", event = "VeryLazy", version = "v3.*" }, { "rcarriga/nvim-dap-ui", event = "VeryLazy", version = "v3.*" },
@ -208,6 +233,9 @@ require("lazy").setup({
ft = { "go", "gomod" }, ft = { "go", "gomod" },
}, },
-- Typescript
{ "pmizio/typescript-tools.nvim", opts = {} },
-- Markdown -- Markdown
{ "mzlogin/vim-markdown-toc" }, { "mzlogin/vim-markdown-toc" },
{ {

View File

@ -33,18 +33,20 @@ require("mason-lspconfig").setup({
local lspconfig = require("lspconfig") local lspconfig = require("lspconfig")
for _, server in pairs(servers) do for _, server in pairs(servers) do
local opts = { if server ~= "yamlls" then
on_attach = require("plugins.lsp.handlers").on_attach, local opts = {
capabilities = require("plugins.lsp.handlers").capabilities, on_attach = require("plugins.lsp.handlers").on_attach,
} capabilities = require("plugins.lsp.handlers").capabilities,
}
server = vim.split(server, "@")[1] server = vim.split(server, "@")[1]
-- https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md -- https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
local config_exists, conf_opts = pcall(require, "plugins.lsp.settings." .. server) local config_exists, conf_opts = pcall(require, "plugins.lsp.settings." .. server)
if config_exists then if config_exists then
opts = vim.tbl_deep_extend("force", conf_opts, opts) opts = vim.tbl_deep_extend("force", conf_opts, opts)
end
lspconfig[server].setup(opts)
end end
lspconfig[server].setup(opts)
end end

View File

@ -1,18 +0,0 @@
local cfg = require("yaml-companion").setup({
lspconfig = {
settings = {
redhat = {
telemetry = {
enabled = false,
},
},
-- yaml = {
-- schemas = {
-- ["https://custom/github-workflow.json"] = "/.github/workflows/*",
-- },
-- },
},
},
})
return cfg

View File

@ -18,12 +18,6 @@ local diff = {
cond = hide_in_width, cond = hide_in_width,
} }
local filetype = {
"filetype",
colored = false,
separator = "",
}
local lsp_progress = { local lsp_progress = {
"lsp_progress", "lsp_progress",
display_components = { "spinner" }, display_components = { "spinner" },
@ -50,18 +44,18 @@ local venv = function()
return "" return ""
end end
local get_schema = function() 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("yaml-companion").get_buf_schema(0)
if schema.result[1].name == "none" then if schema.result[1].name == "none" then
return "" return ft
end end
return "(" .. schema.result[1].name .. ")" return ft .. " (" .. schema.result[1].name .. ")"
else else
return "" return ft
end end
end end
@ -111,8 +105,7 @@ require("lualine").setup({
diff, diff,
spaces, spaces,
"encoding", "encoding",
filetype, { get_filetype, separator = "" },
{ get_schema, separator = "" },
}, },
lualine_y = { "progress" }, lualine_y = { "progress" },
lualine_z = { "location" }, lualine_z = { "location" },