Antoinemadec Coc Fzf Save

fzf :heart: coc.nvim

Project README

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:

  • FZF preview
  • FZF bindings for splits and tabs
  • FZF layout (floating windows etc)
  • FZF multi-select to populate the quickfix window

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

Command List
:CocFzfList List all list sources
:CocFzfList --original-only List only original sources
:CocFzfList {source} Run a list source
:CocFzfListResume Retrieve last list source

Original Sources

These are the list sources implemented with FZF:

Source List Preview Multi-select Vim support
actions Like :CocList actions - -
commands Like :CocList commands - -
diagnostics Like :CocList diagnostics
diagnostics --current-buf Like :CocList diagnostics in the current buffer only
issues Like :CocList issues. Requires coc-git -
location Like :CocList location. Requires fzf.vim
outline Like :CocList outline, with colors. Requires ctags
output Like :CocList output -
services Like :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
yank Like :CocList yank. Requires coc-yank

FZF bindings (default):

  • ctrl-t: open in tab
  • ctrl-v: open in vertical split
  • ctrl-x: open in horizontal split
  • tab: multi-select, populate quickfix window
  • ?: toggle preview window

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

Option Type Description Default value
g:coc_fzf_preview_toggle_key string Change the key to toggle the preview window '?'
g:coc_fzf_preview_fullscreen number Set to 1 to use FZF fullscreen mode in coc-references etc. 0
g:coc_fzf_preview string Change the preview window position 'up:50%'
g:coc_fzf_opts array Pass additional parameters to fzf, e.g. ['--layout=reverse'] ['--layout=reverse-list']
g:coc_fzf_location_delay number Delay(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

Open Source Agenda is not affiliated with "Antoinemadec Coc Fzf" Project. README Source: antoinemadec/coc-fzf
Stars
389
Open Issues
5
Last Commit
1 week ago

Open Source Agenda Badge

Open Source Agenda Rating