added fugitive

This commit is contained in:
n 2024-10-27 07:46:32 +00:00
parent 49ac91e246
commit 8c7fb8053b

34
lua/nat/lazy/fugitive.lua Normal file
View File

@ -0,0 +1,34 @@
return {
"tpope/vim-fugitive",
config = function()
vim.keymap.set("n", "<leader>gs", vim.cmd.Git)
local nat_Fugitive = vim.api.nvim_create_augroup("nat_Fugitive", {})
local autocmd = vim.api.nvim_create_autocmd
autocmd("BufWinEnter", {
group = nat_Fugitive,
pattern = "*",
callback = function()
if vim.bo.ft ~= "fugitive" then
return
end
local bufnr = vim.api.nvim_get_current_buf()
local opts = {buffer = bufnr, remap = false}
-- rebase always
vim.keymap.set("n", "<leader>gp", function() vim.cmd.Git({'pull', '--rebase'}) end, opts)
vim.keymap.set("n", "<leader>gP", function() vim.cmd.Git('push') end, opts)
-- NOTE: It allows me to easily set the branch i am pushing and any tracking
-- needed if i did not set the branch up correctly
vim.keymap.set("n", "<leader>gT", ":Git push -u origin ", opts);
end,
})
vim.keymap.set("n", "gu", "<cmd>diffget //2<CR>")
vim.keymap.set("n", "gh", "<cmd>diffget //3<CR>")
end
}