diff options
| author | TJ DeVries <devries.timothyj@gmail.com> | 2021-02-22 11:30:57 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-02-22 11:30:57 -0500 |
| commit | d7c02e3b52b5a13265e071d0de2d6a989110a515 (patch) | |
| tree | 165f83bac6ffbb8594f6afb53905bc7bc64a4359 /lua/telescope/mappings.lua | |
| parent | 1c5e42a6a5a6d29be8fbf8dcefb0d8da535eac9a (diff) | |
feat: Action improvements (#472)
* feat: replace_map
* feat: Add action_set and action_state
* fix: Move all actions.get_ to action_state.get_
* fix: replace all internal references of _goto_file_selection_edit
* feat: add some docs
* fix: lint
* feat: actions.select
* remove mentions and usage of goto_file_selection APIs
* feat: special case attach_mappings to be overridable and defaultable
* Having goto_file_selection mappings will cause a error
as well as replacing deprecated goto_file_selection methodes
For config and replacing use this instead:
- actions.select_default
- actions.select_horizonal
- actions.select_vertical
- actions.select_tab
Only replacing:
- actions.set.edit -- for replacing all select functions
* adds actions.state.select_key_to_edit_key
Co-authored-by: Simon Hauser <Simon-Hauser@outlook.de>
Diffstat (limited to 'lua/telescope/mappings.lua')
| -rw-r--r-- | lua/telescope/mappings.lua | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/lua/telescope/mappings.lua b/lua/telescope/mappings.lua index 499be3e..efc833e 100644 --- a/lua/telescope/mappings.lua +++ b/lua/telescope/mappings.lua @@ -16,10 +16,10 @@ mappings.default_mappings = config.values.default_mappings or { ["<Down>"] = actions.move_selection_next, ["<Up>"] = actions.move_selection_previous, - ["<CR>"] = actions.goto_file_selection_edit + actions.center, - ["<C-x>"] = actions.goto_file_selection_split, - ["<C-v>"] = actions.goto_file_selection_vsplit, - ["<C-t>"] = actions.goto_file_selection_tabedit, + ["<CR>"] = actions.select_default + actions.center, + ["<C-x>"] = actions.select_horizontal, + ["<C-v>"] = actions.select_vertical, + ["<C-t>"] = actions.select_tab, ["<C-u>"] = actions.preview_scrolling_up, ["<C-d>"] = actions.preview_scrolling_down, @@ -30,10 +30,10 @@ mappings.default_mappings = config.values.default_mappings or { n = { ["<esc>"] = actions.close, - ["<CR>"] = actions.goto_file_selection_edit + actions.center, - ["<C-x>"] = actions.goto_file_selection_split, - ["<C-v>"] = actions.goto_file_selection_vsplit, - ["<C-t>"] = actions.goto_file_selection_tabedit, + ["<CR>"] = actions.select_default + actions.center, + ["<C-x>"] = actions.select_horizontal, + ["<C-v>"] = actions.select_vertical, + ["<C-t>"] = actions.select_tab, -- TODO: This would be weird if we switch the ordering. ["j"] = actions.move_selection_next, @@ -153,8 +153,19 @@ mappings.apply_keymap = function(prompt_bufnr, attach_mappings, buffer_keymap) telescope_map(prompt_bufnr, mode, key_bind, key_func, opts) end - if attach_mappings and not attach_mappings(prompt_bufnr, map) then - return + if attach_mappings then + local attach_results = attach_mappings(prompt_bufnr, map) + + if attach_results == nil then + error( + "Attach mappings must always return a value. `true` means use default mappings, " + .. "`false` means only use attached mappings" + ) + end + + if not attach_results then + return + end end for mode, mode_map in pairs(buffer_keymap or {}) do |
