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
This commit is contained in:
fdschmidt93
2021-09-01 18:17:18 +02:00
committed by GitHub
parent 67bc1dcdd6
commit 5d37c3ea08
11 changed files with 444 additions and 31 deletions

View File

@@ -832,6 +832,21 @@ actions.cycle_previewers_prev = function(prompt_bufnr)
actions.get_current_picker(prompt_bufnr):cycle_previewers(-1)
end
--- Removes the selected picker in |builtin.pickers|.<br>
--- This action is not mapped by default and only intended for |builtin.pickers|.
---@param prompt_bufnr number: The prompt bufnr
actions.remove_selected_picker = function(prompt_bufnr)
local current_picker = action_state.get_current_picker(prompt_bufnr)
local selection_index = current_picker:get_index(current_picker:get_selection_row())
local cached_pickers = state.get_global_key "cached_pickers"
current_picker:delete_selection(function()
table.remove(cached_pickers, selection_index)
end)
if #cached_pickers == 0 then
actions.close(prompt_bufnr)
end
end
-- ==================================================
-- Transforms modules and sets the corect metatables.
-- ==================================================