From b41ffc1883d7cdaec2ecfb3931cecd13283a1adf Mon Sep 17 00:00:00 2001 From: Aiden Scandella Date: Sun, 15 May 2022 19:46:46 -0700 Subject: [PATCH 1/2] Add events for push and commit complete --- lua/neogit/popups/commit.lua | 1 + lua/neogit/popups/push.lua | 1 + 2 files changed, 2 insertions(+) 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 From 50e70cd471f832ebf7989713dc55a4d7892cc064 Mon Sep 17 00:00:00 2001 From: Aiden Scandella Date: Sun, 15 May 2022 20:00:54 -0700 Subject: [PATCH 2/2] Update README --- README.md | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) 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