junegunn / junegunn/fzf.vim

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

Open
#1,381 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Vim Script
Stars
10.3k
Forks
608
Avg merge
5d 8h
Merged PRs (30d)
2

Description

- [x] I have fzf 0.23.0 or above
- [x] I have read through https://github.com/junegunn/fzf.vim/blob/master/README.md
- [x] I have read through https://github.com/junegunn/fzf/blob/master/README-VIM.md
- [x] I have read through the manual page of fzf (`man fzf`)
- [x] I have searched through the existing issues

Custom functions in `fzf_action` don't work for `:Rg`, but works fine for `:GFiles` and `:Files`.
I'm trying to use following configuration:
```vimrc
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 :GFiles
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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.