Make all plugin configs return a function

Simplifies writing the `config = ...` field for each plugin
This commit is contained in:
2023-09-25 16:08:06 +02:00
parent 7739ec5591
commit ac35b77c87
33 changed files with 747 additions and 618 deletions
+67 -63
View File
@@ -16,72 +16,76 @@
-- https://github.com/sindrets/diffview.nvim
local actions = require("diffview.actions")
local function setup()
local actions = require("diffview.actions")
require("diffview").setup({
enhanced_diff_hl = true,
view = {
default = {
layout = "diff2_horizontal",
winbar_info = true,
},
merge_tool = {
layout = "diff3_mixed",
disable_diagnostics = true,
winbar_info = true,
},
file_history = {
layout = "diff2_horizontal",
winbar_info = true,
},
},
default_args = {
DiffviewOpen = { "--imply-local", },
},
keymaps = {
file_panel = {
["<cr>"] = false,
{
"n",
"<CR>",
function ()
actions.select_entry()
vim.cmd.wincmd("l")
end,
{ desc = "Open the current file in diffview", },
require("diffview").setup({
enhanced_diff_hl = true,
view = {
default = {
layout = "diff2_horizontal",
winbar_info = true,
},
{
"n",
"s",
actions.toggle_stage_entry,
{ desc = "Stage / unstage the selected entry", },
merge_tool = {
layout = "diff3_mixed",
disable_diagnostics = true,
winbar_info = true,
},
{
"n",
"u",
actions.toggle_stage_entry,
{ desc = "Stage / unstage the selected entry", },
},
{
"n",
"cc",
function ()
vim.cmd.G("commit")
vim.cmd.wincmd("J")
end,
{ desc = "Commit staged changes", },
},
{
"n",
"ca",
function ()
vim.cmd.G("commit --amend")
vim.cmd.wincmd("J")
end,
{ desc = "Amend the last commit", },
file_history = {
layout = "diff2_horizontal",
winbar_info = true,
},
},
},
})
default_args = {
DiffviewOpen = { "--imply-local", },
},
keymaps = {
file_panel = {
["<cr>"] = false,
{
"n",
"<CR>",
function ()
actions.select_entry()
vim.cmd.wincmd("l")
end,
{ desc = "Open the current file in diffview", },
},
{
"n",
"s",
actions.toggle_stage_entry,
{ desc = "Stage / unstage the selected entry", },
},
{
"n",
"u",
actions.toggle_stage_entry,
{ desc = "Stage / unstage the selected entry", },
},
{
"n",
"cc",
function ()
vim.cmd.G("commit")
vim.cmd.wincmd("J")
end,
{ desc = "Commit staged changes", },
},
{
"n",
"ca",
function ()
vim.cmd.G("commit --amend")
vim.cmd.wincmd("J")
end,
{ desc = "Amend the last commit", },
},
},
},
})
vim.keymap.set("n", "<leader>gg", vim.cmd.DiffviewOpen)
vim.keymap.set("n", "<leader>gg", vim.cmd.DiffviewOpen)
end
return setup