nixvim icon indicating copy to clipboard operation
nixvim copied to clipboard

[Feature] option to disable calling `setup`

Open mathjiajia opened this issue 1 month ago • 5 comments

It is not necessary to call the setup for every plugin, so is it possible to add a boolean to control this in nixvim?

mathjiajia avatar Nov 21 '25 01:11 mathjiajia

Technically, you could do plugins.foo.luaConfig.content = lib.mkForce "".

However, I would be curious to know for which plugin(s) we are calling the setup function unnecessarily.

GaetanLepage avatar Nov 21 '25 09:11 GaetanLepage

thank you

However, I would be curious to know for which plugin(s) we are calling the setup function unnecessarily.

for example, fff-nvim and blink-indent

mathjiajia avatar Nov 21 '25 10:11 mathjiajia

We should probably add an "optional" value to callSetup that makes it so it is only called when settings is set. There are a bunch of especially newer plugins that use this optional setup pattern.

saygo-png avatar Nov 21 '25 11:11 saygo-png

Yeah, I like that. If we don't need to call setup, it would be preferred to avoid injecting it into the init.lua needlessly.

khaneliman avatar Nov 21 '25 19:11 khaneliman

We should probably add an "optional" value to callSetup that makes it so it is only called when settings is set. There are a bunch of especially newer plugins that use this optional setup pattern.

Sure, but there is a nuance to that. When calling setup is necessary for initializing the plugin (whether or not settings is empty), we should definitely do it. AFAIK, this is the case for most plugins.

Maybe we could expose a user-facing callSetup toggle for all plugins.

plugins.foo = {
  enable = true;
  callSetup = false;
};
  • We should make sure that settings cannot be non-empty if callSetup is disabled (assertion or at least warning)
  • We could set the default value of callSetup per plugin (maybe defaulting to true). If we know that foo does not require its setup function to be called when no settings are provided, then we could set plugins.foo.callSetup to false by default.

GaetanLepage avatar Nov 22 '25 09:11 GaetanLepage