local M = {} ---@return boolean local function check_mason() local ok, mason_version = pcall(require, "mason.version") if not ok then vim.health.error("mason.nvim was not found. Is it installed and loaded?") return false end if mason_version.MAJOR_VERSION ~= 2 then vim.health.error(("mason.nvim v2 is required (found v%d)."):format(mason_version.MAJOR_VERSION)) return false end vim.health.ok("mason.nvim v2") return true end function M.check() vim.health.start("mason-conform.nvim") if vim.fn.has("nvim-0.11") == 1 then vim.health.ok("Neovim v0.11+") else vim.health.error("Neovim v0.11 or higher is required.") end local mason_installed = check_mason() if mason_installed then local registry_ok = pcall(require, "mason-registry") if registry_ok then vim.health.ok("mason registry is accessible") else vim.health.error("mason-registry could not be loaded.") end end local conform_ok = pcall(require, "conform") if not conform_ok then vim.health.error("conform.nvim was not found. Is it installed and loaded?") return end vim.health.ok("conform.nvim") local formatters = require("mason-conform.formatters").configured() if #formatters == 0 then vim.health.warn("No formatters are configured in conform's formatters_by_ft, so there is nothing to install.") return end vim.health.ok(("%d formatter(s) configured in formatters_by_ft"):format(#formatters)) local mapping = require("mason-conform.mapping") local unmapped = {} for _, name in ipairs(formatters) do if mapping.conform_to_package[name] == nil then unmapped[#unmapped + 1] = name end end if #unmapped > 0 then vim.health.info( ("No mason package mapping for: %s. These will not be installed automatically."):format( table.concat(unmapped, ", ") ) ) end local ignored = {} for _, name in ipairs(require("mason-conform").config.ignore_install) do ignored[#ignored + 1] = name end if #ignored > 0 then vim.health.info(("Ignored by 'ignore_install': %s"):format(table.concat(ignored, ", "))) end end return M