diff --git a/README.md b/README.md index 669647d..21aacaf 100644 --- a/README.md +++ b/README.md @@ -163,6 +163,11 @@ require("persisted").setup({ ignored_dirs = nil, -- table of dirs that are ignored when auto-saving and auto-loading telescope = { reset_prompt = true, -- Reset the Telescope prompt after an action? + mappings = { -- table of mappings for the Telescope extension + change_branch = "", + copy_session = "", + delete_session = "", + }, }, }) ``` diff --git a/lua/persisted/config.lua b/lua/persisted/config.lua index e5b2984..a32659e 100644 --- a/lua/persisted/config.lua +++ b/lua/persisted/config.lua @@ -21,6 +21,11 @@ local defaults = { telescope = { reset_prompt = true, -- Reset prompt after a telescope action? --TODO: We should add a deprecation notice for the old API here + mappings = { + change_branch = "", + copy_session = "", + delete_session = "", + }, }, } diff --git a/lua/telescope/_extensions/persisted.lua b/lua/telescope/_extensions/persisted.lua index a99cc94..b1723cd 100644 --- a/lua/telescope/_extensions/persisted.lua +++ b/lua/telescope/_extensions/persisted.lua @@ -30,13 +30,15 @@ local function search_sessions(opts) _actions.copy_session:enhance({ post = refresh_sessions }) _actions.delete_session:enhance({ post = refresh_sessions }) - map("i", "", function() + local change_session_branch = function() return _actions.change_branch(config) - end) - map("i", "", function() + end + local copy_session = function() return _actions.copy_session(config) - end) - map("i", "", _actions.delete_session) + end + map("i", config.telescope.mappings.change_branch, change_session_branch) + map("i", config.telescope.mappings.copy_session, copy_session) + map("i", config.telescope.mappings.delete_session, _actions.delete_session) actions.select_default:replace(function() local session = action_state.get_selected_entry()