-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(telescope)!: restructure mapping config and accept
mappings
op…
…tion BREAKING CHANGE: The configuration for Hbac's telescope picker now follows the standard Telescope key mapping pattern of a key(string):function key/value pair. See `hbac.config` for changes Most options that can be found in `h: telescope.builtin.buffers()` and in `h: telescope.setup()` that are relevant to a buffer picker are now accepted in the `telescope` configuration table, including `mappings`. The defaults can be overriden by the user's `setup()` call, and both the user and the default opts can be overriden by an `opts` table passed to the picker's function call, e.g. `hbac.telescope({sort_mru = false})`
- Loading branch information
1 parent
bf22ddf
commit 610a604
Showing
6 changed files
with
93 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
local action_state = require("telescope.actions.state") | ||
local hbac_actions = require("hbac.command.actions") | ||
local make_finder = require("hbac.telescope.make_finder") | ||
|
||
local M = {} | ||
|
||
local function execute_telescope_action(prompt_bufnr, action) | ||
local finder, finder_opts = make_finder.make_finder, make_finder.finder_opts | ||
local picker = action_state.get_current_picker(prompt_bufnr) | ||
local multi_selection = picker:get_multi_selection() | ||
|
||
if next(multi_selection) then | ||
for _, entry in ipairs(multi_selection) do | ||
action(entry.value) | ||
end | ||
else | ||
local single_selection = action_state.get_selected_entry() | ||
action(single_selection.value) | ||
end | ||
|
||
picker:refresh(finder(finder_opts), { reset_prompt = false }) | ||
end | ||
|
||
local function hbac_toggle_pin(prompt_bufnr) | ||
execute_telescope_action(prompt_bufnr, hbac_actions.toggle_pin) | ||
end | ||
local function hbac_pin_all(prompt_bufnr) | ||
execute_telescope_action(prompt_bufnr, hbac_actions.pin_all) | ||
end | ||
local function hbac_unpin_all(prompt_bufnr) | ||
execute_telescope_action(prompt_bufnr, hbac_actions.unpin_all) | ||
end | ||
local function hbac_close_unpinned(prompt_bufnr) | ||
execute_telescope_action(prompt_bufnr, hbac_actions.close_unpinned) | ||
end | ||
local function hbac_delete_buffer(prompt_bufnr) | ||
local close_command = require("hbac.config").values.close_command | ||
execute_telescope_action(prompt_bufnr, close_command) | ||
end | ||
|
||
|
||
M.close_unpinned = hbac_close_unpinned | ||
M.delete_buffer = hbac_delete_buffer | ||
M.pin_all = hbac_pin_all | ||
M.unpin_all = hbac_unpin_all | ||
M.toggle_pin = hbac_toggle_pin | ||
|
||
return M |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters