-
-
Notifications
You must be signed in to change notification settings - Fork 192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: fall back to a function with BufferLinePick #230
Comments
my usecase is this:
Though it works now, but there's a bit of delay from pressing space to the actual telescope picker open |
Okay found the reason of the delay and did this -- Prompts user to select a buffer then applies a function to the buffer
---@param func fun(buf_id: number)
local function select_buffer_apply(func)
state.is_picking = true
local picked = false
refresh()
local char = vim.fn.getchar()
local letter = vim.fn.nr2char(char)
for _, item in ipairs(state.tabs) do
local buf = item:as_buffer()
if buf and letter == buf.letter then
func(buf.id)
picked = true
elseif buf and letter == "\27" then -- ignore escape
picked = true
end
end
state.is_picking = false
refresh()
return picked
end
function M.pick_buffer()
if not select_buffer_apply(function(buf_id)
vim.cmd("buffer " .. buf_id)
end) then
vim.cmd "Telescope buffers"
end
end
|
Hi @tami5, So tbh I think adding a fallback is a complexity I'd rather leave to users since this seems like a specific workflow rather than general functionality that the majority of users need. I think your final example which just adds a return value to If you have time to submit a PR would be happy to add a return value so you can implement picker buffer like that in your config. Otherwise I'll leave this open till when I have time in the future to add it. |
Gonna close this out or it'll be here forever. I personally have just never needed this and it hasn't been requested again after over a year now. I'm definitely happy to take it as a contribution but I think it's not something I'm personally going to get to. |
Hey @akinsho
I have set a mapping to pick a buffer tab, but I wanted to have a fall back function (in my case telescope buffer)
I've changed select_buffer_apply a bit, but not sure how to make it configurable
The text was updated successfully, but these errors were encountered: