Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(health): use non-deprecated functions if available #48

Merged
merged 1 commit into from
Sep 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions lua/conform/health.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
local M = {}

-- The "report_" functions have been deprecated, so use the new ones if defined.
local health_start = vim.health.start or vim.health.report_start
local health_warn = vim.health.warn or vim.health.report_warn
local health_info = vim.health.info or vim.health.report_info
local health_ok = vim.health.ok or vim.health.report_ok

---@param name string
---@return string[]
local function get_formatter_filetypes(name)
Expand Down Expand Up @@ -31,22 +37,18 @@ end

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

local log = require("conform.log")
vim.health.info(string.format("Log file: %s", log.get_logfile()))
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)
)
health_warn(string.format("%s unavailable: %s", formatter.name, formatter.available_msg))
else
local filetypes = get_formatter_filetypes(formatter.name)
vim.health.report_ok(
string.format("%s ready (%s)", formatter.name, table.concat(filetypes, ", "))
)
health_ok(string.format("%s ready (%s)", formatter.name, table.concat(filetypes, ", ")))
end
end
end
Expand Down