How to use selection from picker? #605
Unanswered
patrick-motard
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Here is how you can modify {
"snacks.nvim",
opts = {
---@type snacks.picker.Config
picker = {
sources = {
git_log_file = {
confirm = function(picker, item)
vim.notify("Copied " .. item.commit .. " to clipboard")
vim.fn.setreg("+", item.commit)
picker:close()
end,
},
},
},
},
}, And if you wanted to bind keys to those actions you mentioned, here is a sample keybinding to get your started: git_log_file = {
actions = {
my_action = function(picker, item)
vim.notify(vim.inspect(item))
picker:close()
end,
},
win = {
input = {
keys = {
["<a-c>"] = { "my_action", mode = { "i", "n" } },
},
},
},
}, |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
For context,
Snacks.picker.git_log_file()
lists all git commits for the current buffer. Selecting one or more commits doesn't seem to do anything.Ideally, I want to take the selected commit and proceed to a second list of actions I can take for that commit. For example:
I would be happy if i could just get the commit hash somehow from the selection. I'm thinking if i had that, perhaps in the function i hand to the keybinding i could access that selected value and attempt the things I mentioned above.
TLDR: How can we access the selection from the picker?
Beta Was this translation helpful? Give feedback.
All reactions