feat(health): split required/optional sections, add git check
Problem: all healthcheck items were under a single `[required]` section, including optional tools like uv and git. Solution: move uv/nix/git checks into a new `[optional]` section. Add git version check asserting >= 1.7.9 with the minimum and installed versions shown side by side. Show neovim version the same way.
This commit is contained in:
parent
74f699c5a1
commit
2d709ab898
1 changed files with 38 additions and 15 deletions
|
|
@ -5,12 +5,12 @@ local utils = require('cp.utils')
|
|||
local function check()
|
||||
vim.health.start('cp.nvim [required] ~')
|
||||
|
||||
utils.setup_python_env()
|
||||
|
||||
local nvim_ver = vim.version()
|
||||
local nvim_str = ('%d.%d.%d'):format(nvim_ver.major, nvim_ver.minor, nvim_ver.patch)
|
||||
if vim.fn.has('nvim-0.10.0') == 1 then
|
||||
vim.health.ok('Neovim 0.10.0+ detected')
|
||||
vim.health.ok('Neovim >= 0.10.0: ' .. nvim_str)
|
||||
else
|
||||
vim.health.error('cp.nvim requires Neovim 0.10.0+')
|
||||
vim.health.error('Neovim >= 0.10.0 required, found ' .. nvim_str)
|
||||
end
|
||||
|
||||
local uname = vim.uv.os_uname()
|
||||
|
|
@ -18,6 +18,24 @@ local function check()
|
|||
vim.health.error('Windows is not supported')
|
||||
end
|
||||
|
||||
local time_cap = utils.time_capability()
|
||||
if time_cap.ok then
|
||||
vim.health.ok('GNU time found: ' .. time_cap.path)
|
||||
else
|
||||
vim.health.error('GNU time not found: ' .. (time_cap.reason or ''))
|
||||
end
|
||||
|
||||
local timeout_cap = utils.timeout_capability()
|
||||
if timeout_cap.ok then
|
||||
vim.health.ok('GNU timeout found: ' .. timeout_cap.path)
|
||||
else
|
||||
vim.health.error('GNU timeout not found: ' .. (timeout_cap.reason or ''))
|
||||
end
|
||||
|
||||
vim.health.start('cp.nvim [optional] ~')
|
||||
|
||||
utils.setup_python_env()
|
||||
|
||||
if utils.is_nix_build() then
|
||||
local source = utils.is_nix_discovered() and 'runtime discovery' or 'flake install'
|
||||
vim.health.ok('Nix Python environment detected (' .. source .. ')')
|
||||
|
|
@ -51,18 +69,23 @@ local function check()
|
|||
end
|
||||
end
|
||||
|
||||
local time_cap = utils.time_capability()
|
||||
if time_cap.ok then
|
||||
vim.health.ok('GNU time found: ' .. time_cap.path)
|
||||
if vim.fn.executable('git') == 1 then
|
||||
local r = vim.system({ 'git', '--version' }, { text = true }):wait()
|
||||
if r.code == 0 then
|
||||
local major, minor, patch = r.stdout:match('(%d+)%.(%d+)%.(%d+)')
|
||||
major, minor, patch = tonumber(major), tonumber(minor), tonumber(patch or 0)
|
||||
local ver_str = ('%d.%d.%d'):format(major or 0, minor or 0, patch or 0)
|
||||
if
|
||||
major
|
||||
and (major > 1 or (major == 1 and minor > 7) or (major == 1 and minor == 7 and patch >= 9))
|
||||
then
|
||||
vim.health.ok('git >= 1.7.9: ' .. ver_str)
|
||||
else
|
||||
vim.health.warn('git >= 1.7.9 required for credential storage, found ' .. ver_str)
|
||||
end
|
||||
end
|
||||
else
|
||||
vim.health.error('GNU time not found: ' .. (time_cap.reason or ''))
|
||||
end
|
||||
|
||||
local timeout_cap = utils.timeout_capability()
|
||||
if timeout_cap.ok then
|
||||
vim.health.ok('GNU timeout found: ' .. timeout_cap.path)
|
||||
else
|
||||
vim.health.error('GNU timeout not found: ' .. (timeout_cap.reason or ''))
|
||||
vim.health.warn('git not found (required for credential storage)')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue