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): remove deprecated api warnings in health check #2478

Merged
merged 2 commits into from
Apr 23, 2023
Merged
Changes from 1 commit
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
Next Next commit
fix(health): remove deprecated api warnings in health check
  • Loading branch information
escwxyz authored Apr 23, 2023
commit d230120f52c02d4d6c27e73563f80b23510411fd
27 changes: 16 additions & 11 deletions lua/telescope/health.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
local health = vim.health or require "health"
local start = health.start or health.report_start
local ok = health.ok or health.report_ok
local warn = health.warn or health.report_warn
local error = health.error or health.report_error

local extension_module = require "telescope._extensions"
local extension_info = require("telescope").extensions
local is_win = vim.api.nvim_call_function("has", { "win32" }) == 1
Expand Down Expand Up @@ -60,33 +65,33 @@ local M = {}

M.check = function()
-- Required lua libs
health.report_start "Checking for required plugins"
start "Checking for required plugins"
for _, plugin in ipairs(required_plugins) do
if lualib_installed(plugin.lib) then
health.report_ok(plugin.lib .. " installed.")
ok(plugin.lib .. " installed.")
else
local lib_not_installed = plugin.lib .. " not found."
if plugin.optional then
health.report_warn(("%s %s"):format(lib_not_installed, plugin.info))
warn(("%s %s"):format(lib_not_installed, plugin.info))
else
health.report_error(lib_not_installed)
error(lib_not_installed)
end
end
end

-- external dependencies
-- TODO: only perform checks if user has enabled dependency in their config
health.report_start "Checking external dependencies"
start "Checking external dependencies"

for _, opt_dep in pairs(optional_dependencies) do
for _, package in ipairs(opt_dep.package) do
local installed, version = check_binary_installed(package)
if not installed then
local err_msg = ("%s: not found."):format(package.name)
if package.optional then
health.report_warn(("%s %s"):format(err_msg, ("Install %s for extended capabilities"):format(package.url)))
warn(("%s %s"):format(err_msg, ("Install %s for extended capabilities"):format(package.url)))
else
health.report_error(
error(
("%s %s"):format(
err_msg,
("`%s` finder will not function without %s installed."):format(opt_dep.finder_name, package.url)
Expand All @@ -95,13 +100,13 @@ M.check = function()
end
else
local eol = version:find "\n"
health.report_ok(("%s: found %s"):format(package.name, version:sub(0, eol - 1) or "(unknown version)"))
ok(("%s: found %s"):format(package.name, version:sub(0, eol - 1) or "(unknown version)"))
end
end
end

-- Extensions
health.report_start "===== Installed extensions ====="
start "===== Installed extensions ====="

local installed = {}
for extension_name, _ in pairs(extension_info) do
Expand All @@ -112,11 +117,11 @@ M.check = function()
for _, installed_ext in ipairs(installed) do
local extension_healthcheck = extension_module._health[installed_ext]

health.report_start(string.format("Telescope Extension: `%s`", installed_ext))
start(string.format("Telescope Extension: `%s`", installed_ext))
if extension_healthcheck then
extension_healthcheck()
else
health.report_info "No healthcheck provided"
info "No healthcheck provided"
end
end
end
Expand Down