man fzf)This is an enhacement request to support using FZF from lua.
Im calling fzf#run from lua and would like fzf to use a lua function for the sink:
local fzf_config = {
source = fzf_options,
sink = 'v:lua.MyLuaSink',
options = "+m --with-nth 2.. -d ::"
}
vim.fn['fzf#run'](vim.fn['fzf#wrap'](fzf_config))
since sink is a string, FZF currently treats it as a command. would it be possible to treat strings starting with v:lua in a special way, so FZF does: call v:lua.MyLuaSink(selection)
or maybe add a new luasink property to the existing sink and sink* ones. In that case the v:lua prefix should not be required since FZF should already know that the string is the name of a lua function and should use v:lua to call it from vimL
Thanks!
I'm not familiar with Lua interface of Neovim. But I believe there must be a way to get a "funcref" for the Lua function. You might want to ask this to Neovim guys.
yep, I asked them in gitter and here and apparently there is not :(
Hi all! I just find a way to deal with this issue.
local fzf_run = vim.fn["fzf#run"]
local fzf_wrap = vim.fn["fzf#wrap"]
local wrapped = fzf_wrap("test", {
source = {'line1', 'line2'},
options = {},
-- don't set `sink` or `sink*` here
})
wrapped["sink*"] = nil -- this line is required if you want to use `sink` only
wrapped.sink = function(line)
-- your staff
end
fzf_run(wrapped)
hey @Xuyuanp !
im trying to follow you way and build custom fzf function with lua source, but having 'Unknown function fzf#run' error thrown from vim.fn[...] line...any ideas why that could happen? fzf and fzf#vim is installed
I'm not sure, maybe because you are trying to use fzf#run before junegunn/fzf loaded. Could you provide the minimal config to reproduce this issue?
hey, you are right!
I was calling that function at startup-time, so it wasn't there at the moment...
I've fixed that, now trying to figure out how to pass string properly to fzf for it to be able to navigate me to file line number on enter
Most helpful comment
Hi all! I just find a way to deal with this issue.