vim.api.nvim_create_autocmd("LspAttach", {
	callback = function(ev)
		-- vim.notify("hello LspAttach")
		vim.lsp.handlers["window/showMessage"] = function(_, result, ctx)
			local client = vim.lsp.get_client_by_id(ctx.client_id)
			local lvl = ({
				"ERROR",
				"WARN",
				"INFO",
				"DEBUG",
			})[result.type]

			vim.notify(
				string.format("[%s] %s", client.name, result.message),
				lvl and vim.log.levels[lvl] or vim.log.levels.INFO
			)
		end
	end,
})

return {
	{
		"neovim/nvim-lspconfig",
		opts = {
			servers = {
				lsp_helm_values = {
					cmd = {
						"lsp-helm-values",
					},
				},
			},
			setup = {
				lsp_helm_values = function(_, opts)
					local lspconfig = require("lspconfig")
					local configs = require("lspconfig.configs")
					if not configs.lsp_helm_values then
						configs.lsp_helm_values = {
							default_config = {
								cmd = { "lsp-helm-values" },
								filetypes = { "yaml" },
								single_file_support = true,
								root_dir = vim.fs.dirname(vim.fs.find(".git", { path = ".", upward = true })[1]),
							},
						}
					end
					lspconfig.lsp_helm_values.setup(opts)
				end,
			},
		},
	},
}
