mirror of
https://github.com/LazyVim/LazyVim.git
synced 2026-07-25 14:01:06 +00:00
update plugin spec for avoid messup telescope lazy load
This commit is contained in:
parent
70efad4973
commit
793b2e4b1d
1 changed files with 102 additions and 98 deletions
|
|
@ -1,9 +1,21 @@
|
|||
local findCmd = ""
|
||||
--- @class Set A simple Set implementation using a table to avoid duplicates; it only contains the methods add and toList
|
||||
--- @field _data table<string, 1> Table to hold the set data.
|
||||
local supportedFiletypeSet = { _data = {} }
|
||||
return {
|
||||
{
|
||||
"nvim-telescope/telescope.nvim",
|
||||
optional = true,
|
||||
dependencies = {
|
||||
{
|
||||
"nvim-telescope/telescope-media-files.nvim",
|
||||
enabled = function()
|
||||
if not vim.tbl_contains(LazyVim.config.json.data.extras, "lazyvim.plugins.extras.editor.medias") then
|
||||
return false
|
||||
end
|
||||
|
||||
function supportedFiletypeSet:add(values)
|
||||
local findCmd = ""
|
||||
--- @class Set A simple Set implementation using a table to avoid duplicates; it only contains the methods add and toList
|
||||
--- @field _data table<string, 1> Table to hold the set data.
|
||||
local supportedFiletypeSet = { _data = {} }
|
||||
|
||||
function supportedFiletypeSet:add(values)
|
||||
values = type(values) == "string" and { values } or values
|
||||
|
||||
for _, value in ipairs(values) do
|
||||
|
|
@ -11,33 +23,10 @@ function supportedFiletypeSet:add(values)
|
|||
self._data[value] = 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function supportedFiletypeSet:toList()
|
||||
return vim.tbl_keys(self._data)
|
||||
end
|
||||
|
||||
return {
|
||||
{
|
||||
"nvim-telescope/telescope-media-files.nvim",
|
||||
dependencies = {
|
||||
{
|
||||
"nvim-telescope/telescope.nvim",
|
||||
opts = function(_, opts)
|
||||
opts.extensions = vim.tbl_extend("force", opts.extensions or {}, {
|
||||
media_files = { filetypes = supportedFiletypeSet:toList(), find_cmd = findCmd },
|
||||
})
|
||||
return opts
|
||||
end,
|
||||
},
|
||||
},
|
||||
cond = function()
|
||||
if not LazyVim.has("telescope.nvim") then
|
||||
return false
|
||||
end
|
||||
|
||||
if not vim.tbl_contains(LazyVim.config.json.data.extras, "lazyvim.plugins.extras.editor.medias") then
|
||||
return false
|
||||
function supportedFiletypeSet:toList()
|
||||
return vim.tbl_keys(self._data)
|
||||
end
|
||||
|
||||
local function disableWithWarnMessage(msg)
|
||||
|
|
@ -98,10 +87,25 @@ return {
|
|||
end
|
||||
end
|
||||
|
||||
-- Setup extension for media files when telescope is loaded
|
||||
LazyVim.on_load("telescope.nvim", function()
|
||||
local ok, telescope = pcall(require, "telescope")
|
||||
if ok then
|
||||
telescope.extensions["media_files"] = vim.tbl_extend("force", telescope.extensions["media_files"] or {}, {
|
||||
filetypes = supportedFiletypeSet:toList(),
|
||||
find_cmd = findCmd,
|
||||
})
|
||||
else
|
||||
LazyVim.error("Failed to load telescope.nvim")
|
||||
end
|
||||
end)
|
||||
|
||||
return true
|
||||
end,
|
||||
keys = {
|
||||
{ "<leader>fP", "<cmd>Telescope media_files<cr>", desc = "Find Media Files" },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue