Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F33564
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/lua/ivy/init.lua b/lua/ivy/init.lua
new file mode 100644
index 0000000..f62f6fc
--- /dev/null
+++ b/lua/ivy/init.lua
@@ -0,0 +1,28 @@
+local controller = require "ivy.controller"
+local register_backend = require "ivy.register_backend"
+
+-- Local variable to check if ivy has been setup, this is to prevent multiple
+-- setups of ivy
+local has_setup = false
+
+local ivy = {}
+ivy.run = controller.run
+ivy.register_backend = register_backend
+
+---@class IvySetupOptions
+---@field backends (IvyBackend | { ["1"]: string, ["2"]: IvyBackendOptions} | string)[]
+
+---@param config IvySetupOptions
+function ivy.setup(config)
+ if has_setup then
+ return
+ end
+
+ for _, backend in ipairs(config.backends) do
+ register_backend(backend)
+ end
+
+ has_setup = true
+end
+
+return ivy
diff --git a/plugin/ivy.lua b/plugin/ivy.lua
index 81169f9..cab4b9a 100644
--- a/plugin/ivy.lua
+++ b/plugin/ivy.lua
@@ -1,31 +1,19 @@
local controller = require "ivy.controller"
-local register_backend = require "ivy.register_backend"
-- Put the controller in to the vim global so we can access it in mappings
-- better without requires. You can call controller commands like `vim.ivy.xxx`.
-- luacheck: ignore
vim.ivy = controller
vim.paste = (function(overridden)
return function(lines, phase)
local file_type = vim.api.nvim_buf_get_option(0, "filetype")
if file_type == "ivy" then
vim.ivy.paste()
else
overridden(lines, phase)
end
end
end)(vim.paste)
-register_backend "ivy.backends.buffers"
-register_backend "ivy.backends.files"
-register_backend "ivy.backends.lines"
-register_backend "ivy.backends.lsp-workspace-symbols"
-
-if vim.fn.executable "rg" then
- register_backend "ivy.backends.rg"
-elseif vim.fn.executable "ag" then
- register_backend "ivy.backends.ag"
-end
-
vim.cmd "highlight IvyMatch cterm=bold gui=bold"
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Tue, Dec 16, 7:54 PM (1 w, 1 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
8974
Default Alt Text
(1 KB)
Attached To
Mode
R1 ivy.nvim
Attached
Detach File
Event Timeline
Log In to Comment