From 5c659f5a9f02a6f4a60a927acbbb6ed49621f34e Mon Sep 17 00:00:00 2001 From: Adam Beck Date: Tue, 8 Jul 2025 09:38:45 -0400 Subject: [PATCH] Add diffview --- lua/custom/plugins/init.lua | 56 +++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index 184afbf8..2d31323d 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -11,6 +11,62 @@ vim.keymap.set('n', 'cpe', ':Copilot enable', { silent = true, norem vim.g.copilot_enabled = false return { + { + 'sindrets/diffview.nvim', + dependencies = { 'nvim-lua/plenary.nvim' }, + config = function() + require('diffview').setup { + diff_binaries = false, -- Show diffs for binaries + enhanced_diff_hl = false, -- See ':h diffview-config-enhanced_diff_hl' + git_cmd = { 'git' }, -- The git executable followed by default args. + use_icons = true, -- Requires nvim-web-devicons + show_help_hints = true, -- Show hints for how to open the help panel + watch_index = true, -- Update views and index on git index changes. + icons = { -- Only applies when use_icons is true. + folder_closed = '', + folder_open = '', + }, + signs = { + fold_closed = '', + fold_open = '', + done = '✓', + }, + view = { + -- Configure the layout and behavior of different types of views. + -- Available layouts: + -- 'diff1_plain' + -- |'diff2_horizontal' + -- |'diff2_vertical' + -- |'diff3_horizontal' + -- |'diff3_vertical' + -- |'diff3_mixed' + -- |'diff4_mixed' + -- For more info, see ':h diffview-config-view.x.layout'. + default = { + -- Config for changed files, and staged files in diff views. + layout = 'diff2_horizontal', + winbar_info = false, -- See ':h diffview-config-view.x.winbar_info' + }, + merge_tool = { + -- Config for conflicted files in diff views during a merge or rebase. + layout = 'diff3_horizontal', + disable_diagnostics = true, -- Temporarily disable diagnostics for conflict buffers while in the view. + winbar_info = true, -- See ':h diffview-config-view.x.winbar_info' + }, + }, + } + + -- Diffview keymaps + vim.keymap.set('n', 'gd', ':DiffviewOpen', { desc = 'Open Diffview' }) + vim.keymap.set('n', 'gc', ':DiffviewClose', { desc = 'Close Diffview' }) + vim.keymap.set('n', 'gm', ':DiffviewOpen HEAD~1', { desc = 'Compare with previous commit' }) + vim.keymap.set('n', 'gh', ':DiffviewFileHistory', { desc = 'File history' }) + vim.keymap.set('n', 'gH', ':DiffviewFileHistory %', { desc = 'Current file history' }) + + -- For merge conflicts specifically + vim.keymap.set('n', 'gco', ':DiffviewOpen', { desc = 'Open merge conflict view' }) + end, + }, { 'olrtg/nvim-emmet', config = function()