robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
794886aae7
master
1local M ={} 2 3local health =vim . health 4 5local function check_backend () 6health . start ( 'nvim.zip: backend' ) 7 8local exe =vim . fn . exepath ( 'unzip' ) 9if exe == '' then 10health . error ( '`unzip` executable not found' , { 11'Install Info-ZIP `unzip` to browse and read archives.' , 12'Or `:packadd old-zip` to use the legacy plugin.' , 13} ) 14return 15end 16 17local out =vim . system ( { exe , '-v' } , { text =true } ): wait () 18local version =vim . split ( out . stdout or '' , '\n' )[ 1 ] or '' 19health . ok (( '`unzip` found: %s' ): format ( exe )) 20if version ~= '' then 21health . info ( version ) 22end 23end 24 25--- @return boolean Whether an implementation that needs the backend is handling archives. 26local function check_active () 27health . start ( 'nvim.zip: active implementation' ) 28 29local legacy =vim . fn . exists ( '#zip' ) == 1 30local builtin =vim . fn . exists ( '#nvim.zip' ) == 1 31 32if legacy then 33health . info ( '`old-zip` is loaded, so it handles archives instead of zip.lua' ) 34health . info ( 'zip.lua defers to it while it is loaded' ) 35-- `old-zip` shells out to the same backend. 36return true 37end 38 39if not builtin then 40if vim . g . loaded_nvim_zip_plugin ~= nil then 41health . info ( 'Disabled (`g:loaded_nvim_zip_plugin` is set).' ) 42else 43health . warn ( 'No zip plugin is active' ) 44end 45return false 46end 47 48health . ok ( 'zip.lua is active' ) 49return true 50end 51 52function M . check () 53-- Report the backend only when something is actually going to run it, so that disabling the 54-- plugin does not report a missing `unzip` as an error. 55if check_active () then 56check_backend () 57end 58end 59 60return M