1

Refresh generated neovim config

This commit is contained in:
2024-07-14 21:12:36 +02:00
parent f215ce2ab5
commit 00464e0e65
731 changed files with 6780 additions and 31110 deletions

View File

@ -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",

View File

@ -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" } },

View File

@ -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,

View File

@ -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

View File

@ -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,

View File

@ -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