feat: configurable telescope mappings (#113)

main
jyuan0 2024-03-06 09:16:41 -05:00 committed by GitHub
parent b4e09a639a
commit 18fda8136f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 17 additions and 5 deletions

View File

@ -163,6 +163,11 @@ require("persisted").setup({
ignored_dirs = nil, -- table of dirs that are ignored when auto-saving and auto-loading ignored_dirs = nil, -- table of dirs that are ignored when auto-saving and auto-loading
telescope = { telescope = {
reset_prompt = true, -- Reset the Telescope prompt after an action? reset_prompt = true, -- Reset the Telescope prompt after an action?
mappings = { -- table of mappings for the Telescope extension
change_branch = "<c-b>",
copy_session = "<c-c>",
delete_session = "<c-d>",
},
}, },
}) })
``` ```

View File

@ -21,6 +21,11 @@ local defaults = {
telescope = { telescope = {
reset_prompt = true, -- Reset prompt after a telescope action? reset_prompt = true, -- Reset prompt after a telescope action?
--TODO: We should add a deprecation notice for the old API here --TODO: We should add a deprecation notice for the old API here
mappings = {
change_branch = "<c-b>",
copy_session = "<c-c>",
delete_session = "<c-d>",
},
}, },
} }

View File

@ -30,13 +30,15 @@ local function search_sessions(opts)
_actions.copy_session:enhance({ post = refresh_sessions }) _actions.copy_session:enhance({ post = refresh_sessions })
_actions.delete_session:enhance({ post = refresh_sessions }) _actions.delete_session:enhance({ post = refresh_sessions })
map("i", "<c-b>", function() local change_session_branch = function()
return _actions.change_branch(config) return _actions.change_branch(config)
end) end
map("i", "<c-c>", function() local copy_session = function()
return _actions.copy_session(config) return _actions.copy_session(config)
end) end
map("i", "<c-d>", _actions.delete_session) 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() actions.select_default:replace(function()
local session = action_state.get_selected_entry() local session = action_state.get_selected_entry()