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/pack.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/pack.lua')
| -rw-r--r-- | runtime/lua/vim/pack.lua | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/runtime/lua/vim/pack.lua b/runtime/lua/vim/pack.lua index a4f7389fda..aad11e0915 100644 --- a/runtime/lua/vim/pack.lua +++ b/runtime/lua/vim/pack.lua @@ -232,6 +232,7 @@ local api = vim.api local uv = vim.uv local async = require('vim._async') local util = require('vim._core.util') +local nvim_on = util.nvim_on local N_ = vim.fn.gettext local M = {} @@ -1199,7 +1200,7 @@ local function show_confirm_buf(lines, on_finish) delete_buffer() end -- - Use `nested` to allow other events (useful for statuslines) - api.nvim_create_autocmd('BufWriteCmd', { buf = bufnr, nested = true, callback = finish }) + nvim_on('BufWriteCmd', nil, { buf = bufnr, nested = true }, finish) -- Define action to cancel confirm --- @type integer @@ -1211,7 +1212,7 @@ local function show_confirm_buf(lines, on_finish) pcall(api.nvim_del_autocmd, cancel_au_id) delete_buffer() end - cancel_au_id = api.nvim_create_autocmd('WinClosed', { nested = true, callback = on_cancel }) + cancel_au_id = nvim_on('WinClosed', nil, { nested = true }, on_cancel) -- Set buffer-local options last (so that user autocmmands could override) vim.bo[bufnr].modified = false |