Improve how vim plugin finds fzf executable

This avoids the problem in which :FZF command silently fails when fzf
executable cannot be found in $PATH of the hosting tmux server.
This commit is contained in:
Junegunn Choi 2015-03-07 09:46:32 +09:00
parent f7b52d2541
commit 06ab399497

View File

@ -33,17 +33,24 @@ set cpo&vim
function! s:fzf_exec()
if !exists('s:exec')
call system('type fzf')
if v:shell_error
let s:exec = executable(s:fzf_go) ?
\ s:fzf_go : (executable(s:fzf_rb) ? s:fzf_rb : '')
if executable(s:fzf_go)
let s:exec = s:fzf_go
else
let s:exec = 'fzf'
let path = split(system('which fzf 2> /dev/null'), '\n')
if !v:shell_error && !empty(path)
let s:exec = path[0]
elseif executable(s:fzf_rb)
let s:exec = s:fzf_rb
else
call system('type fzf')
if v:shell_error
throw 'fzf executable not found'
else
let s:exec = 'fzf'
endif
endif
endif
return s:fzf_exec()
elseif empty(s:exec)
unlet s:exec
throw 'fzf executable not found'
return s:exec
else
return s:exec
endif