Summary: Now the users configuration and the default configuration is separated. This will make it easier to setup ivy with some defaults. Right now we only have the backends configurable however, it looks like we will be making other components of ivy configurable. To use this you can now call `ivy.setup` with no parameters and you will get the default config. You can also call it with a partial config and if the option is not found in the users config it will fallback to the users config value. Test Plan: Manual testing and with unit tests in CI
33 lines
704 B
Lua
33 lines
704 B
Lua
local config_mt = {}
|
|
config_mt.__index = config_mt
|
|
|
|
function config_mt:get_in(config, key_table)
|
|
local current_value = config
|
|
for _, key in ipairs(key_table) do
|
|
if current_value == nil then
|
|
return nil
|
|
end
|
|
|
|
current_value = current_value[key]
|
|
end
|
|
|
|
return current_value
|
|
end
|
|
|
|
function config_mt:get(key_table)
|
|
return self:get_in(self.user_config, key_table) or self:get_in(self.default_config, key_table)
|
|
end
|
|
|
|
local config = { user_config = {} }
|
|
|
|
config.default_config = {
|
|
backends = {
|
|
"ivy.backends.buffers",
|
|
"ivy.backends.files",
|
|
"ivy.backends.lines",
|
|
"ivy.backends.rg",
|
|
"ivy.backends.lsp-workspace-symbols",
|
|
},
|
|
}
|
|
|
|
return setmetatable(config, config_mt)
|