aboutsummaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authorGregory Anders <greg@gpanders.com>2021-08-20 11:45:28 -0600
committerGitHub <noreply@github.com>2021-08-20 10:45:28 -0700
commit50b30de2007961718cc11811a30f6b0f35c3c793 (patch)
tree5bef15d7394ec3ccef0ced4c7e93d68bb11fa015 /runtime
parent599af74514d0d7083c0565005f255e59ecd7e2ad (diff)
downloadrneovim-50b30de2007961718cc11811a30f6b0f35c3c793.tar.gz
rneovim-50b30de2007961718cc11811a30f6b0f35c3c793.tar.bz2
rneovim-50b30de2007961718cc11811a30f6b0f35c3c793.zip
feat(terminal): TermClose: set exit code in v:event.status #15406
Closes #4713
Diffstat (limited to 'runtime')
-rw-r--r--runtime/doc/autocmd.txt2
-rw-r--r--runtime/doc/eval.txt1
-rw-r--r--runtime/doc/nvim_terminal_emulator.txt4
3 files changed, 7 insertions, 0 deletions
diff --git a/runtime/doc/autocmd.txt b/runtime/doc/autocmd.txt
index 87c2e11a1e..03e182cb33 100644
--- a/runtime/doc/autocmd.txt
+++ b/runtime/doc/autocmd.txt
@@ -914,6 +914,8 @@ TermLeave After leaving |Terminal-mode|.
After TermClose.
*TermClose*
TermClose When a |terminal| job ends.
+ Sets these |v:event| keys:
+ status
*TermResponse*
TermResponse After the response to t_RV is received from
the terminal. The value of |v:termresponse|
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index a76298c86c..e02d80252f 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -1641,6 +1641,7 @@ v:event Dictionary of event data for the current |autocommand|. Valid
|v:false| if not.
changed_window Is |v:true| if the the event fired
while changing window (or tab) on |DirChanged|.
+ status Job status or exit code, -1 means "unknown". |TermClose|
*v:exception* *exception-variable*
v:exception The value of the exception most recently caught and not
diff --git a/runtime/doc/nvim_terminal_emulator.txt b/runtime/doc/nvim_terminal_emulator.txt
index 6dbc54463c..e0589ba7b8 100644
--- a/runtime/doc/nvim_terminal_emulator.txt
+++ b/runtime/doc/nvim_terminal_emulator.txt
@@ -134,6 +134,10 @@ Example: >
programs can set this by emitting an escape sequence.
- |'channel'| Terminal PTY |job-id|. Can be used with |chansend()| to send
input to the terminal.
+- The |TermClose| event gives the terminal job exit code in the |v:event|
+ "status" field. For example, this autocmd closes terminal buffers if the job
+ exited without error: >
+ autocmd TermClose * if !v:event.status | exe 'bdelete! '..expand('<abuf>') | endif
Use |jobwait()| to check if the terminal job has finished: >
let running = jobwait([&channel], 0)[0] == -1