summaryrefslogtreecommitdiff
path: root/lua/telescope/config.lua
diff options
context:
space:
mode:
authorfdschmidt93 <39233597+fdschmidt93@users.noreply.github.com>2021-09-01 18:17:18 +0200
committerGitHub <noreply@github.com>2021-09-01 18:17:18 +0200
commit5d37c3ea08f40d8c9d3a9ebcc72bd641d366c110 (patch)
treee66df8fe1312c38ad28ff64e0f0218b415bf18af /lua/telescope/config.lua
parent67bc1dcdd6eea1915b7c397b7c02451bbdc277a0 (diff)
feat: allow caching and resuming picker (#1051)
* expose `cache_picker` in telescope.setup to configure caching, see `:h telescope.defaults.cache_picker` * add builtin.resume and builtin.pickers picker
Diffstat (limited to 'lua/telescope/config.lua')
-rw-r--r--lua/telescope/config.lua40
1 files changed, 39 insertions, 1 deletions
diff --git a/lua/telescope/config.lua b/lua/telescope/config.lua
index a4899af..d58b94e 100644
--- a/lua/telescope/config.lua
+++ b/lua/telescope/config.lua
@@ -46,11 +46,22 @@ local smarter_depth_2_extend = function(priority, base)
return result
end
+local resolve_table_opts = function(priority, base)
+ if priority == false or (priority == nil and base == false) then
+ return false
+ end
+ if priority == nil and type(base) == "table" then
+ return base
+ end
+ return smarter_depth_2_extend(priority, base)
+end
+
-- TODO: Add other major configuration points here.
-- selection_strategy
local config = {}
config.smarter_depth_2_extend = smarter_depth_2_extend
+config.resolve_table_opts = resolve_table_opts
config.values = _TelescopeConfigurationValues
config.descriptions = {}
@@ -286,6 +297,33 @@ local telescope_defaults = {
]],
},
+ cache_picker = {
+ {
+ num_pickers = 1,
+ limit_entries = 1000,
+ },
+ [[
+ This field handles the configuration for picker caching.
+ By default it is a table, with default values (more below).
+ To disable caching, set it to false.
+
+ Caching preserves all previous multi selections and results and
+ therefore may result in slowdown or increased RAM occupation
+ if too many pickers (`cache_picker.num_pickers`) or entries
+ ('cache_picker.limit_entries`) are cached.
+
+ Fields:
+ - num_pickers: The number of pickers to be cached.
+ Set to -1 to preserve all pickers of your session.
+ If passed to a picker, the cached pickers with
+ indices larger than `cache_picker.num_pickers` will
+ be cleared.
+ Default: 1
+ - limit_entries: The amount of entries that will be written in the
+ Default: 1000
+ ]],
+ },
+
-- Builtin configuration
-- List that will be executed.
@@ -416,7 +454,7 @@ function config.set_defaults(user_defaults, tele_defaults)
vim.tbl_deep_extend("keep", if_nil(config.values[name], {}), if_nil(default_val, {}))
)
end
- if name == "history" then
+ if name == "history" or name == "cache_picker" then
if user_defaults[name] == false or config.values[name] == false then
return false
end