home: vim: git: use 'partial'

This commit is contained in:
Bruno BELANYI 2024-07-12 20:38:40 +01:00
parent bcd9a31bb8
commit 33084169f2

View file

@ -1,4 +1,5 @@
local gitsigns = require("gitsigns") local gitsigns = require("gitsigns")
local utils = require("ambroisie.utils")
local wk = require("which-key") local wk = require("which-key")
--- Transform `f` into a function which acts on the current visual selection --- Transform `f` into a function which acts on the current visual selection
@ -11,7 +12,6 @@ local function make_visual(f)
end end
local function nav_hunk(dir) local function nav_hunk(dir)
return function()
if vim.wo.diff then if vim.wo.diff then
local map = { local map = {
prev = "[c", prev = "[c",
@ -22,7 +22,6 @@ local function nav_hunk(dir)
gitsigns.nav_hunk(dir) gitsigns.nav_hunk(dir)
end end
end end
end
gitsigns.setup({ gitsigns.setup({
current_line_blame_opts = { current_line_blame_opts = {
@ -33,8 +32,8 @@ gitsigns.setup({
local keys = { local keys = {
-- Navigation -- Navigation
["[c"] = { nav_hunk("prev"), "Previous hunk/diff" }, ["[c"] = { utils.partial(nav_hunk, "prev"), "Previous hunk/diff" },
["]c"] = { nav_hunk("next"), "Next hunk/diff" }, ["]c"] = { utils.partial(nav_hunk, "next"), "Next hunk/diff" },
-- Commands -- Commands
["<leader>g"] = { ["<leader>g"] = {
@ -43,7 +42,7 @@ local keys = {
b = { gitsigns.toggle_current_line_blame, "Toggle blame virtual text" }, b = { gitsigns.toggle_current_line_blame, "Toggle blame virtual text" },
d = { gitsigns.diffthis, "Diff buffer" }, d = { gitsigns.diffthis, "Diff buffer" },
-- stylua: ignore -- stylua: ignore
D = { function() gitsigns.diffthis("~") end, "Diff buffer against last commit" }, D = { utils.partial(gitsigns.diffthis, "~"), "Diff buffer against last commit" },
g = { "<cmd>Git<CR>", "Git status" }, g = { "<cmd>Git<CR>", "Git status" },
h = { gitsigns.toggle_deleted, "Show deleted hunks" }, h = { gitsigns.toggle_deleted, "Show deleted hunks" },
L = { "<cmd>:sp<CR><C-w>T:Gllog --follow -- %:p<CR>", "Current buffer log" }, L = { "<cmd>:sp<CR><C-w>T:Gllog --follow -- %:p<CR>", "Current buffer log" },