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 endfunction
function! s:GF(cmd, file) abort 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, "/") let [file, jump] = split(a:file, "/")
if file !~# '\.' if file !~# '\.'
try try
@ -1267,10 +1270,10 @@ function! s:GF(cmd, file) abort
catch /^Clojure:/ catch /^Clojure:/
endtry endtry
endif endif
let file = fireplace#findfile(file)
else else
let file = a:file let file = fireplace#findfile(a:file)
endif endif
let file = fireplace#findfile(file)
if file ==# '' if file ==# ''
let v:errmsg = "Couldn't find file for ".a:file let v:errmsg = "Couldn't find file for ".a:file
return 'echoerr v:errmsg' return 'echoerr v:errmsg'