mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-04 10:49:08 +00:00
This commit is contained in:
parent
91a4e5fdb8
commit
b773368f8a
2 changed files with 24 additions and 11 deletions
|
@ -83,6 +83,7 @@ function M.have_tool(tools)
|
|||
|
||||
local all = {} ---@type string[]
|
||||
local found = false
|
||||
local version_ok = false
|
||||
for _, tool in ipairs(tools) do
|
||||
if tool.enabled ~= false then
|
||||
local tool_version = tool.version and vim.version.parse(tool.version)
|
||||
|
@ -93,9 +94,10 @@ function M.have_tool(tools)
|
|||
local version = 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.warn("'" .. cmd .. "' `" .. version .. "` is too old, expected `" .. tool.version .. "`")
|
||||
M.error("'" .. cmd .. "' `" .. version .. "` is too old, expected `" .. tool.version .. "`")
|
||||
else
|
||||
M.ok("'" .. cmd .. "' `" .. version .. "`")
|
||||
version_ok = true
|
||||
end
|
||||
found = true
|
||||
end
|
||||
|
@ -103,7 +105,7 @@ function M.have_tool(tools)
|
|||
end
|
||||
end
|
||||
if found then
|
||||
return true
|
||||
return true, version_ok
|
||||
end
|
||||
all = vim.tbl_map(function()
|
||||
return "'" .. tostring(_) .. "'"
|
||||
|
|
|
@ -16,21 +16,32 @@ function M.health()
|
|||
Snacks.health.has_lang("regex")
|
||||
|
||||
Snacks.health.have_tool("git")
|
||||
|
||||
local have_rg = Snacks.health.have_tool("rg")
|
||||
local have_fd = Snacks.health.have_tool({
|
||||
if not have_rg then
|
||||
Snacks.health.error("'rg' is required for `Snacks.picker.grep()`")
|
||||
else
|
||||
Snacks.health.ok("`Snacks.picker.grep()` is available")
|
||||
end
|
||||
|
||||
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 },
|
||||
})
|
||||
if have_rg or have_fd or have_find then
|
||||
Snacks.health.ok("`Snacks.picker.files()` is available")
|
||||
else
|
||||
Snacks.health.error("'rg', 'fd' or 'find' is required for `Snacks.picker.files()`")
|
||||
end
|
||||
|
||||
if not have_rg then
|
||||
Snacks.health.warn("'rg' is required for `Snacks.picker.grep()`")
|
||||
end
|
||||
if not have_rg and not have_fd then
|
||||
Snacks.health.warn("'rg' or 'fd' is required for `Snacks.picker.files()`")
|
||||
end
|
||||
if not have_fd then
|
||||
Snacks.health.warn("'fd' is required for `Snacks.picker.explorer()`")
|
||||
if not have_fd or not version_fd then
|
||||
Snacks.health.error("'fd' `v8.4` is required for `Snacks.picker.explorer()`")
|
||||
else
|
||||
Snacks.health.ok("`Snacks.picker.explorer()` is available")
|
||||
end
|
||||
|
||||
local ok = pcall(require, "snacks.picker.util.db")
|
||||
if ok then
|
||||
Snacks.health.ok("`SQLite3` is available")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue