telescope.lua (2720B)
1 return { 2 "nvim-telescope/telescope.nvim", 3 event = "VeryLazy", 4 dependencies = { 5 "nvim-lua/plenary.nvim", 6 "debugloop/telescope-undo.nvim", 7 "nvim-telescope/telescope-file-browser.nvim", 8 "nvim-telescope/telescope-live-grep-args.nvim", 9 }, 10 config = function() 11 local telescope = require("telescope") 12 local tele_actions = require("telescope.actions") 13 local lga_actions = require("telescope-live-grep-args.actions") 14 local lga_shortcuts = require("telescope-live-grep-args.shortcuts") 15 local undo_actions = require("telescope-undo.actions") 16 local r = require("utils.remaps") 17 local i = require("utils.icons") 18 telescope.setup({ 19 defaults = { 20 layout_config = { 21 anchor = "center", 22 height = 0.8, 23 width = 0.9, 24 preview_width = 0.6, 25 prompt_position = "bottom", 26 }, 27 borderchars = i.telescope, 28 mappings = { 29 i = { 30 ["<esc>"] = tele_actions.close, 31 }, 32 }, 33 }, 34 extensions = { 35 undo = { 36 use_delta = true, 37 side_by_side = true, 38 entry_format = " #$ID, $STAT, $TIME", 39 layout_strategy = "flex", 40 mappings = { 41 i = { 42 ["<cr>"] = undo_actions.yank_additions, 43 ["§"] = undo_actions.yank_deletions, -- term mapped to shift+enter 44 ["<c-\\>"] = undo_actions.restore, 45 }, 46 }, 47 }, 48 live_grep_args = { 49 auto_quoting = true, 50 mappings = { 51 i = { 52 ["<c-\\>"] = lga_actions.quote_prompt({ postfix = " --hidden " }), 53 }, 54 }, 55 }, 56 file_browser = { 57 depth = 1, 58 auto_depth = false, 59 hidden = { file_browser = true, folder_browser = true }, 60 hide_parent_dir = false, 61 collapse_dirs = false, 62 prompt_path = false, 63 quiet = false, 64 dir_icon = " ", 65 dir_icon_hl = "Default", 66 display_stat = { date = true, size = true, mode = true }, 67 git_status = true, 68 }, 69 }, 70 }) 71 r.noremap("n", "<leader>u", ":Telescope undo<cr>", "undo tree") 72 r.noremap("n", "\\", function() 73 telescope.extensions.live_grep_args.live_grep_args({ 74 prompt_title = 'grep', 75 additional_args = '-i', 76 }) 77 end, "live grep") 78 r.noremap("n", "<leader>o", ":Telescope oldfiles<cr>", "old files") 79 r.noremap("n", "<leader>gc", function() 80 lga_shortcuts.grep_word_under_cursor({ postfix = " --hidden " }) 81 end, "grep under cursor") 82 r.noremap("n", "<leader>f", function() 83 telescope.extensions.file_browser.file_browser() 84 end, "browse files") 85 r.noremap("n", "<leader>.", function() 86 telescope.extensions.file_browser.file_browser({ 87 path = vim.fn.stdpath("config") 88 }) 89 end, "nvim dotfiles") 90 telescope.load_extension("undo") 91 telescope.load_extension("file_browser") 92 telescope.load_extension("live_grep_args") 93 end, 94 }