Skip to content

Commit

Permalink
Allow user to always download the prebuilt binary
Browse files Browse the repository at this point in the history
Close #531
  • Loading branch information
liuchengxu committed Sep 30, 2020
1 parent 6fb4b9e commit c6ed3de
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 47 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@

## [unreleased]

### Added

- Allow user to always download the prebuilt binary. #531

## [0.21] 2020-09-27

### Added

- New shortcut for `+no-cache`, `:Clap files!` is equivalent to `:Clap!! files` and `:Clap files +no-cache`. ([#509](https://github.com/liuchengxu/vim-clap/pull/509))
Expand Down
77 changes: 41 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
</p>

[![CI](https://github.com/liuchengxu/vim-clap/workflows/ci/badge.svg)](https://github.com/liuchengxu/vim-clap/actions?workflow=ci)
[![Gitter][G1]][G2]
[![Gitter][g1]][g2]
[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://paypal.me/liuchengxu)

[G1]: https://badges.gitter.im/liuchengxu/vim-clap.svg
[G2]: https://gitter.im/liuchengxu/vim-clap?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge
[g1]: https://badges.gitter.im/liuchengxu/vim-clap.svg
[g2]: https://gitter.im/liuchengxu/vim-clap?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge

Vim-clap is a modern generic interactive finder and dispatcher, based on the newly feature: `floating_win` of neovim or `popup` of vim. The goal of vim-clap is to work everywhere out of the box, with fast response.

Expand Down Expand Up @@ -85,6 +85,11 @@ Plug 'liuchengxu/vim-clap', { 'do': ':Clap install-binary' }
" The bang version will try to download the prebuilt binary if cargo does not exist.
Plug 'liuchengxu/vim-clap', { 'do': ':Clap install-binary!' }
" :Clap install-binary[!] will always try to compile the binary locally,
" if you do care about the disk used for the compilation, try using the force download way,
" which will download the prebuilt binary even you have installed cargo.
Plug 'liuchengxu/vim-clap', { 'do': { -> clap#installer#force_download() } }
" `:Clap install-binary[!]` will run using the terminal feature which is inherently async.
" If you don't want that and hope to run the hook synchorously:
Plug 'liuchengxu/vim-clap', { 'do': has('win32') ? 'cargo build --release' : 'make' }
Expand All @@ -111,37 +116,37 @@ Note the `*` in the spinner, it tells you are using the cache, use `g:clap_forer

#### Providers

Command | List | Requirement
:---- | :---- | :----
`Clap bcommits` | Git commits for the current buffer | **[git][git]**
`Clap blines` | Lines in the current buffer | _none_
`Clap buffers` | Open buffers | _none_
`Clap colors` | Colorschemes | _none_
`Clap command` | Command | _none_
`Clap hist:` or `Clap command_history` | Command history | _none_
`Clap hist/` or `Clap search_history` | Search history | _none_
`Clap commits` | Git commits | **[git][git]**
`Clap files` | Files | **[fd][fd]**/**[git][git]**/**[rg][rg]**/find
`Clap filetypes` | File types | _none_
`Clap gfiles` or `Clap git_files` | Files managed by git | **[git][git]**
`Clap git_diff_files` | Files managed by git and having uncommitted changes | **[git][git]**
`Clap grep`**<sup>+</sup>** | Grep on the fly | **[rg][rg]**
`Clap grep2`**<sup>+</sup>** | Grep on the fly with cache and dynamic results | **[maple][maple]**
`Clap history` | Open buffers and `v:oldfiles` | _none_
`Clap help_tags` | Help tags | _none_
`Clap jumps` | Jumps | _none_
`Clap lines` | Lines in the loaded buffers | _none_
`Clap marks` | Marks | _none_
`Clap maps` | Maps | _none_
`Clap quickfix` | Entries of the quickfix list | _none_
`Clap loclist` | Entries of the location list | _none_
`Clap registers` | Registers | _none_
`Clap tags` | Tags in the current buffer | **[vista.vim][vista.vim]**
`Clap proj_tags` | Tags in the current project | **[maple][maple]** and **[universal-ctags][universal-ctags]** with JSON output support
`Clap yanks` | Yank stack of the current vim session | _none_
`Clap filer` | Ivy-like file explorer | **[maple][maple]**
`Clap providers` | List the vim-clap providers | _none_
`Clap windows` | Windows | _none_
| Command | List | Requirement |
| :------------------------------------- | :-------------------------------------------------- | :------------------------------------------------------------------------------------- |
| `Clap bcommits` | Git commits for the current buffer | **[git][git]** |
| `Clap blines` | Lines in the current buffer | _none_ |
| `Clap buffers` | Open buffers | _none_ |
| `Clap colors` | Colorschemes | _none_ |
| `Clap command` | Command | _none_ |
| `Clap hist:` or `Clap command_history` | Command history | _none_ |
| `Clap hist/` or `Clap search_history` | Search history | _none_ |
| `Clap commits` | Git commits | **[git][git]** |
| `Clap files` | Files | **[fd][fd]**/**[git][git]**/**[rg][rg]**/find |
| `Clap filetypes` | File types | _none_ |
| `Clap gfiles` or `Clap git_files` | Files managed by git | **[git][git]** |
| `Clap git_diff_files` | Files managed by git and having uncommitted changes | **[git][git]** |
| `Clap grep`**<sup>+</sup>** | Grep on the fly | **[rg][rg]** |
| `Clap grep2`**<sup>+</sup>** | Grep on the fly with cache and dynamic results | **[maple][maple]** |
| `Clap history` | Open buffers and `v:oldfiles` | _none_ |
| `Clap help_tags` | Help tags | _none_ |
| `Clap jumps` | Jumps | _none_ |
| `Clap lines` | Lines in the loaded buffers | _none_ |
| `Clap marks` | Marks | _none_ |
| `Clap maps` | Maps | _none_ |
| `Clap quickfix` | Entries of the quickfix list | _none_ |
| `Clap loclist` | Entries of the location list | _none_ |
| `Clap registers` | Registers | _none_ |
| `Clap tags` | Tags in the current buffer | **[vista.vim][vista.vim]** |
| `Clap proj_tags` | Tags in the current project | **[maple][maple]** and **[universal-ctags][universal-ctags]** with JSON output support |
| `Clap yanks` | Yank stack of the current vim session | _none_ |
| `Clap filer` | Ivy-like file explorer | **[maple][maple]** |
| `Clap providers` | List the vim-clap providers | _none_ |
| `Clap windows` | Windows | _none_ |

[fd]: https://github.com/sharkdp/fd
[rg]: https://github.com/BurntSushi/ripgrep
Expand Down Expand Up @@ -213,7 +218,7 @@ See `:help clap-options` for more information.
- [x] Use <kbd>Ctrl-f</kbd> to move cursor right one character.
- [x] Use <kbd>Enter</kbd> to select the entry and exit.
- [x] Use <kbd>Tab</kbd> to select multiple entries and open them using the quickfix window.(Need the provider has `sink*` support)
- Use <kbd>Tab</kbd> to expand the directory for `:Clap filer`.
- Use <kbd>Tab</kbd> to expand the directory for `:Clap filer`.
- [x] Use <kbd>Ctrl-t</kbd> or <kbd>Ctrl-x</kbd>, <kbd>Ctrl-v</kbd> to open the selected entry in a new tab or a new split.
- [x] Use <kbd>Ctrl-u</kbd> to clear inputs.
- [x] Use <kbd>Ctrl-l</kbd> to launch the whole provider list panel for invoking another provider at any time.
Expand Down Expand Up @@ -291,7 +296,7 @@ Vim-clap is still in beta. Any kinds of contributions are highly welcome.

If you would like to see support for more providers or share your own provider, please [create an issue](https://github.com/liuchengxu/vim-clap/issues) or [create a pull request](https://github.com/liuchengxu/vim-clap/pulls).

If you'd liked to discuss the project more directly, check out [![][G1]][G2].
If you'd liked to discuss the project more directly, check out [![][g1]][g2].

## Credit

Expand Down
30 changes: 19 additions & 11 deletions autoload/clap/installer.vim
Original file line number Diff line number Diff line change
Expand Up @@ -104,23 +104,31 @@ function! clap#installer#download_binary() abort
call s:run_term(cmd, s:plugin_root_dir, 'download the prebuilt maple binary successfully')
endfunction

function! s:do_download() abort
if !exists('s:current_version')
let version_line = readfile(s:maple_cargo_toml)[:5][-1]
let s:current_version = str2nr(matchstr(version_line, '0.1.\zs\d\+'))
endif
" Since v0.14 maple itself is able to download the latest release binary.
if executable(s:prebuilt_maple_binary) && s:current_version >= 14
let cmd = s:prebuilt_maple_binary.' upgrade --download'
call s:run_term(cmd, s:plugin_root_dir, 'download the latest prebuilt maple binary successfully')
else
call clap#installer#download_binary()
endif
endfunction

function! clap#installer#force_download() abort
call s:do_download()
endfunction

function! clap#installer#install(try_download) abort
" Always prefer to compile it locally.
if executable('cargo')
call clap#installer#build_all()
" People are willing to use the prebuilt binary
elseif a:try_download
if !exists('s:current_version')
let version_line = readfile(s:maple_cargo_toml)[:5][-1]
let s:current_version = str2nr(matchstr(version_line, '0.1.\zs\d\+'))
endif
" Since v0.14 maple itself is able to download the latest release binary.
if executable(s:prebuilt_maple_binary) && s:current_version >= 14
let cmd = s:prebuilt_maple_binary.' upgrade --download'
call s:run_term(cmd, s:plugin_root_dir, 'download the latest prebuilt maple binary successfully')
else
call clap#installer#download_binary()
endif
call s:do_download()
else
call clap#helper#echo_warn('Skipped, cargo does not exist and no prebuilt binary downloaded.')
endif
Expand Down

0 comments on commit c6ed3de

Please sign in to comment.