mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-07 12:18:10 +00:00
fix(health): better health checks for picker. Closes #917
This commit is contained in:
parent
c494ddc57a
commit
427f036c65
2 changed files with 10 additions and 6 deletions
|
@ -14,7 +14,7 @@ local M = setmetatable({}, {
|
|||
|
||||
---@class snacks.health.Tool
|
||||
---@field cmd string|string[]
|
||||
---@field version? string
|
||||
---@field version? string|false
|
||||
---@field enabled? boolean
|
||||
|
||||
---@alias snacks.health.Tool.spec (string|snacks.health.Tool)[]|snacks.health.Tool|string
|
||||
|
@ -91,10 +91,13 @@ function M.have_tool(tools)
|
|||
vim.list_extend(all, cmds)
|
||||
for _, cmd in ipairs(cmds) do
|
||||
if vim.fn.executable(cmd) == 1 then
|
||||
local version = vim.fn.system(cmd .. " --version") or ""
|
||||
local version = tool.version == false and "" or vim.fn.system(cmd .. " --version") or ""
|
||||
version = vim.trim(vim.split(version, "\n")[1])
|
||||
if tool_version and tool_version > vim.version.parse(version) then
|
||||
M.error("'" .. cmd .. "' `" .. version .. "` is too old, expected `" .. tool.version .. "`")
|
||||
elseif tool.version == false then
|
||||
M.ok("'" .. cmd .. "'")
|
||||
version_ok = true
|
||||
else
|
||||
M.ok("'" .. cmd .. "' `" .. version .. "`")
|
||||
version_ok = true
|
||||
|
|
|
@ -27,9 +27,10 @@ function M.health()
|
|||
local have_fd, version_fd = Snacks.health.have_tool({
|
||||
{ cmd = { "fd", "fdfind" }, version = "v8.4" },
|
||||
})
|
||||
local have_find = Snacks.health.have_tool({
|
||||
{ cmd = "find", enabled = jit.os:find("Windows") == nil },
|
||||
})
|
||||
local have_find = have_fd
|
||||
or (jit.os:find("Windows") == nil and Snacks.health.have_tool({
|
||||
{ cmd = "find", version = false },
|
||||
}))
|
||||
if have_rg or have_fd or have_find then
|
||||
Snacks.health.ok("`Snacks.picker.files()` is available")
|
||||
else
|
||||
|
@ -37,7 +38,7 @@ function M.health()
|
|||
end
|
||||
|
||||
if not have_fd or not version_fd then
|
||||
Snacks.health.error("'fd' `v8.4` is required for `Snacks.picker.explorer()`")
|
||||
Snacks.health.error("'fd' `v8.4` is required for searching with `Snacks.picker.explorer()`")
|
||||
else
|
||||
Snacks.health.ok("`Snacks.picker.explorer()` is available")
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue