From 0ec7a9040b60943597649940619f23bfa4b46990 Mon Sep 17 00:00:00 2001 From: Uthman Mohamed <83053931+uthmanmoh@users.noreply.github.com> Date: Wed, 13 Mar 2024 19:06:47 -0400 Subject: [PATCH] feat(git): add gf for lazygit commit history on current file (#2728) * Add gf for lazygit commit history on current file * Change root dir to git root using git command * refactor: cleanup --------- Co-authored-by: Uthman Mohamed <83053931+1239uth@users.noreply.github.com> Co-authored-by: Folke Lemaitre --- lua/lazyvim/config/keymaps.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lua/lazyvim/config/keymaps.lua b/lua/lazyvim/config/keymaps.lua index 1e7cc1a2..e829973d 100644 --- a/lua/lazyvim/config/keymaps.lua +++ b/lua/lazyvim/config/keymaps.lua @@ -129,6 +129,11 @@ map("n", "ub", function() Util.toggle("background", false, {"light", "da map("n", "gg", function() Util.terminal({ "lazygit" }, { cwd = Util.root(), esc_esc = false, ctrl_hjkl = false }) end, { desc = "Lazygit (root dir)" }) map("n", "gG", function() Util.terminal({ "lazygit" }, {esc_esc = false, ctrl_hjkl = false}) end, { desc = "Lazygit (cwd)" }) +map("n", "gf", function() + local git_path = vim.fn.system("git ls-files --full-name " .. vim.api.nvim_buf_get_name(0)) + Util.terminal({ "lazygit", "-f", vim.trim(git_path) }, { esc_esc = false, ctrl_hjkl = false }) +end, { desc = "Lazygit current file history" }) + -- quit map("n", "qq", "qa", { desc = "Quit all" })