1
Fork 0
satellite/home/features/neovim/config/lua/my/helpers/env.lua
2023-12-13 19:30:04 +01:00

57 lines
1 KiB
Lua

local function makeEnv(cond)
return {
-- I am doing this to get type hints!
active = function()
return cond()
end,
not_active = function()
return not cond()
end,
unless = function(f)
if not cond() then
f()
end
end,
when = function(f)
if cond() then
f()
end
end,
}
end
local M = {
vscode = makeEnv(function()
return vim.g.vscode ~= nil
end),
neovide = makeEnv(function()
return vim.g.neovide ~= nil or vim.g.nix_neovim_app == "neovide"
end),
firenvim = makeEnv(function()
return vim.g.started_by_firenvim ~= nil
or vim.g.nix_neovim_app == "firenvim"
end),
_and = function(a, b)
return makeEnv(function()
return a.active() and b.active()
end)
end,
_or = function(a, b)
return makeEnv(function()
return a.active() or b.active()
end)
end,
}
M.blacklist = function(list)
for _, key in pairs(list) do
if M[key].active() then
return false
end
end
return true
end
return M