telescope.nvim
telescope.nvim copied to clipboard
Let user configure how `select_default` will edit file: `edit`, `new`, `vnew` or `tabedit`
Is your feature request related to a problem? Please describe.
I'm get used to avoid multiple windows and always open new files in a tabs, so I'd like to use <Enter> to open files in a tab instead of split window - it's much more convenient than <C-T>.
The problem is current select_default action does two things: open Telescope submenu or open files.
Because of this trivial solution "just remap <Enter> to select_tab" breaks all menu items which are not a file to be opened (e.g. colorshemes, etc.).
Describe the solution you'd like
Add a setup option with one of "edit", "new", "vnew" or "tabedit" values to configure select_default action.
Describe alternatives you've considered We can monkey-patch to make this work. But, as usually, monkey-patch is complicated and fragile workaround.
-- Force opening files in a new tab.
local actions_state = require 'telescope.actions.state'
local select_key_to_edit_key = actions_state.select_key_to_edit_key
actions_state.select_key_to_edit_key = function(type) ---@diagnostic disable-line: duplicate-set-field
local key = select_key_to_edit_key(type)
return key == 'edit' and 'tabedit' or key
end
alternative way, it works for me
defaults = {
mappings = {
i = {
["<CR>"] = require("telescope.actions").select_tab,
},
n = {
["<CR>"] = require("telescope.actions").select_tab,
},
},
},
pickers = {
find_files = {
mappings = {
i = {
["<CR>"] = require("telescope.actions").select_tab,
},
},
},
},