mirror of
https://github.com/neovim/neovim.git
synced 2026-05-24 05:40:08 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user