@@ -133,6 +133,12 @@ return function(opts)
133
133
end
134
134
end
135
135
136
+ if dynamic_command == nil then
137
+ dynamic_command = function (params , done )
138
+ done (params .command )
139
+ end
140
+ end
141
+
136
142
local is_nil_table_or_func = function (v )
137
143
return v == nil or vim .tbl_contains ({ " function" , " table" }, type (v ))
138
144
end
@@ -279,65 +285,60 @@ return function(opts)
279
285
280
286
params .command = command
281
287
282
- local resolved_command
283
- if dynamic_command then
284
- resolved_command = dynamic_command (params )
285
- else
286
- resolved_command = command
287
- end
288
-
289
- -- if dynamic_command returns nil, don't fall back to command
290
- if not resolved_command then
291
- log :debug (string.format (" unable to resolve command %s; aborting" , command ))
292
- return done ()
293
- end
288
+ dynamic_command (params , function (resolved_command )
289
+ -- if dynamic_command returns nil, don't fall back to command
290
+ if not resolved_command then
291
+ log :debug (string.format (" unable to resolve command %s; aborting" , command ))
292
+ return done ()
293
+ end
294
294
295
- local resolved_cwd = cwd and cwd (params ) or root
296
- params .cwd = resolved_cwd
295
+ local resolved_cwd = cwd and cwd (params ) or root
296
+ params .cwd = resolved_cwd
297
297
298
- if type (env ) == " function" then
299
- env = env (params )
300
- end
298
+ if type (env ) == " function" then
299
+ env = env (params )
300
+ end
301
301
302
- local spawn_opts = {
303
- cwd = resolved_cwd ,
304
- input = to_stdin and get_content (params ) or nil ,
305
- handler = wrapper ,
306
- check_exit_code = check_exit_code ,
307
- timeout = timeout or c .get ().default_timeout ,
308
- env = env ,
309
- }
310
-
311
- if to_temp_file then
312
- local content = get_content (params )
313
- local temp_path , cleanup = loop .temp_file (content , params .bufname , temp_dir or c .get ().temp_dir )
314
-
315
- spawn_opts .on_stdout_end = function ()
316
- if from_temp_file then
317
- params .output = loop .read_file (temp_path )
302
+ local spawn_opts = {
303
+ cwd = resolved_cwd ,
304
+ input = to_stdin and get_content (params ) or nil ,
305
+ handler = wrapper ,
306
+ check_exit_code = check_exit_code ,
307
+ timeout = timeout or c .get ().default_timeout ,
308
+ env = env ,
309
+ }
310
+
311
+ if to_temp_file then
312
+ local content = get_content (params )
313
+ local temp_path , cleanup = loop .temp_file (content , params .bufname , temp_dir or c .get ().temp_dir )
314
+
315
+ spawn_opts .on_stdout_end = function ()
316
+ if from_temp_file then
317
+ params .output = loop .read_file (temp_path )
318
+ end
319
+ cleanup ()
318
320
end
319
- cleanup ()
321
+ params . temp_path = temp_path
320
322
end
321
- params .temp_path = temp_path
322
- end
323
-
324
- local resolved_args = args or {}
325
- resolved_args = type (resolved_args ) == " function" and resolved_args (params ) or resolved_args
326
- resolved_args = parse_args (resolved_args , params )
327
-
328
- opts ._last_command = resolved_command
329
- opts ._last_args = resolved_args
330
- opts ._last_cwd = resolved_cwd
331
323
332
- log :debug (
333
- string.format (
334
- " spawning command %s at %s with args %s" ,
335
- vim .inspect (resolved_command ),
336
- resolved_cwd ,
337
- vim .inspect (resolved_args )
324
+ local resolved_args = args or {}
325
+ resolved_args = type (resolved_args ) == " function" and resolved_args (params ) or resolved_args
326
+ resolved_args = parse_args (resolved_args , params )
327
+
328
+ opts ._last_command = resolved_command
329
+ opts ._last_args = resolved_args
330
+ opts ._last_cwd = resolved_cwd
331
+
332
+ log :debug (
333
+ string.format (
334
+ " spawning command %s at %s with args %s" ,
335
+ vim .inspect (resolved_command ),
336
+ resolved_cwd ,
337
+ vim .inspect (resolved_args )
338
+ )
338
339
)
339
- )
340
- loop . spawn ( resolved_command , resolved_args , spawn_opts )
340
+ loop . spawn ( resolved_command , resolved_args , spawn_opts )
341
+ end )
341
342
end ,
342
343
filetypes = opts .filetypes ,
343
344
opts = opts ,
0 commit comments