2022-10-09 03:28:51 +02:00
|
|
|
local function makeEnv(cond)
|
|
|
|
return {
|
|
|
|
active = cond,
|
2022-12-27 20:45:43 +01:00
|
|
|
not_active = function()
|
|
|
|
return not cond()
|
|
|
|
end,
|
2022-10-09 03:28:51 +02:00
|
|
|
unless = function(f)
|
2022-12-27 20:45:43 +01:00
|
|
|
if not cond() then
|
|
|
|
f()
|
|
|
|
end
|
2022-10-09 03:28:51 +02:00
|
|
|
end,
|
|
|
|
when = function(f)
|
2022-12-27 20:45:43 +01:00
|
|
|
if cond() then
|
|
|
|
f()
|
|
|
|
end
|
|
|
|
end,
|
2022-10-09 03:28:51 +02:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
return {
|
|
|
|
vscode = makeEnv(function()
|
|
|
|
return vim.g.vscode ~= nil
|
|
|
|
end),
|
2022-12-05 01:18:31 +01:00
|
|
|
neovide = makeEnv(function()
|
2022-12-27 20:45:43 +01:00
|
|
|
return vim.g.neovide ~= nil or os.getenv("INSIDE_NEOVIDE") ~= nil
|
2022-12-05 01:18:31 +01:00
|
|
|
end),
|
2022-12-27 20:45:43 +01:00
|
|
|
firenvim = makeEnv(function()
|
2022-10-09 03:28:51 +02:00
|
|
|
return vim.g.started_by_firenvim ~= nil
|
2022-12-27 20:45:43 +01:00
|
|
|
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
|
2022-10-09 03:28:51 +02:00
|
|
|
}
|