-
-
Couldn't load subscription status.
- Fork 353
plugins/alpha: migrate to mkNeovimPlugin #3040
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
plugins/alpha: migrate to mkNeovimPlugin #3040
Conversation
plugins/by-name/alpha/default.nix
Outdated
| plugins.alpha.luaConfig.content = | ||
| optionalString themeDefined "require('alpha').setup(${toLuaObject cfg.theme})\n" | ||
| + "require('alpha.term')"; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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:
settingsas a whole must not be used when a theme is definedsetupmust always be called manually, either passing itsettingsortheme
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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:
nixvim/plugins/by-name/alpha/default.nix
Lines 196 to 201 in c83415c
| apply = | |
| value: | |
| if builtins.isString value then | |
| lib.nixvim.mkRaw ''require("alpha.themes.${value}").config'' | |
| else | |
| value; |
There was a problem hiding this comment.
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";
};c83415c to
3ea66f1
Compare
cbddcc4 to
0337a66
Compare
0337a66 to
03a6663
Compare
There was a problem hiding this 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" 😅
plugins/by-name/alpha/default.nix
Outdated
|
|
||
| maintainers = [ lib.maintainers.HeitorAugustoLN ]; | ||
|
|
||
| callSetup = false; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
plugins/by-name/alpha/default.nix
Outdated
| }; | ||
|
|
||
| extraPlugins = [ cfg.package ]; | ||
| optionsRenamedToSettings = [ |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
plugins/by-name/alpha/default.nix
Outdated
| require('alpha.term') | ||
| ''; | ||
| plugins.alpha.luaConfig.content = '' | ||
| require('alpha').setup(${toLuaObject (if themeDefined then cfg.theme else cfg.settings)}); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 🤔
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
03a6663 to
d12fba9
Compare
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
d12fba9 to
6fa4aaa
Compare
plugins/by-name/alpha/default.nix
Outdated
| require('alpha.term') | ||
| ''; | ||
| plugins.alpha.luaConfig.content = '' | ||
| require('alpha').setup(${toLuaObject (if themeDefined then cfg.theme else cfg.settings)}); |
There was a problem hiding this comment.
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 🤔
6fa4aaa to
faa3eea
Compare
plugins/by-name/alpha/default.nix
Outdated
|
|
||
| assertions = lib.nixvim.mkAssertions "plugins.alpha" [ | ||
| extraConfig = | ||
| opts: cfg: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| opts: cfg: | |
| cfg: opts: |
There was a problem hiding this 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)
plugins/by-name/alpha/default.nix
Outdated
| !( | ||
| themeDefined | ||
| && (opts.settings.highestPrio == 1500 && builtins.length opts.settings.definitions == 1) | ||
| ); |
There was a problem hiding this comment.
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?
| !( | |
| themeDefined | |
| && (opts.settings.highestPrio == 1500 && builtins.length opts.settings.definitions == 1) | |
| ); | |
| themeDefined -> | |
| (opts.settings.highestPrio == 1500 && builtins.length opts.settings.definitions == 1); |
7945e0f to
370ea63
Compare
|
This should now be ready! |
370ea63 to
d64bb14
Compare
d64bb14 to
caaa371
Compare
Tracking: #2638