return { { "telescope.nvim", load = vim.cmd.packadd, cmd = "Telescope", keys = { { "f", "Telescope find_files", desc = "Find Files" }, { "F", "Telescope ripgrep theme=ivy", desc = "Grep" }, -- { "gl", "Telescope git_commits", desc = "Git log" }, -- { "gh", "Telescope git_bcommits", desc = "Git history" }, -- { "gB", "Telescope git_branches", desc = "Git branches" }, -- { "gs", "Telescope git_status", desc = "Git status" }, { "gl", function() require("telescope.builtin").git_commits({ cwd = vim.fs.root(0, ".git") }) end, desc = "Git log" }, { "gh", function() require("telescope.builtin").git_bcommits({ cwd = vim.fs.root(0, ".git") }) end, desc = "Git history" }, { "gB", function() require("telescope.builtin").git_branches({ cwd = vim.fs.root(0, ".git") }) end, desc = "Git branches" }, { "gs", function() require("telescope.builtin").git_status({ cwd = vim.fs.root(0, ".git") }) end, desc = "Git status" }, { "zh", "Telescope help_tags", desc = "Read help" }, }, after = function() local actions = require("telescope.actions") local action_state = require("telescope.actions.state") local function git_show() local entry = action_state.get_selected_entry() vim.cmd("Telescope git_show ref=" .. entry.value) end local function git_show_split(bufr) actions.close(bufr) local entry = action_state.get_selected_entry() vim.cmd("Gedit " .. entry.value) end local function git_fixup(bufr) actions.close(bufr) local entry = action_state.get_selected_entry() vim.cmd("G commit --fixup=" .. entry.value) end local telescope = require("telescope") telescope.setup({ defaults = { prompt_prefix = " ", selection_caret = " ", sorting_strategy = "ascending", layout_config = { horizontal = { prompt_position = "top", } }, mappings = { i = { [""] = actions.close, [""] = actions.close, [""] = function() vim.cmd "normal! I" end, [""] = function() vim.cmd "startinsert!" end, }, } }, pickers = { find_files = { hidden = true, -- remove .git directory find_command = { "fd", "--type", "f", "--strip-cwd-prefix", "-E", ".git" }, }, git_commits = { -- use_file_path = true, mappings = { i = { [""] = git_show, [""] = git_show_split, [""] = git_fixup, }, }, }, git_bcommits = { -- use_file_path = true, mappings = { i = { [""] = git_show, [""] = git_show_split, [""] = git_fixup, [""] = function(bufr) actions.close(bufr) local entry = action_state.get_selected_entry() vim.cmd("Gvsplit " .. entry.value .. ":" .. entry.current_file) end, [""] = function(bufr) actions.close(bufr) local entry = action_state.get_selected_entry() vim.cmd("Gsplit " .. entry.value .. ":" .. entry.current_file) end, }, }, }, git_branches = { -- use_file_path = true, show_remote_tracking_branches = false, mappings = { i = { [""] = actions.git_switch_branch }, } }, git_status = { -- use_file_path = true, }, }, }) telescope.load_extension("fzf") telescope.load_extension("ripgrep") telescope.load_extension("git_show") end }, }