aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/tty.lua
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2026-05-20 17:33:01 -0400
committerGitHub <noreply@github.com>2026-05-20 17:33:01 -0400
commit9aa4608401384a59ea54e0ba800ce063775e8ae9 (patch)
tree6292c7eb1c09d2f0fbc055410bd8a38e58052982 /runtime/lua/vim/tty.lua
parent799cbfff855c72282a54646f3e5e1b71b0da223c (diff)
downloadrneovim-9aa4608401384a59ea54e0ba800ce063775e8ae9.tar.gz
rneovim-9aa4608401384a59ea54e0ba800ce063775e8ae9.tar.bz2
rneovim-9aa4608401384a59ea54e0ba800ce063775e8ae9.zip
refactor: introduce nvim_on internally #39883
Problem: `nvim_create_autocmd` is too verbose and its `callback` requires extra "nesting". Solution: Introduce `nvim_on`. Start using it internally. Then we can get a feel for how it should look before making it public.
Diffstat (limited to 'runtime/lua/vim/tty.lua')
-rw-r--r--runtime/lua/vim/tty.lua13
1 files changed, 7 insertions, 6 deletions
diff --git a/runtime/lua/vim/tty.lua b/runtime/lua/vim/tty.lua
index 2693c1bc97..6771efe849 100644
--- a/runtime/lua/vim/tty.lua
+++ b/runtime/lua/vim/tty.lua
@@ -28,18 +28,19 @@ function M.request(payload, opts, on_response)
timer = assert(vim.uv.new_timer())
end
- local id = vim.api.nvim_create_autocmd('TermResponse', {
- group = opts.group,
- nested = true,
- callback = function(ev)
+ local id = require('vim._core.util').nvim_on(
+ 'TermResponse',
+ opts.group,
+ { nested = true },
+ function(ev)
local stop = on_response(ev.data.sequence)
-- If on_response is done, cancel the timeout so on_timeout doesn't fire spuriously.
if stop and timer and not timer:is_closing() then
timer:close()
end
return stop
- end,
- })
+ end
+ )
if payload ~= '' then
vim.api.nvim_ui_send(payload)