feat(channel): add ChanClose event #40568

Problem:
Plugins using RPC sockets cannot detect when the peer closes a
`sockconnect()` channel, so reconnect logic has no reliable trigger.

Solution:
Add a `ChanClose` event with channel info before the channel is removed,
matching the existing `ChanOpen`/`ChanInfo` event model.
This commit is contained in:
Barrett Ruth
2026-07-04 14:21:25 -05:00
committed by GitHub
parent f0559997dd
commit d0a262db88
10 changed files with 63 additions and 5 deletions

View File

@@ -397,6 +397,13 @@ BufWriteCmd Before writing the whole buffer to a file.
BufWritePost After writing the whole buffer to a file
(should undo the commands for BufWritePre).
*ChanClose*
ChanClose After a channel was closed, before it is removed.
This is triggered even when inside an
autocommand defined without |autocmd-nested|.
Sets these |v:event| keys:
info as from |nvim_get_chan_info()|
*ChanInfo*
ChanInfo State of channel changed, for instance the
client of a RPC channel described itself.

View File

@@ -219,6 +219,7 @@ EVENTS
• |:delmarks| now triggers the |MarkSet| autocommand with line==col==0, same
as |nvim_buf_del_mark()|
• |ChanClose| is triggered after a channel is closed, before it is removed.
• |SessionWritePre| event emits just before |:mksession|.
• |TextPutPre| and |TextPutPost| are triggered before/after putting text.
• |TabMoved| is triggered when tabs are reordered.

View File

@@ -2544,6 +2544,7 @@ A jump table for the options with a short description can be found at |Q_op|.
Note: The following events are considered to happen outside of a
window context and thus cannot be ignored by 'eventignorewin':
|ChanClose|,
|ChanInfo|,
|ChanOpen|,
|CmdUndefined|,

View File

@@ -102,6 +102,7 @@ error('Cannot require a meta file')
--- |'BufWriteCmd'
--- |'BufWritePost'
--- |'BufWritePre'
--- |'ChanClose'
--- |'ChanInfo'
--- |'ChanOpen'
--- |'CmdUndefined'

View File

@@ -2191,6 +2191,7 @@ vim.go.ei = vim.go.eventignore
--- Note: The following events are considered to happen outside of a
--- window context and thus cannot be ignored by 'eventignorewin':
---
--- `ChanClose`,
--- `ChanInfo`,
--- `ChanOpen`,
--- `CmdUndefined`,