{ helpers, ... }: let inherit (helpers) mkRaw; in { plugins.telescope = { enable = true; extensions = { fzf-native = { enable = true; }; ui-select = { settings = { specific_opts = { codeactions = true; }; }; }; undo = { enable = true; }; }; # If you'd prefer Telescope not to enter a normal-like mode when hitting escape (and instead exiting), you can map to do so via: settings = { defaults = { sorting_strategy = "ascending"; mappings = { i = { "" = mkRaw '' function(...) return require("telescope.actions").close(...) end''; }; }; }; }; keymaps = { "" = { action = "find_files"; options.desc = "[F]ind [F]iles"; }; "fg" = { action = "live_grep"; options.desc = "[F]ind files by [G]rep"; }; "cm" = { action = "command_history"; options.desc = "[C]ommand [H]istory"; }; "s." = { action = "oldfiles"; options.desc = "[S]earch Recent Files (\".\" for repeat)"; }; "fb" = { action = "buffers"; options.desc = "[F]ind [B]uffers"; }; "gf" = { action = "git_files"; options.desc = "Search [G]it [F]iles"; }; "gc" = { action = "git_commits"; options.desc = "[G]it [C]ommits"; }; "gs" = { action = "git_status"; options.desc = "[G]it [S]tatus"; }; "sa" = { action = "autocommands"; options.desc = "[S]earch [A]uto Commands"; }; "sb" = { action = "current_buffer_fuzzy_find"; options.desc = "[S]earch current [B]uffer (fuzzy find)"; }; "sB" = { action = "bulitin"; options.desc = "[S]earch [B]uiltins"; }; "sc" = { action = "command_history"; options.desc = "[C]ommand [H]istory"; }; "sC" = { action = "commands"; options.desc = "[S]earch [C]ommands"; }; "sD" = { action = "diagnostics"; options.desc = "[S]earch [D]iagnostics"; }; "sh" = { action = "help_tags"; options.desc = "[S]earch [H]elp pages"; }; "sH" = { action = "highlights"; options.desc = "[S]earch [H]ighlight Groups"; }; "sk" = { action = "keymaps"; options.desc = "[S]earch [K]eymaps"; }; "sM" = { action = "man_pages"; options.desc = "[S]eanch [M]an pages"; }; "sm" = { action = "marks"; options.desc = "[S]eanch (jump) to [M]ark"; }; "so" = { action = "vim_options"; options.desc = "[S]earch vim [O]ptions"; }; "sR" = { action = "resume"; options.desc = "[S]earch [R]esume"; }; "C" = { action = "colorscheme"; options.desc = "[C]olorscheme preview"; }; }; }; keymaps = [ { mode = [ "n" ]; key = "ffn"; action = mkRaw '' function () require("telescope.builtin").find_files { cwd = "~/forgejo/nixos-configs/" } end ''; options.desc = "Find files in nixos-configs"; } { mode = [ "n" ]; key = "ffm"; action = mkRaw '' function () require("telescope.builtin").find_files { cwd = "~/forgejo/my_nixvim/" } end ''; options.desc = "Find files in my_nixvim"; } ]; # use -j1 for ripgrep # https://github.com/nvim-telescope/telescope.nvim/issues/647#issuecomment-1536456802 # keymaps = [ # { # mode = [ "n" ]; # key = ""; # action = mkRaw ''function () require("telescope.builtin").find_files({ additional_args = { "-j1" }}) end''; # options.desc = "Find project files"; # } # { # mode = [ "n" ]; # key = "fg"; # action = mkRaw ''function () require("telescope.builtin").live_grep({ additional_args = { "-j1" }}) end''; # options.desc = "Grep (root dir)"; # } # { # mode = [ "n" ]; # key = "ff"; # action = mkRaw ''function () require("telescope.builtin").find_files({ additional_args = { "-j1" }}) end''; # options.desc = "Find project files"; # } # ]; extraConfigLua = '' local telescope = require('telescope') telescope.setup{ pickers = { colorscheme = { enable_preview = true }, -- To prevent crash on slow machines -- Replace (ripgrep --files) with gnu find for "find_files" find_files = { -- enable hidden file/folder search, but exclude hidden folder in find_command hidden = true, find_command = { "find", ".", "(", "-path", "*/.*", "-type", "d", ")", "-prune", "-o", "-type", "f", "-printf", "%P\n" }, }, }, -- To prevent crash on slow machines -- Replace ripgrep with gnu grep for "live_grep" and "grep_string" -- https://github.com/nvim-telescope/telescope.nvim/issues/2083#issuecomment-1215476157 defaults = { vimgrep_arguments = { "grep", "--extended-regexp", "--color=never", "--with-filename", "--line-number", "-b", -- grep doesn't support a `--column` option :( "--ignore-case", "--recursive", "--no-messages", "--exclude-dir=*cache*", "--exclude-dir=*.git", "--exclude=.*", "--binary-files=without-match", -- skip binary files } } } ''; }