diff --git a/lua/lazyvim/plugins/editor.lua b/lua/lazyvim/plugins/editor.lua index c25537f4..907d2dc0 100644 --- a/lua/lazyvim/plugins/editor.lua +++ b/lua/lazyvim/plugins/editor.lua @@ -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, },