Use info op to drive jump to definition
This commit is contained in:
parent
e974dd4766
commit
e484ad6996
@ -1144,19 +1144,38 @@ augroup END
|
|||||||
" }}}1
|
" }}}1
|
||||||
" Go to source {{{1
|
" Go to source {{{1
|
||||||
|
|
||||||
function! fireplace#source(symbol) abort
|
function! fireplace#info(symbol) abort
|
||||||
let cmd =
|
if fireplace#op_available('info')
|
||||||
\ '(when-let [v (resolve ' . s:qsym(a:symbol) .')]' .
|
let response = fireplace#message({'op': 'info', 'symbol': a:symbol})[0]
|
||||||
\ ' (when-let [filepath (:file (meta v))]' .
|
if type(get(response, 'value')) == type({})
|
||||||
\ ' [filepath' .
|
return response.value
|
||||||
\ ' (:line (meta v))]))'
|
|
||||||
let result = fireplace#evalparse(cmd)
|
|
||||||
if type(result) == type([])
|
|
||||||
let file = fireplace#findresource(result[0])
|
|
||||||
if !empty(file)
|
|
||||||
return '+' . result[1] . ' ' . fnameescape(file)
|
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
let cmd =
|
||||||
|
\ '(if-let [m (meta (resolve ' . s:qsym(a:symbol) .'))]'
|
||||||
|
\ . ' {:name (:name m)'
|
||||||
|
\ . ' :ns (:ns m)'
|
||||||
|
\ . ' :resource (:file m)'
|
||||||
|
\ . ' :line (:line m)'
|
||||||
|
\ . ' :doc (:doc m)'
|
||||||
|
\ . ' :arglists-str (str (:arglists m))}'
|
||||||
|
\ . ' {})'
|
||||||
|
return fireplace#evalparse(cmd)
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! fireplace#source(symbol) abort
|
||||||
|
let info = fireplace#info(a:symbol)
|
||||||
|
|
||||||
|
let file = ''
|
||||||
|
if !empty(get(info, 'resource'))
|
||||||
|
let file = fireplace#findresource(info.resource)
|
||||||
|
elseif get(info, 'file') =~# '^/\|^\w:\\' && filereadable(info.file)
|
||||||
|
let file = info.file
|
||||||
|
endif
|
||||||
|
|
||||||
|
if !empty(file) && !empty(get(info, 'line'))
|
||||||
|
return '+' . info.line . ' ' . fnameescape(file)
|
||||||
|
endif
|
||||||
return ''
|
return ''
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user