some updates

This commit is contained in:
Léana 江 2023-03-25 00:15:20 +01:00
parent 3144c50fca
commit 418aa03ecc
6 changed files with 207 additions and 108 deletions

View file

@ -1,15 +1,15 @@
-- Lua
local actions = require("diffview.actions")
require("diffview").setup({
diff_binaries = false, -- Show diffs for binaries
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.
hg_cmd = { "hg" }, -- The hg 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 buffers when the git index changes.
icons = { -- Only applies when use_icons is true.
git_cmd = { "git" }, -- The git executable followed by default args.
hg_cmd = { "hg" }, -- The hg 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 buffers when the git index changes.
icons = {
-- Only applies when use_icons is true.
folder_closed = "",
folder_open = "",
},
@ -38,7 +38,7 @@ require("diffview").setup({
-- 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'
winbar_info = true, -- See ':h diffview-config-view.x.winbar_info'
},
file_history = {
-- Config for changed files in file history views.
@ -47,19 +47,22 @@ require("diffview").setup({
},
},
file_panel = {
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
listing_style = "list", -- 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'.
},
win_config = { -- See ':h diffview-config-win_config'
win_config = {
-- See ':h diffview-config-win_config'
position = "left",
width = 35,
win_opts = {}
},
},
file_history_panel = {
log_options = { -- See ':h diffview-config-log_options'
log_options = {
-- See ':h diffview-config-log_options'
git = {
single_file = {
diff_merges = "combined",
@ -73,7 +76,8 @@ require("diffview").setup({
multi_file = {},
},
},
win_config = { -- See ':h diffview-config-win_config'
win_config = {
-- See ':h diffview-config-win_config'
position = "bottom",
height = 16,
win_opts = {}
@ -84,26 +88,33 @@ require("diffview").setup({
win_opts = {},
}
},
default_args = { -- Default args prepended to the arg-list for the listed commands
default_args = {
-- Default args prepended to the arg-list for the listed commands
DiffviewOpen = {},
DiffviewFileHistory = {},
},
hooks = {}, -- See ':h diffview-config-hooks'
hooks = {}, -- See ':h diffview-config-hooks'
keymaps = {
disable_defaults = false, -- Disable the default keymaps
view = {
-- The `view` bindings are active in the diff buffers, only when the current
-- tabpage is a Diffview.
{ "n", "<tab>", actions.select_next_entry, { desc = "Open the diff for the next file" } },
{ "n", "<s-tab>", actions.select_prev_entry, { desc = "Open the diff for the previous file" } },
{ "n", "gf", actions.goto_file_edit, { desc = "Open the file in the previous tabpage" } },
{ "n", "<C-w><C-f>", actions.goto_file_split, { desc = "Open the file in a new split" } },
{ "n", "<C-w>gf", actions.goto_file_tab, { desc = "Open the file in a new tabpage" } },
{ "n", "<leader>e", actions.focus_files, { desc = "Bring focus to the file panel" } },
{ "n", "<leader>b", actions.toggle_files, { desc = "Toggle the file panel." } },
{ "n", "g<C-x>", actions.cycle_layout, { desc = "Cycle through available layouts." } },
{ "n", "[x", actions.prev_conflict, { desc = "In the merge-tool: jump to the previous conflict" } },
{ "n", "]x", actions.next_conflict, { desc = "In the merge-tool: jump to the next conflict" } },
{ "n", "<tab>", actions.select_next_entry, { desc = "Open the diff for the next file" } },
{ "n", "<S-tab>", actions.select_prev_entry, { desc = "Open the diff for the previous file" } },
{ "n", "gf", actions.goto_file_edit, { desc = "Open the file in the previous tabpage" } },
{ "n", "<C-w><C-f>", actions.goto_file_split, { desc = "Open the file in a new split" } },
{ "n", "<C-w>gf", actions.goto_file_tab, { desc = "Open the file in a new tabpage" } },
{ "n", "<leader>e", actions.focus_files, { desc = "Bring focus to the file panel" } },
{ "n", "<leader>b", actions.toggle_files, { desc = "Toggle the file panel." } },
{ "n", "g<C-x>", actions.cycle_layout, { desc = "Cycle through available layouts." } },
{ "n", "[x", actions.prev_conflict, {
desc =
"In the merge-tool: jump to the previous conflict"
} },
{ "n", "]x", actions.next_conflict, {
desc =
"In the merge-tool: jump to the next conflict"
} },
{ "n", "<leader>co", actions.conflict_choose("ours"), { desc = "Choose the OURS version of a conflict" } },
{ "n", "<leader>ct", actions.conflict_choose("theirs"), { desc = "Choose the THEIRS version of a conflict" } },
{ "n", "<leader>cb", actions.conflict_choose("base"), { desc = "Choose the BASE version of a conflict" } },
@ -120,62 +131,104 @@ require("diffview").setup({
},
diff3 = {
-- Mappings in 3-way diff layouts
{ { "n", "x" }, "2do", actions.diffget("ours"), { desc = "Obtain the diff hunk from the OURS version of the file" } },
{ { "n", "x" }, "3do", actions.diffget("theirs"), { desc = "Obtain the diff hunk from the THEIRS version of the file" } },
{ "n", "g?", actions.help({ "view", "diff3" }), { desc = "Open the help panel" } },
{ { "n", "x" }, "2do", actions.diffget("ours"),
{
desc =
"Obtain the diff hunk from the OURS version of the file"
} },
{ { "n", "x" }, "3do", actions.diffget("theirs"),
{
desc =
"Obtain the diff hunk from the THEIRS version of the file"
} },
{ "n", "g?", actions.help({ "view", "diff3" }), { desc = "Open the help panel" } },
},
diff4 = {
-- Mappings in 4-way diff layouts
{ { "n", "x" }, "1do", actions.diffget("base"), { desc = "Obtain the diff hunk from the BASE version of the file" } },
{ { "n", "x" }, "2do", actions.diffget("ours"), { desc = "Obtain the diff hunk from the OURS version of the file" } },
{ { "n", "x" }, "3do", actions.diffget("theirs"), { desc = "Obtain the diff hunk from the THEIRS version of the file" } },
{ "n", "g?", actions.help({ "view", "diff4" }), { desc = "Open the help panel" } },
{ { "n", "x" }, "1do", actions.diffget("base"),
{
desc =
"Obtain the diff hunk from the BASE version of the file"
} },
{ { "n", "x" }, "2do", actions.diffget("ours"),
{
desc =
"Obtain the diff hunk from the OURS version of the file"
} },
{ { "n", "x" }, "3do", actions.diffget("theirs"),
{
desc =
"Obtain the diff hunk from the THEIRS version of the file"
} },
{ "n", "g?", actions.help({ "view", "diff4" }), { desc = "Open the help panel" } },
},
file_panel = {
{ "n", "j", actions.next_entry, { desc = "Bring the cursor to the next file entry" } },
{ "n", "<down>", actions.next_entry, { desc = "Bring the cursor to the next file entry" } },
{ "n", "k", actions.prev_entry, { desc = "Bring the cursor to the previous file entry." } },
{ "n", "<up>", actions.prev_entry, { desc = "Bring the cursor to the previous file entry." } },
{ "n", "<cr>", actions.select_entry, { desc = "Open the diff for the selected entry." } },
{ "n", "o", actions.select_entry, { desc = "Open the diff for the selected entry." } },
{ "n", "<2-LeftMouse>", actions.select_entry, { desc = "Open the diff for the selected entry." } },
{ "n", "-", actions.toggle_stage_entry, { desc = "Stage / unstage the selected entry." } },
{ "n", "S", actions.stage_all, { desc = "Stage all entries." } },
{ "n", "U", actions.unstage_all, { desc = "Unstage all entries." } },
{ "n", "X", actions.restore_entry, { desc = "Restore entry to the state on the left side." } },
{ "n", "L", actions.open_commit_log, { desc = "Open the commit log panel." } },
{ "n", "<c-b>", actions.scroll_view( -0.25), { desc = "Scroll the view up" } },
{ "n", "<c-f>", actions.scroll_view(0.25), { desc = "Scroll the view down" } },
{ "n", "<tab>", actions.select_next_entry, { desc = "Open the diff for the next file" } },
{ "n", "<s-tab>", actions.select_prev_entry, { desc = "Open the diff for the previous file" } },
{ "n", "gf", actions.goto_file_edit, { desc = "Open the file in the previous tabpage" } },
{ "n", "<C-w><C-f>", actions.goto_file_split, { desc = "Open the file in a new split" } },
{ "n", "<C-w>gf", actions.goto_file_tab, { desc = "Open the file in a new tabpage" } },
{ "n", "i", actions.listing_style, { desc = "Toggle between 'list' and 'tree' views" } },
{ "n", "f", actions.toggle_flatten_dirs, { desc = "Flatten empty subdirectories in tree listing style." } },
{ "n", "R", actions.refresh_files, { desc = "Update stats and entries in the file list." } },
{ "n", "<leader>e", actions.focus_files, { desc = "Bring focus to the file panel" } },
{ "n", "<leader>b", actions.toggle_files, { desc = "Toggle the file panel" } },
{ "n", "g<C-x>", actions.cycle_layout, { desc = "Cycle available layouts" } },
{ "n", "[x", actions.prev_conflict, { desc = "Go to the previous conflict" } },
{ "n", "]x", actions.next_conflict, { desc = "Go to the next conflict" } },
{ "n", "g?", actions.help("file_panel"), { desc = "Open the help panel" } },
{ "n", "j", actions.next_entry, { desc = "Bring the cursor to the next file entry" } },
{ "n", "<down>", actions.next_entry, { desc = "Bring the cursor to the next file entry" } },
{ "n", "k", actions.prev_entry, { desc = "Bring the cursor to the previous file entry." } },
{ "n", "<up>", actions.prev_entry, { desc = "Bring the cursor to the previous file entry." } },
{ "n", "<cr>", actions.select_entry, { desc = "Open the diff for the selected entry." } },
{ "n", "o", actions.select_entry, { desc = "Open the diff for the selected entry." } },
{ "n", "<2-LeftMouse>", actions.select_entry, { desc = "Open the diff for the selected entry." } },
{ "n", "-", actions.toggle_stage_entry, { desc = "Stage / unstage the selected entry." } },
{ "n", "S", actions.stage_all, { desc = "Stage all entries." } },
{ "n", "U", actions.unstage_all, { desc = "Unstage all entries." } },
{ "n", "X", actions.restore_entry, { desc = "Restore entry to the state on the left side." } },
{ "n", "L", actions.open_commit_log, { desc = "Open the commit log panel." } },
{ "n", "<c-b>", actions.scroll_view(-0.25), { desc = "Scroll the view up" } },
{ "n", "<c-f>", actions.scroll_view(0.25), { desc = "Scroll the view down" } },
{ "n", "<tab>", actions.select_next_entry, { desc = "Open the diff for the next file" } },
{ "n", "<s-tab>", actions.select_prev_entry, { desc = "Open the diff for the previous file" } },
{ "n", "gf", actions.goto_file_edit, { desc = "Open the file in the previous tabpage" } },
{ "n", "<C-w><C-f>", actions.goto_file_split, { desc = "Open the file in a new split" } },
{ "n", "<C-w>gf", actions.goto_file_tab, { desc = "Open the file in a new tabpage" } },
{ "n", "i", actions.listing_style, { desc = "Toggle between 'list' and 'tree' views" } },
{ "n", "f", actions.toggle_flatten_dirs,
{
desc =
"Flatten empty subdirectories in tree listing style."
} },
{ "n", "R", actions.refresh_files, { desc = "Update stats and entries in the file list." } },
{ "n", "<leader>e", actions.focus_files, { desc = "Bring focus to the file panel" } },
{ "n", "<leader>b", actions.toggle_files, { desc = "Toggle the file panel" } },
{ "n", "g<C-x>", actions.cycle_layout, { desc = "Cycle available layouts" } },
{ "n", "[x", actions.prev_conflict, { desc = "Go to the previous conflict" } },
{ "n", "]x", actions.next_conflict, { desc = "Go to the next conflict" } },
{ "n", "g?", actions.help("file_panel"), { desc = "Open the help panel" } },
},
file_history_panel = {
{ "n", "g!", actions.options, { desc = "Open the option panel" } },
{ "n", "<C-A-d>", actions.open_in_diffview, { desc = "Open the entry under the cursor in a diffview" } },
{ "n", "y", actions.copy_hash, { desc = "Copy the commit hash of the entry under the cursor" } },
{ "n", "L", actions.open_commit_log, { desc = "Show commit details" } },
{ "n", "zR", actions.open_all_folds, { desc = "Expand all folds" } },
{ "n", "zM", actions.close_all_folds, { desc = "Collapse all folds" } },
{ "n", "j", actions.next_entry, { desc = "Bring the cursor to the next file entry" } },
{ "n", "<down>", actions.next_entry, { desc = "Bring the cursor to the next file entry" } },
{ "n", "k", actions.prev_entry, { desc = "Bring the cursor to the previous file entry." } },
{ "n", "<up>", actions.prev_entry, { desc = "Bring the cursor to the previous file entry." } },
{ "n", "g!", actions.options, { desc = "Open the option panel" } },
{ "n", "<C-A-d>", actions.open_in_diffview, {
desc =
"Open the entry under the cursor in a diffview"
} },
{ "n", "y", actions.copy_hash, {
desc =
"Copy the commit hash of the entry under the cursor"
} },
{ "n", "L", actions.open_commit_log, { desc = "Show commit details" } },
{ "n", "zR", actions.open_all_folds, { desc = "Expand all folds" } },
{ "n", "zM", actions.close_all_folds, { desc = "Collapse all folds" } },
{ "n", "j", actions.next_entry, {
desc =
"Bring the cursor to the next file entry"
} },
{ "n", "<down>", actions.next_entry, {
desc =
"Bring the cursor to the next file entry"
} },
{ "n", "k", actions.prev_entry, {
desc =
"Bring the cursor to the previous file entry."
} },
{ "n", "<up>", actions.prev_entry, {
desc =
"Bring the cursor to the previous file entry."
} },
{ "n", "<cr>", actions.select_entry, { desc = "Open the diff for the selected entry." } },
{ "n", "o", actions.select_entry, { desc = "Open the diff for the selected entry." } },
{ "n", "<2-LeftMouse>", actions.select_entry, { desc = "Open the diff for the selected entry." } },
{ "n", "<c-b>", actions.scroll_view( -0.25), { desc = "Scroll the view up" } },
{ "n", "<c-b>", actions.scroll_view(-0.25), { desc = "Scroll the view up" } },
{ "n", "<c-f>", actions.scroll_view(0.25), { desc = "Scroll the view down" } },
{ "n", "<tab>", actions.select_next_entry, { desc = "Open the diff for the next file" } },
{ "n", "<s-tab>", actions.select_prev_entry, { desc = "Open the diff for the previous file" } },