|
1 | | -{ |
2 | | - lib, |
3 | | - config, |
4 | | - pkgs, |
5 | | - ... |
6 | | -}: |
7 | | -let |
8 | | - inherit (lib) types mkOption; |
| 1 | +{ lib, ... }: |
| 2 | +lib.nixvim.plugins.mkNeovimPlugin { |
| 3 | + name = "alpha"; |
| 4 | + package = "alpha-nvim"; |
9 | 5 |
|
10 | | - cfg = config.plugins.alpha; |
| 6 | + maintainers = [ lib.maintainers.HeitorAugustoLN ]; |
11 | 7 |
|
12 | | - sectionType = types.submodule { |
13 | | - freeformType = with types; attrsOf anything; |
14 | | - options = { |
15 | | - type = mkOption { |
16 | | - type = types.enum [ |
17 | | - "button" |
18 | | - "group" |
19 | | - "padding" |
20 | | - "text" |
21 | | - "terminal" |
22 | | - ]; |
23 | | - description = "Type of section"; |
24 | | - }; |
25 | | - |
26 | | - val = lib.nixvim.mkNullOrOption ( |
27 | | - with types; |
28 | | - nullOr (oneOf [ |
29 | | - |
30 | | - # "button", "text" |
31 | | - (maybeRaw str) |
32 | | - # "padding" |
33 | | - int |
34 | | - (listOf ( |
35 | | - either |
36 | | - # "text" (list of strings) |
37 | | - str |
38 | | - # "group" |
39 | | - (attrsOf anything) |
40 | | - )) |
41 | | - ]) |
42 | | - ) "Value for section"; |
43 | | - |
44 | | - opts = mkOption { |
45 | | - type = with types; attrsOf anything; |
46 | | - default = { }; |
47 | | - description = "Additional options for the section"; |
48 | | - }; |
49 | | - }; |
50 | | - }; |
51 | | -in |
52 | | -{ |
53 | | - options = { |
54 | | - plugins.alpha = { |
55 | | - enable = lib.mkEnableOption "alpha-nvim"; |
| 8 | + # TODO Added 2025-10-26: remove after 26.05 |
| 9 | + inherit (import ./deprecations.nix lib) imports optionsRenamedToSettings; |
56 | 10 |
|
57 | | - package = lib.mkPackageOption pkgs "alpha-nvim" { |
58 | | - default = [ |
59 | | - "vimPlugins" |
60 | | - "alpha-nvim" |
| 11 | + settingsExample = { |
| 12 | + layout = [ |
| 13 | + { |
| 14 | + type = "padding"; |
| 15 | + val = 2; |
| 16 | + } |
| 17 | + { |
| 18 | + type = "text"; |
| 19 | + val = [ |
| 20 | + "███╗ ██╗██╗██╗ ██╗██╗ ██╗██╗███╗ ███╗" |
| 21 | + "████╗ ██║██║╚██╗██╔╝██║ ██║██║████╗ ████║" |
| 22 | + "██╔██╗ ██║██║ ╚███╔╝ ██║ ██║██║██╔████╔██║" |
| 23 | + "██║╚██╗██║██║ ██╔██╗ ╚██╗ ██╔╝██║██║╚██╔╝██║" |
| 24 | + "██║ ╚████║██║██╔╝ ██╗ ╚████╔╝ ██║██║ ╚═╝ ██║" |
| 25 | + "╚═╝ ╚═══╝╚═╝╚═╝ ╚═╝ ╚═══╝ ╚═╝╚═╝ ╚═╝" |
61 | 26 | ]; |
62 | | - }; |
63 | | - |
64 | | - theme = mkOption { |
65 | | - type = with types; nullOr (maybeRaw str); |
66 | | - apply = v: if lib.isString v then lib.nixvim.mkRaw "require'alpha.themes.${v}'.config" else v; |
67 | | - default = null; |
68 | | - example = "dashboard"; |
69 | | - description = "You can directly use a pre-defined theme."; |
70 | | - }; |
71 | | - |
72 | | - layout = mkOption { |
73 | | - type = with types; either (maybeRaw str) (listOf sectionType); |
74 | | - default = [ ]; |
75 | | - description = "List of sections to layout for the dashboard"; |
76 | | - example = [ |
| 27 | + opts = { |
| 28 | + position = "center"; |
| 29 | + hl = "Type"; |
| 30 | + }; |
| 31 | + } |
| 32 | + { |
| 33 | + type = "padding"; |
| 34 | + val = 2; |
| 35 | + } |
| 36 | + { |
| 37 | + type = "group"; |
| 38 | + val = [ |
77 | 39 | { |
78 | | - type = "padding"; |
79 | | - val = 2; |
| 40 | + type = "button"; |
| 41 | + val = " New file"; |
| 42 | + on_press = lib.nixvim.nestedLiteralLua "function() vim.cmd[[ene]] end"; |
| 43 | + opts.shortcut = "n"; |
80 | 44 | } |
81 | 45 | { |
82 | | - type = "text"; |
83 | | - val = [ |
84 | | - "███╗ ██╗██╗██╗ ██╗██╗ ██╗██╗███╗ ███╗" |
85 | | - "████╗ ██║██║╚██╗██╔╝██║ ██║██║████╗ ████║" |
86 | | - "██╔██╗ ██║██║ ╚███╔╝ ██║ ██║██║██╔████╔██║" |
87 | | - "██║╚██╗██║██║ ██╔██╗ ╚██╗ ██╔╝██║██║╚██╔╝██║" |
88 | | - "██║ ╚████║██║██╔╝ ██╗ ╚████╔╝ ██║██║ ╚═╝ ██║" |
89 | | - "╚═╝ ╚═══╝╚═╝╚═╝ ╚═╝ ╚═══╝ ╚═╝╚═╝ ╚═╝" |
90 | | - ]; |
91 | | - opts = { |
92 | | - position = "center"; |
93 | | - hl = "Type"; |
94 | | - }; |
95 | | - } |
96 | | - { |
97 | | - type = "padding"; |
98 | | - val = 2; |
99 | | - } |
100 | | - { |
101 | | - type = "group"; |
102 | | - val = [ |
103 | | - { |
104 | | - type = "button"; |
105 | | - val = " New file"; |
106 | | - on_press.__raw = "function() vim.cmd[[ene]] end"; |
107 | | - opts.shortcut = "n"; |
108 | | - } |
109 | | - { |
110 | | - type = "button"; |
111 | | - val = " Quit Neovim"; |
112 | | - on_press.__raw = "function() vim.cmd[[qa]] end"; |
113 | | - opts.shortcut = "q"; |
114 | | - } |
115 | | - ]; |
116 | | - } |
117 | | - { |
118 | | - type = "padding"; |
119 | | - val = 2; |
120 | | - } |
121 | | - { |
122 | | - type = "text"; |
123 | | - val = "Inspiring quote here."; |
124 | | - opts = { |
125 | | - position = "center"; |
126 | | - hl = "Keyword"; |
127 | | - }; |
| 46 | + type = "button"; |
| 47 | + val = " Quit Neovim"; |
| 48 | + on_press = lib.nixvim.nestedLiteralLua "function() vim.cmd[[qa]] end"; |
| 49 | + opts.shortcut = "q"; |
128 | 50 | } |
129 | 51 | ]; |
130 | | - }; |
131 | | - |
132 | | - opts = lib.nixvim.mkNullOrOption (with types; attrsOf anything) '' |
133 | | - Optional global options. |
134 | | - ''; |
135 | | - }; |
| 52 | + } |
| 53 | + { |
| 54 | + type = "padding"; |
| 55 | + val = 2; |
| 56 | + } |
| 57 | + { |
| 58 | + type = "text"; |
| 59 | + val = "Inspiring quote here."; |
| 60 | + opts = { |
| 61 | + position = "center"; |
| 62 | + hl = "Keyword"; |
| 63 | + }; |
| 64 | + } |
| 65 | + ]; |
136 | 66 | }; |
137 | 67 |
|
138 | | - config = |
139 | | - let |
140 | | - layoutDefined = cfg.layout != [ ]; |
141 | | - themeDefined = cfg.theme != null; |
142 | | - in |
143 | | - lib.mkIf cfg.enable { |
144 | | - extraPlugins = [ cfg.package ]; |
145 | | - |
146 | | - assertions = lib.nixvim.mkAssertions "plugins.alpha" [ |
147 | | - { |
148 | | - assertion = themeDefined || layoutDefined; |
149 | | - message = '' |
150 | | - You have to either set a `theme` or define some sections in `layout`. |
151 | | - ''; |
152 | | - } |
153 | | - { |
154 | | - assertion = !(themeDefined && layoutDefined); |
155 | | - message = '' |
156 | | - You can't define both a `theme` and custom options. |
157 | | - Set `plugins.alpha.theme = null` if you want to configure alpha manually using the `layout` option. |
158 | | - ''; |
159 | | - } |
160 | | - ]; |
161 | | - |
162 | | - extraConfigLua = |
163 | | - let |
164 | | - setupOptions = |
165 | | - if themeDefined then |
166 | | - cfg.theme |
167 | | - else |
168 | | - (with cfg; { |
169 | | - inherit layout opts; |
170 | | - }); |
171 | | - in |
172 | | - '' |
173 | | - require('alpha').setup(${lib.nixvim.toLuaObject setupOptions}) |
174 | | - require('alpha.term') |
175 | | - ''; |
176 | | - }; |
| 68 | + callSetup = false; |
| 69 | + extraConfig = cfg: { |
| 70 | + plugins.alpha.luaConfig.content = '' |
| 71 | + require('alpha').setup(${lib.nixvim.toLuaObject cfg.settings}) |
| 72 | + require('alpha.term') |
| 73 | + ''; |
| 74 | + }; |
177 | 75 | } |
0 commit comments