Replies: 8 comments
-
You have examples on how to transform callback functions to async functions in utils.lua, for this case I think it would look something like this: functions = {
buffer = {
description = "Pick a buffer to include in chat context.",
schema = {
type = 'object',
required = { 'name' },
properties = {
name = {
type = 'string',
description = 'Buffer number to include in chat context.',
enum = function()
local chat_winid = vim.api.nvim_get_current_win()
local async = require('plenary.async')
local fn = async.wrap(function(callback)
Snacks.picker.buffers({
confirm = function(picker, item)
picker:close()
-- Return focus to the chat window
if vim.api.nvim_win_is_valid(chat_winid) then
vim.api.nvim_set_current_win(chat_winid)
vim.cmd("normal! a")
end
vim.schedule(function()
callback(item.buf)
end)
end,
})
end, 1)
return fn()
end,
},
},
},
}
} and then ofc resolve function that accepts the input buffer number as input.name property. I dont really want to bring back input because it was heavily limiting the plugin as it only supported single choices, where schema supports multiple, optional arguemnts etc (and that is important for tool calling but also for more advanced functions) |
Beta Was this translation helpful? Give feedback.
-
thanks, I got further with your help. But the return of that enum, still gets fed to a |
Beta Was this translation helpful? Give feedback.
-
Ah i see what you mean. Yea i can just auto accept when enum returns only 1 item but this is quite weird use case, any reason why you arent just overriding vim.ui.select instead in this case? |
Beta Was this translation helpful? Give feedback.
-
Either way, your use case should now be supported: e632470 |
Beta Was this translation helpful? Give feedback.
-
because I would like to use snacks.picker.buffers where I have a preview of the buffer's contents and some other customizations |
Beta Was this translation helpful? Give feedback.
-
Hmm makes sense i guess, the vim.ui.select api isnt the most flexible thing ever |
Beta Was this translation helpful? Give feedback.
-
hey, this was working for me yesterday night, now it stopped calling my custom Another reason why I'd like to use a custom picker, is because the default doesn't list hidden buffers only the active and the alternative. |
Beta Was this translation helpful? Give feedback.
-
In case it is helpful, this is how I got telescope going, not sure if there is an easier way, I find the UI way nicer that stock config. https://github.com/SamSaffron/dotfiles/blob/master/nvim/lua/plugins/ai.lua
![]() Note that telescope has an API for multiple file picking but I am not sure if this API can support it cause enum needs to return only 1 thing, and we would need something in the engine to go from: #file:.... ⏬ #file:file1 cause multi files in one line would be very noise visually. |
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.
-
hi, are there any general guidelines on how to migrate code from old
contexts
configs to the newfunctions
?Example, I have a custom
buffer
context with an integration withsnacks.picker
.How do I migrate this to
functions
?Beta Was this translation helpful? Give feedback.
All reactions