Some checks failed
CI / Luacheck (pull_request) Successful in 20s
CI / StyLua (pull_request) Failing after 4s
CI / Cargo Format (pull_request) Successful in 19s
CI / Build and test (pull_request) Successful in 1m55s
Conventional Tools Commitlint / Commitlint (pull_request) Successful in 5s
Summary:
Right now we have two ways to access the public api we have `require('ivy')`
and `vim.ivy. Each way has a different api that will cause some confusion.
Now both apis are the same so anyone that wants to integrate with ivy can do so
without having to figure out what one they need to use.
Test Plan:
The unit tests cover most of the work, I have also been using this locally for
quite some time now with now issues.
49 lines
1.2 KiB
Lua
49 lines
1.2 KiB
Lua
local controller = require "ivy.controller"
|
|
local libivy = require "ivy.libivy"
|
|
local config = require "ivy.config"
|
|
local utils = require "ivy.utils"
|
|
local register_backend = require "ivy.register_backend"
|
|
|
|
local ivy = {}
|
|
|
|
ivy.action = utils.actions
|
|
ivy.utils = utils
|
|
|
|
ivy.match = libivy.ivy_match
|
|
|
|
ivy.run = controller.run
|
|
ivy.register_backend = register_backend
|
|
|
|
ivy.checkpoint = controller.checkpoint
|
|
ivy.paste = controller.paste
|
|
ivy.complete = controller.complete
|
|
ivy.destroy = controller.destroy
|
|
ivy.input = controller.input
|
|
ivy.next = controller.next
|
|
ivy.previous = controller.previous
|
|
ivy.search = controller.search
|
|
|
|
-- Private variable to check if ivy has been setup, this is to prevent multiple
|
|
-- setups of ivy. This is only exposed for testing purposes.
|
|
---@private
|
|
ivy.has_setup = false
|
|
|
|
---@class IvySetupOptions
|
|
---@field backends (IvyBackend | { ["1"]: string, ["2"]: IvyBackendOptions} | string)[]
|
|
|
|
---@param user_config IvySetupOptions
|
|
function ivy.setup(user_config)
|
|
if ivy.has_setup then
|
|
return
|
|
end
|
|
|
|
config.user_config = user_config or {}
|
|
|
|
for _, backend in ipairs(config:get { "backends" } or {}) do
|
|
register_backend(backend)
|
|
end
|
|
|
|
ivy.has_setup = true
|
|
end
|
|
|
|
return ivy
|