Replies: 2 comments 2 replies
-
|
Hi there, not out-of-the-box, but something akin to this is very easily achieved with, for instance, the below pattern (to get you started). You may or may not want to filter as to whether the window is also in the current tabpage and if not fall back to showing the buffer in the current window, of course. Many ways lead to Rome. We are currently revamping our docs and I can only wholeheartedly recommend https://github.com/Conni2461/telescope.nvim/blob/docs_rework/developers.md (preview of what's coming) to learn about actions and more. local actions = require "telescope.actions"
local action_state = require "telescope.actions.state"
require("telescope.builtin").buffers {
attach_mappings = function(_, map)
map("i", "<C-j>", function(prompt_bufnr)
local bufnr = action_state.get_selected_entry().bufnr
local winid = vim.tbl_filter(function(win)
return vim.api.nvim_win_get_buf(win) == bufnr
end, vim.api.nvim_list_wins())[1]
actions.close(prompt_bufnr)
vim.api.nvim_set_current_win(winid)
-- easily add fallback, only for current tabpage, etc.
end)
return true
end,
}You can also then add this function to your require("telescope").setup {
pickers = {
buffers = {
mappings = {
i = {
["<c-j>"] = function(prompt_bufnr) ... end,
},
}
},
},
} |
Beta Was this translation helpful? Give feedback.
-
|
I got "Invalid window id" error in most cases. require("telescope").setup {
pickers = {
buffers = {
mappings = {
i = {
["<CR>"] = function(prompt_bufnr)
local bufnr = require("telescope.actions.state").get_selected_entry().bufnr
require("telescope.actions").close(prompt_bufnr) -- move to here!
local winid = vim.tbl_filter(function(win)
return vim.api.nvim_win_get_buf(win) == bufnr
end, vim.api.nvim_list_wins())[1]
vim.api.nvim_set_current_win(winid)
end
},
}
},
},
} |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
👋 folks, thanks for this great project!
Does anybody know if telescope provides something similar to fzf.vim's
fzf_buffers_jump?It basically jumps to an existing window if the buffer you are navigating to is already being shown.
Thanks!
[EDIT: link to fzf's doc.]
Beta Was this translation helpful? Give feedback.
All reactions