Skip to content

Commit

Permalink
feat(neovim): added gitsigns keymaps
Browse files Browse the repository at this point in the history
  • Loading branch information
AlejandroSuero committed Apr 4, 2024
1 parent a4d0e32 commit 3bd70a8
Showing 1 changed file with 70 additions and 1 deletion.
71 changes: 70 additions & 1 deletion roles/neovim/files/lua/custom/plugins/ui/git_plugins.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,78 @@ return {
changedelete = { text = "~" },
untracked = { text = "" },
},
current_line_blame = true,
numhl = true,
max_file_length = 10000,
on_attach = function(bufnr)
local gs = package.loaded.gitsigns

local mappings = {
n = {
["]h"] = {
gs.next_hunk,
"next [h]unk",
},
["[h"] = {
gs.prev_hunk,
"previous [h]unk",
},
["<leader>hb"] = {
gs.toggle_current_line_blame,
"Line [b]lame",
},
["<leader>hs"] = {
gs.stage_hunk,
"[h]unk [s]tage",
},
["<leader>hr"] = {
gs.reset_hunk,
"[h]unk [r]eset",
},
["<leader>hS"] = {
gs.stage_buffer,
"[h]unk [S]tage buffer",
},
["<leader>hR"] = {
gs.reset_buffer,
"[h]unk [R]eset buffer",
},
["<leader>hd"] = {
gs.diffthis,
"[h]unk [d]iff",
},
["<leader>hD"] = {
function()
gs.diffthis "~"
end,
"[h]unk [D]iff ~",
},
["<leader>hu"] = {
gs.undo_stage_hunk,
"[h]unk [u]ndo stage",
},
["<leader>hp"] = {
gs.preview_hunk,
"[h]unk [p]review",
},
},
v = {
["<leader>hs"] = {
function()
gs.stage_hunk { vim.fn.line ".", vim.fn.line "v" }
end,
"[h]unk [s]tage selected",
},
["<leader>hr"] = {
function()
gs.reset_hunk { vim.fn.line ".", vim.fn.line "v" }
end,
"[h]unk [r]eset selected",
},
},
}

require("aome.core.utils").map_keys(mappings, { buffer = bufnr })
end,
},
event = { "BufReadPre", "BufNewFile" },
},
Expand Down

0 comments on commit 3bd70a8

Please sign in to comment.