local function git_root() local git_dir = vim.fn.systemlist("git rev-parse --show-toplevel")[1] if git_dir and git_dir ~= "" then return git_dir else return vim.fn.getcwd() -- Fallback to current working directory if not in a Git repo end end return { { "nvim-telescope/telescope.nvim", brach = '0.1.x', dependencies = { { 'nvim-lua/plenary.nvim' }, { 'nvim-tree/nvim-web-devicons' } }, config = function() -- Custom Telescope command to grep from Git root require("which-key").add({ { "/", function() require('telescope.builtin').live_grep({ cwd = git_root() }) end, desc = "grep" }, { "/", ":Telescope live_grep", desc = "grep" }, { "ff", ":Telescope fd", desc = "Search for Files" }, { "fp", ":Telescope oldfiles", desc = "Oldfiles" }, { "?", ":Telescope command_history", desc = "Command History" }, { "cm", ":Telescope man_pages", desc = "Manpages" }, -- Code { "gd", ":Telescope lsp_definitions", desc = "Go to Definition" }, { "gi", ":Telescope lsp_implementations", desc = "Go to Implementations" }, { "gt", ":Telescope lsp_type_definitions", desc = "Go to Type Definition" }, { "cv", ":Telescope treesitter", desc = "List function names & variables" }, { "cd", ":Telescope diagnostics", desc = "Code diagnostics" }, -- Git { "Gt", ":Telescope git_branches", desc = "Git Branches" }, { "Gc", ":Telescope git_commits", desc = "Git Commits" }, }) end } }