Add support for repeat.vim

This commit is contained in:
Lewis Russell 2020-10-25 21:36:26 +00:00
parent fdc7bb60a0
commit 83a85d430d
3 changed files with 38 additions and 8 deletions

View File

@ -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

View File

@ -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
@ -570,9 +571,9 @@ end
return {
update = update,
stage_hunk = stage_hunk,
undo_stage_hunk = undo_stage_hunk,
reset_hunk = reset_hunk,
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,

28
lua/gitsigns/repeat.lua Normal file
View File

@ -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