1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
local map = vim.keymap.set
require("gitsigns").setup({
signs = {
add = { hl = 'GitSignsAdd' , text = '│', numhl='GitSignsAddNr' , linehl='GitSignsAddLn' },
untracked = { hl = 'GitSignsAdd' , text = '│', numhl='GitSignsAddNr' , linehl='GitSignsAddLn' },
change = { hl = 'GitSignsChange', text = '│', numhl='GitSignsChangeNr', linehl='GitSignsChangeLn' },
changedelete = { hl = 'GitSignsChange', text = '│', numhl='GitSignsChangeNr', linehl='GitSignsChangeLn' },
delete = { hl = 'GitSignsDelete', text = '▁', numhl='GitSignsDeleteNr', linehl='GitSignsDeleteLn' },
topdelete = { hl = 'GitSignsDelete', text = '▔', numhl='GitSignsDeleteNr', linehl='GitSignsDeleteLn' },
},
on_attach = function(buf)
local gs = package.loaded.gitsigns
local opts = { buffer = buf, expr = true, replace_keycodes = false }
-- Navigation
map("n", "]c", "&diff ? ']c' : '<CMD>Gitsigns next_hunk<CR>'", opts)
map("n", "[c", "&diff ? '[c' : '<CMD>Gitsigns prev_hunk<CR>'", opts)
-- Actions
map({ "n", "v" }, "<leader>hr", gs.reset_hunk, { buffer = buf })
map({ "n", "v" }, "<leader>hs", gs.stage_hunk)
map("n", "<leader>hS", gs.stage_buffer, { buffer = buf })
map("n", "<leader>hp", gs.preview_hunk, { buffer = buf })
-- Text object
map({ "o", "x" }, "ih", ":<C-U>Gitsigns select_hunk<CR>", { buffer = buf })
end,
})
|