Drop setup() entirely #39
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#39
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
Remove
M.setup()fromlua/canola/init.luaand replace it with initialization driven byplugin/canola.luareadingvim.g.canola. This is a hard break — no compatibility shim, no fallback path.Motivation
setup()is a call-time initialization pattern inherited from the Lua plugin ecosystem. It requires the user torequire()the plugin explicitly, which conflicts with lazy-loading and makes session restore fragile (the plugin may not be initialized when a session buffer tries to load).vim.g.canolais set before any plugin loads, soplugin/canola.luacan always read a fully-formed config at startup regardless of when or whether the userrequire()s anything.Keeping
setup()alongsidevim.g.canolacreates two config surfaces that must be merged in a defined order, with edge cases around partial configs and late calls. Droppingsetup()entirely eliminates that complexity.What changes
lua/canola/init.lua:M.setup()and its bodyif M._initialized then return end) thatsetup()currently usesplugin/canola.lua:vim.g.canola(defaulting to{}if unset)setup())lua/canola/config.lua:config.setup(opts)remains — it merges opts with defaults and sets module fields. The publicM.setup()wrapper ininit.luais what's removed.Setter API
Function-valued config fields cannot live in
vim.g. They are replaced by setter functions on the public API:require('canola').set_is_hidden_file(fn)require('canola').set_is_always_hidden(fn)require('canola').set_highlight_filename(fn)require('canola').set_disable_preview(fn)These must be called after the plugin loads (e.g. in an
after/pluginfile or lazy.nvim'sconfigcallback). They update the live config and take effect on the next render.Hook replacements
git.add,git.mv,git.rm,float.override, andfloat.get_win_titleare replaced by User autocmds. See #182 for the full autocmd event design.Migration guide outline
Users coming from oil.nvim or canola v1.0:
require('oil').setup({...})/require('canola').setup({...})from your config.vim.g.canola = {...}in yourinit.luaor equivalent, before any plugin loads.view_options.is_hidden_file→require('canola').set_is_hidden_file(fn)view_options.is_always_hidden→require('canola').set_is_always_hidden(fn)view_options.highlight_filename→require('canola').set_highlight_filename(fn)preview_win.disable_preview→require('canola').set_disable_preview(fn)git.add, etc.) to the corresponding User autocmds (see #182).initkey (notopts) to setvim.g.canola.Related
vim.g.canolaconfig system (full field reference)