|
|
@ -1,21 +1,32 @@ |
|
|
|
local pickers = require('telescope.pickers') |
|
|
|
local finders = require('telescope.finders') |
|
|
|
local previewers = require('telescope.previewers') |
|
|
|
local action_state = require('telescope.actions.state') |
|
|
|
local conf = require('telescope.config').values |
|
|
|
local previewers_utils = require('telescope.previewers.utils') |
|
|
|
local builtin = require('telescope.builtin') |
|
|
|
local sorters = require('telescope.sorters') |
|
|
|
local actions = require('telescope.actions') |
|
|
|
|
|
|
|
local max_size = 100000 |
|
|
|
local truncate_large_files = function(filepath, bufnr, opts) |
|
|
|
opts = opts or {} |
|
|
|
|
|
|
|
filepath = vim.fn.expand(filepath) |
|
|
|
vim.loop.fs_stat(filepath, function(_, stat) |
|
|
|
if not stat then return end |
|
|
|
if stat.size > max_size then |
|
|
|
local cmd = {"head", "-c", max_size, filepath} |
|
|
|
previewers_utils.job_maker(cmd, bufnr, opts) |
|
|
|
else |
|
|
|
previewers.buffer_previewer_maker(filepath, bufnr, opts) |
|
|
|
end |
|
|
|
end) |
|
|
|
end |
|
|
|
|
|
|
|
require('telescope').setup({ |
|
|
|
defaults = { |
|
|
|
file_sorter = sorters.get_fzy_sorter, |
|
|
|
prompt_prefix = ' >', |
|
|
|
color_devicons = true, |
|
|
|
|
|
|
|
file_previewer = previewers.vim_buffer_cat.new, |
|
|
|
grep_previewer = previewers.vim_buffer_vimgrep.new, |
|
|
|
qflist_previewer = previewers.vim_buffer_qflist.new, |
|
|
|
buffer_previewer_maker = truncate_large_files, |
|
|
|
|
|
|
|
initial_mode = "insert", |
|
|
|
selection_strategy = "reset", |
|
|
|