-
-
Notifications
You must be signed in to change notification settings - Fork 363
Description
Updated: sorry, I just realized that luaContent.post is what extract I am looking for. I have open a PR to improve the document. See PR for details.
Summary
Right now, when lazyLoad.enable = true, Nixvim will automatically route the generated setup code (luaConfig.content) into the lazy loading provider (lz.n), and use it as the after function if lazyLoad.settings.after is not set.
But as soon as I set lazyLoad.settings.after, I can only override this behavior. There is no way to extend the default after (e.g. “keep what Nixvim would do, plus a bit more”).
Example use case
I want to lazy load catppuccin and let Nixvim do its normal setup for it. After catppuccin has been loaded, configure bufferline integration. This order is required as documented in catppuccin/nvim.
With the current design:
- Nixvim will generate a lua function
- If I now set
lazyLoad.settings.after, I lose this default after and must completely reimplement it, just to add my bufferline color setup, for example:
plugins.bufferline = {
enable = true;
settings.highlights.__raw = ''require("catppuccin.special.bufferline").get_theme()'';
lazyLoad.settings.lazy = true; # Lazy load manually
};
plugins.catppuccin = {
enable = true;
# `plugins.catppuccin.settings` is invalid, we have to reimplement it
lazyLoad.settings.after.__raw = ''
function()
require("catppuccin").setup({
-- plugins.catppuccin is invalid now
flavour = "mocha";
transparent_background = true;
})
require('lz.n').trigger_load("bufferline.nvim")
end
'';
};The key point: I don’t want to change what Nixvim already generates, I just want to append some logic when the lazy-loaded plugin finishes its normal setup.
Requested change
It would be very helpful if Nixvim provided a way to extend the default after instead of only overriding it. For example:
Add an extra hook like lazyLoad.settings.afterExtra, which runs after the default after.
This would allow configs like:
plugins.catppuccin = {
enable = true;
settings = {
flavour = "mocha";
transparent_background = true;
};
# only my extra part, keep default catppuccin setup
lazyLoad.settings.afterExtra.__raw = ''
require('lz.n').trigger_load("bufferline.nvim")
'';
};Workaround
Completely override lazyLoad.settings.after.__raw = ''function() ... end, and manually re-call the plugin’s setup (duplicating what Nixvim would have generated), plus my extra code.
This works, but:
- It’s fragile (can get out of sync with Nixvim’s generated setup).
- It’s verbose for a very common pattern: “run the default setup, then do X”.
If there’s already an intended way to extend after without replacing it, I’d love to know; otherwise, I hope this feature can be considered.