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
30 lines
1,004 B
Lua
30 lines
1,004 B
Lua
local ivy = require "ivy"
|
|
local config = require "ivy.config"
|
|
|
|
describe("ivy.setup", function()
|
|
before_each(function()
|
|
ivy.has_setup = false
|
|
config.user_config = {}
|
|
end)
|
|
|
|
it("sets the users config options", function()
|
|
ivy.setup { backends = { "ivy.backends.files" } }
|
|
assert.is_equal("ivy.backends.files", config:get { "backends", 1 })
|
|
end)
|
|
|
|
it("will not reconfigure if its called twice", function()
|
|
ivy.setup { backends = { "ivy.backends.files" } }
|
|
ivy.setup { backends = { "some.backend" } }
|
|
assert.is_equal("ivy.backends.files", config:get { "backends", 1 })
|
|
end)
|
|
|
|
it("does not crash if you don't pass in any params to the setup function", function()
|
|
ivy.setup()
|
|
assert.is_equal("ivy.backends.buffers", config:get { "backends", 1 })
|
|
end)
|
|
|
|
it("will fallback if the key is not set at all in the users config", function()
|
|
ivy.setup { some_key = "some_value" }
|
|
assert.is_equal("ivy.backends.buffers", config:get { "backends", 1 })
|
|
end)
|
|
end)
|