@@ -335,7 +335,16 @@ function! dispatch#compiler_options(compiler) abort
335
335
endfunction
336
336
337
337
function ! s: completion_filter (results, query) abort
338
- return filter (a: results , ' strpart(v:val, 0, len(a:query)) ==# a:query' )
338
+ if type (get (g: , ' completion_filter' )) == type ({})
339
+ return g: completion_filter .Apply (a: results , a: query )
340
+ else
341
+ return filter (a: results , ' strpart(v:val, 0, len(a:query)) ==# a:query' )
342
+ endif
343
+ endfunction
344
+
345
+ function ! s: file_complete (A) abort
346
+ return map (split (glob (substitute (a: A , ' \(.\@<=[\\/]\|$\)' , ' *\1' , ' g' )), " \n " ),
347
+ \ ' isdirectory(v:val) ? v:val . dispatch#slash() : v:val' )
339
348
endfunction
340
349
341
350
function ! s: compiler_complete (compiler , A, L, P ) abort
@@ -363,8 +372,7 @@ function! s:compiler_complete(compiler, A, L, P) abort
363
372
return results
364
373
elseif type (results) != type (' ' )
365
374
unlet ! results
366
- let results = join (map (split (glob (a: A .' *' ), " \n " ),
367
- \ ' isdirectory(v:val) ? v:val . dispatch#slash() : v:val' ), " \n " )
375
+ let results = join (s: file_complete (a: A ), " \n " )
368
376
endif
369
377
370
378
return s: completion_filter (split (results, " \n " ), a: A )
@@ -375,13 +383,15 @@ function! dispatch#command_complete(A, L, P) abort
375
383
if len >= 0 && len <= a: P
376
384
let compiler = dispatch#compiler_for_program (matchstr (a: L , ' \s\zs.*' ))
377
385
return s: compiler_complete (compiler , a: A , ' Make ' .strpart (a: L , len ), a: P- len + 5 )
386
+ elseif a: A = ~# ' ^\%(\w:\|\.\)\=[\/]'
387
+ let executables = s: file_complete (a: A )
378
388
else
379
389
let executables = []
380
390
for dir in split ($PATH , has (' win32' ) ? ' ;' : ' :' )
381
- let executables += map (split (glob (dir .' /' .a: A .' *' ), " \n " ), ' v:val[strlen(dir)+1 : -1]' )
391
+ let executables += map (split (glob (dir .' /' .substitute ( a: A, ' . ' , ' *& ' , ' g ' ) .' *' ), " \n " ), ' v:val[strlen(dir)+1 : -1]' )
382
392
endfor
383
- return s: completion_filter (sort (dispatch#uniq (executables)), a: A )
384
393
endif
394
+ return s: completion_filter (sort (dispatch#uniq (executables)), a: A )
385
395
endfunction
386
396
387
397
function ! dispatch#make_complete (A, L, P ) abort
0 commit comments