Skip to content

fix: forward ev.data, validate buffer, chain dependencies, and dedupl…#10

Merged
zuqini merged 1 commit intomainfrom
zuqini/event-fire-missing-data
Apr 9, 2026
Merged

fix: forward ev.data, validate buffer, chain dependencies, and dedupl…#10
zuqini merged 1 commit intomainfrom
zuqini/event-fire-missing-data

Conversation

@zuqini
Copy link
Copy Markdown
Owner

@zuqini zuqini commented Apr 9, 2026

…icate augroups on event re-fire

After lazy-loading a plugin, the re-fired autocmd was missing ev.data (crashing callbacks like LspAttach that read event.data.client_id), could error on wiped buffers, lacked dependency chaining (BufReadPre → BufReadPost → FileType), and double-fired pre-existing handlers.

Extract shared refire module with snapshot-based augroup dedup: before loading, snapshot existing augroups per event; after loading, fire only newly-added groups. FileType is exempt from dedup (all handlers re-fire). All nvim_exec_autocmds calls are pcall-wrapped so one plugin's error does not break the chain.

Also wrap process_spec in pcall so a failed plugin load doesn't prevent the re-fire chain from executing, and remove vim.schedule deferral in ft.lua to fire synchronously (matching lazy.nvim's behavior).

Closes #9

…icate augroups on event re-fire

After lazy-loading a plugin, the re-fired autocmd was missing ev.data
(crashing callbacks like LspAttach that read event.data.client_id),
could error on wiped buffers, lacked dependency chaining (BufReadPre →
BufReadPost → FileType), and double-fired pre-existing handlers.

Extract shared refire module with snapshot-based augroup dedup: before
loading, snapshot existing augroups per event; after loading, fire only
newly-added groups. FileType is exempt from dedup (all handlers re-fire).
All nvim_exec_autocmds calls are pcall-wrapped so one plugin's error
does not break the chain.

Also wrap process_spec in pcall so a failed plugin load doesn't prevent
the re-fire chain from executing, and remove vim.schedule deferral in
ft.lua to fire synchronously (matching lazy.nvim's behavior).

Closes #9
@zuqini zuqini force-pushed the zuqini/event-fire-missing-data branch from 1cc0a2f to 2351956 Compare April 9, 2026 06:49
@zuqini zuqini merged commit 7ea1529 into main Apr 9, 2026
2 checks passed
@zuqini zuqini deleted the zuqini/event-fire-missing-data branch April 9, 2026 06:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: nvim_exec_autocmds re-fire missing data and buffer validation after lazy-load

1 participant