feat(git): add <leader>gf for lazygit commit history on current file (#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 <83053931+1239uth@users.noreply.github.com>
Co-authored-by: Folke Lemaitre <folke.lemaitre@gmail.com>
This commit is contained in:
Uthman Mohamed 2024-03-13 19:06:47 -04:00 committed by GitHub
parent cca2e09149
commit 0ec7a9040b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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" })