--[[ [ WARNING: This is potential spaghetti code written late at night to solve a problem that has yet to occur... [ I strongly suggest to anyone reading this (and that means me) to double check what you think it does before { making any attempt to edit it ]] local telescope = {} telescope.opts = {} -- default dependencies telescope.dependencies = { ---@string[] 'nvim-treesitter', 'nvim-web-devicons', 'plenary.nvim', 'popup.nvim', } telescope.keys = { ---@LazyKeys[] -- Keys defined for finding files { 'fg', 'Telescope live_grep', desc = 'Find grep', }, { 'fG', 'Telescope git_files', desc = 'Find git files', }, -- Misc telescope functions { 'tc', 'Telescope commands theme=dropdown', desc = 'Command Pallet', }, { 'ts', 'Telescope current_buffer_fuzzy_find', desc = 'Fuzzy find in buffer', }, { 'tm', 'Telescope man_pages sections=1,2,3,4,5,6,7,8,9', desc = 'Man', }, { 'tt', 'Telescope builtin', desc = 'All pickers' }, } -- This must exist even if we keep it empty for later configuration to work telescope.opts.opts = { defaults = {}, pickers = {}, extensions = {}, } -- TESTS for telescope-media-files if vim.fn.executable('chafa') then -- if chafa is installed then we set a flag and add the dependency to telescope telescope.opts.has_chafa = true table.insert(telescope.dependencies, 'nvim-telescope/telescope-media-files.nvim') telescope.opts.opts.extensions.media_files = { filetypes = { 'png', 'jpg', 'jpeg', 'webp', 'svg' }, } end -- TESTS for telescope-fzf-native -- If not windows then attempt to build and use it. -- We also check a global flag here that we can set if we can't build fzf-native if vim.fn.has('win32') == 0 and not vim.g.no_fzf then -- NOTE: has returns 0 when we don't have a feature telescope.opts.do_fzf = true table.insert(telescope.dependencies, 'telescope-fzf-native.nvim') end -- TESTS for fzf-native telescope.config = function(_, opts) require('telescope').setup() if opts.has_chafa then require('telescope').load_extension('media_files') end if opts.do_fzf then require('telescope').load_extension('fzf') end end return { { 'nvim-telescope/telescope.nvim', cmd = 'Telescope', opts = telescope.opts, config = telescope.config, keys = telescope.keys, dependencies = telescope.dependencies, }, { 'nvim-telescope/telescope-fzf-native.nvim', build = 'make', cond = function() return vim.fn.has('win32') == 0 and not vim.g.no_fzf end, }, }