dotfiles/modules/editor/neovim/lua/packer/telescope.lua

140 lines
4.8 KiB
Lua
Raw Normal View History

2022-07-09 21:27:04 +00:00
-- =======================================================================
-- Fuzzy Launcher
-- =======================================================================
local M = {}
M.packer = function(use)
use({
"nvim-telescope/telescope.nvim",
branch = "master",
requires = { "nvim-lua/plenary.nvim" },
config = function()
-- Telescope: quit instantly with escape
local actions = require("telescope.actions")
require("telescope").setup({
defaults = {
mappings = {
i = {
["<esc>"] = actions.close,
["<C-h>"] = "which_key",
},
},
},
pickers = {
find_files = { theme = "ivy" },
oldfiles = { theme = "ivy" },
buffers = { theme = "dropdown" },
},
extensions = {
fzy_native = {},
zoxide = {},
project = {
base_dirs = { "~/dev" },
},
},
})
2022-07-11 03:31:48 +00:00
local telescope = require("telescope.builtin")
vim.keymap.set("n", "<Leader>k", telescope.keymaps)
vim.keymap.set("n", "<Leader>/", telescope.live_grep)
vim.keymap.set("n", "<Leader>ff", telescope.find_files)
vim.keymap.set("n", "<Leader>fp", telescope.git_files)
vim.keymap.set("n", "<Leader>fw", telescope.grep_string)
vim.keymap.set("n", "<Leader>b", telescope.buffers)
vim.keymap.set("n", "<Leader>hh", telescope.help_tags)
vim.keymap.set("n", "<Leader>fr", telescope.oldfiles)
vim.keymap.set("n", "<Leader>cc", telescope.commands)
vim.keymap.set("n", "<Leader>gc", telescope.git_commits)
vim.keymap.set("n", "<Leader>gf", telescope.git_bcommits)
vim.keymap.set("n", "<Leader>gb", telescope.git_branches)
vim.keymap.set("n", "<Leader>gs", telescope.git_status)
vim.keymap.set("n", "<Leader>s", telescope.current_buffer_fuzzy_find)
vim.keymap.set("n", "<Leader>N", function()
local opts = {
prompt_title = "Search Notes",
cwd = "$NOTES_PATH",
}
telescope.live_grep(opts)
end)
vim.keymap.set("n", "<Leader>fN", function()
local opts = {
prompt_title = "Find Notes",
cwd = "$NOTES_PATH",
}
telescope.find_files(opts)
end)
vim.keymap.set("n", "<Leader>cr", function()
local opts = require("telescope.themes").get_ivy({
layout_config = {
bottom_pane = {
height = 15,
},
},
})
telescope.command_history(opts)
end)
2022-07-09 21:27:04 +00:00
end,
})
-- Faster sorting
use("nvim-telescope/telescope-fzy-native.nvim")
-- Jump around tmux sessions
2022-07-10 17:54:21 +00:00
-- use("camgraff/telescope-tmux.nvim")
2022-07-09 21:27:04 +00:00
-- Jump directories
use({
"jvgrootveld/telescope-zoxide",
2022-07-11 03:31:48 +00:00
requires = { "nvim-lua/popup.nvim", "nvim-telescope/telescope.nvim" },
config = function()
vim.keymap.set("n", "<Leader>fz", require("telescope").extensions.zoxide.list)
end,
2022-07-09 21:27:04 +00:00
})
-- Jump projects
use({
"nvim-telescope/telescope-project.nvim",
requires = { "nvim-telescope/telescope.nvim" },
config = function()
require("telescope").load_extension("project")
2022-07-10 14:15:41 +00:00
2022-07-11 03:31:48 +00:00
vim.keymap.set("n", "<C-p>", function()
2022-07-10 14:15:41 +00:00
local opts = require("telescope.themes").get_ivy({
layout_config = {
bottom_pane = {
height = 10,
},
},
})
require("telescope").extensions.project.project(opts)
2022-07-11 03:31:48 +00:00
end)
2022-07-09 21:27:04 +00:00
end,
})
-- File browser
use({
"nvim-telescope/telescope-file-browser.nvim",
requires = { "nvim-telescope/telescope.nvim" },
config = function()
require("telescope").load_extension("file_browser")
2022-07-11 03:31:48 +00:00
vim.keymap.set("n", "<Leader>fa", require("telescope").extensions.file_browser.file_browser)
vim.keymap.set("n", "<Leader>fD", function()
local opts = {
prompt_title = "Find Downloads",
cwd = "~/downloads",
}
require("telescope").extensions.file_browser.file_browser(opts)
end)
2022-07-09 21:27:04 +00:00
end,
})
end
return M