Rename util functions

This commit is contained in:
2023-09-04 15:23:43 +02:00
parent a4ec17b5c3
commit aafa05df7a
3 changed files with 18 additions and 19 deletions
+8 -8
View File
@@ -21,16 +21,16 @@ M.os_name = vim.loop.os_uname().sysname
--- Check that an executable is available
--- @param exe string: Array to look for
--- @return boolean
function M.is_available(exe)
function M.is_installed(exe)
return vim.fn.executable(exe) == 1
end
--- Check that at least one executable is available
--- @param exes table: Array of exes
--- @return boolean
function M.any_available(exes)
function M.any_installed(exes)
for _, e in ipairs(exes) do
if M.is_available(e) then
if M.is_installed(e) then
return true
end
end
@@ -41,8 +41,8 @@ end
--- Asserts that an executable is available
--- Raises error if missing.
--- @param exe string: Array to look for
function M.assert_available(exe)
if not M.is_available(exe) then
function M.assert_installed(exe)
if not M.is_installed(exe) then
M.notify("Missing executable '" .. exe .. "'.")
end
end
@@ -50,15 +50,15 @@ end
--- Asserts that at least one executable is available
--- Raises error if missing.
--- @param exes table: Array of exes
function M.assert_any_available(exes)
if not M.any_available(exes) then
function M.assert_any_installed(exes)
if not M.any_installed(exes) then
error("At least one of the following is required:\n" .. table.concat(exes, ", "))
end
end
--- Asserts that a python module is installed
---@param mod string: The python module to check
function M.assert_python3_module(mod)
function M.python3_module_installed(mod)
local resp = vim.system({ "python3", "-m", "pip", "show", mod, }):wait()
if not resp.code == 0 then
error("Python3 module " .. mod .. " not installed:\n" .. resp.stdout .. "\n" .. resp.stderr)