return { -- Fuzzy Finder (files, lsp, etc) 'nvim-telescope/telescope.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim', { -- If encountering errors, see telescope-fzf-native README for installation instructions 'nvim-telescope/telescope-fzf-native.nvim', -- `build` is used to run some command when the plugin is installed/updated. -- This is only run then, not every time Neovim starts up. build = 'make', -- `cond` is a condition used to determine whether this plugin should be -- installed and loaded. cond = function() return vim.fn.executable('make') == 1 end, }, { 'nvim-telescope/telescope-ui-select.nvim' }, -- Useful for getting pretty icons, but requires a Nerd Font. { 'nvim-tree/nvim-web-devicons', enabled = vim.g.have_nerd_font }, }, config = function() local actions = require('telescope.actions') require('telescope').setup({ extensions = { ['ui-select'] = { require('telescope.themes').get_dropdown(), }, }, defaults = { preview = { treesitter = true, }, mappings = { i = { [''] = actions.select_horizontal, }, n = { [''] = actions.select_horizontal, }, }, }, }) -- Enable Telescope extensions if they are installed pcall(require('telescope').load_extension, 'fzf') pcall(require('telescope').load_extension, 'ui-select') -- See `:help telescope.builtin` local builtin = require('telescope.builtin') vim.keymap.set('n', 'fh', builtin.help_tags) vim.keymap.set('n', 'fk', builtin.keymaps) -- vim.keymap.set('n', 'ff', builtin.find_files) vim.keymap.set('n', 'fs', builtin.builtin) vim.keymap.set('n', 'fw', builtin.grep_string) vim.keymap.set('n', 'fg', builtin.live_grep) vim.keymap.set('n', 'fd', builtin.diagnostics) vim.keymap.set('n', 'fr', builtin.resume) vim.keymap.set('n', 'f.', builtin.oldfiles) vim.keymap.set('n', 'fb', builtin.buffers) vim.keymap.set('n', 'ft', 'TodoTelescope') -- keybind to grep after find local actions = require('telescope.actions') local action_state = require('telescope.actions.state') local builtin = require('telescope.builtin') vim.keymap.set('n', 'ff', function() builtin.find_files({ attach_mappings = function(_, map) map('i', '', function(prompt_bufnr) local picker = action_state.get_current_picker(prompt_bufnr) local dirs = {} -- collect all selected/filtered results for _, entry in ipairs(picker:get_multi_selection()) do table.insert(dirs, entry.path) end -- fallback to current entry if nothing multi-selected if #dirs == 0 then local entry = action_state.get_selected_entry() table.insert(dirs, vim.fn.fnamemodify(entry.path, ':h')) end actions.close(prompt_bufnr) builtin.live_grep({ search_dirs = dirs }) end) return true end, }) end) end, }