diff --git a/config/nvim/lua/plugins/gitsigns.lua b/config/nvim/lua/plugins/gitsigns.lua new file mode 100644 index 0000000..be5df23 --- /dev/null +++ b/config/nvim/lua/plugins/gitsigns.lua @@ -0,0 +1,35 @@ +return { + "lewis6991/gitsigns.nvim", + event = "LazyFile", + opts = { + signs = { + add = { text = "▎" }, + change = { text = "▎" }, + delete = { text = "" }, + topdelete = { text = "" }, + changedelete = { text = "▎" }, + untracked = { text = "▎" }, + }, + 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" }, "ghs", ":Gitsigns stage_hunk", "Stage Hunk") + map({ "n", "v" }, "ghr", ":Gitsigns reset_hunk", "Reset Hunk") + map("n", "ghS", gs.stage_buffer, "Stage Buffer") + map("n", "ghu", gs.undo_stage_hunk, "Undo Stage Hunk") + map("n", "ghR", gs.reset_buffer, "Reset Buffer") + map("n", "ghp", gs.preview_hunk, "Preview Hunk") + map("n", "ghb", function() gs.blame_line({ full = true }) end, "Blame Line") + map("n", "ghd", gs.diffthis, "Diff This") + map("n", "ghD", function() gs.diffthis("~") end, "Diff This ~") + map({ "o", "x" }, "ih", ":Gitsigns select_hunk", "GitSigns Select Hunk") + end, + }, +}