From ace830ed5efa9adfb03f2b68c00063125a2cc5bd Mon Sep 17 00:00:00 2001 From: joelazar Date: Mon, 5 Oct 2026 15:41:36 +0200 Subject: [PATCH] :sparkles: add keymap to open blamed commit in browser --- lua/config/keymaps.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lua/config/keymaps.lua b/lua/config/keymaps.lua index a871637..41dd7a7 100644 --- a/lua/config/keymaps.lua +++ b/lua/config/keymaps.lua @@ -249,3 +249,14 @@ if vim.g.neovide then map("i", "", "^", { desc = "Start of line" }) map("i", "", "", { desc = "End of line" }) end + +vim.keymap.set("n", "gO", function() + local file = vim.fn.expand("%:p") + local line = vim.fn.line(".") + local out = vim.fn.systemlist({ "git", "-C", vim.fn.expand("%:p:h"), "blame", "-L", line .. "," .. line, "--porcelain", file }) + local sha = out[1] and out[1]:match("^(%x+)") + if not sha or sha:match("^0+$") then + return Snacks.notify.warn("Line not committed yet") + end + Snacks.gitbrowse({ what = "commit", commit = sha }) +end, { desc = "Open blamed commit in browser" }) -- 2.51.2