@@ -144,22 +144,40 @@ local eval = function(v, ...)
144144 return v
145145end
146146
147+
148+ --- expand opts that were specified with a dot
149+ --- @param opts table
150+ local normalize_tbl = function (opts )
151+ -- convert keys only after full iteration or we will
152+ -- miss keys due to messing with map ordering
153+ local to_convert = {}
154+ for k , _ in pairs (opts ) do
155+ if k :match (" %." ) then
156+ table.insert (to_convert , k )
157+ end
158+ end
159+ for _ , k in ipairs (to_convert ) do
160+ utils .map_set (opts , k , opts [k ])
161+ opts [k ] = nil
162+ end
163+ end
164+
147165--- @param opts fzf-lua.config.Base |{}| fun (): table ?
148166--- @param globals string | table ?
149167--- @param __resume_key string ?
150168--- @return fzf-lua.Config ?
151169function M .normalize_opts (opts , globals , __resume_key )
152- if not opts then opts = {} end
153-
154170 -- opts can also be a function that returns an opts table
155- if type (opts ) == " function" then
156- opts = opts () or {}
157- end
171+ --- @type fzf-lua.config.Base |{}
172+ opts = eval (opts ) or {}
158173
159174 if opts ._normalized then
160175 return opts
161176 end
162177
178+ -- e.g. `:FzfLua files winopts.border=single`
179+ normalize_tbl (opts )
180+
163181 local profile = opts .profile or (function ()
164182 if type (globals ) == " string" then
165183 local picker_opts = M .globals [globals ]
@@ -171,23 +189,6 @@ function M.normalize_opts(opts, globals, __resume_key)
171189 M ._profile_opts = utils .load_profiles (profile , 1 )
172190 end
173191
174- -- expand opts that were specified with a dot
175- -- e.g. `:FzfLua files winopts.border=single`
176- do
177- -- convert keys only after full iteration or we will
178- -- miss keys due to messing with map ordering
179- local to_convert = {}
180- for k , _ in pairs (opts ) do
181- if k :match (" %." ) then
182- table.insert (to_convert , k )
183- end
184- end
185- for _ , k in ipairs (to_convert ) do
186- utils .map_set (opts , k , opts [k ])
187- opts [k ] = nil
188- end
189- end
190-
191192 -- save the user's original call params separately
192193 opts .__call_opts = opts .__call_opts or utils .deepcopy (opts )
193194 opts .__call_fn = utils .__FNCREF2__ ()
@@ -209,7 +210,7 @@ function M.normalize_opts(opts, globals, __resume_key)
209210 -- merge with setup options "defaults" table
210211 globals = vim .tbl_deep_extend (" keep" , globals , M .setup_opts .defaults or {})
211212 end
212- --- @cast globals table
213+ --- @cast globals fzf-lua.config.Base
213214
214215 -- merge current opts with revious __call_opts on resume
215216 if opts .resume then
0 commit comments