nvim_config/lua/mpx/plugins/telescope.lua

84 lines
2.1 KiB
Lua

return {
"nvim-telescope/telescope.nvim",
tag = '0.1.8',
version = false,
dependencies = {
"nvim-lua/plenary.nvim",
{ "nvim-telescope/telescope-fzf-native.nvim", build = "make" },
"nvim-tree/nvim-web-devicons",
"BurntSushi/ripgrep",
"folke/todo-comments.nvim",
},
config = function()
local telescope = require("telescope")
local actions = require("telescope.actions")
telescope.setup({
defaults = {
mappings = {
i = {
["<C-k>"] = actions.move_selection_previous, -- move to prev result
["<C-j>"] = actions.move_selection_next, -- move to next result
["<C-q>"] = actions.send_selected_to_qflist + actions.open_qflist,
},
},
file_ignore_patterns = { "node_modules", "dist", ".git", ".next" },
path_display = { "filename_first" },
sorting_strategy = "ascending",
layout_strategy = "flex",
layout_config = {
horizontal = {
prompt_position = "top",
width = 0.9,
height = 0.9,
preview_width = 0.5,
},
vertical = {
width = 0.9,
height = 0.9,
},
},
},
pickers = {
find_files = {
hidden = true,
no_ignore = true,
},
},
extensions = {
themes = {
layout_strategy = "vertical",
layout_config = {
vertical = {
height = 0.4,
width = 0.4,
prompt_position = "top",
},
horizontal = {
width = 0.8,
height = 0.7,
},
},
light_themes = {
ignore = true,
keywords = { "light", "day", "frappe", "latte", "dawn" },
},
enable_previewer = false,
enable_live_preview = true,
},
},
})
telescope.load_extension("fzf")
-- set keymaps
local keymap = vim.keymap -- for conciseness
keymap.set("n", "<leader>ff", "<cmd>Telescope find_files<cr>", { desc = "Fuzzy find files in cwd" })
keymap.set("n", "<leader>fr", "<cmd>Telescope oldfiles<cr>", { desc = "Fuzzy find recent files" })
keymap.set("n", "<leader>fs", "<cmd>Telescope live_grep<cr>", { desc = "Find string in cwd" })
keymap.set("n", "<leader>fc", "<cmd>Telescope grep_string<cr>", { desc = "Find string under cursor in cwd" })
keymap.set("n", "<leader>ft", "<cmd>TodoTelescope<cr>", { desc = "Find todos" })
end,
}