mirror of
https://github.com/junegunn/fzf.git
synced 2025-08-20 23:13:49 -07:00
[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.
This commit is contained in:
@@ -25,7 +25,6 @@ let s:default_height = '40%'
|
|||||||
let s:fzf_go = expand('<sfile>:h:h').'/bin/fzf'
|
let s:fzf_go = expand('<sfile>:h:h').'/bin/fzf'
|
||||||
let s:install = expand('<sfile>:h:h').'/install'
|
let s:install = expand('<sfile>:h:h').'/install'
|
||||||
let s:installed = 0
|
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:fzf_tmux = expand('<sfile>:h:h').'/bin/fzf-tmux'
|
||||||
|
|
||||||
let s:cpo_save = &cpo
|
let s:cpo_save = &cpo
|
||||||
@@ -35,32 +34,24 @@ function! s:fzf_exec()
|
|||||||
if !exists('s:exec')
|
if !exists('s:exec')
|
||||||
if executable(s:fzf_go)
|
if executable(s:fzf_go)
|
||||||
let s:exec = s:fzf_go
|
let s:exec = s:fzf_go
|
||||||
else
|
elseif executable('fzf')
|
||||||
let path = split(system('which fzf 2> /dev/null'), '\n')
|
let s:exec = 'fzf'
|
||||||
if !v:shell_error && !empty(path)
|
elseif !s:installed && executable(s:install) &&
|
||||||
let s:exec = path[0]
|
\ input('fzf executable not found. Download binary? (y/n) ') =~? '^y'
|
||||||
elseif !s:installed && executable(s:install)
|
redraw
|
||||||
|
echo
|
||||||
echohl WarningMsg
|
echohl WarningMsg
|
||||||
echo 'Downloading fzf binary. Please wait ...'
|
echo 'Downloading fzf binary. Please wait ...'
|
||||||
echohl None
|
echohl None
|
||||||
let s:installed = 1
|
let s:installed = 1
|
||||||
call system(s:install.' --bin')
|
call system(s:install.' --bin')
|
||||||
return s:fzf_exec()
|
return s:fzf_exec()
|
||||||
elseif executable(s:fzf_rb)
|
|
||||||
let s:exec = s:fzf_rb
|
|
||||||
else
|
else
|
||||||
call system('type fzf')
|
redraw
|
||||||
if v:shell_error
|
|
||||||
throw 'fzf executable not found'
|
throw 'fzf executable not found'
|
||||||
else
|
|
||||||
let s:exec = 'fzf'
|
|
||||||
endif
|
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
return s:exec
|
return s:exec
|
||||||
else
|
|
||||||
return s:exec
|
|
||||||
endif
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:tmux_enabled()
|
function! s:tmux_enabled()
|
||||||
|
Reference in New Issue
Block a user