Skip to content

Commit

Permalink
Add diffview mappings
Browse files Browse the repository at this point in the history
  • Loading branch information
thallada committed Dec 1, 2023
1 parent 299e3dd commit 76d8cc8
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
5 changes: 4 additions & 1 deletion lua/install-plugins.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
20 changes: 20 additions & 0 deletions lua/plugins/diffview.lua
Original file line number Diff line number Diff line change
@@ -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" })
2 changes: 1 addition & 1 deletion lua/plugins/fugitive.lua
Original file line number Diff line number Diff line change
@@ -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" })
Expand Down

0 comments on commit 76d8cc8

Please sign in to comment.