diff options
| author | TJ DeVries <devries.timothyj@gmail.com> | 2020-11-16 10:58:30 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-11-16 10:58:30 -0500 |
| commit | 985856946e30a7d93eb3b8aac6b5b5d7d589a768 (patch) | |
| tree | 0e334d5dd1808f6508c869322699825d2b576130 /lua/telescope/builtin.lua | |
| parent | ad7280e0b99ecd9f78ac6c70b4e5b49ed5e632f8 (diff) | |
feat: Allow overriding actions from mappings (#248)
Diffstat (limited to 'lua/telescope/builtin.lua')
| -rw-r--r-- | lua/telescope/builtin.lua | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/lua/telescope/builtin.lua b/lua/telescope/builtin.lua index c792f54..4102906 100644 --- a/lua/telescope/builtin.lua +++ b/lua/telescope/builtin.lua @@ -804,12 +804,15 @@ builtin.current_buffer_fuzzy_find = function(opts) table.insert(lines_with_numbers, {k, v}) end + local bufnr = vim.api.nvim_get_current_buf() + pickers.new(opts, { prompt_title = 'Current Buffer Fuzzy', finder = finders.new_table { results = lines_with_numbers, entry_maker = function(enumerated_line) return { + bufnr = bufnr, display = enumerated_line[2], ordinal = enumerated_line[2], @@ -818,17 +821,13 @@ builtin.current_buffer_fuzzy_find = function(opts) end }, sorter = sorters.get_generic_fuzzy_sorter(), - attach_mappings = function(prompt_bufnr, map) - local goto_line = function() - local selection = actions.get_selected_entry(prompt_bufnr) - actions.close(prompt_bufnr) - - vim.api.nvim_win_set_cursor(0, {selection.lnum, 0}) - vim.cmd [[stopinsert]] - end - - map('n', '<CR>', goto_line) - map('i', '<CR>', goto_line) + attach_mappings = function(prompt_bufnr) + actions._goto_file_selection:enhance { + post = vim.schedule_wrap(function() + local selection = actions.get_selected_entry(prompt_bufnr) + vim.api.nvim_win_set_cursor(0, {selection.lnum, 0}) + end), + } return true end |
