Skip to content

Commit

Permalink
feat(git): add <leader>gf for lazygit commit history on current file (L…
Browse files Browse the repository at this point in the history
…azyVim#2728)

* Add <leader>gf for lazygit commit history on current file

* Change root dir to git root using git command

* refactor: cleanup

---------

Co-authored-by: Uthman Mohamed <[email protected]>
Co-authored-by: Folke Lemaitre <[email protected]>
  • Loading branch information
3 people authored and anjotadena committed Apr 9, 2024
1 parent 1a41e22 commit c6c5f92
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lua/lazyvim/config/keymaps.lua
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ map("n", "<leader>ub", function() Util.toggle("background", false, {"light", "da
map("n", "<leader>gg", function() Util.terminal({ "lazygit" }, { cwd = Util.root(), esc_esc = false, ctrl_hjkl = false }) end, { desc = "Lazygit (root dir)" })
map("n", "<leader>gG", function() Util.terminal({ "lazygit" }, {esc_esc = false, ctrl_hjkl = false}) end, { desc = "Lazygit (cwd)" })

map("n", "<leader>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", "<leader>qq", "<cmd>qa<cr>", { desc = "Quit all" })

Expand Down

0 comments on commit c6c5f92

Please sign in to comment.