---@module 'lazy'
---@type LazySpec
return { {
	'nvim-telescope/telescope.nvim', -- fuzzy finder (files, lsp, etc)
	event = 'VeryLazy',
	branch = '0.1.x',
	dependencies = {
		{ 'nvim-lua/plenary.nvim' },     -- contains lua functions for neovim, apparently
		{ 'nvim-telescope/telescope-ui-select.nvim' }, -- allows neovim core stuff to enter the telescope picker
		{ 'nvim-tree/nvim-web-devicons' },
		{
			'nvim-telescope/telescope-fzf-native.nvim',
			build = 'make',                        -- used for when the plugin is installed/updated
			cond = function() return vim.fn.executable 'make' == 1 end, -- condition for whether the plugin should be loaded / installed
		},
	},
	opts = {
		pickers = {
			find_files = {
				find_command = { 'fd', '-t', 'f', '-HE', '/.git', '--strip-cwd-prefix' },
			},
		},
		extensions = {
			file_browser = {
				hijack_netrw = true,
			},
		},
	},
	config = function(_, opts)
		local tel = require('telescope')
		local std = require("telescope.builtin")
		local ext = tel.extensions
		require('telescope').setup(opts)

		-- load telescope extensions, if they are installed
		pcall(tel.load_extension, 'fzf')
		pcall(tel.load_extension, 'ui-select')

		-- set the telescope keymaps
		Map({ 'n' }, '<C-g>', std.live_grep, { desc = 'Search by Grep' })
		Map({ 'n' }, '<C-s>', std.resume, { desc = 'Search Resume' })
		Map({ 'n', 'i' }, '<C-p>', std.find_files, { desc = 'Search Project' })
		Map({ 'n' }, '<leader>p', std.find_files, { desc = 'Search Project' })
		Map({ 'n' }, '<leader>gf', std.git_status, { desc = 'Search through Git status Files' })
		Map({ 'n' }, '<leader>sq', std.quickfix, { desc = 'Search Quickfix' })
		Map({ 'n' }, '<leader>sh', std.help_tags, { desc = 'Search Help' })
		Map({ 'n' }, '<leader>sk', std.keymaps, { desc = 'Search Keymaps' })
		Map({ 'n' }, '<leader>sf', std.find_files, { desc = 'Search Files' })
		Map({ 'n' }, '<leader>ss', std.builtin, { desc = 'Sarch Select telescope' })
		Map({ 'n' }, '<leader>sw', std.grep_string, { desc = 'Search current Word' })
		Map({ 'n' }, '<leader>sg', std.live_grep, { desc = 'Search by Grep' })
		Map({ 'n' }, '<leader>sd', std.diagnostics, { desc = 'Search Diagnostics' })
		Map({ 'n' }, '<leader>sr', std.resume, { desc = 'Search Resume' })
		Map({ 'n' }, '<leader>s.', std.oldfiles, { desc = 'Search recent Files ("." for repeat)' })
		Map({ 'n' }, '<leader><leader>', std.buffers, { desc = 'find existing buffers' })

		-- for fuzzily searching in the current buffer
		Map('n', '<leader>/', function()
			std.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { winblend = 10, previewer = false })
		end, { desc = 'fuzzily search in current buffer' })

		-- for executing grep
		Map('n', '<leader>s/', function()
			std.live_grep { grep_open_files = true, prompt_title = 'Live Grep in Open Files' }
		end, { desc = 'Search in open files' })

		-- shortcut for searching neovim config files
		Map('n', '<leader>sn', function()
			std.find_files { cwd = vim.fn.stdpath 'config' }
		end, { desc = 'Search Neovim files' })
	end,
} }
