@@ -2,6 +2,7 @@ local git = require("neogit.lib.git")
2
2
local state = require (" neogit.lib.state" )
3
3
local util = require (" neogit.lib.util" )
4
4
local notification = require (" neogit.lib.notification" )
5
+ local config = require (" neogit.config" )
5
6
6
7
--- @class PopupBuilder
7
8
--- @field state PopupState
@@ -54,6 +55,7 @@ local M = {}
54
55
--- @field type string
55
56
--- @field user_input boolean
56
57
--- @field value string ?
58
+ --- @field persisted ? boolean
57
59
58
60
--- @class PopupConfig
59
61
--- @field id string
@@ -90,6 +92,7 @@ local M = {}
90
92
--- @field value ? string Allows for pre-building cli flags that can be customized by user input
91
93
--- @field user_input ? boolean If true , allows user to customize the value of the cli flag
92
94
--- @field dependent ? string[] other switches /options with a state dependency on this one
95
+ --- @field persisted ? boolean Allows overwriting the default ' true' to decide if this switch should be persisted
93
96
94
97
--- @class PopupOptionOpts
95
98
--- @field key_prefix ? string Allows overwriting the default ' =' to set option
@@ -222,6 +225,10 @@ function M:switch(key, cli, description, opts)
222
225
opts .cli_suffix = " "
223
226
end
224
227
228
+ if opts .persisted == nil then
229
+ opts .persisted = true
230
+ end
231
+
225
232
local value
226
233
if opts .enabled and opts .value then
227
234
value = cli .. opts .value
@@ -253,6 +260,7 @@ function M:switch(key, cli, description, opts)
253
260
cli_prefix = opts .cli_prefix ,
254
261
user_input = opts .user_input ,
255
262
cli_suffix = opts .cli_suffix ,
263
+ persisted = opts .persisted ,
256
264
options = opts .options ,
257
265
incompatible = util .build_reverse_lookup (opts .incompatible ),
258
266
dependent = util .build_reverse_lookup (opts .dependent ),
@@ -467,6 +475,10 @@ function M:build()
467
475
error (" A popup needs to have a name!" )
468
476
end
469
477
478
+ if config .values .builders ~= nil and type (config .values .builders [self .state .name ]) == " function" then
479
+ config .values .builders [self .state .name ](self )
480
+ end
481
+
470
482
return self .builder_fn (self .state )
471
483
end
472
484
0 commit comments