From 81ab0beacd8f050fda8f742feb4dd2b2d7586a4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Fri, 15 Sep 2023 16:24:19 +0200 Subject: [PATCH] docs: add README.md --- README.md | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..b15168e --- /dev/null +++ b/README.md @@ -0,0 +1,94 @@ +# Nix wrapper for Lazy.nvim +## Installation +### For flakes (recommended) +``` +{ + # 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."" = nixpkgs.lib.nixosSystem { + # ... + + modules = [ + { + home-manager.sharedModules = [ inputs.nix-lazy-nvim.homeManagerModules.default ]; + } + ]; + # ... + }; + # ... + }; +} +``` + +## Usage +See also [lazy.nvim](https://github.com/folke/lazy.nvim/#-plugin-spec) plugin spec. + +| Property | Type | Description | +|----------|------|-------------| +| plugin | derivation | The plugins vimPlugin derivation. | +| lazy | bool | Like [lazy.nvim](https://github.com/folke/lazy.nvim/#-plugin-spec). | +| enabled | bool | Like [lazy.nvim](https://github.com/folke/lazy.nvim/#-plugin-spec) | +| dependecies | list 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](https://github.com/folke/lazy.nvim/#-plugin-spec) | +| event | list str | List of event names to lazy load on. | +| cmd | list str | List of commands to lazy load on. | +| ft | list str | List of filetypes to lazy load on. | +| keys | attrset | See [Example](#example) | +| priority | int | Like [lazy.nvim](https://github.com/folke/lazy.nvim/#-plugin-spec) | + + +## Example + +```nix +{ pkgs, ... }: + +{ + 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 = "re"; cmd = ": Refactor eextract "; desc = "Extract"; mode = [ "x" ]; } + { key = "rf"; cmd = ": Refactor extract_to_file "; desc = "Extract to file"; mode = [ "x" ]; } + { key = "rv"; cmd = ": Refactor extract_var "; desc = "Extract variable"; mode = [ "x" ]; } + { key = "ri"; cmd = ": Refactor inline_var"; desc = "Inline variable"; mode = [ "n" "x" ]; } + { key = "rI"; cmd = ": Refactor inline_func"; desc = "Inline function"; mode = [ "n" "x" ]; } + { key = "rb"; cmd = ": Refactor extract_block"; desc = "Extract block"; mode = [ "n" ]; } + { key = "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; + } + ]; +} +```