Skip to content

Commit 18fda81

Browse files
authored
feat: configurable telescope mappings (#113)
1 parent b4e09a6 commit 18fda81

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,11 @@ require("persisted").setup({
163163
ignored_dirs = nil, -- table of dirs that are ignored when auto-saving and auto-loading
164164
telescope = {
165165
reset_prompt = true, -- Reset the Telescope prompt after an action?
166+
mappings = { -- table of mappings for the Telescope extension
167+
change_branch = "<c-b>",
168+
copy_session = "<c-c>",
169+
delete_session = "<c-d>",
170+
},
166171
},
167172
})
168173
```

lua/persisted/config.lua

+5
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ local defaults = {
2121
telescope = {
2222
reset_prompt = true, -- Reset prompt after a telescope action?
2323
--TODO: We should add a deprecation notice for the old API here
24+
mappings = {
25+
change_branch = "<c-b>",
26+
copy_session = "<c-c>",
27+
delete_session = "<c-d>",
28+
},
2429
},
2530
}
2631

lua/telescope/_extensions/persisted.lua

+7-5
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,15 @@ local function search_sessions(opts)
3030
_actions.copy_session:enhance({ post = refresh_sessions })
3131
_actions.delete_session:enhance({ post = refresh_sessions })
3232

33-
map("i", "<c-b>", function()
33+
local change_session_branch = function()
3434
return _actions.change_branch(config)
35-
end)
36-
map("i", "<c-c>", function()
35+
end
36+
local copy_session = function()
3737
return _actions.copy_session(config)
38-
end)
39-
map("i", "<c-d>", _actions.delete_session)
38+
end
39+
map("i", config.telescope.mappings.change_branch, change_session_branch)
40+
map("i", config.telescope.mappings.copy_session, copy_session)
41+
map("i", config.telescope.mappings.delete_session, _actions.delete_session)
4042

4143
actions.select_default:replace(function()
4244
local session = action_state.get_selected_entry()

0 commit comments

Comments
 (0)