local actions = require("telescope.actions") local finders = require("telescope.builtin") local action_mt = require "telescope.actions.mt" local action_state = require "telescope.actions.state" -- global for later inspection custom_actions = action_mt.transform_mod({ print_entry = function() print(vim.inspect(action_state.get_selected_entry())) end, }) require("telescope").setup({ defaults = { prompt_prefix = " ", initial_mode = "insert", sorting_strategy = "ascending", layout_config = { prompt_position = "top", }, mappings = { i = { [""] = custom_actions['print_entry'], [""] = actions.close, [""] = actions.move_selection_next, [""] = actions.move_selection_previous, [""] = actions.toggle_selection + actions.move_selection_next, [""] = actions.send_selected_to_qflist, [""] = actions.send_to_qflist, }, }, }, extensions = { fzf = { fuzzy = true, override_generic_sorter = true, override_file_sorter = true, case_mode = "smart_case", }, }, }) local Telescope = setmetatable({}, { __index = function(_, k) if vim.bo.filetype == "NvimTree" then vim.cmd.wincmd("l") end return finders[k] end, }) vim.keymap.set("n", "", function() local ok = pcall(Telescope.git_files, { show_untracked = true }) if not ok then Telescope.find_files() end end) -- Get :help at the speed of light vim.keymap.set("n", "H", Telescope.help_tags) -- Search for string vim.keymap.set("n", "s", Telescope.live_grep) -- Fuzzy find changed files in git vim.keymap.set("n", "c", Telescope.git_status)