Refresh generated neovim config
This commit is contained in:
@ -276,6 +276,8 @@ require("diffview").setup({
|
||||
-- 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", "[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", "<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" } },
|
||||
@ -341,6 +343,8 @@ require("diffview").setup({
|
||||
{ "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", "[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", "<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" } },
|
||||
@ -365,9 +369,7 @@ require("diffview").setup({
|
||||
{ "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", "X", actions.restore_entry, { desc = "Restore file to the state from the selected entry" } },
|
||||
{ "n", "zr", actions.open_fold, { desc = "Expand fold" } },
|
||||
{ "n", "zo", actions.open_fold, { desc = "Expand fold" } },
|
||||
{ "n", "zm", actions.close_fold, { desc = "Collapse fold" } },
|
||||
{ "n", "zc", actions.close_fold, { desc = "Collapse fold" } },
|
||||
{ "n", "h", actions.close_fold, { desc = "Collapse fold" } },
|
||||
{ "n", "za", actions.toggle_fold, { desc = "Toggle fold" } },
|
||||
@ -385,6 +387,8 @@ require("diffview").setup({
|
||||
{ "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", "[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", "<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" } },
|
||||
|
||||
@ -1165,16 +1165,36 @@ select_entry *diffview-actions-select_entry*
|
||||
multiple files, this will collapse or open the entry. In the option
|
||||
panel this will interact with the option under the cursor.
|
||||
|
||||
select_next_entry *diffview-actions-select_next_entry*
|
||||
[count] select_next_entry *diffview-actions-select_next_entry*
|
||||
Contexts: `view`, `file_panel`, `file_history_panel`
|
||||
|
||||
Select the entry following the subject.
|
||||
|
||||
select_prev_entry *diffview-actions-select_prev_entry*
|
||||
[count] select_prev_entry *diffview-actions-select_prev_entry*
|
||||
Contexts: `view`, `file_panel`, `file_history_panel`
|
||||
|
||||
Select the entry preceding the subject.
|
||||
|
||||
select_first_entry *diffview-actions-select_first_entry*
|
||||
Contexts: `view`, `file_panel`, `file_history_panel`
|
||||
|
||||
Select the first entry.
|
||||
|
||||
select_last_entry *diffview-actions-select_last_entry*
|
||||
Contexts: `view`, `file_panel`, `file_history_panel`
|
||||
|
||||
Select the last entry.
|
||||
|
||||
[count] select_next_commit *diffview-actions-select_next_commit*
|
||||
Contexts: `file_history_view`, `file_history_panel`
|
||||
|
||||
Select the commit following the subject.
|
||||
|
||||
[count] select_prev_commit *diffview-actions-select_prev_commit*
|
||||
Contexts: `file_history_view`, `file_history_panel`
|
||||
|
||||
Select the commit preceding the subject.
|
||||
|
||||
stage_all *diffview-actions-stage_all*
|
||||
Contexts: `diff_view`, `file_panel`
|
||||
|
||||
|
||||
@ -97,6 +97,8 @@ DEFAULT CONFIG *diffview.defaults*
|
||||
-- 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", "[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", "<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" } },
|
||||
@ -162,6 +164,8 @@ DEFAULT CONFIG *diffview.defaults*
|
||||
{ "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", "[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", "<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" } },
|
||||
@ -186,9 +190,7 @@ DEFAULT CONFIG *diffview.defaults*
|
||||
{ "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", "X", actions.restore_entry, { desc = "Restore file to the state from the selected entry" } },
|
||||
{ "n", "zr", actions.open_fold, { desc = "Expand fold" } },
|
||||
{ "n", "zo", actions.open_fold, { desc = "Expand fold" } },
|
||||
{ "n", "zm", actions.close_fold, { desc = "Collapse fold" } },
|
||||
{ "n", "zc", actions.close_fold, { desc = "Collapse fold" } },
|
||||
{ "n", "h", actions.close_fold, { desc = "Collapse fold" } },
|
||||
{ "n", "za", actions.toggle_fold, { desc = "Toggle fold" } },
|
||||
@ -206,6 +208,8 @@ DEFAULT CONFIG *diffview.defaults*
|
||||
{ "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", "[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", "<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" } },
|
||||
|
||||
@ -35,7 +35,11 @@ diffview-actions-refresh_files diffview.txt /*diffview-actions-refresh_files*
|
||||
diffview-actions-restore_entry diffview.txt /*diffview-actions-restore_entry*
|
||||
diffview-actions-scroll_view diffview.txt /*diffview-actions-scroll_view*
|
||||
diffview-actions-select_entry diffview.txt /*diffview-actions-select_entry*
|
||||
diffview-actions-select_first_entry diffview.txt /*diffview-actions-select_first_entry*
|
||||
diffview-actions-select_last_entry diffview.txt /*diffview-actions-select_last_entry*
|
||||
diffview-actions-select_next_commit diffview.txt /*diffview-actions-select_next_commit*
|
||||
diffview-actions-select_next_entry diffview.txt /*diffview-actions-select_next_entry*
|
||||
diffview-actions-select_prev_commit diffview.txt /*diffview-actions-select_prev_commit*
|
||||
diffview-actions-select_prev_entry diffview.txt /*diffview-actions-select_prev_entry*
|
||||
diffview-actions-stage_all diffview.txt /*diffview-actions-stage_all*
|
||||
diffview-actions-toggle_files diffview.txt /*diffview-actions-toggle_files*
|
||||
|
||||
@ -635,6 +635,10 @@ local action_names = {
|
||||
"select_entry",
|
||||
"select_next_entry",
|
||||
"select_prev_entry",
|
||||
"select_first_entry",
|
||||
"select_last_entry",
|
||||
"select_next_commit",
|
||||
"select_prev_commit",
|
||||
"stage_all",
|
||||
"toggle_files",
|
||||
"toggle_flatten_dirs",
|
||||
|
||||
@ -124,6 +124,8 @@ M.defaults = {
|
||||
-- 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", "[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", "<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" } },
|
||||
@ -190,6 +192,8 @@ M.defaults = {
|
||||
{ "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", "[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", "<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" } },
|
||||
@ -232,6 +236,8 @@ M.defaults = {
|
||||
{ "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", "[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", "<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" } },
|
||||
|
||||
@ -65,6 +65,18 @@ return function(view)
|
||||
view:close()
|
||||
end
|
||||
end,
|
||||
select_first_entry = function()
|
||||
local files = view.panel:ordered_file_list()
|
||||
if files and #files > 0 then
|
||||
view:set_file(files[1], false, true)
|
||||
end
|
||||
end,
|
||||
select_last_entry = function()
|
||||
local files = view.panel:ordered_file_list()
|
||||
if files and #files > 0 then
|
||||
view:set_file(files[#files], false, true)
|
||||
end
|
||||
end,
|
||||
select_next_entry = function()
|
||||
view:next_file(true)
|
||||
end,
|
||||
|
||||
@ -170,8 +170,13 @@ FileHistoryView.set_file = async.void(function(self, file, focus)
|
||||
if self:file_safeguard() or not file then return end
|
||||
|
||||
local entry = self.panel:find_entry(file)
|
||||
local cur_entry = self.panel.cur_item[1]
|
||||
|
||||
if entry then
|
||||
if cur_entry and entry ~= cur_entry then
|
||||
self.panel:set_entry_fold(cur_entry, false)
|
||||
end
|
||||
|
||||
self.panel:set_cur_item({ entry, file })
|
||||
self.panel:highlight_item(file)
|
||||
self.nulled = false
|
||||
|
||||
@ -59,6 +59,38 @@ return function(view)
|
||||
select_prev_entry = function()
|
||||
view:prev_item()
|
||||
end,
|
||||
select_first_entry = function()
|
||||
local entry = view.panel.entries[1]
|
||||
if entry and #entry.files > 0 then
|
||||
view:set_file(entry.files[1])
|
||||
end
|
||||
end,
|
||||
select_last_entry = function()
|
||||
local entry = view.panel.entries[#view.panel.entries]
|
||||
if entry and #entry.files > 0 then
|
||||
view:set_file(entry.files[#entry.files])
|
||||
end
|
||||
end,
|
||||
select_next_commit = function()
|
||||
local cur_entry = view.panel.cur_item[1]
|
||||
if not cur_entry then return end
|
||||
local entry_idx = utils.vec_indexof(view.panel.entries, cur_entry)
|
||||
if entry_idx == -1 then return end
|
||||
|
||||
local next_idx = (entry_idx + vim.v.count1 - 1) % #view.panel.entries + 1
|
||||
local next_entry = view.panel.entries[next_idx]
|
||||
view:set_file(next_entry.files[1])
|
||||
end,
|
||||
select_prev_commit = function()
|
||||
local cur_entry = view.panel.cur_item[1]
|
||||
if not cur_entry then return end
|
||||
local entry_idx = utils.vec_indexof(view.panel.entries, cur_entry)
|
||||
if entry_idx == -1 then return end
|
||||
|
||||
local next_idx = (entry_idx - vim.v.count1 - 1) % #view.panel.entries + 1
|
||||
local next_entry = view.panel.entries[next_idx]
|
||||
view:set_file(next_entry.files[1])
|
||||
end,
|
||||
next_entry = function()
|
||||
view.panel:highlight_next_file()
|
||||
end,
|
||||
|
||||
@ -23,65 +23,44 @@ function M.now()
|
||||
return vim.loop.hrtime() / 1000000
|
||||
end
|
||||
|
||||
---Echo string with multiple lines.
|
||||
---@param msg string|string[]
|
||||
---@param hl? string Highlight group name.
|
||||
---@param schedule? boolean Schedule the echo call.
|
||||
function M.echo_multiln(msg, hl, schedule)
|
||||
---@param level integer
|
||||
function M.notify(msg, level, schedule)
|
||||
if schedule then
|
||||
vim.schedule(function() M.echo_multiln(msg, hl, false) end)
|
||||
vim.schedule(function() M.notify(msg, level, false) end)
|
||||
return
|
||||
end
|
||||
if type(msg) == "table" then
|
||||
msg = table.concat(msg, "\n")
|
||||
end
|
||||
if msg == "" then
|
||||
return
|
||||
end
|
||||
|
||||
if type(msg) ~= "table" then msg = { msg } end
|
||||
if level == vim.log.levels.ERROR then
|
||||
logger:error(msg)
|
||||
end
|
||||
|
||||
local text = table.concat(msg, "\n")
|
||||
api.nvim_echo({ { text, hl } }, true, {})
|
||||
vim.notify(msg, level, { title = "diffview.nvim" })
|
||||
end
|
||||
|
||||
---@param msg string|string[]
|
||||
---@param schedule? boolean Schedule the echo call.
|
||||
function M.info(msg, schedule)
|
||||
if type(msg) ~= "table" then
|
||||
msg = { msg }
|
||||
end
|
||||
if not msg[1] or (msg[1] == "" and #msg == 1) then
|
||||
return
|
||||
end
|
||||
msg = M.vec_slice(msg)
|
||||
msg[1] = "[Diffview.nvim] " .. msg[1]
|
||||
M.echo_multiln(msg, "DiagnosticInfo", schedule)
|
||||
M.notify(msg, vim.log.levels.INFO, schedule)
|
||||
end
|
||||
|
||||
---@param msg string|string[]
|
||||
---@param schedule? boolean Schedule the echo call.
|
||||
function M.warn(msg, schedule)
|
||||
if type(msg) ~= "table" then
|
||||
msg = { msg }
|
||||
end
|
||||
if not msg[1] or (msg[1] == "" and #msg == 1) then
|
||||
return
|
||||
end
|
||||
msg = M.vec_slice(msg)
|
||||
msg[1] = "[Diffview.nvim] " .. msg[1]
|
||||
M.echo_multiln(msg, "WarningMsg", schedule)
|
||||
M.notify(msg, vim.log.levels.WARN, schedule)
|
||||
end
|
||||
|
||||
---@param msg string|string[]
|
||||
---@param schedule? boolean Schedule the echo call.
|
||||
function M.err(msg, schedule)
|
||||
if type(msg) ~= "table" then
|
||||
msg = { msg }
|
||||
end
|
||||
if not msg[1] or (msg[1] == "" and #msg == 1) then
|
||||
return
|
||||
end
|
||||
msg = M.vec_slice(msg)
|
||||
|
||||
logger:error(table.concat(msg, "\n"))
|
||||
|
||||
msg[1] = "[Diffview.nvim] " .. msg[1]
|
||||
M.echo_multiln(msg, "ErrorMsg", schedule)
|
||||
M.notify(msg, vim.log.levels.ERROR, schedule)
|
||||
end
|
||||
|
||||
---Call the function `f`, ignoring most of the window and buffer related
|
||||
|
||||
Reference in New Issue
Block a user