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