From 5722b9eaa767683eb747e95c1545ed0f73def402 Mon Sep 17 00:00:00 2001 From: James Trew Date: Sun, 5 Nov 2023 12:32:16 -0500 Subject: [PATCH] fix: augment `attach_mappings` without overwriting defaults closes #321 --- lua/telescope/_extensions/file_browser/config.lua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lua/telescope/_extensions/file_browser/config.lua b/lua/telescope/_extensions/file_browser/config.lua index 13d45934..6b2222c3 100644 --- a/lua/telescope/_extensions/file_browser/config.lua +++ b/lua/telescope/_extensions/file_browser/config.lua @@ -44,7 +44,7 @@ _TelescopeFileBrowserConfig = { ["s"] = fb_actions.toggle_all, }, }, - attach_mappings = function() + attach_mappings = function(_, _) local entry_is_dir = function() local entry = action_state.get_selected_entry() return entry and entry.Path:is_dir() @@ -120,6 +120,15 @@ config.setup = function(opts) -- TODO maybe merge other keys as well from telescope.config config.values.mappings = vim.tbl_deep_extend("force", config.values.mappings, require("telescope.config").values.mappings) + + if opts.attach_mappings then + local opts_attach = opts.attach_mappings + local default_attach = config.values.attach_mappings + opts.attach_mappings = function(prompt_bufnr, map) + default_attach(prompt_bufnr, map) + return opts_attach(prompt_bufnr, map) + end + end config.values = vim.tbl_deep_extend("force", config.values, opts) if config.values.hijack_netrw then