2023-01-10 02:38:06 +01:00
|
|
|
local env = require("my.helpers.env")
|
|
|
|
|
|
|
|
local telescope = {
|
|
|
|
"nvim-telescope/telescope.nvim",
|
|
|
|
cmd = "Telescope",
|
|
|
|
dependencies = {
|
|
|
|
{ "nvim-telescope/telescope-fzf-native.nvim", build = "make" },
|
2023-08-29 14:24:30 +02:00
|
|
|
"nvim-lua/plenary.nvim",
|
2023-01-10 02:38:06 +01:00
|
|
|
},
|
|
|
|
version = "0.1.x",
|
|
|
|
cond = env.vscode.not_active(),
|
|
|
|
}
|
|
|
|
|
|
|
|
local M = telescope
|
|
|
|
|
|
|
|
local function find_files_by_extension(extension)
|
|
|
|
return "find_files find_command=rg,--files,--glob=**/*." .. extension
|
|
|
|
end
|
|
|
|
|
|
|
|
local function with_theme(base, theme)
|
|
|
|
return base .. " theme=" .. theme
|
|
|
|
end
|
|
|
|
|
|
|
|
local defaultTheme = "ivy"
|
|
|
|
|
|
|
|
local keybinds = {
|
|
|
|
{ "<C-P>", "find_files", "Find files" },
|
|
|
|
{ "<Leader>ft", find_files_by_extension("tex"), "[F]ind [t]ex files" },
|
|
|
|
{ "<Leader>fl", find_files_by_extension("lua"), "[F]ind [l]ua files" },
|
2023-07-17 16:50:07 +02:00
|
|
|
{ "<Leader>fn", find_files_by_extension("nix"), "[F]ind [n]ix files" },
|
2023-01-10 02:38:06 +01:00
|
|
|
{
|
|
|
|
"<Leader>fp",
|
|
|
|
find_files_by_extension("purs"),
|
|
|
|
"[F]ind [p]urescript files",
|
|
|
|
},
|
|
|
|
{ "<Leader>d", "diagnostics", "[D]iagnostics" },
|
|
|
|
{ "<C-F>", "live_grep", "[F]ind in project" },
|
|
|
|
{ "<Leader>t", "builtin", "[T]elescope pickers" },
|
|
|
|
}
|
|
|
|
|
|
|
|
local function mkAction(action)
|
|
|
|
if not string.find(action, "theme=") then
|
|
|
|
action = with_theme(action, defaultTheme)
|
|
|
|
end
|
|
|
|
|
|
|
|
if not string.find(action, "winblend=") and env.neovide.active() then
|
|
|
|
action = action .. " winblend=45"
|
|
|
|
end
|
|
|
|
|
|
|
|
return "<cmd>Telescope " .. action .. "<cr>"
|
|
|
|
end
|
|
|
|
|
|
|
|
function telescope.init()
|
|
|
|
for _, mapping in pairs(keybinds) do
|
|
|
|
vim.keymap.set("n", mapping[1], mkAction(mapping[2]), { desc = mapping[3] })
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function telescope.config()
|
|
|
|
local settings = {
|
|
|
|
defaults = { mappings = { i = { ["<C-h>"] = "which_key" } } },
|
|
|
|
pickers = { find_files = { hidden = true } },
|
|
|
|
extensions = {
|
|
|
|
fzf = {
|
|
|
|
fuzzy = true,
|
|
|
|
override_generic_sorter = true,
|
|
|
|
override_file_sorter = true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
require("telescope").setup(settings)
|
|
|
|
require("telescope").load_extension("fzf")
|
|
|
|
end
|
|
|
|
|
|
|
|
return M
|