2024-05-27 00:58:58 +02:00
|
|
|
# homepage: https://github.com/nvim-telescope/telescope.nvim
|
|
|
|
|
# nixvim doc: https://nix-community.github.io/nixvim/plugins/telescope/index.html
|
2024-06-05 14:45:18 +02:00
|
|
|
{ helpers, pkgs, ... }:
|
2024-05-27 00:58:58 +02:00
|
|
|
|
|
|
|
|
{
|
|
|
|
|
opts = {
|
|
|
|
|
enable = true;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
rootOpts = {
|
2024-05-27 09:40:12 +02:00
|
|
|
# Needed for live grep
|
|
|
|
|
extraPackages = [ pkgs.ripgrep ];
|
|
|
|
|
|
2024-05-27 00:58:58 +02:00
|
|
|
# Enable catppuccin colors
|
|
|
|
|
# https://github.com/catppuccin/nvim/blob/main/lua/catppuccin/groups/integrations/telescope.lua
|
|
|
|
|
colorschemes.catppuccin.settings.integrations.telescope.enabled = true;
|
|
|
|
|
|
|
|
|
|
# Set custom behavior for dropdown theme:
|
|
|
|
|
# - use 80% of window width
|
|
|
|
|
# - use all window height
|
|
|
|
|
# - display preview at bottom
|
|
|
|
|
# ┌──────────────────────────────────────────────────┐
|
|
|
|
|
# │ ┌────────────────────────────────────────┐ │
|
|
|
|
|
# │ │ Prompt │ │
|
|
|
|
|
# │ ├────────────────────────────────────────┤ │
|
|
|
|
|
# │ │ Result │ │
|
|
|
|
|
# │ │ Result │ │
|
|
|
|
|
# │ └────────────────────────────────────────┘ │
|
|
|
|
|
# │ ┌────────────────────────────────────────┐ │
|
|
|
|
|
# │ │ Preview │ │
|
|
|
|
|
# │ │ Preview │ │
|
|
|
|
|
# │ │ Preview │ │
|
|
|
|
|
# │ │ Preview │ │
|
|
|
|
|
# │ │ Preview │ │
|
|
|
|
|
# │ │ Preview │ │
|
|
|
|
|
# │ └────────────────────────────────────────┘ │
|
|
|
|
|
# └──────────────────────────────────────────────────┘
|
|
|
|
|
extraConfigLuaPre = ''
|
2024-06-10 00:13:25 +02:00
|
|
|
local TelescopeWithTheme = function(fn, args, extension)
|
2024-05-27 00:58:58 +02:00
|
|
|
args.layout_config = {
|
|
|
|
|
anchor = "N",
|
|
|
|
|
mirror = true,
|
|
|
|
|
width = 0.8,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if fn == "keymaps" or fn == "registers" then args.layout_config.height = function(_, _, max_lines) return max_lines end end
|
|
|
|
|
|
2024-06-10 00:13:25 +02:00
|
|
|
local args_with_theme = require("telescope.themes").get_dropdown(args)
|
|
|
|
|
|
|
|
|
|
if extension ~= "" then
|
|
|
|
|
require("telescope").extensions[extension][fn](args_with_theme)
|
|
|
|
|
else
|
|
|
|
|
require("telescope.builtin")[fn](args_with_theme)
|
|
|
|
|
end
|
2024-05-27 00:58:58 +02:00
|
|
|
end
|
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
# Use root keymaps to allow usage of custom TelescopeWithTheme function
|
|
|
|
|
keymaps =
|
|
|
|
|
let
|
|
|
|
|
mkTelescopeKeymap =
|
|
|
|
|
{ key
|
|
|
|
|
, fn
|
|
|
|
|
, args ? { __empty = true; }
|
|
|
|
|
, desc ? ""
|
2024-06-10 00:13:25 +02:00
|
|
|
, extension ? null
|
|
|
|
|
, mode ? "n"
|
2024-05-27 00:58:58 +02:00
|
|
|
}: {
|
|
|
|
|
inherit key mode;
|
|
|
|
|
|
2024-06-10 00:13:25 +02:00
|
|
|
action.__raw = "function() TelescopeWithTheme('${fn}', ${helpers.toLuaObject args}, '${builtins.toString extension}') end";
|
2024-05-27 00:58:58 +02:00
|
|
|
options = { inherit desc; };
|
|
|
|
|
};
|
|
|
|
|
in
|
|
|
|
|
map mkTelescopeKeymap [
|
|
|
|
|
{
|
|
|
|
|
desc = "Resume previous search";
|
|
|
|
|
key = "<leader>f<cr>";
|
|
|
|
|
fn = "resume";
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
desc = "Find words in current buffer";
|
|
|
|
|
key = "<leader>f/";
|
|
|
|
|
fn = "current_buffer_fuzzy_find";
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
desc = "Find buffers";
|
|
|
|
|
key = "<leader>fb";
|
|
|
|
|
fn = "buffers";
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
desc = "Find files";
|
|
|
|
|
key = "<leader>ff";
|
|
|
|
|
fn = "find_files";
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
desc = "Find all files";
|
|
|
|
|
key = "<leader>fF";
|
|
|
|
|
fn = "find_files";
|
|
|
|
|
args = {
|
|
|
|
|
hidden = true;
|
|
|
|
|
no_ignore = true;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
desc = "Find words";
|
|
|
|
|
key = "<leader>fg";
|
|
|
|
|
fn = "live_grep";
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
desc = "Find help tags";
|
|
|
|
|
key = "<leader>fh";
|
|
|
|
|
fn = "help_tags";
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
desc = "Find keymaps";
|
|
|
|
|
key = "<leader>fk";
|
|
|
|
|
fn = "keymaps";
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
desc = "Find history";
|
|
|
|
|
key = "<leader>fo";
|
|
|
|
|
fn = "oldfiles";
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
desc = "Find registers";
|
|
|
|
|
key = "<leader>fr";
|
|
|
|
|
fn = "registers";
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
desc = "Find word under cursor";
|
|
|
|
|
key = "<leader>fw";
|
|
|
|
|
fn = "grep_string";
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
desc = "Search references";
|
|
|
|
|
key = "gr";
|
|
|
|
|
fn = "lsp_references";
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
};
|
|
|
|
|
}
|