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.
This commit is contained in:
Justin M. Keyes
2026-05-20 17:33:01 -04:00
committed by GitHub
parent 799cbfff85
commit 9aa4608401
32 changed files with 842 additions and 1040 deletions

View File

@@ -1,3 +1,5 @@
local nvim_on = require('vim._core.util').nvim_on
local M = {}
---@brief
@@ -142,10 +144,8 @@ function M._supported(opts)
return require('vim.ui.img._kitty').supported(opts)
end
vim.api.nvim_create_autocmd('VimLeavePre', {
callback = function()
M.del(math.huge)
end,
})
nvim_on('VimLeavePre', nil, function()
M.del(math.huge)
end)
return M