summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2015-05-03 00:58:45 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2015-05-03 00:58:45 +0900
commit0937bd6c166c9d8be1fdafa8535460cdd0b28620 (patch)
tree4d1909265751f215100f84a100fbeb391171bd51
parent3d26b5336c964164b42dc698d7f3bd927368c90e (diff)
[vim] Improve binary detection
/cc @alerque - Ask for user confirmation before running `install --bin` - Removed `s:fzf_rb` since `install --bin` will create a wrapper executable that just runs Ruby version on the platforms where prebuilt binaries are not available.
-rw-r--r--plugin/fzf.vim39
1 files changed, 15 insertions, 24 deletions
diff --git a/plugin/fzf.vim b/plugin/fzf.vim
index ffb0e2cd..68c9c9e3 100644
--- a/plugin/fzf.vim
+++ b/plugin/fzf.vim
@@ -25,7 +25,6 @@ let s:default_height = '40%'
let s:fzf_go = expand('<sfile>:h:h').'/bin/fzf'
let s:install = expand('<sfile>:h:h').'/install'
let s:installed = 0
-let s:fzf_rb = expand('<sfile>:h:h').'/fzf'
let s:fzf_tmux = expand('<sfile>:h:h').'/bin/fzf-tmux'
let s:cpo_save = &cpo
@@ -35,32 +34,24 @@ function! s:fzf_exec()
if !exists('s:exec')
if executable(s:fzf_go)
let s:exec = s:fzf_go
+ elseif executable('fzf')
+ let s:exec = 'fzf'
+ elseif !s:installed && executable(s:install) &&
+ \ input('fzf executable not found. Download binary? (y/n) ') =~? '^y'
+ redraw
+ echo
+ echohl WarningMsg
+ echo 'Downloading fzf binary. Please wait ...'
+ echohl None
+ let s:installed = 1
+ call system(s:install.' --bin')
+ return s:fzf_exec()
else
- let path = split(system('which fzf 2> /dev/null'), '\n')
- if !v:shell_error && !empty(path)
- let s:exec = path[0]
- elseif !s:installed && executable(s:install)
- echohl WarningMsg
- echo 'Downloading fzf binary. Please wait ...'
- echohl None
- let s:installed = 1
- call system(s:install.' --bin')
- return s:fzf_exec()
- 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
+ redraw
+ throw 'fzf executable not found'
endif
- return s:exec
- else
- return s:exec
endif
+ return s:exec
endfunction
function! s:tmux_enabled()