return { 'sindrets/diffview.nvim', config = function() vim.keymap.set('n', 'dv', ':DiffviewOpen', { silent = true }) vim.api.nvim_create_autocmd("User", { pattern = "DiffviewViewEnter", callback = function() vim.keymap.del('n', 'Ā') for _, buf in ipairs(vim.api.nvim_list_bufs()) do if vim.api.nvim_buf_is_loaded(buf) and vim.api.nvim_buf_get_name(buf) == "" and vim.bo[buf].buftype == "" then vim.api.nvim_buf_delete(buf, { force = true }) end end end, }) vim.api.nvim_create_autocmd("User", { pattern = "DiffviewViewLeave", callback = function() vim.keymap.set('n', 'Ā', ':NvimTreeToggle', { silent = true }) end, }) local actions = require("diffview.actions") require('diffview').setup({ view = { merge_tool = { disable_diagnostics = false }, }, keymaps = { view = { -- The `view` bindings are active in the diff buffers, only when the current -- tabpage is a Diffview. { "n", "", actions.select_next_entry, { desc = "Open the diff for the next file" } }, { "n", "", actions.select_prev_entry, { desc = "Open the diff for the previous file" } }, { "n", "[F", actions.select_first_entry, { desc = "Open the diff for the first file" } }, { "n", "]F", actions.select_last_entry, { desc = "Open the diff for the last file" } }, { "n", "gf", actions.goto_file_edit, { desc = "Open the file in the previous tabpage" } }, { "n", "", actions.goto_file_split, { desc = "Open the file in a new split" } }, { "n", "gf", actions.goto_file_tab, { desc = "Open the file in a new tabpage" } }, { "n", "Ā", actions.toggle_files, { desc = "Toggle the file panel." } }, { "n", "g", actions.cycle_layout, { desc = "Cycle through available layouts." } }, { "n", "", actions.prev_conflict, { desc = "In the merge-tool: jump to the previous conflict" } }, { "n", "", actions.next_conflict, { desc = "In the merge-tool: jump to the next conflict" } }, { "n", "gh", actions.conflict_choose("ours"), { desc = "Choose the OURS version of a conflict" } }, { "n", "gl", actions.conflict_choose("theirs"), { desc = "Choose the THEIRS version of a conflict" } }, { "n", "gb", actions.conflict_choose("base"), { desc = "Choose the BASE version of a conflict" } }, { "n", "ga", actions.conflict_choose("all"), { desc = "Choose all the versions of a conflict" } }, { "n", "gx", actions.conflict_choose("none"), { desc = "Delete the conflict region" } }, { "n", "gH", actions.conflict_choose_all("ours"), { desc = "Choose the OURS version of a conflict for the whole file" } }, { "n", "gL", actions.conflict_choose_all("theirs"), { desc = "Choose the THEIRS version of a conflict for the whole file" } }, { "n", "gB", actions.conflict_choose_all("base"), { desc = "Choose the BASE version of a conflict for the whole file" } }, { "n", "gA", actions.conflict_choose_all("all"), { desc = "Choose all the versions of a conflict for the whole file" } }, { "n", "gX", actions.conflict_choose_all("none"), { desc = "Delete the conflict region for the whole file" } }, }, file_panel = { { "n", "Ā", actions.toggle_files, { desc = "Toggle the file panel" } }, } } }) end }