mirror of
https://github.com/lewis6991/gitsigns.nvim
synced 2024-09-08 02:35:46 +02:00
parent
ee5b6ba0b5
commit
ec6aab13ef
3 changed files with 37 additions and 8 deletions
|
@ -1181,18 +1181,25 @@ via the config, see |gitsigns-config-keymaps|. The lua implementation is
|
|||
exposed through |gitsigns.select_hunk()|.
|
||||
|
||||
==============================================================================
|
||||
EVENT *gitsigns-event*
|
||||
EVENTS *gitsigns-events*
|
||||
|
||||
Every time Gitsigns updates its knowledge about hunks, it issues a custom
|
||||
|User| event named `GitSignsUpdate`. You can use it via usual autocommands,
|
||||
like so: >lua
|
||||
|User| |autocommands| provided to allow extending behaviors.
|
||||
|
||||
Example: >lua
|
||||
vim.api.nvim_create_autocmd('User', {
|
||||
pattern = 'GitSignsUpdate',
|
||||
callback = function(args)
|
||||
print(os.time(), ' Gitsigns made an update on ', args.data.buffer)
|
||||
end
|
||||
})
|
||||
<
|
||||
*User_GitSignsUpdate*
|
||||
GitSignsUpdate After Gitsigns updates its knowledge about hunks.
|
||||
Provides `bufnr` in the autocmd user data.
|
||||
|
||||
*User_GitSignsChanged*
|
||||
GitSignsChanged After any event in which Gitsigns can potentially change
|
||||
the repository. Provides `file` in the autocmd user data.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
vim:tw=78:ts=8:ft=help:norl:
|
||||
|
|
|
@ -163,18 +163,25 @@ via the config, see |gitsigns-config-keymaps|. The lua implementation is
|
|||
exposed through |gitsigns.select_hunk()|.
|
||||
|
||||
==============================================================================
|
||||
EVENT *gitsigns-event*
|
||||
EVENTS *gitsigns-events*
|
||||
|
||||
Every time Gitsigns updates its knowledge about hunks, it issues a custom
|
||||
|User| event named `GitSignsUpdate`. You can use it via usual autocommands,
|
||||
like so: >lua
|
||||
|User| |autocommands| provided to allow extending behaviors.
|
||||
|
||||
Example: >lua
|
||||
vim.api.nvim_create_autocmd('User', {
|
||||
pattern = 'GitSignsUpdate',
|
||||
callback = function(args)
|
||||
print(os.time(), ' Gitsigns made an update on ', args.data.buffer)
|
||||
end
|
||||
})
|
||||
<
|
||||
*User_GitSignsUpdate*
|
||||
GitSignsUpdate After Gitsigns updates its knowledge about hunks.
|
||||
Provides `bufnr` in the autocmd user data.
|
||||
|
||||
*User_GitSignsChanged*
|
||||
GitSignsChanged After any event in which Gitsigns can potentially change
|
||||
the repository. Provides `file` in the autocmd user data.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
vim:tw=78:ts=8:ft=help:norl:
|
||||
|
|
|
@ -486,8 +486,19 @@ function Obj:get_show_text(revision)
|
|||
return stdout, stderr
|
||||
end
|
||||
|
||||
local function autocmd_changed(file)
|
||||
vim.schedule(function()
|
||||
vim.api.nvim_exec_autocmds('User', {
|
||||
pattern = 'GitSignsChanged',
|
||||
modeline = false,
|
||||
data = { file = file },
|
||||
})
|
||||
end)
|
||||
end
|
||||
|
||||
function Obj:unstage_file()
|
||||
self:command({ 'reset', self.file })
|
||||
autocmd_changed(self.file)
|
||||
end
|
||||
|
||||
--- @class Gitsigns.CommitInfo
|
||||
|
@ -734,6 +745,8 @@ function Obj:stage_lines(lines)
|
|||
'--cacheinfo',
|
||||
string.format('%s,%s,%s', self.mode_bits, new_object, self.relpath),
|
||||
})
|
||||
|
||||
autocmd_changed(self.file)
|
||||
end
|
||||
|
||||
--- @param hunks Gitsigns.Hunk.Hunk[]
|
||||
|
@ -761,6 +774,8 @@ function Obj:stage_hunks(hunks, invert)
|
|||
}, {
|
||||
stdin = patch,
|
||||
})
|
||||
|
||||
autocmd_changed(self.file)
|
||||
end
|
||||
|
||||
--- @return string?
|
||||
|
|
Loading…
Reference in a new issue