-
Hello! I am trying to make a custom source using the "select" layout preset. Specifically, I want to add rebind a keymap to a custom function while in the input field. I tried the following, but hitting ctrl+r while in the input activates the regular binding (showing registers). Snacks.picker.pick({
source = "mysource",
items = { { text = "test1" }, { text = "test2" } },
format = "text",
layout = {
preset = "select",
layout = { title = " My picker " },
},
win = {
input = {
keys = {
["<c-r>"] = {
"refresh",
function()
print("Refreshing")
end,
mode = "i",
},
},
},
},
confirm = function(picker, item)
picker:close()
if item then
print("Selected: " .. item.text)
end
end,
}) What do I lack for it to work? Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Answered by
pkazmier
Jan 20, 2025
Replies: 1 comment 7 replies
-
Try this version instead. Your keymap needs to point to an action: Snacks.picker.pick({
source = "mysource",
items = { { text = "test1" }, { text = "test2" } },
format = "text",
layout = {
preset = "select",
layout = { title = " My picker " },
},
win = {
input = {
keys = {
["<c-r>"] = { "refresh", mode = "i" },
},
},
},
actions = {
refresh = function(picker, item)
vim.notify("Hello, world")
end,
},
confirm = function(picker, item)
picker:close()
if item then
vim.notify("Selected: " .. item.text)
end
end,
})
|
Beta Was this translation helpful? Give feedback.
7 replies
Answer selected by
Silzinc
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Try this version instead. Your keymap needs to point to an action: