-- lua/plugins/telescope.lua local function searchBranchFiles() local results = require("mj.utils").branch_files() local pickers = require("telescope.pickers") local finders = require("telescope.finders") local sorters = require("telescope.sorters") local previewers = require("telescope.previewers") pickers .new({}, { prompt_title = "Branch Files", finder = finders.new_table({ results = results, }), -- @see https://github.com/nvim-telescope/telescope.nvim/tree/master?tab=readme-ov-file#sorters sorter = sorters.get_fzy_sorter(), previewer = previewers.vim_buffer_cat.new({}), }) :find() end return { { "nvim-telescope/telescope.nvim", dependencies = { "nvim-lua/plenary.nvim", "nvim-tree/nvim-web-devicons", "nvim-telescope/telescope-fzy-native.nvim", }, config = function() local telescope = require("telescope") telescope.load_extension("fzy_native") end, cmd = "Telescope", keys = { -- Files { "fg", "Telescope git_files", desc = "Find files with Telescope git_files" }, { "ff", "Telescope find_files", desc = "Find Files" }, { "fr", "Telescope oldfiles", desc = "Recent Files" }, { "", function() local project_root = require("project_nvim.project").get_project_root() or vim.fn.getcwd() require("telescope.builtin").find_files({ cwd = project_root, -- Force project root }) end, desc = "Find Files (Project Root)" }, -- Search -- { "sg", "Telescope live_grep", desc = "Grep" }, { "sw", "Telescope grep_string", desc = "Word" }, { "sb", "Telescope current_buffer_fuzzy_find", desc = "Buffer" }, { "sd", "Telescope diagnostics", desc = "Diagnostics" }, { "sh", "Telescope help_tags", desc = "Help Pages" }, { "sk", "Telescope keymaps", desc = "Key Maps" }, { "sR", "Telescope resume", desc = "Resume" }, -- Git { "gc", "Telescope git_commits", desc = "commits" }, { "gs", "Telescope git_status", desc = "status" }, { "gb", "Telescope git_branches", desc = "branches" }, { "h", searchBranchFiles, desc = "Branch Files" }, -- LSP { "ls", "Telescope lsp_document_symbols", desc = "Document Symbols" }, { "lS", "Telescope lsp_dynamic_workspace_symbols", desc = "Workspace Symbols" }, { "lr", "Telescope lsp_references", desc = "References" }, { "li", "Telescope lsp_implementations", desc = "Implementations" }, { "ld", "Telescope lsp_definitions", desc = "Definitions" }, { "lt", "Telescope lsp_type_definitions", desc = "Type Definitions" }, -- Commands { ":", "Telescope command_history", desc = "Command History" }, { "sc", "Telescope commands", desc = "Commands" }, -- Custom { "sg", function() require("mj.telescope.grep_with_args").setup() end, desc = "Custom Live Grep With args" }, }, opts = { defaults = { prompt_prefix = " ", selection_caret = " ", -- sorter = require("telescope.sorters").get_fzy_sorter(), -- TODO: Check if this will be needed mappings = { i = { [""] = function(...) require("telescope.actions").move_selection_next(...) end, [""] = function(...) require("telescope.actions").move_selection_previous(...) end, [""] = function(...) require("telescope.actions").cycle_history_next(...) end, [""] = function(...) require("telescope.actions").cycle_history_prev(...) end, }, }, }, }, }, }