diff options
| author | Junegunn Choi <junegunn.c@gmail.com> | 2020-02-14 14:01:46 +0900 |
|---|---|---|
| committer | Junegunn Choi <junegunn.c@gmail.com> | 2020-02-14 14:04:23 +0900 |
| commit | 6c03571887cda7c0253c0a28439230cc8fcea3e6 (patch) | |
| tree | 46fab9a995dd35e22e128a47420bfbd70a182ce4 /plugin | |
| parent | 4fb410a93c6567cfae1a72e1581a3bd193cd307a (diff) | |
| download | fzf-6c03571887cda7c0253c0a28439230cc8fcea3e6.tar.gz | |
[vim] Add fzf#install() for downloading fzf binary
Diffstat (limited to 'plugin')
| -rw-r--r-- | plugin/fzf.vim | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/plugin/fzf.vim b/plugin/fzf.vim index 8b88ae4b..2585570a 100644 --- a/plugin/fzf.vim +++ b/plugin/fzf.vim @@ -119,40 +119,30 @@ let s:default_layout = { 'down': '~40%' } let s:layout_keys = ['window', 'up', 'down', 'left', 'right'] let s:fzf_go = s:base_dir.'/bin/fzf' let s:fzf_tmux = s:base_dir.'/bin/fzf-tmux' -let s:installed = 0 let s:cpo_save = &cpo set cpo&vim -function! s:download_bin() - if s:installed - return 0 - endif - +function! fzf#install() if s:is_win && !has('win32unix') let script = s:base_dir.'/install.ps1' if !filereadable(script) - return 0 + throw script.' not found' endif let script = 'powershell -ExecutionPolicy Bypass -file ' . script else let script = s:base_dir.'/install' if !executable(script) - return 0 + throw script.' not found' endif let script .= ' --bin' endif - if input('fzf executable not found. Download binary? (y/n) ') !~? '^y' - return 0 - end - - redraw - echo - call s:warn('Downloading fzf binary. Please wait ...') - let s:installed = 1 + call s:warn('Running fzf installer ...') call system(script) - return v:shell_error == 0 + if v:shell_error + throw 'Failed to download fzf: '.script + endif endfunction function! s:fzf_exec() @@ -161,7 +151,10 @@ function! s:fzf_exec() let s:exec = s:fzf_go elseif executable('fzf') let s:exec = 'fzf' - elseif s:download_bin() + elseif input('fzf executable not found. Download binary? (y/n) ') =~? '^y' + redraw + echo + call fzf#install() return s:fzf_exec() else redraw |
