Skip to content

Commit

Permalink
fix(nvim): telescope enter to open selected
Browse files Browse the repository at this point in the history
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
  • Loading branch information
caarlos0 committed Mar 16, 2024
1 parent 0fd49cd commit f456716
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions modules/neovim/config/lua/user/telescope.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,27 @@
local telescope = require("telescope")

local select_one_or_multi = function(prompt_bufnr)
local picker = require("telescope.actions.state").get_current_picker(prompt_bufnr)
local multi = picker:get_multi_selection()
if not vim.tbl_isempty(multi) then
require("telescope.actions").close(prompt_bufnr)
for _, j in pairs(multi) do
if j.path ~= nil then
vim.cmd(string.format("%s %s", "edit", j.path))
end
end
else
require("telescope.actions").select_default(prompt_bufnr)
end
end

telescope.setup({
defaults = {
mappings = {
i = {
["<CR>"] = select_one_or_multi,
},
},
prompt_prefix = "",
selection_caret = "",
entry_prefix = " ",
Expand Down

0 comments on commit f456716

Please sign in to comment.