feat(picker): Support git browse for a specific commit, directly from git objects like git_log git_log_line git_log_file.
Description
Right now there is not way to directly open a commit in browser from git log apart from checking out locally.
from any commit press gb in normal mode to open the commit in web.
Screenshots
I'm using LazyVim and I've added the keybinding config in my plugin config. I think it'd be good if we can add as the default keybinding
return {
"rjshrjndrn/snacks.nvim",
opts = function(_, opts)
local preview_window_opts = {
input = {
keys = {
["gb"] = {
"git_browse",
mode = { "n" },
},
},
},
}
local gitbrowse = require("snacks.gitbrowse")
return vim.tbl_deep_extend("force", opts or {}, {
picker = {
sources = {
git_log = {
win = preview_window_opts,
},
git_log_line = {
win = preview_window_opts,
},
git_log_file = {
win = preview_window_opts,
},
},
actions = {
git_browse = function(picker, item)
-- picker:close()
-- vim.notify(vim.inspect(item), vim.log.levels.INFO)
gitbrowse.open({ what = "commit", commit = item.commit })
end,
},
},
})
end,
}
If you press <M-w> to cycle through to the list window, then if you put your cursor over a commit sha and press <leader>gB it will do what you want.
PS: Oh you mean a separate action to directly operate on the commit itself, that's why you're exposing commit in opts. I misunderstood.
This will also close #393, which I believe is better to expose commit in opts if it's something that the maintainer would consider adding.
HI @folke Can you kindly have a look at the PR and suggest any changes needed.
Thank you.
This PR is stale because it has been open 30 days with no activity.
@folke Gentle reminder
This PR is stale because it has been open 30 days with no activity.