summaryrefslogtreecommitdiffstats
path: root/lua/conform/health.lua
blob: 76309be30ed662b0e16ea12a9011ff602f9f8aec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
local M = {}

M.check = function()
  local conform = require("conform")
  vim.health.report_start("conform.nvim report")

  local log = require("conform.log")
  vim.health.info(string.format("Log file: %s", log.get_logfile()))

  local all_formatters = conform.list_all_formatters()
  for _, formatter in ipairs(all_formatters) do
    if not formatter.available then
      vim.health.report_warn(
        string.format("%s unavailable: %s", formatter.name, formatter.available_msg)
      )
    else
      local filetypes = {}
      for filetype, formatters in pairs(conform.formatters_by_ft) do
        if not vim.tbl_islist(formatters) then
          formatters = formatters.formatters
        end
        if vim.tbl_contains(formatters, formatter.name) then
          table.insert(filetypes, filetype)
        end
      end

      vim.health.report_ok(
        string.format("%s ready (%s)", formatter.name, table.concat(filetypes, ", "))
      )
    end
  end
end

return M