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.
Vim-clap is in a very early stage, breaking changes and bugs are expected.
The Windows support is not fully tested. The providers without using any system related command should work smoothly, that is to say, most sync providers are just able to work. Please create an issue if you run into any error in Windows. And any help would be appreciated.
Although a lot of effort has been made to unify the behavior of vim-clap between vim and neovim, and most part works in the same way, it just can't be exactly the same, for floating_win
and popup
are actually two different things anyway.
:echo has('patch-8.1.2114')
.:echo has('nvim-0.4.2')
.Plug 'liuchengxu/vim-clap'
" Build the extra binary if cargo exists on your system.
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' }
The do
hook for installing the extra binary is highly recommended, which can mostly help you get a performant vim-clap easily. If that does not work for you, please refer to INSTALL.md for installing the optional dependencies manually.
Vim-clap is utterly easy to use, just type, press Ctrl-J/K to locate the wanted entry, and press Enter to apply and exit. The default settings should work well for most people in most cases, but it's absolutely hackable too.
The paradigm is Clap [provider_id_or_alias] {provider_args}
, where the provider_id_or_alias
is obviously either the name or alias of provider. Technically the provider_id
can be anything that can be used a key of a Dict, but I recommend you using an identifier like name as the provider id, and use the alias rule if you prefer a special name.
You can use +no-cache
option to disable/refresh the cache, e.g., :Clap files +no-cache ~
for searching files under the home directory without cache, the shortcut for +no-cache
option:
:Clap!! [provider_id_or_alias] {provider_args}
, e.g, :Clap!! files ~
.:Clap [provider_id_or_alias][!] {provider_args}
, e.g, :Clap files! ~
. (Recommended)Note the *
in the spinner, it tells you are using the cache, use g:clap_forerunner_status_sign
to configure it.
Command | List | Requirement |
---|---|---|
Clap bcommits |
Git commits for the current buffer | 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 |
Clap files |
Files | fd/git/rg/find |
Clap filetypes |
File types | none |
Clap gfiles or Clap git_files |
Files managed by git | git |
Clap git_diff_files |
Files managed by git and having uncommitted changes | git |
Clap grep + |
Grep on the fly | rg |
Clap grep2 + |
Grep on the fly with cache and dynamic results | 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 |
Clap proj_tags |
Tags in the current project | maple and universal-ctags with JSON output support |
Clap yanks |
Yank stack of the current vim session | none |
Clap filer |
Ivy-like file explorer | maple |
Clap recent_files |
Persistent ordered history of recent files | maple |
Clap dumb_jump |
Definitions/References using regexp with grep fallback | rg with --pcre2 |
Clap providers |
List the vim-clap providers | none |
Clap windows |
Windows | none |
The command with a superscript !
means that it is not yet implemented or not tested.
The command with a superscript +
means that it supports multi-selection via Tab.
Use :Clap grep ++query=<cword>
to grep the word under cursor.
Use :Clap grep ++query=@visual
to grep the visual selection.
:Clap grep
is not recommended now as it's relatively much slower to :Clap grep2
and :Clap dumb_jump
.
Send a pull request if you want to get your provider listed here.
g:clap_layout
: Dict, { 'width': '67%', 'height': '33%', 'row': '33%', 'col': '17%' }
by default. This variable controls the size and position of vim-clap window. By default, the vim-clap window is placed relative to the currently active window. To make it relative to the whole editor modify this variable as shown below:
let g:clap_layout = { 'relative': 'editor' }
g:clap_open_action
: Dict, { 'ctrl-t': 'tab split', 'ctrl-x': 'split', 'ctrl-v': 'vsplit' }
, extra key bindings for opening the selected file in a different way. NOTE: do not define a key binding which is conflicted with the other default bindings of vim-clap, and only ctrl-*
is supported for now.
g:clap_provider_alias
: Dict, if you don't want to invoke some clap provider by its id(name), as it's too long or somehow, you can add an alias for that provider.
" The provider name is `command_history`, with the following alias config,
" now you can call it via both `:Clap command_history` and `:Clap hist:`.
let g:clap_provider_alias = {'hist:': 'command_history'}
g:clap_selected_sign
: Dict, { 'text': ' >', 'texthl': "ClapSelectedSign", "linehl": "ClapSelected"}
.
g:clap_current_selection_sign
: Dict, { 'text': '>>', 'texthl': "ClapCurrentSelectionSign", "linehl": "ClapCurrentSelection"}
.
g:clap_no_matches_msg
: String, 'NO MATCHES FOUND'
, message to show when there is no matches found.
g:clap_popup_input_delay
: Number, 200ms
by default, delay for actually responsing to the input, vim only.
g:clap_disable_run_rooter
: Bool, v:false
, vim-clap by default will try to run from the project root by changing cwd
temporarily. Set it to v:true
to run from the origin cwd
. The project root here means the git base directory. Create an issue if you want to see more support about the project root.
The option naming convention for provider is g:clap_provider_{provider_id}_{opt}
.
g:clap_provider_grep_delay
: 300ms by default, delay for actually spawning the grep job in the background.
g:clap_provider_grep_blink
: [2, 100] by default, blink 2 times with 100ms timeout when jumping the result. Set it to [0, 0] to disable the blink.
g:clap_provider_grep_opts
: An empty string by default, allows you to enable flags such as '--hidden -g "!.git/"'
.
See :help clap-options
for more information.
:Clap filer
.:Clap filer
.sink*
support)
:Clap filer
.g:clap_open_action
.:q
to exit.See :help clap-keybindings
for more information.
augroup YourGroup
autocmd!
autocmd User ClapOnEnter call YourFunction()
autocmd User ClapOnExit call YourFunction()
augroup END
By default vim-clap will use the colors extracted from your colorscheme, which is not guaranteed to suitable for all the colorschemes. Then you can try the built-in material_design_dark
theme then:
let g:clap_theme = 'material_design_dark'
You could also set g:clap_theme
to be a Dict
to specify the palette:
" Change the CamelCase of related highlight group name to under_score_case.
let g:clap_theme = { 'search_text': {'guifg': 'red', 'ctermfg': 'red'} }
ClapDisplay
and ClapPreview
are the most basic highlight groups for the display and preview window, which can be overrided if the provider has its own syntax highlight, then checkout the related syntax file for more granular highlights directly.
If you want to write your own clap theme, take autoload/clap/themes/material_design_dark.vim as a reference.
See :help clap-highlights
for more information.
vim-clap uses a search syntax similar to the one used in fzf, please refer to the search syntax section of fzf's README for more details. Note that the OR operator defined by a single bar character is not yet implemented, but you can achieve that by using multiple exact matches.
" `:Clap quick_open` to open some dotfiles quickly.
" `description` is actually optional, but if you want to show this provider
" when you call `:Clap`, the `description` is neccessary.
let g:clap_provider_quick_open = {
\ 'source': ['~/.vimrc', '~/.spacevim', '~/.bashrc', '~/.tmux.conf'],
\ 'sink': 'e',
\ 'description': 'Quick open some dotfiles',
\ }
Find more examples at wiki/Examples.
For complete guide about writing a clap provider please see PROVIDER.md.
Some of the auto-completion engines need to turn off to prevent bizarre behaviors(#580)
For nvim-completion, add autocmd to your init.vim:
autocmd FileType clap_input let g:completion_enable_auto_pop = 0
For nvim-compe:
autocmd FileType clap_input call compe#setup({ 'enabled': v:false }, 0)
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 or create a pull request.
If you'd liked to discuss the project more directly, check out .
MIT
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。