diff --git a/lua/fzf-lua/init.lua b/lua/fzf-lua/init.lua index 1975f0f..d60c155 100644 --- a/lua/fzf-lua/init.lua +++ b/lua/fzf-lua/init.lua @@ -187,7 +187,14 @@ function M.setup(opts) -- reset default window opts if set by user fzf.default_window_options = config.winopts() -- set the fzf binary if set by the user - if config.fzf_bin then fzf.fzf_binary = config.fzf_bin end + if config.fzf_bin then + if fzf.default_options ~= nil and + vim.fn.executable(config.fzf_bin) == 1 then + fzf.default_options.fzf_binary = config.fzf_bin + else + config.fzf_bin = nil + end + end end -- we usually send winopts with every fzf.fzf call diff --git a/lua/fzf-lua/providers/helptags.lua b/lua/fzf-lua/providers/helptags.lua index 3a78028..5738fe3 100644 --- a/lua/fzf-lua/providers/helptags.lua +++ b/lua/fzf-lua/providers/helptags.lua @@ -87,7 +87,8 @@ local fzf_function = function (cb) end end end - -- done + -- done, we can't call utils.delayed_cb here + -- because sleep() messes up the coroutine cb(nil, function() end) end)() end diff --git a/lua/fzf-lua/providers/lsp.lua b/lua/fzf-lua/providers/lsp.lua index 0709678..39aba0b 100644 --- a/lua/fzf-lua/providers/lsp.lua +++ b/lua/fzf-lua/providers/lsp.lua @@ -144,10 +144,7 @@ local function set_lsp_fzf_fn(opts) opts.lsp_handler.handler(opts, cb, co, result) -- close the pipe to fzf, this -- removes the loading indicator in fzf - -- HACK: slight delay to prevent missing results - -- otherwise the input stream closes too fast - vim.cmd("sleep! 10m") - cb(nil, function() end) + utils.delayed_cb(cb) return end @@ -407,8 +404,7 @@ M.diagnostics = function(opts) -- coroutine.yield() -- close the pipe to fzf, this -- removes the loading indicator in fzf - vim.cmd("sleep! 10m") - cb(nil, function() end) + utils.delayed_cb(cb) end)() end diff --git a/lua/fzf-lua/providers/oldfiles.lua b/lua/fzf-lua/providers/oldfiles.lua index 3e32aec..0ae9384 100644 --- a/lua/fzf-lua/providers/oldfiles.lua +++ b/lua/fzf-lua/providers/oldfiles.lua @@ -59,7 +59,7 @@ M.oldfiles = function(opts) cb(nil, function() end) end) end - cb(nil, function() end) + utils.delayed_cb(cb) end --[[ opts.cb_selected = function(_, x) diff --git a/lua/fzf-lua/providers/quickfix.lua b/lua/fzf-lua/providers/quickfix.lua index 52f5b3e..80a73e0 100644 --- a/lua/fzf-lua/providers/quickfix.lua +++ b/lua/fzf-lua/providers/quickfix.lua @@ -36,7 +36,7 @@ local quickfix_run = function(opts, cfg, locations) cb(nil, function() end) end) end - cb(nil, function() end) + utils.delayed_cb(cb) end --[[ opts.cb_selected = function(_, x) diff --git a/lua/fzf-lua/utils.lua b/lua/fzf-lua/utils.lua index 7e1512e..4bd58b9 100644 --- a/lua/fzf-lua/utils.lua +++ b/lua/fzf-lua/utils.lua @@ -193,4 +193,11 @@ function M.send_ctrl_c() vim.api.nvim_replace_termcodes("", true, false, true), 'n', true) end +function M.delayed_cb(cb) + -- HACK: slight delay to prevent missing results + -- otherwise the input stream closes too fast + vim.cmd("sleep! 10m") + cb(nil, function() end) +end + return M