Leverage classpath#split from ns completion

This commit is contained in:
Tim Pope 2012-12-05 13:16:10 -05:00
parent 17e3eeb2c6
commit 8865fcbb23

View File

@ -46,19 +46,17 @@ endfunction
function! foreplay#ns_complete(A, L, P) abort function! foreplay#ns_complete(A, L, P) abort
let matches = [] let matches = []
for pattern in split(&path, ',') for dir in classpath#split(classpath#from_vim(&path))
for dir in split(glob(pattern, 1), "\n") if dir =~# '\.jar$' && executable('zipinfo')
if dir =~# '\.jar$' && executable('zipinfo') let files = split(system('zipinfo -1 '.shellescape(dir).' "*.clj"'), "\n")
let files = split(system('zipinfo -1 '.shellescape(dir).' "*.clj"'), "\n") if v:shell_error
if v:shell_error let files = []
let files = []
endif
else
let files = split(glob(dir."/**/*.clj", 1), "\n")
call map(files, 'v:val[strlen(dir)+1 : -1]')
endif endif
let matches += files else
endfor let files = split(glob(dir."/**/*.clj", 1), "\n")
call map(files, 'v:val[strlen(dir)+1 : -1]')
endif
let matches += files
endfor endfor
return filter(map(matches, 's:tons(v:val)'), 'a:A ==# "" || a:A ==# v:val[0 : strlen(a:A)-1]') return filter(map(matches, 's:tons(v:val)'), 'a:A ==# "" || a:A ==# v:val[0 : strlen(a:A)-1]')
endfunction endfunction