-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgitsigns-config.lua
More file actions
60 lines (50 loc) · 1.9 KB
/
gitsigns-config.lua
File metadata and controls
60 lines (50 loc) · 1.9 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
local M = {
'lewis6991/gitsigns.nvim',
event = 'VeryLazy',
}
M.opts = {
gh = true,
signcolumn = true,
numhl = true,
preview_config = {
border = 'solid',
row = 1,
col = -1,
},
on_attach = function(bufnr)
local gitsigns_keymap = require('config.keymaps').gitsigns
local gitsigns_actions = 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', gitsigns_keymap.next_hunk,
function()
if vim.wo.diff then
vim.cmd.normal({ gitsigns_keymap.next_hunk, bang = true })
else
gitsigns_actions.nav_hunk('next')
end
end)
map('n', gitsigns_keymap.prev_hunk,
function()
if vim.wo.diff then
vim.cmd.normal({ gitsigns_keymap.prev_hunk, bang = true })
else
gitsigns_actions.nav_hunk('prev')
end
end)
map('n', gitsigns_keymap.stage_hunk, gitsigns_actions.stage_hunk)
map('v', gitsigns_keymap.stage_hunk,
function() gitsigns_actions.stage_hunk { vim.fn.line('.'), vim.fn.line('v') } end)
map('n', gitsigns_keymap.reset_hunk, gitsigns_actions.reset_hunk)
map('v', gitsigns_keymap.reset_hunk,
function() gitsigns_actions.reset_hunk { vim.fn.line('.'), vim.fn.line('v') } end)
map('n', gitsigns_keymap.preview_hunk, gitsigns_actions.preview_hunk_inline)
map('n', gitsigns_keymap.blame_line, function() gitsigns_actions.blame_line { full = true } end)
map('n', gitsigns_keymap.toggle_blame, gitsigns_actions.toggle_current_line_blame)
map('n', gitsigns_keymap.diff_this, gitsigns_actions.diffthis)
end
}
return M