Add support for repeat.vim
This commit is contained in:
parent
fdc7bb60a0
commit
83a85d430d
|
@ -83,3 +83,4 @@ set statusline+=%{get(b:,'gitsigns_status','')}
|
|||
- [x] Add action for ~~undoing~~ reseting a hunk
|
||||
- [ ] Add action for showing diff (or original text) in a floating window
|
||||
- [ ] Add ability to show staged hunks with different signs (maybe in a different sign column?)
|
||||
- [x] Add support for repeat.vim
|
||||
|
|
|
@ -3,6 +3,7 @@ local CM = require('plenary.context_manager')
|
|||
|
||||
local AS = require('gitsigns/async')
|
||||
local default_config = require('gitsigns/defaults')
|
||||
local mk_repeatable = require('gitsigns/repeat').mk_repeatable
|
||||
|
||||
local api = vim.api
|
||||
local current_buf = api.nvim_get_current_buf
|
||||
|
@ -569,12 +570,12 @@ local function setup(cfg)
|
|||
end
|
||||
|
||||
return {
|
||||
update = update,
|
||||
stage_hunk = stage_hunk,
|
||||
undo_stage_hunk = undo_stage_hunk,
|
||||
reset_hunk = reset_hunk,
|
||||
next_hunk = next_hunk,
|
||||
prev_hunk = prev_hunk,
|
||||
attach = attach,
|
||||
setup = setup,
|
||||
update = update,
|
||||
stage_hunk = mk_repeatable(stage_hunk),
|
||||
undo_stage_hunk = mk_repeatable(undo_stage_hunk),
|
||||
reset_hunk = mk_repeatable(reset_hunk),
|
||||
next_hunk = next_hunk,
|
||||
prev_hunk = prev_hunk,
|
||||
attach = attach,
|
||||
setup = setup,
|
||||
}
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
|
||||
local M = {}
|
||||
|
||||
local repeat_fn
|
||||
|
||||
function M.repeat_action()
|
||||
repeat_fn()
|
||||
end
|
||||
|
||||
function M.mk_repeatable(fn)
|
||||
return function()
|
||||
repeat_fn = function()
|
||||
fn()
|
||||
vim.cmd('silent! call repeat#set("\\<Plug>GitsignsRepeat",-1)')
|
||||
end
|
||||
|
||||
repeat_fn()
|
||||
end
|
||||
end
|
||||
|
||||
vim.api.nvim_set_keymap(
|
||||
'n',
|
||||
'<Plug>GitsignsRepeat',
|
||||
'<cmd>lua require"gitsigns/repeat".repeat_action()<CR>',
|
||||
{noremap = false, silent = true}
|
||||
)
|
||||
|
||||
return M
|
Loading…
Reference in New Issue