junegunn / junegunn/fzf.vim

`g:fzf_action` doesn't accept functions

Open
#1,348 0 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

`a.vim`:

```vim
function! s:build_quickfix_list(lines)
call setqflist(map(copy(a:lines), '{ "filename": v:val }'))
copen
cc
endfunction

let g:fzf_action = {
\ 'ctrl-q': function('s:build_quickfix_list')}
```

Not Alpine Linux-specific.

```
$ docker run --rm -itv $PWD/a.vim:/a.vim alpine
/ # apk add vim bash curl git ripgrep bat
/ # bash
bash-5.1# TERM=xterm-256color
bash-5.1# cd /usr/share/vim
bash-5.1# vim -Nu <(curl https://gist.githubusercontent.com/junegunn/6936bf79fedd3a079aeb1dd2f3c81ef5/raw)
:so /a.vim
:Rg
ctrl-q
:copen
```

![](https://i.imgur.com/WnuURxw.png)

The `build_quickfix_list` solution was suggested [here][a] and [here][c]. It doesn't work because for some reason non-strings are [not accepted][b].

**UPD** I've found the [change][d]. I don't get the description, but in `fzf.vim` actions only ever received the [first filename][e]. And it's kind of confusing:

https://github.com/junegunn/fzf.vim/issues/621
https://github.com/junegunn/fzf.vim/pull/867
https://github.com/junegunn/fzf.vim/issues/185#issuecomment-322120216
https://github.com/junegunn/fzf/blob/a74731d/README-VIM.md#examples

[a]: https://github.com/junegunn/fzf/blob/a74731d/README-VIM.md#examples
[b]: https://github.com/junegunn/fzf.vim/blob/a4ce66d/autoload/fzf/vim.vim#L300
[c]: https://github.com/junegunn/fzf.vim/issues/185#issuecomment-322120216
[d]: https://github.com/junegunn/fzf.vim/commit/b9b275a897e3cc5f900bf802ca74e3442f9027d4
[e]: https://github.com/junegunn/fzf.vim/commit/f13853cc8dbf019652051eda1f3be2a537dac794#diff-f697bec8f1ba94d14196b753546e9fe6a486a33e10f25afb42765573c991fa0fR221

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with autoload/fzf/vim.vim around the linked line where actions are handled, then reproduce the behavior using the a.vim configuration and the Rg command described in the issue. Compare the referenced fzf.vim and fzf changes to understand how g:fzf_action values are processed and verify that the function-based quickfix action works as intended.

Written by the indexing model from the issue text.

Assessment

Tech stack
vim
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.