Nix wrapper for Lazy.nvim
Go to file
Moritz Böhme 408ab5cad3
feat!: do not format by default
2023-10-27 17:38:49 +02:00
README.md docs: add enable option to docs 2023-09-16 14:45:21 +02:00
flake.nix feat: initial commit 2023-09-15 13:36:36 +02:00
home-manager.nix feat!: do not format by default 2023-10-27 17:38:49 +02:00
lib.nix feat: initial commit 2023-09-15 13:36:36 +02:00

README.md

Nix wrapper for Lazy.nvim

Installation

{
  # Add flake to your flakes inputs:
  inputs.nix-lazy-nvim.url = "git+https://git.moritzboeh.me/moritz/NixLazy.nvim";

  outputs = { self, nixpkgs, nix-lazy-nvim, ... }:
    {
      # ...
      nixosConfiguration."<your-hostname>" = nixpkgs.lib.nixosSystem {
        # ...

        modules = [
          {
            home-manager.sharedModules = [ inputs.nix-lazy-nvim.homeManagerModules.default ];
          }
        ];
        # ...
      };
      # ...
    };
}

Usage

See also lazy.nvim plugin spec.

Property Type Description
plugin derivation The plugins vimPlugin derivation.
lazy bool Like lazy.nvim.
enabled bool Like lazy.nvim
dependecies [attrset] List of plugin definitions.
init str Lua code to run on startup.
opts attrset Attrset of primitive types (str, bool, int, float, list, attrset) which gets transformed into lua
conf str Lua code. Like config function body in lazy.nvim
event [str] List of event names to lazy load on.
cmd [str] List of commands to lazy load on.
ft [str] List of filetypes to lazy load on.
keys attrset See Example
priority int Like lazy.nvim

Example

{ pkgs, ... }:

{
  programs.neovim.lazy.enable = true;
  programs.neovim.lazy.plugins = with pkgs.vimPlugins; [
    # Simple lazy loaded plugin based on events
    {
      plugin = nvim-surround;
      event = [ "BufReadPost" "BufNewFile" ];
      opts = { };
    }

    # Or based on keys
    {
      plugin = refactoring-nvim;
      keys = [
        { key = "<leader>re"; cmd = ": Refactor eextract "; desc = "Extract"; mode = [ "x" ]; }
        { key = "<leader>rf"; cmd = ": Refactor extract_to_file "; desc = "Extract to file"; mode = [ "x" ]; }
        { key = "<leader>rv"; cmd = ": Refactor extract_var "; desc = "Extract variable"; mode = [ "x" ]; }
        { key = "<leader>ri"; cmd = ": Refactor inline_var"; desc = "Inline variable"; mode = [ "n" "x" ]; }
        { key = "<leader>rI"; cmd = ": Refactor inline_func"; desc = "Inline function"; mode = [ "n" "x" ]; }
        { key = "<leader>rb"; cmd = ": Refactor extract_block"; desc = "Extract block"; mode = [ "n" ]; }
        { key = "<leader>rbf"; cmd = ": Refactor extract_block_to_file"; desc = "Extract block to file"; mode = [ "n" ]; }
      ];
      dependencies = [
        { plugin = plenary-nvim; }
        { plugin = nvim-lspconfig; }
      ];
      opts = { };
    }

    # Example usage for color themes. Should have a high priority and should not be lazy loaded.
    # Also shows usage of conf.
    {
      plugin = catppuccin-nvim;
      conf = ''
        require("catppuccin").setup({
          compile_path = vim.fn.stdpath("cache") .. "/catppuccin", -- fix issue of writing to nix store
        })
        vim.cmd.colorscheme("catppuccin-macchiato")
      '';
      lazy = false;
      priority = 99;
    }
  ];
}