nix-config/config/neovim/lua/opdavies/telescope/setup.lua

102 lines
2.3 KiB
Lua
Raw Normal View History

2022-01-30 20:18:01 +00:00
local status_ok, telescope = pcall(require, "telescope")
if not status_ok then
return
end
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)
2022-08-16 13:37:01 +01:00
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()
2022-01-30 20:18:01 +00:00
end
2022-08-16 13:37:01 +01:00
local action_layout = require "telescope.actions.layout"
local actions = require "telescope.actions"
2023-03-22 22:22:08 +00:00
local lga_actions = require "telescope-live-grep-args.actions"
2022-01-30 20:18:01 +00:00
telescope.setup {
defaults = {
buffer_previewer_maker = new_maker,
2023-03-22 22:22:08 +00:00
file_ignore_patterns = { '.git/' },
layout_config = {
prompt_position = 'top',
},
preview = {
hide_on_startup = true,
},
mappings = {
i = {
["<C-h>"] = actions.which_key,
["<M-p>"] = action_layout.toggle_preview,
["<M-m>"] = action_layout.toggle_mirror,
},
},
2023-03-22 22:22:08 +00:00
no_ignore = true,
2023-03-22 22:22:08 +00:00
path_display = { truncate = 1 },
2022-01-30 20:18:01 +00:00
prompt_prefix = "$ ",
2023-03-22 22:22:08 +00:00
sorting_strategy = 'ascending',
},
pickers = {
find_files = {
hidden = true,
},
buffers = {
previewer = false,
layout_config = {
width = 80,
},
},
lsp_references = {
previewer = false,
},
2022-01-30 20:18:01 +00:00
},
2022-01-30 20:18:01 +00:00
extensions = {
file_browser = {
theme = "ivy",
},
2023-03-22 22:22:08 +00:00
live_grep_args = {
auto_quoting = true,
mappings = {
i = {
["<C-k>"] = lga_actions.quote_prompt {},
["<C-i>"] = lga_actions.quote_prompt { postfix = " --iglob " },
},
},
},
["ui-select"] = {
require("telescope.themes").get_dropdown {},
},
2022-01-30 20:18:01 +00:00
},
}
telescope.load_extension "file_browser"
telescope.load_extension "fzf"
2022-08-06 01:14:11 -04:00
telescope.load_extension "git_worktree"
2022-01-30 20:18:01 +00:00
telescope.load_extension "refactoring"
telescope.load_extension "ui-select"