feat(nvim): telescope configuration
This commit is contained in:
parent
0786ed3b3d
commit
0dfeb542fe
|
@ -1,3 +1,35 @@
|
||||||
|
local previewers = require('telescope.previewers')
|
||||||
|
local Job = require('plenary.job')
|
||||||
|
|
||||||
|
-- Create a new maker that won't preview binary files
|
||||||
|
-- https://github.com/nvim-telescope/telescope.nvim/wiki/Configuration-Recipes#dont-preview-binaries
|
||||||
|
local new_maker = function(filepath, bufnr, opts)
|
||||||
|
filepath = vim.fn.expand(filepath)
|
||||||
|
Job:new({
|
||||||
|
command = 'file',
|
||||||
|
args = { '--mime-type', '-b', filepath },
|
||||||
|
on_exit = function(j)
|
||||||
|
local mime_type = vim.split(j:result()[1], '/')[1]
|
||||||
|
if mime_type == "text" then
|
||||||
|
previewers.buffer_previewer_maker(filepath, bufnr, opts)
|
||||||
|
else
|
||||||
|
vim.schedule(function()
|
||||||
|
vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, { 'BINARY' })
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
}):sync()
|
||||||
|
end
|
||||||
|
|
||||||
|
require "telescope".setup{
|
||||||
|
defaults = {
|
||||||
|
buffer_previewer_maker = new_maker,
|
||||||
|
prompt_prefix = "$ "
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
require "telescope".load_extension("fzf")
|
||||||
|
|
||||||
local map = vim.api.nvim_set_keymap
|
local map = vim.api.nvim_set_keymap
|
||||||
|
|
||||||
local options = {
|
local options = {
|
||||||
|
|
Loading…
Reference in a new issue