From d541e0d6e00a0d89f21e1b0e6fe92c736ac0f83b Mon Sep 17 00:00:00 2001 From: ADoyle Date: Mon, 7 Nov 2022 00:42:29 +0800 Subject: feat: the parameter "map" of attach_mappings can be list of modes to create mapping on multiple modes (#2220) --- lua/telescope/builtin/__git.lua | 35 ++++++++++------------------------- 1 file changed, 10 insertions(+), 25 deletions(-) (limited to 'lua/telescope/builtin/__git.lua') diff --git a/lua/telescope/builtin/__git.lua b/lua/telescope/builtin/__git.lua index 7c4f28b..cc40503 100644 --- a/lua/telescope/builtin/__git.lua +++ b/lua/telescope/builtin/__git.lua @@ -71,12 +71,9 @@ git.commits = function(opts) sorter = conf.file_sorter(opts), attach_mappings = function(_, map) actions.select_default:replace(actions.git_checkout) - map("i", "m", actions.git_reset_mixed) - map("n", "m", actions.git_reset_mixed) - map("i", "s", actions.git_reset_soft) - map("n", "s", actions.git_reset_soft) - map("i", "h", actions.git_reset_hard) - map("n", "h", actions.git_reset_hard) + map({ "i", "n" }, "m", actions.git_reset_mixed) + map({ "i", "n" }, "s", actions.git_reset_soft) + map({ "i", "n" }, "h", actions.git_reset_hard) return true end, }) @@ -293,23 +290,12 @@ git.branches = function(opts) sorter = conf.file_sorter(opts), attach_mappings = function(_, map) actions.select_default:replace(actions.git_checkout) - map("i", "", actions.git_track_branch) - map("n", "", actions.git_track_branch) - - map("i", "", actions.git_rebase_branch) - map("n", "", actions.git_rebase_branch) - - map("i", "", actions.git_create_branch) - map("n", "", actions.git_create_branch) - - map("i", "", actions.git_switch_branch) - map("n", "", actions.git_switch_branch) - - map("i", "", actions.git_delete_branch) - map("n", "", actions.git_delete_branch) - - map("i", "", actions.git_merge_branch) - map("n", "", actions.git_merge_branch) + map({ "i", "n" }, "", actions.git_track_branch) + map({ "i", "n" }, "", actions.git_rebase_branch) + map({ "i", "n" }, "", actions.git_create_branch) + map({ "i", "n" }, "", actions.git_switch_branch) + map({ "i", "n" }, "", actions.git_delete_branch) + map({ "i", "n" }, "", actions.git_merge_branch) return true end, }) @@ -368,8 +354,7 @@ git.status = function(opts) end, } - map("i", "", actions.git_staging_toggle) - map("n", "", actions.git_staging_toggle) + map({ "i", "n" }, "", actions.git_staging_toggle) return true end, }) -- cgit v1.2.3