From 7c758fd69e19c26c5f77c5b96789339c79135c7d Mon Sep 17 00:00:00 2001 From: arthur Date: Sun, 9 Jun 2024 22:45:17 +0800 Subject: [PATCH] update: if the required prerequisites are not installed, we need an early return. --- lua/lazyvim/plugins/extras/editor/medias.lua | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lua/lazyvim/plugins/extras/editor/medias.lua b/lua/lazyvim/plugins/extras/editor/medias.lua index 17a368b5..d52bf70b 100644 --- a/lua/lazyvim/plugins/extras/editor/medias.lua +++ b/lua/lazyvim/plugins/extras/editor/medias.lua @@ -28,13 +28,13 @@ return { }, } - local errors = {} local filetypes = {} -- Ensure all required prerequisites are installed for _, tool in ipairs(prerequisites.required) do if vim.fn.executable(tool.cmd) == 0 then - table.insert(errors, "Required prerequisite not installed: " .. tool.name) + LazyVim.error("Required prerequisite not installed: " .. tool.name) + return else filetypes = vim.tbl_extend("force", filetypes, tool.filetypes) end @@ -50,7 +50,13 @@ return { end if not findCmd then - table.insert(errors, "None of the required 'find cmd' prerequisites are installed") + LazyVim.error( + "None of the required 'find cmd' prerequisites is installed.\n" + .. "Please install at least one of the following: `rd`, `rg`, or `find`.\n" + .. "More information can be found at: " + .. "https://github.com/nvim-telescope/telescope-media-files.nvim?tab=readme-ov-file#prerequisites" + ) + return end -- Check optional prerequisites and include their filetypes if installed @@ -60,12 +66,6 @@ return { end end - -- If one of required prerequisites not installed print them and return - if #errors > 0 then - LazyVim.error(table.concat(errors, "\n")) - return - end - -- Setup media_files extension for telescope LazyVim.on_load("telescope.nvim", function() local ok, err = pcall(require("telescope").load_extension, "media_files")