summaryrefslogtreecommitdiff
path: root/plugin/fzf.vim
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2015-03-07 09:46:32 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2015-03-07 09:48:56 +0900
commit06ab3994979278e33d4e7c6f02ae90055981eca8 (patch)
tree548246ccb347d3f3e7ea8b9381bd6fab1d812bc8 /plugin/fzf.vim
parentf7b52d2541fba6f10a86d33399f38fc38efcbc2a (diff)
downloadfzf-06ab3994979278e33d4e7c6f02ae90055981eca8.tar.gz
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.
Diffstat (limited to 'plugin/fzf.vim')
-rw-r--r--plugin/fzf.vim25
1 files changed, 16 insertions, 9 deletions
diff --git a/plugin/fzf.vim b/plugin/fzf.vim
index 22fb4cc9..ba49c7e3 100644
--- a/plugin/fzf.vim
+++ b/plugin/fzf.vim
@@ -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