From 76d8cc8d6ecef44d2a6d1a6183997698d812c146 Mon Sep 17 00:00:00 2001 From: Tyler Hallada Date: Fri, 1 Dec 2023 15:26:00 -0500 Subject: [PATCH] Add diffview mappings --- lua/install-plugins.lua | 5 ++++- lua/plugins/diffview.lua | 20 ++++++++++++++++++++ lua/plugins/fugitive.lua | 2 +- 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 lua/plugins/diffview.lua diff --git a/lua/install-plugins.lua b/lua/install-plugins.lua index c05e6f6..66a2d74 100644 --- a/lua/install-plugins.lua +++ b/lua/install-plugins.lua @@ -267,7 +267,10 @@ return require('packer').startup(function(use) } use { 'sindrets/diffview.nvim', - requires = 'nvim-lua/plenary.nvim' + requires = 'nvim-lua/plenary.nvim', + config = function() + require('plugins.diffview') + end, } use 'kyazdani42/nvim-web-devicons' use { diff --git a/lua/plugins/diffview.lua b/lua/plugins/diffview.lua new file mode 100644 index 0000000..23c554f --- /dev/null +++ b/lua/plugins/diffview.lua @@ -0,0 +1,20 @@ +local actions = require("diffview.actions") + +require("diffview").setup({ + keymaps = { + view = { + ["gq"] = "DiffviewClose", + }, + file_panel = { + ["gq"] = "DiffviewClose", + }, + file_history_panel = { + ["gq"] = "DiffviewClose", + }, + } +}) + +vim.keymap.set('v', 'gl', [['<,'>DiffviewFileHistory]], { noremap = false, silent = true, desc = "Toggle [G]it [L]og of selected lines" }) +vim.keymap.set('n', 'gL', [[DiffviewFileHistory]], { noremap = false, silent = true, desc = "Toggle [G]it [L]og of current branch" }) +vim.keymap.set('n', 'gl', [[DiffviewFileHistory %]], { noremap = false, silent = true, desc = "Toggle [G]it [L]og of current file history" }) +vim.keymap.set('n', 'gd', [[DiffviewOpen]], { noremap = false, silent = true, desc = "[G]it [D]iff current file against index" }) diff --git a/lua/plugins/fugitive.lua b/lua/plugins/fugitive.lua index be12d3e..836fa84 100644 --- a/lua/plugins/fugitive.lua +++ b/lua/plugins/fugitive.lua @@ -1,6 +1,6 @@ vim.keymap.set('n', 'gx', [[G]], { noremap = false, silent = true, desc = "Toggle [G]it status window" }) vim.keymap.set('n', 'gs', [[Git]], { noremap = false, silent = true, desc = "Toggle [G]it [S]tatus window" }) -vim.keymap.set('n', 'gd', [[Gdiffsplit]], { noremap = false, silent = true, desc = "[G]it [D]iff current file against index" }) +vim.keymap.set('n', 'gfd', [[Gdiffsplit]], { noremap = false, silent = true, desc = "[G]it [D]iff current file against index with [F]ugitive" }) vim.keymap.set('n', 'gc', [[Git commit]], { noremap = false, silent = true, desc = "[G]it [C]ommit" }) vim.keymap.set('n', 'gb', [[Git blame -C]], { noremap = false, silent = true, desc = "[G]it [B]lame" }) vim.keymap.set('n', 'gp', [[Git push]], { noremap = false, silent = true, desc = "[G]it [P]ush" })