From c39111af2544fb283d47f3d148adf7d372118339 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Do=C4=9Fa=C3=A7=20Eldenk?= Date: Mon, 1 Apr 2024 10:43:38 -0500 Subject: [PATCH] fix: add yaml companion to yaml setup --- lua/lazyvim/plugins/extras/lang/yaml.lua | 37 ++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/lua/lazyvim/plugins/extras/lang/yaml.lua b/lua/lazyvim/plugins/extras/lang/yaml.lua index 9fd88a3b..53d42b3e 100644 --- a/lua/lazyvim/plugins/extras/lang/yaml.lua +++ b/lua/lazyvim/plugins/extras/lang/yaml.lua @@ -74,4 +74,41 @@ return { }, }, }, + + -- support auto-detecting and selecting yaml schemas. + -- use ":Telescope yaml_schema" to change current schema. + { + "someone-stole-my-name/yaml-companion.nvim", + ft = { "yaml" }, + dependencies = { + { "neovim/nvim-lspconfig" }, + { "nvim-lua/plenary.nvim" }, + { "nvim-telescope/telescope.nvim" }, + }, + config = function(_, opts) + local cfg = require("yaml-companion").setup(opts) + require("lspconfig")["yamlls"].setup(cfg) + require("telescope").load_extension("yaml_schema") + end, + }, + + -- Show currently used yaml-schema on lualine status bar + { + "nvim-lualine/lualine.nvim", + event = "VeryLazy", + opts = function(_, opts) + opts.sections.lualine_z = { + { + function() + local schema = require("yaml-companion").get_buf_schema(0) + if schema.result[1].name == "none" then + return "" + end + return schema.result[1].name + end, + }, + opts.sections.lualine_z, + } + end, + }, }