blob: 0c87988d4dec3546e64d9c58c1f367aa86a63370 (
plain)
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
31
32
33
34
35
36
37
38
|
local M = {}
---@return inbox.Indexer
function M.get_indexer()
if not M.indexer then
local config = require("inbox.config")
M.setup(config.indexer_config)
end
return M.indexer
end
---@param opts inbox.Indexer.Config
function M.setup(opts)
if not opts then
vim.notify("No indexer set", vim.log.levels.ERROR)
return nil
end
if type(opts) == "string" then
opts = { name = opts }
end
local ok, indexer = pcall(require, string.format("inbox.indexers.%s", opts.name))
if not ok then
vim.notify(string.format("Indexer not found: '%s'", indexer), vim.log.levels.ERROR)
end
-- TODO: Validate indexer spec
if indexer.available() then
M.indexer = indexer
M.indexer.setup(opts)
else
vim.notify(string.format("Indexer not available: '%s'", indexer), vim.log.levels.ERROR)
end
end
return M
|