--[[ Copyright 2023 Oscar Wallberg Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ]] local cb = require "diffview.config".diffview_callback require "diffview".setup { diff_binaries = false, -- Show diffs for binaries enhanced_diff_hl = true, -- See ':h diffview-config-enhanced_diff_hl' use_icons = true, -- Requires nvim-web-devicons icons = { -- Only applies when use_icons is true. folder_closed = "", folder_open = "", }, signs = { fold_closed = "", fold_open = "", }, file_panel = { position = "left", -- One of 'left', 'right', 'top', 'bottom' width = 35, -- Only applies when position is 'left' or 'right' height = 10, -- Only applies when position is 'top' or 'bottom' listing_style = "tree", -- One of 'list' or 'tree' tree_options = { -- Only applies when listing_style is 'tree' flatten_dirs = true, -- Flatten dirs that only contain one single dir folder_statuses = "only_folded", -- One of 'never', 'only_folded' or 'always'. }, }, file_history_panel = { position = "bottom", width = 35, height = 16, log_options = { max_count = 256, -- Limit the number of commits follow = false, -- Follow renames (only for single file) all = false, -- Include all refs under 'refs/' including HEAD merges = false, -- List only merge commits no_merges = false, -- List no merge commits reverse = false, -- List commits in reverse order }, }, default_args = { -- Default args prepended to the arg-list for the listed commands DiffviewOpen = {}, DiffviewFileHistory = {}, }, hooks = {}, -- See ':h diffview-config-hooks' 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 ["gf"] = cb("goto_file"), -- Open the file in a new split in previous tabpage [""] = cb("goto_file_split"), -- Open the file in a new split ["gf"] = cb("goto_file_tab"), -- Open the file in a new tabpage ["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. ["X"] = cb("restore_entry"), -- Restore entry to the state on the left side. ["R"] = cb("refresh_files"), -- Update stats and entries in the file list. [""] = cb("select_next_entry"), [""] = cb("select_prev_entry"), ["gf"] = cb("goto_file"), [""] = cb("goto_file_split"), ["gf"] = cb("goto_file_tab"), ["i"] = cb("listing_style"), -- Toggle between 'list' and 'tree' views ["f"] = cb("toggle_flatten_dirs"), -- Flatten empty subdirectories in tree listing style. ["e"] = cb("focus_files"), ["b"] = cb("toggle_files"), }, file_history_panel = { ["g!"] = cb("options"), -- Open the option panel [""] = cb("open_in_diffview"), -- Open the entry under the cursor in a diffview ["y"] = cb("copy_hash"), -- Copy the commit hash of the entry under the cursor ["zR"] = cb("open_all_folds"), ["zM"] = cb("close_all_folds"), ["j"] = cb("next_entry"), [""] = cb("next_entry"), ["k"] = cb("prev_entry"), [""] = cb("prev_entry"), [""] = cb("select_entry"), ["o"] = cb("select_entry"), ["<2-LeftMouse>"] = cb("select_entry"), [""] = cb("select_next_entry"), [""] = cb("select_prev_entry"), ["gf"] = cb("goto_file"), [""] = cb("goto_file_split"), ["gf"] = cb("goto_file_tab"), ["e"] = cb("focus_files"), ["b"] = cb("toggle_files"), }, option_panel = { [""] = cb("select"), ["q"] = cb("close"), }, }, }