Use python for zipfile contents when possible

This commit is contained in:
Tim Pope 2014-01-11 20:15:45 -05:00
parent a9c3318817
commit c99bda551e
1 changed files with 22 additions and 6 deletions

View File

@ -39,14 +39,25 @@ let s:jar_contents = {}
function! fireplace#jar_contents(path) abort function! fireplace#jar_contents(path) abort
if !exists('s:zipinfo') if !exists('s:zipinfo')
let s:zipinfo = executable('zipinfo') if executable('zipinfo')
let s:zipinfo = 'zipinfo -1 '
elseif executable('python')
let s:zipinfo = 'python -c '.shellescape('import zipfile, sys; print chr(10).join(zipfile.ZipFile(sys.argv[1]).namelist())').' '
else
let s:zipinfo = ''
endif endif
if !has_key(s:jar_contents, a:path) && s:zipinfo endif
let s:jar_contents[a:path] = split(system('zipinfo -1 '.shellescape(a:path)), "\n")
if !has_key(s:jar_contents, a:path) && has('python')
python import vim, zipfile
python vim.command("let s:jar_contents[a:path] = split('" + "\n".join(zipfile.ZipFile(vim.eval('a:path')).namelist()) + "', \"\n\")")
elseif !has_key(s:jar_contents, a:path) && !empty(s:zipinfo)
let s:jar_contents[a:path] = split(system(s:zipinfo.shellescape(a:path)), "\n")
if v:shell_error if v:shell_error
return [] let s:jar_contents[a:path] = []
endif endif
endif endif
return copy(get(s:jar_contents, a:path, [])) return copy(get(s:jar_contents, a:path, []))
endfunction endfunction
@ -355,6 +366,11 @@ function! s:buf() abort
endif endif
endfunction endfunction
function! fireplace#buffer(...) abort
let buf = a:0 ? a:1 : s:buf()
return fireplace#clojure#buffer(bufnr(buf))
endfunction
function! s:client(...) abort function! s:client(...) abort
silent doautocmd User FireplacePreConnect silent doautocmd User FireplacePreConnect
let buf = a:0 ? a:1 : s:buf() let buf = a:0 ? a:1 : s:buf()