if vim.g.did_load_telescope_plugin then return end vim.g.did_load_telescope_plugin = true local telescope = require('telescope') local actions = require('telescope.actions') local builtin = require('telescope.builtin') local layout_config = { vertical = { width = function(_, max_columns) return math.floor(max_columns * 0.99) end, height = function(_, _, max_lines) return math.floor(max_lines * 0.99) end, prompt_position = 'bottom', preview_cutoff = 0, }, } vim.keymap.set('n', 'tp', function() builtin.find_files() end, { desc = '[t]elescope find files - ctrl[p] style' }) vim.keymap.set('n', 'sh', builtin.help_tags, { desc = '[S]earch [H]elp' }) vim.keymap.set('n', 'sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' }) vim.keymap.set('n', 'sf', builtin.find_files, { desc = '[S]earch [F]iles' }) vim.keymap.set('n', 'ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' }) vim.keymap.set('n', 'sw', builtin.grep_string, { desc = '[S]earch current [W]ord' }) vim.keymap.set('n', 'sg', builtin.live_grep, { desc = '[S]earch by [G]rep' }) vim.keymap.set('n', 'sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' }) vim.keymap.set('n', 'sr', builtin.resume, { desc = '[S]earch [R]esume' }) vim.keymap.set('n', 's.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) vim.keymap.set('n', '', builtin.buffers, { desc = '[ ] Find existing buffers' }) telescope.setup { defaults = { path_display = { 'truncate', }, layout_strategy = 'vertical', layout_config = layout_config, mappings = { i = { [''] = actions.send_to_qflist, [''] = actions.send_to_loclist, -- [''] = actions.close, [''] = actions.cycle_previewers_next, [''] = actions.cycle_previewers_prev, }, n = { q = actions.close, }, }, preview = { treesitter = true, }, history = { path = vim.fn.stdpath('data') .. '/telescope_history.sqlite3', limit = 1000, }, color_devicons = true, set_env = { ['COLORTERM'] = 'truecolor' }, prompt_prefix = '  ', selection_caret = ' ', entry_prefix = ' ', initial_mode = 'insert', vimgrep_arguments = { 'rg', '-L', '--color=never', '--no-heading', '--with-filename', '--line-number', '--column', '--smart-case', }, }, extensions = { fzy_native = { override_generic_sorter = false, override_file_sorter = true, }, }, } telescope.load_extension('fzy_native') -- telescope.load_extension('smart_history')