{ 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; grouped = true; hidden = true; }; }; project = { enable = true; settings = { base_dirs = [ { path = "~/Projects"; max_depth = 3; } { path = "/etc/nixos"; max_depth = 1; } ]; }; }; }; settings = { defaults = { prompt_prefix = "🔍"; layout_config = { prompt_position = "bottom"; }; }; }; }; }; # 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"), find_command = { "rg", "--ignore", "--hidden", "--files", "--glob=!.git/", }, }) end) end ''; } ]; keymaps = [ { mode = "n"; key = "tf"; action = "Telescope find_files find_command=rg,--ignore,--hidden,--files,--glob=!.git/"; options = { desc = "Find Files"; silent = true; }; } { mode = "n"; key = "te"; action = "Telescope file_browser path=%:p:h select_buffer=true"; options = { desc = "File Explorer"; silent = true; }; } { mode = "n"; key = "tr"; action = "Telescope live_grep"; options = { desc = "Live Grep"; silent = true; }; } { mode = "n"; key = "ta"; action = "Telescope aerial"; options = { desc = "Aerial"; silent = true; }; } { mode = "n"; key = "tb"; action = "Telescope buffers"; options = { desc = "Buffers"; silent = true; }; } { mode = "n"; key = "tt"; action = "Telescope colorscheme"; options = { desc = "Color Schemes"; silent = true; }; } { mode = "n"; key = "tk"; action = "Telescope keymaps"; options = { desc = "Keymaps"; silent = true; }; } { mode = "n"; key = "tp"; action = "Telescope project display_type=full hide_workspace=true"; options = { desc = "Projects"; silent = true; }; } { mode = "n"; key = "tc"; action = "Telescope commands"; options = { desc = "Commands"; silent = true; }; } { mode = "n"; key = "tm"; action = "Telescope man_pages"; options = { desc = "Man Pages"; silent = true; }; } { mode = "n"; key = "tn"; action = "Telescope vim_options"; options = { desc = "Vim Options"; silent = true; }; } # Git { mode = "n"; key = "tgc"; action = "Telescope git_commits"; options = { desc = "Git Commits"; silent = true; }; } { mode = "n"; key = "tgb"; action = "Telescope git_branches"; options = { desc = "Git Branches"; silent = true; }; } { mode = "n"; key = "tgs"; action = "Telescope git_status"; options = { desc = "Git Status"; silent = true; }; } { mode = "n"; key = "tgS"; action = "Telescope git_stash"; options = { desc = "Git Stash"; silent = true; }; } ]; }; }