fix(fzf-native): try rebuilding fzf-native when needed. Fixes #2464

This commit is contained in:
Folke Lemaitre
2024-05-13 08:53:17 +02:00
parent abb1ff0d60
commit 39901c1f00

View File

@ -1,3 +1,6 @@
local have_make = vim.fn.executable("make") == 1
local have_cmake = vim.fn.executable("cmake") == 1
return {
-- file explorer
@ -141,12 +144,23 @@ return {
dependencies = {
{
"nvim-telescope/telescope-fzf-native.nvim",
build = vim.fn.executable("make") == 1 and "make"
build = have_make and "make"
or "cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build",
enabled = vim.fn.executable("make") == 1 or vim.fn.executable("cmake") == 1,
config = function()
enabled = have_make or have_cmake,
config = function(plugin)
LazyVim.on_load("telescope.nvim", function()
require("telescope").load_extension("fzf")
local ok, err = pcall(require("telescope").load_extension, "fzf")
if not ok then
local lib = plugin.dir .. "/build/libfzf." .. (LazyVim.is_win() and "dll" or "so")
if not vim.uv.fs_stat(lib) then
LazyVim.warn("`telescope-fzf-native.nvim` not built. Rebuilding...")
require("lazy").build({ plugins = { plugin }, show = false }):wait(function()
LazyVim.info("Rebuilding `telescope-fzf-native.nvim` done.\nPlease restart Neovim.")
end)
else
LazyVim.error("Failed to load `telescope-fzf-native.nvim`:\n" .. err)
end
end
end)
end,
},