Enhanced User autocmd events with rich data fields #32
Labels
No labels
autorelease: pending
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
upstream/digest
upstream/pr
wontfix
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
barrettruth/canola.nvim#32
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Overview
v1.1 replaces all hook functions that were in
setup()with User autocmds, and enriches the existing notification events with richer data payloads. This issue tracks the full event surface for v1.1.Renamed existing events
The three events from oil.nvim are renamed and given richer
datafields.CanolaEnter(wasOilEnter)Fires once when an oil buffer is first loaded.
CanolaReadPost(wasOilReadPost)Fires after every successful render of an oil buffer.
firstistrueon the initial render,falseon subsequent refreshes.CanolaMutationComplete(wasOilMutationComplete)Fires after all mutations in a save cycle have been applied.
Each entry in
actionsmirrors the internal action format from the mutator pipeline.New hook events
These replace callback functions that were previously set in
setup(). The pattern is uniform:ev.datacarries mutable fields, and the callback signals intent by writing back intoev.data.CanolaGitAdd/CanolaGitMv/CanolaGitRmReplaces
git.add,git.mv,git.rminsetup(). Setev.data.result = trueto enable the git operation; leave itfalseto skip.Example handler:
CanolaFloatConfigReplaces
float.overrideinsetup(). The callback receives the fully-resolvednvim_open_winconfig and may mutate it in place.Example — force the float to always be full-width:
CanolaWinTitleReplaces
float.get_win_titleinsetup(). Setev.data.titleto override the window title string.Example — show only the last path component:
CanolaPreviewDisableReplaces
preview_win.disable_previewinsetup(). Setev.data.result = trueto suppress the preview for the given file.Example — disable preview for files larger than 1 MB:
Init tier refactor
To support zero-
setup()-call usage (i.e.vim.g.canolaset before the plugin loads, no explicitrequire('oil').setup()), autocmd registration is split into two tiers.Tier 1 —
plugin/canola.lua(always-on, fires at startup)Registered unconditionally when the plugin file is sourced:
BufReadCmd oil://*— core buffer loading handlerBufAdd— directory hijacking (replaces netrw for local dirs)ColorScheme— re-applies highlight groups after colorscheme changesvim.filetype.add— registers theoilfiletypeThese must be up before any config is resolved because Neovim may fire
BufReadCmdbefore the user'sinit.luafinishes (e.g.nvim /some/dir).Tier 2 — registered after config is resolved
Registered once config has been merged from
vim.g.canolaorsetup():VimEnter—default_to_floathandling (open a float when Neovim starts on a directory)SessionLoadPost— session restore compatibilityWinNew— float geometry recalculation on window resizeBufLeave/BufEnterpairs — cursor save/restore, modifiable guardsBufNew— SCP path warning (netrw conflict)An
_initializedguard prevents double-registration ifsetup()is called aftervim.g.canolahas already triggered tier-2 init.The practical result: users who set
vim.g.canolabeforelazy.nvimorpackpathloads canola get a fully working plugin with nosetup()call required.Implemented in #228.