From 4a96e6457b0a0241ca7361ce62177aa6b9a33a38 Mon Sep 17 00:00:00 2001 From: mpaulson Date: Wed, 14 Dec 2022 06:22:00 -0700 Subject: [PATCH] feat: fugitive keymap updates chore testing noteuh:wq --- after/plugin/fugitive.lua | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/after/plugin/fugitive.lua b/after/plugin/fugitive.lua index dd4fcc30..067d8a98 100644 --- a/after/plugin/fugitive.lua +++ b/after/plugin/fugitive.lua @@ -1,2 +1,31 @@ vim.keymap.set("n", "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() + print("help", vim.bo.ft) + if vim.bo.ft ~= "fugitive" then + return + end + + local bufnr = vim.api.nvim_get_current_buf() + local opts = {buffer = bufnr, remap = false} + print("great success", vim.bo.ft, bufnr, vim.inspect(opts)) + vim.keymap.set("n", "p", function() + vim.cmd [[ Git push ]] + end, opts) + + -- rebase always + vim.keymap.set("n", "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", "t", ":Git push -u origin ", opts); + end, +})