Add diffview mappings

This commit is contained in:
Tyler Hallada 2023-12-01 15:26:00 -05:00
parent 299e3dde49
commit 76d8cc8d6e
3 changed files with 25 additions and 2 deletions

View File

@ -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 {

20
lua/plugins/diffview.lua Normal file
View File

@ -0,0 +1,20 @@
local actions = require("diffview.actions")
require("diffview").setup({
keymaps = {
view = {
["gq"] = "<Cmd>DiffviewClose<CR>",
},
file_panel = {
["gq"] = "<Cmd>DiffviewClose<CR>",
},
file_history_panel = {
["gq"] = "<Cmd>DiffviewClose<CR>",
},
}
})
vim.keymap.set('v', '<leader>gl', [[<Cmd>'<,'>DiffviewFileHistory<CR>]], { noremap = false, silent = true, desc = "Toggle [G]it [L]og of selected lines" })
vim.keymap.set('n', '<leader>gL', [[<Cmd>DiffviewFileHistory<CR>]], { noremap = false, silent = true, desc = "Toggle [G]it [L]og of current branch" })
vim.keymap.set('n', '<leader>gl', [[<Cmd>DiffviewFileHistory %<CR>]], { noremap = false, silent = true, desc = "Toggle [G]it [L]og of current file history" })
vim.keymap.set('n', '<leader>gd', [[<Cmd>DiffviewOpen<CR>]], { noremap = false, silent = true, desc = "[G]it [D]iff current file against index" })

View File

@ -1,6 +1,6 @@
vim.keymap.set('n', '<leader>gx', [[<Cmd>G<CR>]], { noremap = false, silent = true, desc = "Toggle [G]it status window" })
vim.keymap.set('n', '<leader>gs', [[<Cmd>Git<CR>]], { noremap = false, silent = true, desc = "Toggle [G]it [S]tatus window" })
vim.keymap.set('n', '<leader>gd', [[<Cmd>Gdiffsplit<CR>]], { noremap = false, silent = true, desc = "[G]it [D]iff current file against index" })
vim.keymap.set('n', '<leader>gfd', [[<Cmd>Gdiffsplit<CR>]], { noremap = false, silent = true, desc = "[G]it [D]iff current file against index with [F]ugitive" })
vim.keymap.set('n', '<leader>gc', [[<Cmd>Git commit<CR>]], { noremap = false, silent = true, desc = "[G]it [C]ommit" })
vim.keymap.set('n', '<leader>gb', [[<Cmd>Git blame -C<CR>]], { noremap = false, silent = true, desc = "[G]it [B]lame" })
vim.keymap.set('n', '<leader>gp', [[<Cmd>Git push<CR>]], { noremap = false, silent = true, desc = "[G]it [P]ush" })