226 lines
6 KiB
Nix
226 lines
6 KiB
Nix
{ 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 <Esc> to do so via:
|
|
settings = {
|
|
defaults = {
|
|
sorting_strategy = "ascending";
|
|
mappings = {
|
|
i = {
|
|
"<esc>" = mkRaw ''
|
|
function(...)
|
|
return require("telescope.actions").close(...)
|
|
end'';
|
|
};
|
|
};
|
|
};
|
|
};
|
|
keymaps = {
|
|
"<leader><space>" = {
|
|
action = "find_files";
|
|
options.desc = "[F]ind [F]iles";
|
|
};
|
|
"<leader>fg" = {
|
|
action = "live_grep";
|
|
options.desc = "[F]ind files by [G]rep";
|
|
};
|
|
"<leader>cm" = {
|
|
action = "command_history";
|
|
options.desc = "[C]ommand [H]istory";
|
|
};
|
|
"<leader>s." = {
|
|
action = "oldfiles";
|
|
options.desc = "[S]earch Recent Files (\".\" for repeat)";
|
|
};
|
|
"<leader>fb" = {
|
|
action = "buffers";
|
|
options.desc = "[F]ind [B]uffers";
|
|
};
|
|
"<leader>gf" = {
|
|
action = "git_files";
|
|
options.desc = "Search [G]it [F]iles";
|
|
};
|
|
"<leader>gc" = {
|
|
action = "git_commits";
|
|
options.desc = "[G]it [C]ommits";
|
|
};
|
|
"<leader>gs" = {
|
|
action = "git_status";
|
|
options.desc = "[G]it [S]tatus";
|
|
};
|
|
"<leader>sa" = {
|
|
action = "autocommands";
|
|
options.desc = "[S]earch [A]uto Commands";
|
|
};
|
|
"<leader>sb" = {
|
|
action = "current_buffer_fuzzy_find";
|
|
options.desc = "[S]earch current [B]uffer (fuzzy find)";
|
|
};
|
|
"<leader>sB" = {
|
|
action = "bulitin";
|
|
options.desc = "[S]earch [B]uiltins";
|
|
};
|
|
"<leader>sc" = {
|
|
action = "command_history";
|
|
options.desc = "[C]ommand [H]istory";
|
|
};
|
|
"<leader>sC" = {
|
|
action = "commands";
|
|
options.desc = "[S]earch [C]ommands";
|
|
};
|
|
"<leader>sD" = {
|
|
action = "diagnostics";
|
|
options.desc = "[S]earch [D]iagnostics";
|
|
};
|
|
"<leader>sh" = {
|
|
action = "help_tags";
|
|
options.desc = "[S]earch [H]elp pages";
|
|
};
|
|
"<leader>sH" = {
|
|
action = "highlights";
|
|
options.desc = "[S]earch [H]ighlight Groups";
|
|
};
|
|
"<leader>sk" = {
|
|
action = "keymaps";
|
|
options.desc = "[S]earch [K]eymaps";
|
|
};
|
|
"<leader>sM" = {
|
|
action = "man_pages";
|
|
options.desc = "[S]eanch [M]an pages";
|
|
};
|
|
"<leader>sm" = {
|
|
action = "marks";
|
|
options.desc = "[S]eanch (jump) to [M]ark";
|
|
};
|
|
"<leader>so" = {
|
|
action = "vim_options";
|
|
options.desc = "[S]earch vim [O]ptions";
|
|
};
|
|
"<leader>sR" = {
|
|
action = "resume";
|
|
options.desc = "[S]earch [R]esume";
|
|
};
|
|
"<leader>C" = {
|
|
action = "colorscheme";
|
|
options.desc = "[C]olorscheme preview";
|
|
};
|
|
};
|
|
};
|
|
keymaps = [
|
|
{
|
|
mode = [ "n" ];
|
|
key = "<leader>ffn";
|
|
action = mkRaw ''
|
|
function () require("telescope.builtin").find_files
|
|
{ cwd = "~/forgejo/nixos-configs/" }
|
|
end
|
|
'';
|
|
options.desc = "Find files in nixos-configs";
|
|
}
|
|
{
|
|
mode = [ "n" ];
|
|
key = "<leader>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 = "<leader><space>";
|
|
# action = mkRaw ''function () require("telescope.builtin").find_files({ additional_args = { "-j1" }}) end'';
|
|
# options.desc = "Find project files";
|
|
# }
|
|
# {
|
|
# mode = [ "n" ];
|
|
# key = "<leader>fg";
|
|
# action = mkRaw ''function () require("telescope.builtin").live_grep({ additional_args = { "-j1" }}) end'';
|
|
# options.desc = "Grep (root dir)";
|
|
# }
|
|
# {
|
|
# mode = [ "n" ];
|
|
# key = "<leader>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
|
|
}
|
|
}
|
|
}
|
|
'';
|
|
}
|