Support gf on relative (load) paths

This doesn't do a file existence check because that's tricky with jar
files in the mix.  Instead, it's limited to strings, so a gf on a random
symbol doesn't send us flying.
This commit is contained in:
Tim Pope 2014-07-03 12:30:32 -04:00
parent a14328c1dc
commit 25e18b5f82

View File

@ -1259,7 +1259,10 @@ function! fireplace#findfile(path) abort
endfunction
function! s:GF(cmd, file) abort
if a:file =~# '^[^/]*/[^/.]*$' && a:file =~# '^\k\+$'
if a:file =~# '^\w[[:alnum:]_/]*$' &&
\ synIDattr(synID(line("."),col("."),1),"name") =~# 'String'
let file = substitute(expand('%:p'), '[^\/:]*$', '', '').a:file.'.'.expand('%:e')
elseif a:file =~# '^[^/]*/[^/.]*$' && a:file =~# '^\k\+$'
let [file, jump] = split(a:file, "/")
if file !~# '\.'
try
@ -1267,10 +1270,10 @@ function! s:GF(cmd, file) abort
catch /^Clojure:/
endtry
endif
let file = fireplace#findfile(file)
else
let file = a:file
let file = fireplace#findfile(a:file)
endif
let file = fireplace#findfile(file)
if file ==# ''
let v:errmsg = "Couldn't find file for ".a:file
return 'echoerr v:errmsg'