@@ -130,14 +130,21 @@ local function project_live_grep(opts)
130
130
require (" telescope.builtin" ).live_grep (opts )
131
131
end
132
132
133
- local function call_picker (opts , command , prompt_title_supplement )
133
+ local function call_picker (list_opts , command , prompt_title_supplement , user_opts )
134
+ if list_opts == nil then
135
+ error (" Incorrect call to call_picker, list_opts should be specified to pass relevant options to the first picker" )
136
+ end
137
+ if user_opts == nil then
138
+ error (" Incorrect call to call_picker, user_opts should be specified to pass relevant options to the second picker" )
139
+ end
140
+
134
141
local prompt_title = " Git repositories"
135
142
if prompt_title_supplement ~= nil then
136
143
prompt_title = prompt_title .. prompt_title_supplement
137
144
end
138
- pickers .new (opts , {
145
+ pickers .new (list_opts , {
139
146
prompt_title = prompt_title ,
140
- finder = finders .new_oneshot_job (command , opts ),
147
+ finder = finders .new_oneshot_job (command , list_opts ),
141
148
previewer = previewers .new_termopen_previewer ({
142
149
get_command = function (entry )
143
150
local dir = Path :new (from_entry .path (entry ))
@@ -156,28 +163,28 @@ local function call_picker(opts, command, prompt_title_supplement)
156
163
return utils .find_generic_previewer_for_document (doc .filename )
157
164
end ,
158
165
}),
159
- sorter = conf .file_sorter (opts ),
166
+ sorter = conf .file_sorter (list_opts ),
160
167
attach_mappings = function (prompt_bufnr )
161
168
actions_set .select :replace (function (_ , type )
162
169
local entry = actions_state .get_selected_entry ()
163
170
local dir = from_entry .path (entry )
164
171
if type == " default" then
165
172
actions ._close (prompt_bufnr , false )
166
173
vim .schedule (function ()
167
- project_files (vim .tbl_extend (" force" , opts , { cwd = dir }))
174
+ project_files (vim .tbl_extend (" force" , user_opts , { cwd = dir }))
168
175
end )
169
176
end
170
177
if type == " vertical" then
171
178
actions ._close (prompt_bufnr , false )
172
179
vim .schedule (function ()
173
- project_live_grep (vim .tbl_extend (" force" , opts , { cwd = dir }))
180
+ project_live_grep (vim .tbl_extend (" force" , list_opts , { cwd = dir }))
174
181
end )
175
182
return
176
183
end
177
184
if type == " tab" then
178
185
vim .cmd (" tabe " .. dir )
179
186
vim .cmd (" tcd " .. dir )
180
- project_files (vim .tbl_extend (" force" , opts , { cwd = dir }))
187
+ project_files (vim .tbl_extend (" force" , list_opts , { cwd = dir }))
181
188
return
182
189
end
183
190
end )
@@ -188,20 +195,22 @@ end
188
195
189
196
-- List of repos built using locate (or variants)
190
197
M .cached_list = function (opts )
191
- opts = vim .tbl_deep_extend (" force" , r_config .values .cached_list or {}, opts or {})
192
- opts .entry_maker = t_utils .get_lazy_default (opts .entry_maker , gen_from_locate_wrapper , opts )
193
- local locate_command = cached_list .prepare_command (opts )
198
+ local common_opts = opts or {}
199
+ local list_opts = vim .tbl_deep_extend (" force" , r_config .values .cached_list or {}, common_opts )
200
+ list_opts .entry_maker = t_utils .get_lazy_default (list_opts .entry_maker , gen_from_locate_wrapper , list_opts )
201
+ local locate_command = cached_list .prepare_command (list_opts )
194
202
195
- call_picker (opts , locate_command , " (cached)" )
203
+ call_picker (list_opts , locate_command , " (cached)" , common_opts )
196
204
end
197
205
198
206
-- Always up to date list of repos built using fd
199
207
M .list = function (opts )
200
- opts = vim .tbl_deep_extend (" force" , r_config .values .list or {}, opts or {})
201
- opts .entry_maker = t_utils .get_lazy_default (opts .entry_maker , gen_from_fd , opts )
202
- local fd_command = list .prepare_command (opts )
208
+ local common_opts = opts or {}
209
+ local list_opts = vim .tbl_deep_extend (" force" , r_config .values .list or {}, common_opts )
210
+ list_opts .entry_maker = t_utils .get_lazy_default (list_opts .entry_maker , gen_from_fd , list_opts )
211
+ local fd_command = list .prepare_command (list_opts )
203
212
204
- call_picker (opts , fd_command , " (built on the fly)" )
213
+ call_picker (list_opts , fd_command , " (built on the fly)" , common_opts )
205
214
end
206
215
207
216
return M
0 commit comments