summaryrefslogtreecommitdiff
path: root/lua/plugins/fugitive.lua
diff options
context:
space:
mode:
authorMichiel Schuurmans <michielschuurmans@gmail.com>2025-11-12 10:01:42 +0100
committerMichiel Schuurmans <michielschuurmans@gmail.com>2025-11-12 10:01:42 +0100
commited8094042fcab613771b1ee74883828d1a7310b3 (patch)
tree8d27fad322fb606fcced7359e49a5a7f8435a7d2 /lua/plugins/fugitive.lua
downloadnvim-ed8094042fcab613771b1ee74883828d1a7310b3.tar.xz
nvim-ed8094042fcab613771b1ee74883828d1a7310b3.zip
Base config
Diffstat (limited to 'lua/plugins/fugitive.lua')
-rw-r--r--lua/plugins/fugitive.lua38
1 files changed, 38 insertions, 0 deletions
diff --git a/lua/plugins/fugitive.lua b/lua/plugins/fugitive.lua
new file mode 100644
index 0000000..1739932
--- /dev/null
+++ b/lua/plugins/fugitive.lua
@@ -0,0 +1,38 @@
+return {
+ "tpope/vim-fugitive",
+ config = function()
+ vim.keymap.set("n", "<leader>gs", vim.cmd.Git)
+
+ local ThePrimeagen_Fugitive = vim.api.nvim_create_augroup("ThePrimeagen_Fugitive", {})
+
+ local autocmd = vim.api.nvim_create_autocmd
+ autocmd("BufWinEnter", {
+ group = ThePrimeagen_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}
+ vim.keymap.set("n", "<leader>p", function()
+ vim.cmd.Git('push')
+ end, opts)
+
+ -- rebase always
+ vim.keymap.set("n", "<leader>P", function()
+ vim.cmd.Git({'pull', '--rebase'})
+ 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>t", ":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
+}