{ 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 = "tf"; action = ":Telescope find_files"; options = { desc = "Find Files"; silent = true; }; } { mode = "n"; key = "te"; action = ":Telescope file_browser"; 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 repo list"; 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; }; } ]; }; }