return {
  'nvim-telescope/telescope.nvim',
  dependencies = {
    'nvim-telescope/telescope-ui-select.nvim',
    'nvim-telescope/telescope-file-browser.nvim',
    'nvim-telescope/telescope-live-grep-args.nvim',
    'debugloop/telescope-undo.nvim',
    { 'nvim-telescope/telescope-fzf-native.nvim', build = 'make', cond = vim.fn.executable 'make' == 1 },
  },
  config = function()
    local themes = require 'telescope.themes'
    local actions = require 'telescope.actions'
    local previewers = require 'telescope.previewers'
    local builtin = require 'telescope.builtin'
    local trouble = require 'trouble.providers.telescope'

    local vimgrep_arguments = { unpack(require('telescope.config').values.vimgrep_arguments) }

    -- I want to search in hidden/dot files.
    table.insert(vimgrep_arguments, '--hidden')
    -- I don't want to search in the `.git` directory.
    table.insert(vimgrep_arguments, '--glob')
    table.insert(vimgrep_arguments, '!**/.git/*')

    require('telescope').setup {
      defaults = {
        vimgrep_arguments = vimgrep_arguments,
        dynamic_preview_title = true,
        wrap_results = true,
        layout_strategy = 'flex',
        preview = {
          filesize_limit = 5,
          timeout = 150,
          treesitter = true,
        },
        pickers = {
          find_files = {
            find_command = { 'fd', '--strip-cwd-prefix' },
          },
          diagnostics = {
            path_display = 'hidden',
            layout_strategy = 'vertical',
          },
        },
        borderchars = { '─', '│', '─', '│', '┌', '┐', '┘', '└' },
        selection_caret = ' ',
        file_ignore_patterns = { '%.jpeg$', '%.jpg$', '%.png$', '%.pdf$', 'node_modules', '.git/', 'dist/' },
        mappings = {
          n = { ['<c-s-t>'] = trouble.open_with_trouble },
          i = {
            ['<C-j>'] = actions.cycle_history_next,
            ['<C-k>'] = actions.cycle_history_prev,
            ['<C-o>'] = actions.select_horizontal,
            ['<TAB>'] = actions.toggle_selection + actions.move_selection_next,
            ['<M-space>'] = actions.to_fuzzy_refine,
            ['<c-s-t>'] = trouble.open_with_trouble,
            ['<esc>'] = actions.close,
          },
        },
      },
      extensions = {
        file_browser = {
          hidden = true,
          hijack_netrw = true,
          theme = 'ivy',
          borderchars = { '─', ' ', ' ', ' ', ' ', ' ', ' ', ' ' },
          grouped = true,
          initial_mode = 'normal',
          sorting_strategy = 'ascending',
        },
        undo = {
          side_by_side = true,
          use_delta = true,
          entry_format = '󰣜 #$ID, $STAT, $TIME',
          diff_context_lines = vim.o.scrolloff,
          layout_strategy = 'flex',
          layout_config = {
            preview_height = 0.4,
          },
        },
      },
    }
    local extensions = {
      'fzf',
      'file_browser',
      'undo',
      'ui-select',
      'live_grep_args',
    }
    for _, ext in ipairs(extensions) do
      require('telescope').load_extension(ext)
    end

    local delta_bcommits = previewers.new_termopen_previewer {
      get_command = function(entry)
        return {
          'git',
          '-c',
          'core.pager=delta',
          '-c',
          'delta.side-by-side=false',
          'diff',
          entry.value .. '^!',
          '--',
          entry.current_file,
        }
      end,
    }

    local delta = previewers.new_termopen_previewer {
      get_command = function(entry)
        return { 'git', '-c', 'core.pager=delta', '-c', 'delta.side-by-side=false', 'diff', entry.value .. '^!' }
      end,
    }

    Delta_git_commits = function(opts)
      opts = opts or {}
      opts = {
        layout_strategy = 'vertical',
        layout_config = {
          vertical = {
            mirror = true,
            width = 0.9,
            height = 0.9,
            preview_height = 0.6,
            preview_cutoff = 0,
          },
        },
      }
      opts.previewer = {
        delta,
        previewers.git_commit_message.new(opts),
        previewers.git_commit_diff_as_was.new(opts),
      }
      builtin.git_commits(opts)
    end

    Delta_git_bcommits = function(opts)
      opts = opts or {}
      opts = {
        layout_strategy = 'vertical',
        layout_config = {
          vertical = {
            mirror = true,
            width = 0.9,
            height = 0.9,
            preview_height = 0.6,
            preview_cutoff = 0,
          },
        },
      }
      opts.previewer = {
        delta_bcommits,
        previewers.git_commit_message.new(opts),
        previewers.git_commit_diff_as_was.new(opts),
      }
      builtin.git_bcommits(opts)
    end

    Project_files = function()
      local opts = { show_untracked = false } -- define here if you want to define something
      local ok = pcall(builtin.git_files, opts)
      if not ok then
        builtin.find_files(opts)
      end
    end

    -- See `:help telescope.builtin`
    vim.keymap.set('n', '<leader>u', '<cmd>Telescope undo<cr>', { desc = 'Telescope [U]ndo' })
    vim.keymap.set('n', '<leader>sw', builtin.grep_string, { desc = '[S]earch current [W]ord' })
    vim.keymap.set('n', '<leader>sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' })
    vim.keymap.set('n', '<leader>?', builtin.oldfiles, { desc = '[?] Find recently opened files' })
    vim.keymap.set('n', '<leader>P', builtin.commands, { desc = 'Command [P]allete' })
    vim.keymap.set('n', '<leader>f', function()
      builtin.current_buffer_fuzzy_find(themes.get_dropdown {
        results_height = 50,
        borderchars = { '─', '│', '─', '│', '┌', '┐', '┘', '└' },
        previewer = false,
      })
    end, { desc = '[F]uzzily search in current buffer]' })

    vim.keymap.set('n', '<F1>', builtin.help_tags, { desc = 'Search Help' })
    vim.keymap.set('n', '<F2>', '<cmd>lua Project_files()<CR>', { desc = 'Project Files' })
    vim.keymap.set('n', '<F3>', '<cmd>Telescope file_browser<CR>', { desc = 'File Browser' })
    vim.keymap.set('n', '<F4>', function()
      builtin.buffers(themes.get_dropdown {
        sort_lastused = true,
        previewer = false,
        results_height = 20,
        disable_devicons = true,
        borderchars = { '─', '│', '─', '│', '┌', '┐', '┘', '└' },
      })
    end, { desc = 'Find existing buffers' })
    vim.keymap.set('n', '<F5>', '<cmd>lua Delta_git_commits()<CR>', { desc = 'Project Commits' })
    vim.keymap.set('n', '<F6>', '<cmd>lua Delta_git_bcommits()<CR>', { desc = 'Buffer Commits' })
    vim.keymap.set(
      'n',
      '<F11>',
      "<cmd>lua require('telescope').extensions.live_grep_args.live_grep_args()<CR>",
      { desc = 'Grep with args' }
    )
    vim.keymap.set('n', '<F12>', '<cmd>Telescope diagnostics bufnr=0<CR>', { desc = 'Search Diagnostics' })
  end,
}
