Add a neovim plugin: telescope.nvim

The telescope.nvim plugin gives us Doom Emacs-like fuzzy finder for standard editor operations, like opening files or switching buffers.

Continuing from the Nix of previous post, you only need to make two changes to the Nix to add this plugin:

  • Add the plugin to plugins list
    • To find the exact Nix plugin name, look for β€˜telescope’ in generated.nix
    • I found telescope-nvim, but I’m also going to add telescope-zoxide since I also use zoxide directory switcher.
  • Add the vim config to extraConfig.
{
    plugins = with pkgs.vimPlugins; [
      ...
      telescope-nvim
      telescope-zoxide
    ];
    extraConfig = ''
      ..
      nnoremap <leader>ff <cmd>Telescope find_files<cr>
      nnoremap <leader>fg <cmd>Telescope live_grep<cr>
      nnoremap <leader>fb <cmd>Telescope buffers<cr>
      nnoremap <leader>fh <cmd>Telescope help_tags<cr>
    '';
}

Open nvim, and hit <leader>ff. The leader key is by default \, so hit \ ff. This will bring up a fuzzy finder for opening files in current directory.

Nits

I wish the plugin installation and configuration was modularized in home-manager, so that you can configure the individual plugins using Nix instead of writing vim.

Links to this page
#neovim