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

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')
endif let s:zipinfo = 'zipinfo -1 '
if !has_key(s:jar_contents, a:path) && s:zipinfo elseif executable('python')
let s:jar_contents[a:path] = split(system('zipinfo -1 '.shellescape(a:path)), "\n") let s:zipinfo = 'python -c '.shellescape('import zipfile, sys; print chr(10).join(zipfile.ZipFile(sys.argv[1]).namelist())').' '
if v:shell_error else
return [] let s:zipinfo = ''
endif endif
endif endif
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
let s:jar_contents[a:path] = []
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()