diff options
| author | Justin M. Keyes <justinkz@gmail.com> | 2026-05-20 17:33:01 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-05-20 17:33:01 -0400 |
| commit | 9aa4608401384a59ea54e0ba800ce063775e8ae9 (patch) | |
| tree | 6292c7eb1c09d2f0fbc055410bd8a38e58052982 /runtime/lua/vim/ui.lua | |
| parent | 799cbfff855c72282a54646f3e5e1b71b0da223c (diff) | |
| download | rneovim-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/ui.lua')
| -rw-r--r-- | runtime/lua/vim/ui.lua | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/runtime/lua/vim/ui.lua b/runtime/lua/vim/ui.lua index fd065d1ad5..c34c28f23a 100644 --- a/runtime/lua/vim/ui.lua +++ b/runtime/lua/vim/ui.lua @@ -342,11 +342,13 @@ do --- Initialize Progress handlers. local function progress_init() progress_group = vim.api.nvim_create_augroup('nvim.ui.progress_status', { clear = true }) - progress_autocmd = vim.api.nvim_create_autocmd('Progress', { - group = progress_group, - desc = 'Tracks progress messages for vim.ui.progress_status()', - ---@param ev {data: vim.event.progress.data} - callback = function(ev) + progress_autocmd = require('vim._core.util').nvim_on( + 'Progress', + progress_group, + { + desc = 'Tracks progress messages for vim.ui.progress_status()', + }, ---@param ev {data: vim.event.progress.data} + function(ev) if not ev.data or not ev.data.id then return end @@ -362,8 +364,8 @@ do then progress[ev.data.id] = nil end - end, - }) + end + ) end --- Gets a status description summarizing currently running progress messages. |