From fb9748c38d393c81c4e453428e86e3d86f848b53 Mon Sep 17 00:00:00 2001 From: Daniel Carrillo Date: Fri, 3 Nov 2023 18:48:15 +0100 Subject: [PATCH] [neovim] Fix yaml-companion --- .config/nvim/lua/core/plugins.lua | 30 ++++++++++++++++++- .config/nvim/lua/plugins/lsp/mason.lua | 24 ++++++++------- .../nvim/lua/plugins/lsp/settings/yamlls.lua | 18 ----------- .config/nvim/lua/plugins/lualine.lua | 17 ++++------- 4 files changed, 47 insertions(+), 42 deletions(-) delete mode 100644 .config/nvim/lua/plugins/lsp/settings/yamlls.lua diff --git a/.config/nvim/lua/core/plugins.lua b/.config/nvim/lua/core/plugins.lua index 817856f..2aef829 100644 --- a/.config/nvim/lua/core/plugins.lua +++ b/.config/nvim/lua/core/plugins.lua @@ -179,7 +179,6 @@ require("lazy").setup({ { "folke/trouble.nvim", cmd = { "TroubleToggle", "Trouble" } }, { "glepnir/lspsaga.nvim", event = "BufRead" }, { "arkav/lualine-lsp-progress" }, - { "someone-stole-my-name/yaml-companion.nvim", event = "BufRead" }, -- Telescope { "nvim-telescope/telescope.nvim", cmd = "Telescope" }, @@ -191,6 +190,32 @@ require("lazy").setup({ { "sindrets/diffview.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 { "mfussenegger/nvim-dap", event = "VeryLazy", version = "0.*" }, { "rcarriga/nvim-dap-ui", event = "VeryLazy", version = "v3.*" }, @@ -208,6 +233,9 @@ require("lazy").setup({ ft = { "go", "gomod" }, }, + -- Typescript + { "pmizio/typescript-tools.nvim", opts = {} }, + -- Markdown { "mzlogin/vim-markdown-toc" }, { diff --git a/.config/nvim/lua/plugins/lsp/mason.lua b/.config/nvim/lua/plugins/lsp/mason.lua index 546252a..01ebc8e 100644 --- a/.config/nvim/lua/plugins/lsp/mason.lua +++ b/.config/nvim/lua/plugins/lsp/mason.lua @@ -33,18 +33,20 @@ require("mason-lspconfig").setup({ local lspconfig = require("lspconfig") for _, server in pairs(servers) do - local opts = { - on_attach = require("plugins.lsp.handlers").on_attach, - capabilities = require("plugins.lsp.handlers").capabilities, - } + if server ~= "yamlls" then + local opts = { + 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 - local config_exists, conf_opts = pcall(require, "plugins.lsp.settings." .. server) - if config_exists then - opts = vim.tbl_deep_extend("force", conf_opts, opts) + -- https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md + local config_exists, conf_opts = pcall(require, "plugins.lsp.settings." .. server) + if config_exists then + opts = vim.tbl_deep_extend("force", conf_opts, opts) + end + + lspconfig[server].setup(opts) end - - lspconfig[server].setup(opts) end diff --git a/.config/nvim/lua/plugins/lsp/settings/yamlls.lua b/.config/nvim/lua/plugins/lsp/settings/yamlls.lua deleted file mode 100644 index 07259af..0000000 --- a/.config/nvim/lua/plugins/lsp/settings/yamlls.lua +++ /dev/null @@ -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 diff --git a/.config/nvim/lua/plugins/lualine.lua b/.config/nvim/lua/plugins/lualine.lua index 2771577..b248bf4 100644 --- a/.config/nvim/lua/plugins/lualine.lua +++ b/.config/nvim/lua/plugins/lualine.lua @@ -18,12 +18,6 @@ local diff = { cond = hide_in_width, } -local filetype = { - "filetype", - colored = false, - separator = "", -} - local lsp_progress = { "lsp_progress", display_components = { "spinner" }, @@ -50,18 +44,18 @@ local venv = function() return "" end -local get_schema = function() +local get_filetype = function() local ft = vim.bo.filetype or "" if ft == "yaml" then local schema = require("yaml-companion").get_buf_schema(0) if schema.result[1].name == "none" then - return "" + return ft end - return "(" .. schema.result[1].name .. ")" + return ft .. " (" .. schema.result[1].name .. ")" else - return "" + return ft end end @@ -111,8 +105,7 @@ require("lualine").setup({ diff, spaces, "encoding", - filetype, - { get_schema, separator = "" }, + { get_filetype, separator = "" }, }, lualine_y = { "progress" }, lualine_z = { "location" },