aboutsummaryrefslogtreecommitdiffstats
path: root/nvim/lua/profiles.lua
blob: eefc8627fabb312aa286dd5f7fc78cc2b32ae951 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
-- Tools for conditionally loading plugins via lazy
M = {}

M.machines = { 'nest', 'Goose.local' }

local getDefaultmetatable = {
    __index = function(tbl, key)
        if rawget(tbl, key) then
            return tbl[key]
        else
            return tbl["default"]
        end
    end
}

-- Create a table for each machine with a default value
-- @param default the default value for each profile
-- @return a table with each machine as a key and a default
-- current machines: nest, Goose.local
M.createProfiles = function(default)
    local profiles = {}
    profiles.default = default
    for _, machine in ipairs(M.machines) do
        profiles[machine] = default
    end
    setmetatable(profiles, getDefaultmetatable)
    return profiles
end

return M