2022-10-01 11:46:18 +00:00
|
|
|
local status_ok, gitsigns = pcall(require, "gitsigns")
|
|
|
|
if not status_ok then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
gitsigns.setup({
|
|
|
|
signs = {
|
2022-11-16 18:53:30 +00:00
|
|
|
add = { hl = "GitSignsAdd", text = "", numhl = "GitSignsAddNr", linehl = "GitSignsAddLn" },
|
|
|
|
change = { hl = "GitSignsChange", text = "", numhl = "GitSignsChangeNr", linehl = "GitSignsChangeLn" },
|
2022-10-01 11:46:18 +00:00
|
|
|
delete = { hl = "GitSignsDelete", text = "契", numhl = "GitSignsDeleteNr", linehl = "GitSignsDeleteLn" },
|
|
|
|
topdelete = { hl = "GitSignsDelete", text = "契", numhl = "GitSignsDeleteNr", linehl = "GitSignsDeleteLn" },
|
2022-11-16 18:53:30 +00:00
|
|
|
changedelete = { hl = "GitSignsChange", text = "", numhl = "GitSignsChangeNr", linehl = "GitSignsChangeLn" },
|
2022-10-01 11:46:18 +00:00
|
|
|
},
|
2022-10-08 10:44:11 +00:00
|
|
|
preview_config = {
|
2022-10-12 14:02:54 +00:00
|
|
|
border = "rounded",
|
2022-10-08 10:44:11 +00:00
|
|
|
},
|
|
|
|
|
2022-10-07 17:30:29 +00:00
|
|
|
on_attach = function(bufnr)
|
|
|
|
local gs = package.loaded.gitsigns
|
|
|
|
|
|
|
|
local function map(mode, l, r, opts)
|
|
|
|
opts = opts or {}
|
|
|
|
opts.buffer = bufnr
|
|
|
|
vim.keymap.set(mode, l, r, opts)
|
|
|
|
end
|
|
|
|
|
|
|
|
map({ "n", "v" }, "<leader>hs", ":Gitsigns stage_hunk<CR>")
|
|
|
|
map({ "n", "v" }, "<leader>hr", ":Gitsigns reset_hunk<CR>")
|
2022-11-12 12:23:32 +00:00
|
|
|
map("n", "<leader>hp", gs.preview_hunk)
|
2022-10-07 17:30:29 +00:00
|
|
|
map("n", "<leader>hR", gs.reset_buffer)
|
2022-11-24 18:30:42 +00:00
|
|
|
map('n', '<leader>hd', gs.diffthis)
|
|
|
|
map('n', '<leader>hj', gs.next_hunk)
|
|
|
|
map('n', '<leader>hk', gs.prev_hunk)
|
2022-10-07 17:30:29 +00:00
|
|
|
end,
|
2022-10-01 11:46:18 +00:00
|
|
|
})
|