what is it?

a neovim setup powered by 💤 lazy.nvim to make it easy to customize and extend your config

how-to

following this guide create a module

editors/lazyvim.nix
{ config, lib, pkgs, ... }:
 
{
  programs.neovim = {
    enable = true;
    extraPackages = with pkgs; [
      # language servers
      lua-language-server
      nil
      stylua
 
      # formatters
      alejandra
      # black
    ];
 
    plugins = with pkgs.vimPlugins; [
      lazy-nvim
    ];
 
    extraLuaConfig =
      let
        plugins = with pkgs.vimPlugins; [
          # all the plugins.. can be added here, or alternatively lazy
          # will grab them from the github repos
          LazyVim
          bufferline-nvim
          cmp-buffer
          cmp-nvim-lsp
          { name = "mini.pairs"; path = mini-nvim; }
          { name = "mini.surround"; path = mini-nvim; }
        ];
        
        # how to handle plugins with dots such as 'mini.pairs', etc
        mkEntryFromDrv = drv:
          if lib.isDerivation drv then
            { name = "${lib.getName drv}"; path = drv; }
          else
            drv;
        
        # creates a set of symlinks to the plugins defined above
        lazyPath = pkgs.linkFarm "lazy-plugins" (builtins.map mkEntryFromDrv plugins);
      in
      ''
        require("lazy").setup({
          defaults = {
            lazy = false,
          },
          
          dev = {
            -- reuse files from pkgs.vimPlugins.*
            path = "${lazyPath}",
            patterns = { "." },
            -- fallback to download
            fallback = true,
          },
 
          spec = {
            { "LazyVim/LazyVim", import = "lazyvim.plugins" },
            -- The following configs are needed for fixing lazyvim on nix
            -- force enable telescope-fzf-native.nvim
            { "nvim-telescope/telescope-fzf-native.nvim", enabled = true },
            -- disable mason.nvim, use programs.neovim.extraPackages
            { "williamboman/mason-lspconfig.nvim", enabled = false },
            { "williamboman/mason.nvim", enabled = false },
            -- import/override with your plugins
            { import = "plugins" },
            -- treesitter handled by xdg.configFile."nvim/parser", put this line at the end of spec to clear ensure_installed
            { "nvim-treesitter/nvim-treesitter",
               opts = function(_, opts)
                opts.ensure_installed = {}
              end,
            },
          },
      '';
  };
  
  # https://github.com/nvim-treesitter/nvim-treesitter#i-get-query-error-invalid-node-type-at-position
  xdg.configFile."nvim/parser".source =
    let
      parsers = pkgs.symlinkJoin {
        name = "treesitter-parsers";
        paths = (pkgs.vimPlugins.nvim-treesitter.withPlugins (plugins: with plugins; [
          c
          lua
        ])).dependencies;
      };
    in
    "${parsers}/parser";
 
  # Normal LazyVim config here, copy https://github.com/LazyVim/starter/tree/main/lua
  # and then remove config/lazy.lua
  xdg.configFile."nvim/lua".source = ./lua;
}

clone the lazyvim starter. copy the lua directory to the same directory as the above lazyvim.nix module and remove the lazy.lua file in config

git clone https://github.com/LazyVim/starter
 
cp -a starter/lua .
 
sudo rm -r starter
rm lua/config/lazy.lua

import lazyvim.nix in home.nix

home.nix
{ ... }:
{
  imports = [ .editors/lazyvim.nix ];
}