@@ -2,6 +2,7 @@ local git = require("neogit.lib.git")
22local state = require (" neogit.lib.state" )
33local util = require (" neogit.lib.util" )
44local notification = require (" neogit.lib.notification" )
5+ local config = require (" neogit.config" )
56
67--- @class PopupBuilder
78--- @field state PopupState
@@ -54,6 +55,7 @@ local M = {}
5455--- @field type string
5556--- @field user_input boolean
5657--- @field value string ?
58+ --- @field persisted ? boolean
5759
5860--- @class PopupConfig
5961--- @field id string
@@ -90,6 +92,7 @@ local M = {}
9092--- @field value ? string Allows for pre-building cli flags that can be customized by user input
9193--- @field user_input ? boolean If true , allows user to customize the value of the cli flag
9294--- @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
9396
9497--- @class PopupOptionOpts
9598--- @field key_prefix ? string Allows overwriting the default ' =' to set option
@@ -222,6 +225,10 @@ function M:switch(key, cli, description, opts)
222225 opts .cli_suffix = " "
223226 end
224227
228+ if opts .persisted == nil then
229+ opts .persisted = true
230+ end
231+
225232 local value
226233 if opts .enabled and opts .value then
227234 value = cli .. opts .value
@@ -253,6 +260,7 @@ function M:switch(key, cli, description, opts)
253260 cli_prefix = opts .cli_prefix ,
254261 user_input = opts .user_input ,
255262 cli_suffix = opts .cli_suffix ,
263+ persisted = opts .persisted ,
256264 options = opts .options ,
257265 incompatible = util .build_reverse_lookup (opts .incompatible ),
258266 dependent = util .build_reverse_lookup (opts .dependent ),
@@ -467,6 +475,10 @@ function M:build()
467475 error (" A popup needs to have a name!" )
468476 end
469477
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+
470482 return self .builder_fn (self .state )
471483end
472484
0 commit comments