local cb = require "diffview.config".diffview_callback require "diffview".setup { diff_binaries = false, -- Show diffs for binaries use_icons = true, -- Requires nvim-web-devicons key_bindings = { disable_defaults = false, -- Disable the default key bindings -- The `view` bindings are active in the diff buffers, only when the current -- tabpage is a Diffview. view = { [""] = cb("select_next_entry"), -- Open the diff for the next file [""] = cb("select_prev_entry"), -- Open the diff for the previous file ["e"] = cb("focus_files"), -- Bring focus to the files panel ["b"] = cb("toggle_files") -- Toggle the files panel. }, file_panel = { ["j"] = cb("next_entry"), -- Bring the cursor to the next file entry [""] = cb("next_entry"), ["k"] = cb("prev_entry"), -- Bring the cursor to the previous file entry. [""] = cb("prev_entry"), [""] = cb("select_entry"), -- Open the diff for the selected entry. ["o"] = cb("select_entry"), ["<2-LeftMouse>"] = cb("select_entry"), ["-"] = cb("toggle_stage_entry"), -- Stage / unstage the selected entry. ["S"] = cb("stage_all"), -- Stage all entries. ["U"] = cb("unstage_all"), -- Unstage all entries. ["R"] = cb("refresh_files"), -- Update stats and entries in the file list. [""] = cb("select_next_entry"), [""] = cb("select_prev_entry"), ["e"] = cb("focus_files"), ["b"] = cb("toggle_files") } } } vim.api.nvim_set_keymap("n", "g", ":DiffviewOpen", {silent = true}) vim.api.nvim_set_keymap("n", "G", ":DiffviewClose", {silent = true})