From 4850c6df6d04aa6b98912b1dac9def713b1eda44 Mon Sep 17 00:00:00 2001 From: tami5 <65782666+tami5@users.noreply.github.com> Date: Wed, 23 Dec 2020 20:36:20 +0300 Subject: [PATCH] feat: include buf local maps, execute item on enter (#360) keymaps should now include local buffer mappings and execute the mappings one enter --- lua/telescope/builtin/internal.lua | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/lua/telescope/builtin/internal.lua b/lua/telescope/builtin/internal.lua index 12c158e..5987546 100644 --- a/lua/telescope/builtin/internal.lua +++ b/lua/telescope/builtin/internal.lua @@ -591,13 +591,18 @@ internal.registers = function(opts) }):find() end --- find normal mode mappings +-- TODO: make filtering include the mapping and the action internal.keymaps = function(opts) local modes = {"n", "i", "c"} local keymaps_table = {} + for _, mode in pairs(modes) do - local keymaps_iter = vim.api.nvim_get_keymap(mode) - for _, keymap in pairs(keymaps_iter) do + local global = vim.api.nvim_get_keymap(mode) + for _, keymap in pairs(global) do + table.insert(keymaps_table, keymap) + end + local buf_local = vim.api.nvim_buf_get_keymap(0, mode) + for _, keymap in pairs(buf_local) do table.insert(keymaps_table, keymap) end end @@ -616,6 +621,16 @@ internal.keymaps = function(opts) end }, sorter = conf.generic_sorter(opts), + attach_mappings = function(prompt_bufnr) + actions.goto_file_selection_edit:replace(function() + local selection = actions.get_selected_entry() + vim.api.nvim_feedkeys( + vim.api.nvim_replace_termcodes(selection.value.lhs, true, false, true), + "t", true) + return actions.close(prompt_bufnr) + end) + return true + end }):find() end