ctrlpvim / ctrlp.vim

Active fork of kien/ctrlp.vim—Fuzzy file, buffer, mru, tag, etc finder.
ctrlpvim.github.com/ctrlp.vim
Other
5.56k stars 260 forks source link

Call fzf through ctrlp? #439

Open alphaCTzo7G opened 6 years ago

alphaCTzo7G commented 6 years ago

I love ctrlp.. and it provides a lot of features that fzf.vim doesn't provide and fzf provides some features that ctrlp doesn't provide.

Is it possible to wrap fzf such that the commands are provided through ctrlp?

alphaCTzo7G commented 6 years ago

Seems like something like this has been proposed before (https://github.com/ctrlpvim/ctrlp.vim/issues/111).. I see a lot of people moving over to fzf..

Somebody suggested that there are some workarounds to integrate ctrlp with fzf.. but it maynot work well. It would be great if it could be officially integrated.

mattn commented 6 years ago

Why you don't use fzf directly?

alphaCTzo7G commented 6 years ago

@mattn Because ctrlp is awesome :) and I and a lot of other people are already very familiar with ctrlp. ctrlp is a very stable software with low bugs and unexpected edge cases. fzf and ctrlp provide similar functionalities.. and if we unite the community to within ctrlp, we will get more people to contribute towards 1 single project instead of breaking up into multiple fragmented communities.

Also as far as I can see, fzf.vim doesn't have as many features and the author of fzf.vim seems to not very interested to creating a good wrapper for vim..from the statement here:

This repository is a bundle of fzf-based commands and mappings extracted from my .vimrc to address such needs. They are not designed to be flexible or configurable, and there's no guarantee of backward-compatibility.

prabirshrestha commented 6 years ago

@alphaCTzo7G You could try vim-fz by mattn. It is easy to extend. I use vim-fz with fzf. https://github.com/mattn/vim-fz/issues/4

This is what I do, if fzf executable exist it uses vim-fz else fallsback to ctrlp.

Plug 'ctrlpvim/ctrlp.vim'
Plug 'mattn/vim-fz'
if executable('fzf')
  let g:fz_command = 'fzf'
  let g:fz_command_files = ''
  let g:fz_command_options_action = '--expect=%s'
  let g:ctrlp_map = ''
  nnoremap <C-p> :call fz#run({ 'type': 'cmd', 'cmd': 'git ls-files' })<CR>
endif

I personally prefer vim-fz apis. Wished ctrlp.vim adopted its api.

If you want to use list instead of running command it is simple as setting the type to be list.

function! s:accept(result)
    exec 'colorscheme ' . a:result['items'][0]
endfunction

command! FzColors call fz#run({
    \ 'type': 'list',
    \ 'list': uniq(map(split(globpath(&rtp, "colors/*.vim"), "\n"), "substitute(fnamemodify(v:val, ':t'), '\\..\\{-}$', '', '')")),
    \ 'accept': function('s:accept'),
    \ })
alphaCTzo7G commented 6 years ago

Didn't know about vim-fz.. Thank you @prabirshrestha.. @mattn.. vim-fz seems to be awesome..Perhaps.. it could slowly integrated into ctrlp, so more people can use the vim-fz apis that you and @prabirshrestha created, through ctrlp, as ctrlp has a lot more following..

HaleTom commented 6 years ago

It would be great to be able to specify a path-like list of executables:

fzy:fzf:peco:percol:selecta

And perhaps listers:

fd -options:find -options

alphaCTzo7G commented 6 years ago

+1.. I was also thinking something like what @HaleTom mentioned.. and was going to look into whether this is possible with ctrlp or not.. How hard is it to modify ctrlp to do this, or is it possible to do it currently?

poetaman commented 3 years ago

Why use fzf? shouldn't fd work better for this task? I have the following, and its super fast:

if executable('fd')
    let g:ctrlp_user_command = 'fd %s -i -p -L -d4 --type f'
endif