aboutsummaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authorGhjuvan Lacambre <code@lacamb.re>2024-01-09 15:27:56 +0100
committerGitHub <noreply@github.com>2024-01-09 08:27:56 -0600
commitbeca827212b106114c371f8bb61aa1a50810062f (patch)
tree8c48282193fef8f58768a03663df94bf00b8aa29 /runtime
parentf40df63bdca33d343cada6ceaafbc8b765ed7cc6 (diff)
downloadrneovim-beca827212b106114c371f8bb61aa1a50810062f.tar.gz
rneovim-beca827212b106114c371f8bb61aa1a50810062f.tar.bz2
rneovim-beca827212b106114c371f8bb61aa1a50810062f.zip
feat(terminal): trigger TermRequest autocommand events (#22159)
This commit implements a new TermRequest autocommand event and has Neovim emit this event when children of terminal buffers emit an OSC or DCS sequence libvterm does not handle. The TermRequest autocommand event has additional data in the v:termrequest variable. Co-authored-by: Gregory Anders <greg@gpanders.com>
Diffstat (limited to 'runtime')
-rw-r--r--runtime/doc/autocmd.txt5
-rw-r--r--runtime/doc/news.txt3
-rw-r--r--runtime/doc/vvars.txt9
-rw-r--r--runtime/lua/vim/_meta/vvars.lua11
4 files changed, 25 insertions, 3 deletions
diff --git a/runtime/doc/autocmd.txt b/runtime/doc/autocmd.txt
index 45d7a4244c..ce3af01073 100644
--- a/runtime/doc/autocmd.txt
+++ b/runtime/doc/autocmd.txt
@@ -986,6 +986,11 @@ TermLeave After leaving |Terminal-mode|.
TermClose When a |terminal| job ends.
Sets these |v:event| keys:
status
+ *TermRequest*
+TermRequest When a |terminal| job emits an OSC or DCS
+ sequence. Sets |v:termrequest|. When used from
+ Lua, the request string is included in the
+ "data" field of the autocommand callback.
*TermResponse*
TermResponse When Nvim receives an OSC or DCS response from
the terminal. Sets |v:termresponse|. When used
diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt
index d3ace5f33b..98b782a105 100644
--- a/runtime/doc/news.txt
+++ b/runtime/doc/news.txt
@@ -284,6 +284,9 @@ The following new APIs and features were added.
• |vim.deepcopy()| has a `noref` argument to avoid hashing table values.
+• Terminal buffers emit a |TermRequest| autocommand event when the child
+ process emits an OSC or DCS control sequence.
+
==============================================================================
CHANGED FEATURES *news-changed*
diff --git a/runtime/doc/vvars.txt b/runtime/doc/vvars.txt
index 7e96d356d0..e71e31abf8 100644
--- a/runtime/doc/vvars.txt
+++ b/runtime/doc/vvars.txt
@@ -647,9 +647,16 @@ v:t_number Value of |Number| type. Read-only. See: |type()|
*v:t_string* *t_string-variable*
v:t_string Value of |String| type. Read-only. See: |type()|
+ *v:termrequest* *termrequest-variable*
+v:termrequest
+ The value of the most recent OSC or DCS control sequence
+ sent from a process running in the embedded |terminal|.
+ This can be read in a |TermRequest| event handler to respond
+ to queries from embedded applications.
+
*v:termresponse* *termresponse-variable*
v:termresponse
- The value of the most recent OSC or DCS escape sequence
+ The value of the most recent OSC or DCS control sequence
received by Nvim from the terminal. This can be read in a
|TermResponse| event handler after querying the terminal using
another escape sequence.
diff --git a/runtime/lua/vim/_meta/vvars.lua b/runtime/lua/vim/_meta/vvars.lua
index e3b89aeff7..ca87fb9d15 100644
--- a/runtime/lua/vim/_meta/vvars.lua
+++ b/runtime/lua/vim/_meta/vvars.lua
@@ -687,11 +687,18 @@ vim.v.t_number = ...
--- @type integer
vim.v.t_string = ...
---- The value of the most recent OSC or DCS escape sequence
+--- The value of the most recent OSC or DCS control sequence
+--- sent from a process running in the embedded `terminal`.
+--- This can be read in a `TermRequest` event handler to respond
+--- to queries from embedded applications.
+--- @type string
+vim.v.termrequest = ...
+
+--- The value of the most recent OSC or DCS control sequence
--- received by Nvim from the terminal. This can be read in a
--- `TermResponse` event handler after querying the terminal using
--- another escape sequence.
---- @type any
+--- @type string
vim.v.termresponse = ...
--- Must be set before using `test_garbagecollect_now()`.