-
Notifications
You must be signed in to change notification settings - Fork 2
/
gitsigns.lua
32 lines (27 loc) · 1.03 KB
/
gitsigns.lua
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
local M = {}
---@param options { forward: boolean }
function M.jump(options)
return function()
require('demicolon.jump').repeatably_do(function(opts)
if vim.wo.diff then -- If we're in a diff
local direction_key = (opts.forward == nil or opts.forward) and ']' or '['
vim.cmd.normal({ vim.v.count1 .. direction_key .. 'c', bang = true })
else
local direction = (opts.forward == nil or opts.forward) and 'next' or 'prev'
require('gitsigns').nav_hunk(direction)
end
end, options)
end
end
function M.create_keymaps()
local options = require('demicolon').get_options().integrations.gitsigns
if options and not options.enabled then
return
end
local nxo = { 'n', 'x', 'o' }
---@diagnostic disable-next-line: need-check-nil
vim.keymap.set(nxo, options.keymaps.next, M.jump({ forward = true }), {desc = "Next hunk"})
---@diagnostic disable-next-line: need-check-nil
vim.keymap.set(nxo, options.keymaps.prev, M.jump({ forward = false }), {desc= "Previous hunk"})
end
return M