diff --git a/README.md b/README.md index 1fea66022..38da1b6bd 100644 --- a/README.md +++ b/README.md @@ -251,15 +251,31 @@ Set `disable_insert_on_commit = true` in your call to [`setup`](#configuration) ## Events -Neogit emits a `NeogitStatusRefreshed` event whenever the status gets reloaded. +Neogit emits the following events: -You can listen to the event using the following code: +| Event | Description | +|-------------------------|----------------------------------| +| `NeogitStatusRefreshed` | Status has been reloaded | +| `NeogitCommitComplete` | Commit has been created | +| `NeogitPushComplete` | Push has completed | + + +You can listen to the events using the following code: ```vim autocmd User NeogitStatusRefreshed echom "Hello World!" ``` -Further information can be found under `:h autocmd`. +Or, if you prefer to configure autocommands via Lua: + +```lua +local group = vim.api.nvim_create_augroup('MyCustomNeogitEvents', { clear = true }) +vim.api.nvim_create_autocmd('User', { + pattern = 'NeogitPushComplete', + group = group, + callback = require('neogit').close, +}) +``` ## Magit-style Keybindings diff --git a/lua/neogit/popups/commit.lua b/lua/neogit/popups/commit.lua index be4d1105c..93551f2f9 100644 --- a/lua/neogit/popups/commit.lua +++ b/lua/neogit/popups/commit.lua @@ -112,6 +112,7 @@ local function do_commit(popup, data, cmd, skip_gen) if result.code == 0 then a.uv.fs_unlink(commit_file) status.refresh(true) + vim.cmd([[do User NeogitCommitComplete]]) end end diff --git a/lua/neogit/popups/push.lua b/lua/neogit/popups/push.lua index 816aa2c57..5f7f04045 100644 --- a/lua/neogit/popups/push.lua +++ b/lua/neogit/popups/push.lua @@ -19,6 +19,7 @@ local function push_to(popup, name, remote, branch) logger.error("Pushed to " .. name) notif.create("Pushed to " .. name) status.refresh(true) + vim.cmd([[do User NeogitPushComplete]]) else logger.error("Failed to push to " .. name) end