From 7b66c9995381054b4e63eacaebc242f519b69c0e Mon Sep 17 00:00:00 2001 From: Miguel Da Silva Date: Tue, 10 Sep 2024 18:33:25 +0200 Subject: [PATCH] Add fugitive --- lua/lazy_plugins.lua | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/lua/lazy_plugins.lua b/lua/lazy_plugins.lua index 99d5cdd1..5d8ed9ef 100644 --- a/lua/lazy_plugins.lua +++ b/lua/lazy_plugins.lua @@ -1,6 +1,43 @@ -- NOTE: Here is where you install your plugins. require('lazy').setup({ -- NOTE: Plugins can be added with a link (or for a github repo: 'owner/repo' link). + -- + { + 'tpope/vim-fugitive', + + config = function() + vim.keymap.set('n', 'gs', vim.cmd.Git) + + local mimivalsi_fugitive = vim.api.nvim_create_augroup('mimivalsi_fugitive', {}) + + local autocmd = vim.api.nvim_create_autocmd + autocmd('BufWinEnter', { + group = mimivalsi_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', 'p', function() + vim.cmd.Git 'push' + end, opts) + + vim.keymap.set('n', 'P', function() + vim.cmd.Git { 'pull', '--rebase' } + end, opts) + + vim.keymap.set('n', 'o', ':Git push -u origin', opts) + end, + }) + + vim.keymap.set('n', 'gu', 'diffget //2') + vim.keymap.set('n', 'gh', 'diffget //3') + end, + }, + 'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically -- NOTE: Plugins can also be added by using a table,