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

This commit is contained in:
Uthman Mohamed 2024-03-13 17:02:28 -04:00
parent cca2e09149
commit ad6eb7ed0b

View file

@ -129,6 +129,20 @@ 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" }, { 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>gG", function() Util.terminal({ "lazygit" }, {esc_esc = false, ctrl_hjkl = false}) end, { desc = "Lazygit (cwd)" })
-- Function to get the current file path from the root directory
local current_file_path_from_root_dir = function()
local path = vim.fn.expand("%:p")
local root = Util.root()
if not path:find(root, 1, true) then
return path
end
return path:sub(#root + 2)
end
map("n", "<leader>gf", function()
Util.terminal({ "lazygit", "-f", current_file_path_from_root_dir() }, { esc_esc = false, ctrl_hjkl = false })
end, { desc = "Lazygit current file history" })
-- quit -- quit
map("n", "<leader>qq", "<cmd>qa<cr>", { desc = "Quit all" }) map("n", "<leader>qq", "<cmd>qa<cr>", { desc = "Quit all" })