Home

Awesome

fzf :heart: coc.nvim

Use FZF instead of coc.nvim built-in fuzzy finder.

Rationale

This plugin uses FZF fuzzy finder in place of Coc's built-in CocList sources as well as Coc's jumps (definition, reference etc).
It makes the interaction with Coc easier when you are used to FZF.

The main features are:

It was inspired by Robert Buhren's functions and coc-denite.

Installation

Make sure to have the following plugins in your vimrc:

Plug 'junegunn/fzf', {'dir': '~/.fzf','do': './install --all'}
Plug 'junegunn/fzf.vim' " needed for previews
Plug 'neoclide/coc.nvim', {'do': 'yarn install --frozen-lockfile'}
Plug 'antoinemadec/coc-fzf'

Or, if you prefer using the release branch:

Plug 'junegunn/fzf', {'dir': '~/.fzf','do': './install --all'}
Plug 'junegunn/fzf.vim' " needed for previews
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'antoinemadec/coc-fzf', {'branch': 'release'}

Also consider installing bat for colorful previews.

Commands

CommandList
:CocFzfListList all list sources
:CocFzfList --original-onlyList only original sources
:CocFzfList {source}Run a list source
:CocFzfListResumeRetrieve last list source

Original Sources

These are the list sources implemented with FZF:

SourceListPreviewMulti-selectVim support
actionsLike :CocList actions--
commandsLike :CocList commands--
diagnosticsLike :CocList diagnostics
diagnostics --current-bufLike :CocList diagnostics in the current buffer only
issuesLike :CocList issues. Requires coc-git-
locationLike :CocList location. Requires fzf.vim
outlineLike :CocList outline, with colors. Requires ctags
outputLike :CocList output-
servicesLike :CocList services--
snippets Like :CocList snippets. Requires coc-snippets
sources Like :CocList sources--
symbols ({query})Like :CocList symbols. Requires pynvim
symbols --kind {kind} ({query})Like :CocList symbols -kind {kind} Requires pynvim
yankLike :CocList yank. Requires coc-yank

FZF bindings (default):

Wrapper Sources

Not every list source is implementable with FZF.
For those sources, :CocFzfList acts as a wrapper calling :CocList

Wrapper Sources appear with the [wrapper] mention when running :CocFzfList

Add/Delete Sources

" add_list_source(name, description, command)
call coc_fzf#common#add_list_source('fzf-buffers', 'display open buffers', 'Buffers')

" delete_list_source(name)
call coc_fzf#common#delete_list_source('fzf-buffers')

Options

OptionTypeDescriptionDefault value
g:coc_fzf_preview_toggle_keystringChange the key to toggle the preview window'?'
g:coc_fzf_preview_fullscreennumberSet to 1 to use FZF fullscreen mode in coc-references etc.0
g:coc_fzf_previewstringChange the preview window position'up:50%'
g:coc_fzf_optsarrayPass additional parameters to fzf, e.g. ['--layout=reverse']['--layout=reverse-list']
g:coc_fzf_location_delaynumberDelay(ms) fzf_run() to solve weird race conditions.0

Vimrc Example

" allow to scroll in the preview
set mouse=a

" mappings
nnoremap <silent> <space><space> :<C-u>CocFzfList<CR>
nnoremap <silent> <space>a       :<C-u>CocFzfList diagnostics<CR>
nnoremap <silent> <space>b       :<C-u>CocFzfList diagnostics --current-buf<CR>
nnoremap <silent> <space>c       :<C-u>CocFzfList commands<CR>
nnoremap <silent> <space>e       :<C-u>CocFzfList extensions<CR>
nnoremap <silent> <space>l       :<C-u>CocFzfList location<CR>
nnoremap <silent> <space>o       :<C-u>CocFzfList outline<CR>
nnoremap <silent> <space>s       :<C-u>CocFzfList symbols<CR>
nnoremap <silent> <space>p       :<C-u>CocFzfListResume<CR>

FAQ

Q: How to get the FZF floating window?
A: You can look at FZF Vim integration:

let g:fzf_layout = { 'window': { 'width': 0.9, 'height': 0.6 } }

Q: How to see references, definitions etc in a FZF window?
A: It is already supported by default, just make sure to have the default coc mappings:

nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)

Q: How to get colors in previews?
A: Install bat.

Q: CocFzf looks different from my other Fzf commands. How to make it the same?
A: By default, CocFzf tries to mimic CocList. Here is how to change this:

let g:coc_fzf_preview = ''
let g:coc_fzf_opts = []

Q: CocFzf symbol search reports get_workspace_symbols.py could not be executed successfully A: You are most likely missing pynvim

License

MIT