junegunn / fzf.vim

fzf :heart: vim
MIT License
9.59k stars 582 forks source link

Custom function in fzf_action works only for `GFiles` and `Files` #1381

Open StrongerXi opened 2 years ago

StrongerXi commented 2 years ago

Custom functions in fzf_action don't work for :Rg, but works fine for :GFiles and :Files. I'm trying to use following configuration:

function! s:vsplit_and_nerdtree_find(lines)
  exec "vsplit" a:lines[0]
  NERDTreeFind
  wincmd p
endfunction

function! s:tab_split_and_nerdtree_find(lines)
  exec "tab split" a:lines[0]
  NERDTreeFind
  wincmd p
endfunction

nmap <c-p> :GFiles<CR>
let g:fzf_action = {
      \ 'enter' : function('s:vsplit_and_nerdtree_find'),
      \ 'ctrl-t': function('s:tab_split_and_nerdtree_find'),
      \ }
let $FZF_DEFAULT_COMMAND='find .'

When I use :Rg and enter or ctrl-t, it simply opens up the file in the current buffer.

If I map the actions to non-custom functions, e.g., tab split, then everything works as expected.

bruhtus commented 2 years ago

You might want to read junegunn explanation here: https://github.com/junegunn/fzf.vim/issues/1345#issuecomment-963743146

StrongerXi commented 2 years ago

Thanks for sharing. So basically there's no way of supporting my example use cases right now?