Skip to content

Commit

Permalink
feat: Add global settings for the commands
Browse files Browse the repository at this point in the history
Fixes #38
  • Loading branch information
cljoly committed Jun 4, 2022
1 parent b898ded commit 9b42c5b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 2 additions & 0 deletions lua/telescope/_extensions/repo.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
local main = require("telescope._extensions.repo.main")
local r_config = require("telescope._extensions.repo.config")
local health = require("telescope._extensions.repo.health")

local fallback_error = { "Falling back to `:Telescope repo list`, but this behavior may change in the future" }

return require("telescope").register_extension({
health = health.check,
setup = r_config.setup,
exports = {
list = main.list,
cached_list = main.cached_list,
Expand Down
9 changes: 9 additions & 0 deletions lua/telescope/_extensions/repo/config.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
local M = {}

M.values = {}

M.setup = function (opts)
M.values = opts
end

return M
5 changes: 3 additions & 2 deletions lua/telescope/_extensions/repo/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ local Path = require("plenary.path")
local utils = require("telescope._extensions.repo.utils")
local list = require("telescope._extensions.repo.list")
local cached_list = require("telescope._extensions.repo.cached_list")
local r_config = require("telescope._extensions.repo.config")

local M = {}

Expand Down Expand Up @@ -187,7 +188,7 @@ end

-- List of repos built using locate (or variants)
M.cached_list = function(opts)
opts = opts or {}
opts = vim.tbl_deep_extend("force", r_config.values.cached_list or {}, opts or {})
opts.entry_maker = t_utils.get_lazy_default(opts.entry_maker, gen_from_locate_wrapper, opts)
local locate_command = cached_list.prepare_command(opts)

Expand All @@ -196,7 +197,7 @@ end

-- Always up to date list of repos built using fd
M.list = function(opts)
opts = opts or {}
opts = vim.tbl_deep_extend("force", r_config.values.list or {}, opts or {})
opts.entry_maker = t_utils.get_lazy_default(opts.entry_maker, gen_from_fd, opts)
local fd_command = list.prepare_command(opts)

Expand Down

0 comments on commit 9b42c5b

Please sign in to comment.