2023-02-28 07:13:56 +00:00
|
|
|
{
|
|
|
|
pkgs,
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
...
|
2023-11-07 00:50:27 +00:00
|
|
|
}: let
|
2024-03-24 00:14:39 +00:00
|
|
|
inherit (lib.modules) mkIf mkMerge;
|
|
|
|
inherit (lib.nvim.binds) addDescriptionsToMappings mkSetBinding;
|
|
|
|
inherit (lib.nvim.dag) entryAnywhere;
|
|
|
|
# TODO: move this to its own module
|
|
|
|
inherit (lib) pushDownDefault;
|
2023-11-07 00:50:27 +00:00
|
|
|
|
2023-02-28 07:13:56 +00:00
|
|
|
cfg = config.vim.telescope;
|
2023-04-22 13:48:21 +00:00
|
|
|
self = import ./telescope.nix {inherit lib;};
|
|
|
|
mappingDefinitions = self.options.vim.telescope.mappings;
|
|
|
|
|
|
|
|
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions;
|
2023-02-28 07:13:56 +00:00
|
|
|
in {
|
|
|
|
config = mkIf (cfg.enable) {
|
|
|
|
vim.startPlugins = [
|
|
|
|
"telescope"
|
|
|
|
];
|
|
|
|
|
2023-04-22 13:48:21 +00:00
|
|
|
vim.maps.normal = mkMerge [
|
|
|
|
(mkSetBinding mappings.findFiles "<cmd> Telescope find_files<CR>")
|
|
|
|
(mkSetBinding mappings.liveGrep "<cmd> Telescope live_grep<CR>")
|
|
|
|
(mkSetBinding mappings.buffers "<cmd> Telescope buffers<CR>")
|
|
|
|
(mkSetBinding mappings.helpTags "<cmd> Telescope help_tags<CR>")
|
|
|
|
(mkSetBinding mappings.open "<cmd> Telescope<CR>")
|
|
|
|
|
|
|
|
(mkSetBinding mappings.gitCommits "<cmd> Telescope git_commits<CR>")
|
|
|
|
(mkSetBinding mappings.gitBufferCommits "<cmd> Telescope git_bcommits<CR>")
|
|
|
|
(mkSetBinding mappings.gitBranches "<cmd> Telescope git_branches<CR>")
|
|
|
|
(mkSetBinding mappings.gitStatus "<cmd> Telescope git_status<CR>")
|
|
|
|
(mkSetBinding mappings.gitStash "<cmd> Telescope git_stash<CR>")
|
2023-02-28 07:13:56 +00:00
|
|
|
|
2023-04-22 13:48:21 +00:00
|
|
|
(mkIf config.vim.lsp.enable (mkMerge [
|
|
|
|
(mkSetBinding mappings.lspDocumentSymbols "<cmd> Telescope lsp_document_symbols<CR>")
|
|
|
|
(mkSetBinding mappings.lspWorkspaceSymbols "<cmd> Telescope lsp_workspace_symbols<CR>")
|
2023-02-28 07:13:56 +00:00
|
|
|
|
2023-04-22 13:48:21 +00:00
|
|
|
(mkSetBinding mappings.lspReferences "<cmd> Telescope lsp_references<CR>")
|
|
|
|
(mkSetBinding mappings.lspImplementations "<cmd> Telescope lsp_implementations<CR>")
|
|
|
|
(mkSetBinding mappings.lspDefinitions "<cmd> Telescope lsp_definitions<CR>")
|
|
|
|
(mkSetBinding mappings.lspTypeDefinitions "<cmd> Telescope lsp_type_definitions<CR>")
|
|
|
|
(mkSetBinding mappings.diagnostics "<cmd> Telescope diagnostics<CR>")
|
|
|
|
]))
|
|
|
|
|
|
|
|
(
|
|
|
|
mkIf config.vim.treesitter.enable
|
|
|
|
(mkSetBinding mappings.treesitter "<cmd> Telescope treesitter<CR>")
|
2023-02-28 07:13:56 +00:00
|
|
|
)
|
2023-06-05 20:10:25 +00:00
|
|
|
|
|
|
|
(
|
|
|
|
mkIf config.vim.projects.project-nvim.enable
|
|
|
|
(mkSetBinding mappings.findProjects "<cmd Telescope projects<CR>")
|
|
|
|
)
|
2023-04-22 13:48:21 +00:00
|
|
|
];
|
2023-02-28 07:13:56 +00:00
|
|
|
|
2024-02-26 03:52:21 +00:00
|
|
|
vim.binds.whichKey.register = pushDownDefault {
|
2024-02-25 16:39:05 +00:00
|
|
|
"<leader>f" = "+Telescope";
|
|
|
|
"<leader>fl" = "Telescope LSP";
|
|
|
|
"<leader>fm" = "Cellular Automaton";
|
|
|
|
"<leader>fv" = "Telescope Git";
|
|
|
|
"<leader>fvc" = "Commits";
|
|
|
|
};
|
|
|
|
|
2024-03-24 00:14:39 +00:00
|
|
|
vim.luaConfigRC.telescope = entryAnywhere ''
|
2023-02-28 07:13:56 +00:00
|
|
|
local telescope = require('telescope')
|
|
|
|
telescope.setup {
|
|
|
|
defaults = {
|
|
|
|
vimgrep_arguments = {
|
|
|
|
"${pkgs.ripgrep}/bin/rg",
|
|
|
|
"--color=never",
|
|
|
|
"--no-heading",
|
|
|
|
"--with-filename",
|
|
|
|
"--line-number",
|
|
|
|
"--column",
|
2023-03-01 11:09:31 +00:00
|
|
|
"--smart-case",
|
|
|
|
"--hidden",
|
|
|
|
"--no-ignore",
|
2023-02-28 07:13:56 +00:00
|
|
|
},
|
|
|
|
pickers = {
|
|
|
|
find_command = {
|
|
|
|
"${pkgs.fd}/bin/fd",
|
|
|
|
},
|
|
|
|
},
|
2023-03-01 11:09:31 +00:00
|
|
|
},
|
|
|
|
prompt_prefix = " ",
|
|
|
|
selection_caret = " ",
|
|
|
|
entry_prefix = " ",
|
|
|
|
initial_mode = "insert",
|
|
|
|
selection_strategy = "reset",
|
|
|
|
sorting_strategy = "ascending",
|
|
|
|
layout_strategy = "horizontal",
|
|
|
|
layout_config = {
|
|
|
|
horizontal = {
|
|
|
|
prompt_position = "top",
|
|
|
|
preview_width = 0.55,
|
|
|
|
results_width = 0.8,
|
|
|
|
},
|
|
|
|
vertical = {
|
|
|
|
mirror = false,
|
|
|
|
},
|
|
|
|
width = 0.8,
|
|
|
|
height = 0.8,
|
|
|
|
preview_cutoff = 120,
|
|
|
|
},
|
|
|
|
file_ignore_patterns = { "node_modules", ".git/", "dist/", "build/", "target/", "result/" }, -- TODO: make this configurable
|
|
|
|
color_devicons = true,
|
|
|
|
path_display = { "absolute" },
|
|
|
|
set_env = { ["COLORTERM"] = "truecolor" },
|
|
|
|
winblend = 0,
|
|
|
|
border = {},
|
2023-02-28 07:13:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
${
|
|
|
|
if config.vim.ui.noice.enable
|
|
|
|
then "telescope.load_extension('noice')"
|
2023-03-31 20:37:24 +00:00
|
|
|
else ""
|
2023-02-28 07:13:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
${
|
|
|
|
if config.vim.notify.nvim-notify.enable
|
|
|
|
then "telescope.load_extension('notify')"
|
2023-03-31 20:37:24 +00:00
|
|
|
else ""
|
2023-02-28 07:13:56 +00:00
|
|
|
}
|
2023-04-07 17:36:03 +00:00
|
|
|
|
|
|
|
${
|
|
|
|
if config.vim.projects.project-nvim.enable
|
|
|
|
then "telescope.load_extension('projects')"
|
|
|
|
else ""
|
|
|
|
}
|
2023-02-28 07:13:56 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
}
|