mirror of
https://github.com/neovim/neovim.git
synced 2026-08-15 20:09:41 +00:00
Problem: There is no health check. Encrypted entries cannot be read at all, since Info-ZIP takes a password only from a terminal and `-P` would expose it in the process arguments. Solution: Add `:checkhealth nvim.zip`, reporting the backend and which implementation is handling archives. Prompt for the password on a pty, extracting to a file so the entry's bytes stay off the terminal. Report Info-ZIP's exit code rather than inferring a cause, so an archive using AES is not reported as a failed decryption.
63 lines
1.7 KiB
Lua
63 lines
1.7 KiB
Lua
local M = {}
|
|
|
|
local health = vim.health
|
|
|
|
local function check_backend()
|
|
health.start('nvim.zip: backend')
|
|
|
|
local exe = vim.fn.exepath('unzip')
|
|
if exe == '' then
|
|
health.error('`unzip` executable not found', {
|
|
'Install Info-ZIP `unzip` to browse and read archives.',
|
|
'Or `:packadd old-zip` to use the legacy plugin.',
|
|
})
|
|
return
|
|
end
|
|
|
|
local out = vim.system({ exe, '-v' }, { text = true }):wait()
|
|
local version = vim.split(out.stdout or '', '\n')[1] or ''
|
|
health.ok(('`unzip` found: %s'):format(exe))
|
|
if version ~= '' then
|
|
health.info(version)
|
|
end
|
|
end
|
|
|
|
--- @return boolean Whether an implementation that needs the backend is handling archives.
|
|
local function check_active()
|
|
health.start('nvim.zip: active implementation')
|
|
|
|
local legacy = vim.fn.exists('#zip') == 1
|
|
local builtin = vim.fn.exists('#nvim.zip') == 1
|
|
|
|
if legacy then
|
|
health.info('`old-zip` is loaded, so it handles archives instead of zip.lua')
|
|
health.info('zip.lua yields to it and removes its own autocommands')
|
|
-- `old-zip` shells out to the same backend.
|
|
return true
|
|
end
|
|
|
|
if not builtin then
|
|
if vim.g.loaded_nvim_zip_plugin ~= nil then
|
|
health.warn('zip.lua is disabled by `g:loaded_nvim_zip_plugin`', {
|
|
'Unset it before startup to enable the builtin zip plugin.',
|
|
})
|
|
else
|
|
health.warn('No zip plugin is active')
|
|
end
|
|
return false
|
|
end
|
|
|
|
health.ok('zip.lua is active')
|
|
return true
|
|
end
|
|
|
|
function M.check()
|
|
-- Report the backend only when something is actually going to run it, so that disabling the
|
|
-- plugin does not report a missing `unzip` as an error.
|
|
if check_active() then
|
|
check_backend()
|
|
end
|
|
end
|
|
|
|
return M
|