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>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user