flake/nixos/nvim/plugins/telescope.nix
2025-02-04 08:28:09 -06:00

233 lines
5.2 KiB
Nix

{ pkgs, ... }:
{
programs.nixvim = {
extraPackages = with pkgs; [
ripgrep
fd
plocate
glow
];
plugins = {
aerial.enable = true;
neoclip.enable = true;
telescope = {
enable = true;
extensions = {
fzf-native.enable = true;
file-browser = {
enable = true;
settings = {
hijack_netrw = false;
};
};
};
enabledExtensions = [
"repo"
];
settings = {
defaults = {
layout_config = {
prompt_position = "bottom";
};
};
};
};
};
extraPlugins = [
(pkgs.vimUtils.buildVimPlugin {
# https://github.com/cljoly/telescope-repo.nvim
name = "telescope-repo.nvim";
src = pkgs.fetchFromGitHub {
owner = "cljoly";
repo = "telescope-repo.nvim";
rev = "a5395a4bf0fd742cc46b4e8c50e657062f548ba9";
sha256 = "sha256-cIovB45hfG4lDK0VBIgK94dk2EvGXZtfAJETkQ+lrcw=";
};
})
];
# https://github.com/nvim-telescope/telescope.nvim/issues/2806#issuecomment-1904877188
autoGroups.find_files_hijack_netrw.clear = true;
autoCmd = [
{
event = "VimEnter";
pattern = "*";
once = true;
callback.__raw = # lua
''
function()
pcall(vim.api.nvim_clear_autocmds, { group = "FileExplorer" })
end
'';
}
{
event = "BufEnter";
group = "find_files_hijack_netrw";
pattern = "*";
callback.__raw = # lua
''
function()
vim.schedule(function()
-- Early return if netrw or not a directory
if vim.bo[0].filetype == "netrw" or vim.fn.isdirectory(vim.fn.expand("%:p")) == 0 then
return
end
vim.api.nvim_buf_set_option(0, "bufhidden", "wipe")
require("telescope.builtin").find_files({
cwd = vim.fn.expand("%:p:h"),
})
end)
end
'';
}
];
keymaps = [
{
mode = "n";
key = "<leader>t";
action = ":Telescope<CR>";
options = {
desc = "Telescope";
silent = true;
};
}
{
mode = "n";
key = "<leader>tf";
action = ":Telescope find_files<CR>";
options = {
desc = "Find Files";
silent = true;
};
}
{
mode = "n";
key = "<leader>te";
action = ":Telescope file_browser<CR>";
options = {
desc = "File Explorer";
silent = true;
};
}
{
mode = "n";
key = "<leader>tg";
action = ":Telescope live_grep<CR>";
options = {
desc = "Live Grep";
silent = true;
};
}
{
mode = "n";
key = "<leader>ta";
action = ":Telescope aerial<CR>";
options = {
desc = "Aerial";
silent = true;
};
}
{
mode = "n";
key = "<leader>tb";
action = ":Telescope buffers<CR>";
options = {
desc = "Buffers";
silent = true;
};
}
{
mode = "n";
key = "<leader>fc";
action = ":Telescope colorscheme<CR>";
options = {
desc = "Color Schemes";
silent = true;
};
}
{
mode = "n";
key = "<leader>tk";
action = ":Telescope keymaps<CR>";
options = {
desc = "Keymaps";
silent = true;
};
}
{
mode = "n";
key = "<leader>tp";
action = ":Telescope repo list<CR>";
options = {
desc = "Projects";
silent = true;
};
}
{
mode = "n";
key = "<leader>tc";
action = ":Telescope commands<CR>";
options = {
desc = "Commands";
silent = true;
};
}
{
mode = "n";
key = "<leader>tm";
action = ":Telescope man_pages<CR>";
options = {
desc = "Man Pages";
silent = true;
};
}
{
mode = "n";
key = "<leader>tn";
action = ":Telescope vim_options<CR>";
options = {
desc = "Vim Options";
silent = true;
};
}
# Git
{
mode = "n";
key = "<leader>tgc";
action = ":Telescope git_commits<CR>";
options = {
desc = "Git Commits";
silent = true;
};
}
{
mode = "n";
key = "<leader>tgb";
action = ":Telescope git_branches<CR>";
options = {
desc = "Git Branches";
silent = true;
};
}
{
mode = "n";
key = "<leader>tgs";
action = ":Telescope git_status<CR>";
options = {
desc = "Git Status";
silent = true;
};
}
{
mode = "n";
key = "<leader>tgS";
action = ":Telescope git_stash<CR>";
options = {
desc = "Git Stash";
silent = true;
};
}
];
};
}