@@ -137,47 +137,63 @@ rec {
137
137
} " ;
138
138
} ;
139
139
140
- pluginLuaConfig = types . submodule (
141
- { config , ... } :
140
+ pluginLuaConfig =
141
+ { hasContent } :
142
142
let
143
143
inherit ( builtins ) toString ;
144
144
inherit ( lib . nixvim . utils ) mkBeforeSection mkAfterSection ;
145
- in
146
- {
147
- options = {
148
- pre = lib . mkOption {
149
- type = with types ; nullOr lines ;
150
- default = null ;
151
- description = ''
152
- Lua code inserted at the start of the plugin's configuration.
153
- This is the same as using `lib.nixvim.utils.mkBeforeSection` when defining `content`.
154
- '' ;
155
- } ;
156
- post = lib . mkOption {
157
- type = with types ; nullOr lines ;
158
- default = null ;
159
- description = ''
160
- Lua code inserted at the end of the plugin's configuration.
161
- This is the same as using `lib.nixvim.utils.mkAfterSection` when defining `content`.
162
- '' ;
163
- } ;
164
- content = lib . mkOption {
165
- type = types . lines ;
166
- default = "" ;
167
- description = ''
168
- Configuration of the plugin.
169
-
170
- If `pre` and/or `post` are non-null, they will be merged using the order priorities
171
- ${ toString ( mkBeforeSection null ) . priority } and ${ toString ( mkBeforeSection null ) . priority }
172
- respectively.
173
- '' ;
145
+
146
+ commonModule = {
147
+ options = {
148
+ pre = lib . mkOption {
149
+ type = with types ; nullOr lines ;
150
+ default = null ;
151
+ description =
152
+ ''
153
+ Lua code inserted at the start of the plugin's configuration.
154
+ ''
155
+ + lib . optionalString hasContent ''
156
+ This is the same as using `lib.nixvim.utils.mkBeforeSection` when defining `content`.
157
+ '' ;
158
+ } ;
159
+ post = lib . mkOption {
160
+ type = with types ; nullOr lines ;
161
+ default = null ;
162
+ description =
163
+ ''
164
+ Lua code inserted at the end of the plugin's configuration.
165
+ ''
166
+ + lib . optionalString hasContent ''
167
+ This is the same as using `lib.nixvim.utils.mkAfterSection` when defining `content`.
168
+ '' ;
169
+ } ;
174
170
} ;
175
171
} ;
176
172
177
- config . content = lib . mkMerge (
178
- lib . optional ( config . pre != null ) ( mkBeforeSection config . pre )
179
- ++ lib . optional ( config . post != null ) ( mkAfterSection config . post )
180
- ) ;
181
- }
182
- ) ;
173
+ contentModule =
174
+ { config , ... } :
175
+ {
176
+ options = {
177
+ content = lib . mkOption {
178
+ type = types . lines ;
179
+ default = "" ;
180
+ description = ''
181
+ Configuration of the plugin.
182
+
183
+ If `pre` and/or `post` are non-null, they will be merged using the order priorities
184
+ ${ toString ( mkBeforeSection null ) . priority } and ${ toString ( mkBeforeSection null ) . priority }
185
+ respectively.
186
+ '' ;
187
+ } ;
188
+ } ;
189
+
190
+ config = {
191
+ content = lib . mkMerge (
192
+ lib . optional ( config . pre != null ) ( mkBeforeSection config . pre )
193
+ ++ lib . optional ( config . post != null ) ( mkAfterSection config . post )
194
+ ) ;
195
+ } ;
196
+ } ;
197
+ in
198
+ types . submodule ( [ commonModule ] ++ ( lib . optional hasContent contentModule ) ) ;
183
199
}
0 commit comments