junegunn / fzf.vim

fzf :heart: vim
MIT License
9.66k stars 584 forks source link

fzf#run with sink 'let variable = ' #1327

Open abzrg opened 3 years ago

abzrg commented 3 years ago
Neovim v 0.5
fzf v 0.27.2 (8255aa2)

I want to store the selected item into a variable. The error I get is that variable x (the selected item) is not defined. It seems that when the command let var = x is issued, x is not placed there as string. For that, I tried to use the reducer per below, but I couldn't get it right. Note that I am able to select my item, but when it comes to sink, it crashes.

fzf#run({'source' : list, 'sink': 'let var = ', 'reducer': { lines -> '"' . string(lines[0]) . '"' } })

My goal is to simply give it a list and put the selected item into a variable as a string.