Files
flake/nvim/lua/plugins/telescope.lua
T

104 lines
2.3 KiB
Lua

return {
{
"telescope.nvim",
load = vim.cmd.packadd,
cmd = "Telescope",
keys = {
{ "<leader>f", "<cmd>Telescope find_files<cr>", desc = "Find Files" },
{ "<leader>F", "<cmd>Telescope ripgrep theme=ivy<cr>", desc = "Grep" },
{
"<leader>gl",
function()
require("telescope.builtin").git_commits({ cwd = vim.fs.root(0, ".git") })
end,
desc = "Git log"
},
{
"<leader>gh",
function()
require("telescope.builtin").git_bcommits({ cwd = vim.fs.root(0, ".git") })
end,
desc = "Git history"
},
{
"<leader>gB",
function()
require("telescope.builtin").git_branches({ cwd = vim.fs.root(0, ".git") })
end,
desc = "Git branches"
},
{
"<leader>gs",
function()
require("telescope.builtin").git_status({ cwd = vim.fs.root(0, ".git") })
end,
desc = "Git status"
},
{ "<leader>zh", "<cmd>Telescope help_tags<CR>", 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 telescope = require("telescope")
telescope.setup({
defaults = {
prompt_prefix = "",
selection_caret = "",
sorting_strategy = "ascending",
layout_config = {
horizontal = {
prompt_position = "top",
}
},
mappings = {
i = {
["<esc>"] = actions.close,
["<C-c>"] = actions.close,
},
}
},
pickers = {
find_files = {
hidden = true,
-- remove .git directory
find_command = { "fd", "--type", "f", "--strip-cwd-prefix", "-E", ".git" },
},
git_commits = {
mappings = {
i = {
["<CR>"] = git_show,
["<C-g>"] = git_show_split
},
},
},
git_bcommits = {
mappings = {
i = {
["<CR>"] = git_show,
["<C-g>"] = git_show_split
},
},
},
},
})
telescope.load_extension("fzf")
telescope.load_extension("ripgrep")
telescope.load_extension("git_show")
end
},
}