Skip to content

Commit

Permalink
feat(gitsigns): add motion to jump to next hunk etc..
Browse files Browse the repository at this point in the history
  • Loading branch information
asyncedd committed Jun 26, 2023
1 parent 4fd4e3b commit a8fe193
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 16 deletions.
13 changes: 0 additions & 13 deletions lua/plugins/configs/editor/gitsigns.lua

This file was deleted.

37 changes: 34 additions & 3 deletions lua/plugins/specs/editor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,40 @@ return {
},
{
"lewis6991/gitsigns.nvim",
opts = function()
return require("plugins.configs.editor.gitsigns")
end,
opts = {
signs = {
add = { text = "" },
change = { text = "" },
delete = { text = "" },
topdelete = { text = "" },
changedelete = { text = "" },
untracked = { text = "" },
},
current_line_blame = true,
current_line_blame_formatter = "󰧮 <author>, <author_time:%Y-%m-%d> - <summary>",
trouble = false,
on_attach = function(buffer)
local gs = package.loaded.gitsigns

local function map(mode, l, r, desc)
vim.keymap.set(mode, l, r, { buffer = buffer, desc = desc })
end

-- stylua: ignore start
map("n", "]h", gs.next_hunk, "Next Hunk")
map("n", "[h", gs.prev_hunk, "Prev Hunk")
map({ "n", "v" }, "<leader>ghs", ":Gitsigns stage_hunk<CR>", "Stage Hunk")
map({ "n", "v" }, "<leader>ghr", ":Gitsigns reset_hunk<CR>", "Reset Hunk")
map("n", "<leader>ghS", gs.stage_buffer, "Stage Buffer")
map("n", "<leader>ghu", gs.undo_stage_hunk, "Undo Stage Hunk")
map("n", "<leader>ghR", gs.reset_buffer, "Reset Buffer")
map("n", "<leader>ghp", gs.preview_hunk, "Preview Hunk")
map("n", "<leader>ghb", function() gs.blame_line({ full = true }) end, "Blame Line")
map("n", "<leader>ghd", gs.diffthis, "Diff This")
map("n", "<leader>ghD", function() gs.diffthis("~") end, "Diff This ~")
map({ "o", "x" }, "ih", ":<C-U>Gitsigns select_hunk<CR>", "GitSigns Select Hunk")
end,
},
config = true,
init = function()
require("core.utils.lazy")("gitsigns.nvim")
Expand Down

0 comments on commit a8fe193

Please sign in to comment.