Do all classpath searching locally

In addition to being cleaner, this means we no longer need to worry
about evaling on a "local" server.
This commit is contained in:
Tim Pope 2014-01-11 00:05:32 -05:00
parent cf094f970f
commit f605cd7824
1 changed files with 11 additions and 36 deletions

View File

@ -473,7 +473,7 @@ endfunction
function! s:eval(expr, ...) abort function! s:eval(expr, ...) abort
let options = a:0 ? copy(a:1) : {} let options = a:0 ? copy(a:1) : {}
let client = get(options, 'client', s:client()) let client = s:client()
if !has_key(options, 'ns') if !has_key(options, 'ns')
if fireplace#ns() !=# client.user_ns() if fireplace#ns() !=# client.user_ns()
let error = client.require(fireplace#ns()) let error = client.require(fireplace#ns())
@ -929,26 +929,16 @@ augroup END
" }}}1 " }}}1
" Go to source {{{1 " Go to source {{{1
function! s:decode_url(url) abort
let url = a:url
let url = substitute(url, '^\%(jar:\)\=file:\zs/\ze\w:/', '', '')
let url = substitute(url, '^file:', '', '')
let url = substitute(url, '^jar:\(.*\)!/', 'zip\1::', '')
let url = substitute(url, '%\(\x\x\)', '\=eval(''"\x''.submatch(1).''"'')', 'g')
return url
endfunction
function! fireplace#source(symbol) abort function! fireplace#source(symbol) abort
let options = {'client': fireplace#local_client(), 'session': 0} let options = {'session': 0}
let cmd = let cmd =
\ '(when-let [v (resolve ' . s:qsym(a:symbol) .')]' . \ '(when-let [v (resolve ' . s:qsym(a:symbol) .')]' .
\ ' (when-let [filepath (:file (meta v))]' . \ ' (when-let [filepath (:file (meta v))]' .
\ ' (when-let [url (.getResource (clojure.lang.RT/baseLoader) filepath)]' . \ ' [filepath' .
\ ' [(str url)' . \ ' (:line (meta v))]))'
\ ' (:line (meta v))])))'
let result = fireplace#evalparse(cmd, options) let result = fireplace#evalparse(cmd, options)
if type(result) == type([]) if type(result) == type([])
return '+' . result[1] . ' ' . fnameescape(s:decode_url(result[0])) return '+' . result[1] . ' ' . fireplace#findresource(result[0])
else else
return '' return ''
endif endif
@ -999,23 +989,16 @@ augroup END
" Go to file {{{1 " Go to file {{{1
function! fireplace#findfile(path) abort function! fireplace#findfile(path) abort
let options = {'client': fireplace#local_client(), 'session': 0} let options = {'session': 0}
let cmd =
\ '(symbol' .
\ ' (or' .
\ ' (when-let [url (.getResource (clojure.lang.RT/baseLoader) %s)]' .
\ ' (str url))' .
\ ' ""))'
let path = a:path let path = a:path
if path !~# '[/.]' && path =~# '^\k\+$' if path !~# '[/.]' && path =~# '^\k\+$'
let aliascmd = printf(cmd, let aliascmd =
\ '(if-let [ns ((ns-aliases *ns*) '.s:qsym(path).')]' . \ '(symbol (if-let [ns ((ns-aliases *ns*) '.s:qsym(path).')]' .
\ ' (str (.replace (.replace (str (ns-name ns)) "-" "_") "." "/") ".clj")' . \ ' (str (.replace (.replace (str (ns-name ns)) "-" "_") "." "/") ".clj")' .
\ ' "'.path.'.clj")') \ ' "'.path.'.clj"))'
let result = get(split(s:eval(aliascmd, options).value, "\n"), 0, '') let path = get(split(s:eval(aliascmd, options).value, "\n"), 0, '')
else else
if path !~# '/' if path !~# '/'
let path = tr(path, '.-', '/_') let path = tr(path, '.-', '/_')
@ -1023,16 +1006,8 @@ function! fireplace#findfile(path) abort
if path !~# '\.\w\+$' if path !~# '\.\w\+$'
let path .= '.clj' let path .= '.clj'
endif endif
let response = s:eval(printf(cmd, s:str(path)), options)
let result = get(split(get(response, 'value', ''), "\n"), 0, '')
endif endif
let result = s:decode_url(result)
if result ==# ''
return fireplace#findresource(path) return fireplace#findresource(path)
else
return result
endif
endfunction endfunction
function! s:GF(cmd, file) abort function! s:GF(cmd, file) abort