Skip to content

Conversation

@HeitorAugustoLN
Copy link
Member

@HeitorAugustoLN HeitorAugustoLN commented Feb 27, 2025

Tracking: #2638

Comment on lines 233 to 235
plugins.alpha.luaConfig.content =
optionalString themeDefined "require('alpha').setup(${toLuaObject cfg.theme})\n"
+ "require('alpha.term')";
Copy link
Member

@MattSturgeon MattSturgeon Feb 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little confused. You have a settings option, but you are also manually calling setup and passing it a theme option.

The idea of settings is that it is the nix representation of the lua passed to setup.

Usually, mkNeovimPlugin will take responsibility for calling setup and passing it the settings.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.setup needs to be manually called when using theme option. Because that is the only way we can set pre-defined themes. That's why, theme and settings.layout options can't be used at the same time

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If so, that also implies:

  1. settings as a whole must not be used when a theme is defined
  2. setup must always be called manually, either passing it settings or theme

Copy link
Member

@MattSturgeon MattSturgeon Feb 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, the upstream examples show a different usage:

require('alpha').setup(require('alpha.themes.dashboard').config)

They are passing pre-defined settings to setup; getting those settings from a theme module.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is the same usage, the theme option is being converted here:

apply =
value:
if builtins.isString value then
lib.nixvim.mkRaw ''require("alpha.themes.${value}").config''
else
value;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now solved as settings can accept a rawLua type.
Hence, the user can do:

plugins.alpha = {
  enable = true;
  settings.__raw = "require('alpha.themes.dashboard').config";
};

@HeitorAugustoLN HeitorAugustoLN force-pushed the alpha-mkneovimplug branch 2 times, most recently from c83415c to 3ea66f1 Compare February 27, 2025 23:11
@HeitorAugustoLN HeitorAugustoLN force-pushed the alpha-mkneovimplug branch 2 times, most recently from cbddcc4 to 0337a66 Compare February 28, 2025 19:14
Copy link
Member

@MattSturgeon MattSturgeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I always struggle to review mkNeovimPlugin migrations as the diff ends up very noisy.

I also had most of this review "pending" for a while as I forgot to hit "submit" 😅


maintainers = [ lib.maintainers.HeitorAugustoLN ];

callSetup = false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typically we have an explanatory comment.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved callSetup = false; right above extraConfig to make its purpose obvious.

};

extraPlugins = [ cfg.package ];
optionsRenamedToSettings = [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should have a comment saying when it was added.

Also, we need to update the test cases. See CI failures: https://buildbot.nix-community.org/#/builders/2885/builds/3656/steps/1/logs/stdio

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

require('alpha.term')
'';
plugins.alpha.luaConfig.content = ''
require('alpha').setup(${toLuaObject (if themeDefined then cfg.theme else cfg.settings)});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels like it could be confusing to users. I wonder if we should have it so that we do this in the module system?

settings = mkDerivedConfig opts.theme (
  value:
  if builtins.isString value then mkRaw ''require("alpha.themes.${value}").config'' else value
);

However, that'd require refactoring settings to a maybeRaw type.

As a minimum, the weird behaviour of discarding all configured settings if a theme is defined should be documented somewhere.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still feel like this behaviour of settings only being used when there is no theme is a bad design 🤔

@MattSturgeon

This comment was marked as resolved.

@GaetanLepage

This comment was marked as resolved.

@HeitorAugustoLN

This comment was marked as resolved.

@MattSturgeon

This comment was marked as resolved.

require('alpha.term')
'';
plugins.alpha.luaConfig.content = ''
require('alpha').setup(${toLuaObject (if themeDefined then cfg.theme else cfg.settings)});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still feel like this behaviour of settings only being used when there is no theme is a bad design 🤔


assertions = lib.nixvim.mkAssertions "plugins.alpha" [
extraConfig =
opts: cfg:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
opts: cfg:
cfg: opts:

Copy link
Member

@MattSturgeon MattSturgeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Note: there are a few older unresolved threads still)

Comment on lines 228 to 231
!(
themeDefined
&& (opts.settings.highestPrio == 1500 && builtins.length opts.settings.definitions == 1)
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm probably mis-understanding this logic. But should the assertion be themeDefined implies settings not defined?

Suggested change
!(
themeDefined
&& (opts.settings.highestPrio == 1500 && builtins.length opts.settings.definitions == 1)
);
themeDefined ->
(opts.settings.highestPrio == 1500 && builtins.length opts.settings.definitions == 1);

@GaetanLepage GaetanLepage force-pushed the alpha-mkneovimplug branch 3 times, most recently from 7945e0f to 370ea63 Compare October 26, 2025 13:17
@GaetanLepage
Copy link
Member

This should now be ready!

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.

3 participants