### Example: Add Plugin to by-name Directory Source: https://github.com/nix-community/nixvim/blob/main/CONTRIBUTING.md This example shows how a plugin like 'direnv' is configured within the `plugins/by-name` directory, indicating it's automatically imported. ```nix plugins/by-name/direnv/default.nix ``` -------------------------------- ### Nix Module Option Example Source: https://github.com/nix-community/nixvim/blob/main/CONTRIBUTING.md Demonstrates how to define a Nix module option with a description, default value, and an example string. This example will be automatically rendered in documentation. ```nix { foo = lib.mkOption { type = lib.types.nullOr lib.types.str; description = "Some string"; default = null; example = "Hello, world!"; }; } ``` -------------------------------- ### Enable Nixvim with Colorscheme and Plugin Source: https://github.com/nix-community/nixvim/blob/main/README.md Enable Nixvim and configure the catppuccin colorscheme and lualine plugin. This provides a sensible default setup for both. ```nix { programs.nixvim = { enable = true; colorschemes.catppuccin.enable = true; plugins.lualine.enable = true; }; } ``` -------------------------------- ### Serve Documentation Locally Source: https://github.com/nix-community/nixvim/blob/main/CONTRIBUTING.md Run Nixvim's documentation server locally to preview changes. This command starts an HTTP server on port 8000 and opens it in your browser. ```bash nix run .#docs ``` ```bash serve-docs ``` -------------------------------- ### Setup NixVim Development Environment Source: https://github.com/nix-community/nixvim/blob/main/CONTRIBUTING.md To contribute to NixVim plugins, ensure you are in the nixvim directory and use `nix develop` to enter the development shell, or set up `nix-direnv`. ```bash # Ensure you are in the nixvim directory cd nixvim # Either setup nix-direnv, or manually enter a devshell using: nix develop ``` -------------------------------- ### Example: Add Plugin to Custom Directory Source: https://github.com/nix-community/nixvim/blob/main/CONTRIBUTING.md When adding a plugin to a custom directory like `plugins/colorschemes`, ensure it's also added to `plugins/default.nix` for proper import. ```nix plugins/colorschemes ``` ```nix plugins/default.nix ``` -------------------------------- ### Initialize Nixvim Flake Template Source: https://github.com/nix-community/nixvim/blob/main/README.md Command to initialize a new project using the Nixvim flake template. Recommended for starting a standalone configuration. ```console nix flake init --template github:nix-community/nixvim ``` -------------------------------- ### Install Nixvim Without Flakes Source: https://github.com/nix-community/nixvim/blob/main/README.md Use this configuration to install Nixvim by importing it directly from a Git repository. Ensure your nixpkgs version is compatible; 'nixpkgs-unstable' is recommended for the main branch. ```nix { pkgs, lib, ... }: let nixvim = import (builtins.fetchGit { url = "https://github.com/nix-community/nixvim"; # If you are not running an unstable channel of nixpkgs, select the corresponding branch of Nixvim. # ref = "nixos-26.05"; }); in { imports = [ # For Home Manager nixvim.homeModules.nixvim # For NixOS nixvim.nixosModules.nixvim # For nix-darwin nixvim.nixDarwinModules.nixvim ]; programs.nixvim.enable = true; } ``` -------------------------------- ### Literal Expression Example Source: https://github.com/nix-community/nixvim/blob/main/CONTRIBUTING.md Shows how to use `lib.literalExpression` to provide a Nix example that includes function applications or specific Nix constructs, such as `lib.nixvim.mkRaw`. This is useful when the default rendering is insufficient. ```nix example = lib.literalExpression '' { foo = lib.nixvim.mkRaw "foo"; } ''; ``` -------------------------------- ### Literal Markdown Example Source: https://github.com/nix-community/nixvim/blob/main/CONTRIBUTING.md Demonstrates using `lib.literalMD` to embed markdown content, including code blocks, directly within a Nix option example. This allows for richer documentation formatting. ```nix example = lib.literalMD '' This will render as normal text. Markdown formatting is **supported**! ```nix This will render as nix code. ``` ''; ``` -------------------------------- ### Configure nixd with Nixvim Options Source: https://github.com/nix-community/nixvim/blob/main/docs/platforms/standalone.md Access Nixvim module options to configure external tools like nixd. This example shows how to provide Nixvim's options expression to nixd. ```nix { plugins.lsp.servers.nixd = { enable = true; settings.options.nixvim.expr = ''(builtins.getFlake "/path/to/flake").packages.${system}.default.options''; }; } ``` -------------------------------- ### Set Custom Colorscheme with Extra Plugin Source: https://github.com/nix-community/nixvim/blob/main/README.md If your desired colorscheme is not provided as a module, install it using `extraPlugins` and set it via the `colorscheme` option. ```nix { programs.nixvim = { extraPlugins = [ pkgs.vimPlugins.gruvbox ]; colorscheme = "gruvbox"; }; } ``` -------------------------------- ### Minimal Nixvim Flake Configuration Source: https://github.com/nix-community/nixvim/blob/main/README.md A basic flake configuration for Nixvim, defining packages for multiple systems. This setup allows for running Neovim with the specified configuration. ```nix { description = "A very basic flake"; inputs = { nixpkgs.follows = "nixvim/nixpkgs"; nixvim.url = "github:nix-community/nixvim"; }; outputs = { nixpkgs, nixvim, ... }: let systems = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" ]; forAllSystems = nixpkgs.lib.genAttrs systems; in { packages = forAllSystems ( system: let configuration = nixvim.lib.evalNixvim { inherit system; modules = [ { colorschemes.gruvbox.enable = true; } ]; }; in { default = configuration.config.build.package; } ); }; } ``` -------------------------------- ### Disable Plugin Package Installation Source: https://github.com/nix-community/nixvim/blob/main/docs/user-guide/faq.md Prevent plugins from installing extra packages (e.g., `gcc` for `treesitter`) by setting their respective `xxxPackage` option to `null`. ```nix plugin.treesitter.gccPackage = null; ``` -------------------------------- ### Set NixVim Leader Key Source: https://github.com/nix-community/nixvim/blob/main/README.md Use the `globals` attribute to define global variables, such as setting the leader key. This example sets the leader key to a comma. ```nix { programs.nixvim = { globals.mapleader = ","; # Sets the leader key to comma }; } ``` -------------------------------- ### Add Extra Lua Configuration to NixVim Source: https://github.com/nix-community/nixvim/blob/main/README.md Use `extraConfigLua` to add custom Lua code to your NixVim configuration. This example prints a welcome message when Neovim is opened. ```nix { programs.nixvim = { extraConfigLua = '' -- Print a little welcome message when Neovim is opened! print("Hello world!") ''; }; } ``` -------------------------------- ### Integrate Standalone Nixvim into NixOS/Home Manager Source: https://github.com/nix-community/nixvim/blob/main/docs/platforms/standalone.md Incorporate a standalone Nixvim configuration into your NixOS or Home Manager setup. Assumes the standalone config is exported as a flake's default package. ```nix { inputs, system, ... }: { # NixOS environment.systemPackages = [ inputs.nixvim-config.packages.${system}.default ]; # Home Manager home.packages = [ inputs.nixvim-config.packages.${system}.default ]; } ``` -------------------------------- ### Literal Expression with Multi-line String Source: https://github.com/nix-community/nixvim/blob/main/CONTRIBUTING.md Illustrates using `lib.literalExpression` with Nix indented strings to include multi-line string examples. Note the use of `'''` to escape a literal `''` within the indented string. ```nix example = lib.literalExpression '' { long-string = ''' This string spans over several lines! '''; } ''; ``` -------------------------------- ### Execute Nixvim configuration Source: https://github.com/nix-community/nixvim/blob/main/templates/experimental-flake-parts/README.md Run the default Nixvim configuration using the Nix flake command. ```bash nix run ``` -------------------------------- ### Using Custom Lib with Nixvim Extensions Source: https://github.com/nix-community/nixvim/blob/main/docs/lib/index.md Extend Nixpkgs' lib with your own extensions and then further extend it with Nixvim's overlay for use in standalone builds. ```nix # Example flake { inputs = { # ... }; outputs = { nixpkgs, ... }@inputs: let myCustomLib = nixpkgs.lib.extend (final: prev: { # ... }); myCustomLibForNixvim = myCustomLib.extend inputs.nixvim.lib.overlay; in { # ... }; } ``` -------------------------------- ### Register and Configure Extra Nixvim Plugins Source: https://github.com/nix-community/nixvim/blob/main/docs/user-guide/faq.md Use `extraPlugins` to register plugins packaged in nixpkgs and `extraConfigLua` to configure them. ```nix extraPlugins = [pkgs.vimPlugins.""] extraConfigLua = "require('my-plugin').setup({foo = \"bar\"})"; ``` -------------------------------- ### Configure Post-Setup Hooks for Lazy-Loaded Colorschemes Source: https://github.com/nix-community/nixvim/blob/main/docs/user-guide/lazy-loading.md Configure special integrations to run after a colorscheme has been set up, while still allowing Nixvim to manage lazy loading. The `luaConfig.post` hook is used for this purpose, ensuring that code runs after the colorscheme is configured, regardless of whether it was lazy-loaded. ```nix { colorscheme = "catppuccin"; colorschemes.catppuccin = { enable = true; lazyLoad.enable = true; # This code runs after catppuccin is setup, # regardless of whether it was lazy-loaded or not. luaConfig.post = '' -- At this point catppuccin is configured, so we can safely -- derive bufferline highlights or similar settings from it. require('lz.n').trigger_load("bufferline.nvim") ''; }; # Configure bufferline to load after catppuccin plugins.bufferline = { enable = true; settings.highlights.__raw = "require('catppuccin.special.bufferline').get_theme()"; lazyLoad.settings.lazy = true; # Lazy load manually }; } ``` -------------------------------- ### Format Code with Nix Source: https://github.com/nix-community/nixvim/blob/main/CONTRIBUTING.md Use `nix fmt` to ensure code is properly formatted according to Nix style guidelines. ```bash nix fmt ``` -------------------------------- ### Build generate.nix with nix-build Source: https://github.com/nix-community/nixvim/blob/main/ci/README.md Use `nix-build` to build `./generate.nix` when developing CI scripts. This command places the output in `./result/bin/generate`. ```nix nix-build -A generate ``` -------------------------------- ### Run Nixvim Configuration Source: https://github.com/nix-community/nixvim/blob/main/templates/simple/README.md Use this command to test your Nixvim configuration after making changes. Ensure you are in the project directory. ```bash nix run . ``` -------------------------------- ### Add GitHub-Hosted Plugin to Nixvim Source: https://github.com/nix-community/nixvim/blob/main/docs/user-guide/faq.md Integrate plugins hosted on GitHub by using `pkgs.vimUtils.buildVimPlugin` and specifying the repository details. ```nix extraPlugins = [(pkgs.vimUtils.buildVimPlugin { name = "my-plugin"; src = pkgs.fetchFromGitHub { owner = ""; repo = ""; rev = ""; hash = ""; }; })]; ``` -------------------------------- ### Nixvim Configuration in Imported File Source: https://github.com/nix-community/nixvim/blob/main/docs/lib/index.md Configure Nixvim options and plugins directly in imported Nix files without the `plugins.nixvim` prefix. ```nix # nixvim.nix { lib, ... }: { # You can use lib.nixvim in your config fooOption = lib.nixvim.mkRaw "print('hello')"; # Configure Nixvim without prefixing with `plugins.nixvim` plugins.my-plugin.enable = true; } ``` -------------------------------- ### Equivalent Vimscript Key Mappings Source: https://github.com/nix-community/nixvim/blob/main/README.md Illustrates the Vimscript equivalent of the NixVim key mappings, showing how NixVim abstracts common Neovim configurations. ```vimscript noremap ; : noremap m make ``` -------------------------------- ### Enter CI development shell Source: https://github.com/nix-community/nixvim/blob/main/ci/README.md Use `nix-shell` to enter a development environment for CI scripts. This command makes the `generate` executable available on your PATH. ```nix nix-shell ./ci ``` -------------------------------- ### Run the Full Test Suite Source: https://github.com/nix-community/nixvim/blob/main/CONTRIBUTING.md Execute all tests across all systems. This is typically handled by CI but can be run locally if necessary. ```bash nix flake check --all-systems ``` -------------------------------- ### Create NixVim Package with makeNixvim Source: https://github.com/nix-community/nixvim/blob/main/docs/platforms/standalone-legacy.md Use `makeNixvim` to create a NixVim package from a single NixVim module. This is equivalent to evaluating a configuration and using its package output. ```nix nixvim.legacyPackages.${system}.makeNixvim { colorschemes.gruvbox.enable = true; } ``` -------------------------------- ### Build Nixvim Package with buildNixvimWith Source: https://github.com/nix-community/nixvim/blob/main/docs/platforms/standalone.md Use `buildNixvimWith` when you need to pass the full set of arguments supported by `evalNixvim` to build a Nixvim package. It is equivalent to calling `evalNixvim` and selecting the package. ```nix buildNixvimWith { inherit system; modules = [ ./config ]; } ``` ```nix (evalNixvim { inherit system; modules = [ ./config ]; }).config.build.package ``` -------------------------------- ### Nixvim Plugin Template Source: https://github.com/nix-community/nixvim/blob/main/CONTRIBUTING.md A template file for creating new Neovim plugins, demonstrating the structure and options available for configuration. ```nix plugins/TEMPLATE.nix ``` -------------------------------- ### Direct Import of Nixvim Source: https://github.com/nix-community/nixvim/blob/main/docs/user-guide/install.md Use this method to import Nixvim directly from a Git repository. Specify a ref for stable channels. ```nix let nixvim = import (builtins.fetchGit { url = "https://github.com/nix-community/nixvim"; # When using a different channel you can use `ref = "nixos-"` to set it here }); in # configurations... ``` -------------------------------- ### Enable NixVim Plugin Module Source: https://github.com/nix-community/nixvim/blob/main/README.md To enable a supported plugin, activate its corresponding module within the NixVim configuration. ```nix { programs.nixvim = { plugins.lightline.enable = true; }; } ``` -------------------------------- ### Importing Nixvim Modules Source: https://github.com/nix-community/nixvim/blob/main/docs/user-guide/install.md Add Nixvim modules to your configuration for NixOS, Home Manager, or nix-darwin. This enables Nixvim and allows configuration via `programs.nixvim`. ```nix # home-config.nix { # Imported modules are scoped within the `programs.nixvim` submodule programs.nixvim.imports = [ ./nixvim.nix ]; } ``` ```nix # nixvim.nix { # You can use lib.nixvim in your config fooOption = lib.nixvim.mkRaw "print('hello')"; # Configure Nixvim without prefixing with `plugins.nixvim` plugins.my-plugin.enable = true; } ``` -------------------------------- ### Configure Plugin Lazy Loading with Keymaps and Dependency Source: https://github.com/nix-community/nixvim/blob/main/docs/user-guide/lazy-loading.md Enable lazy loading for a plugin, specifying keymaps as triggers. The `before.__raw` field is used to ensure a dependency (like nvim-dap) is loaded before the plugin's `after` function executes. This is useful when the plugin's functionality relies on another plugin being available. ```nix { plugins.dap-ui = { enable = true; lazyLoad.settings = { # We need to access nvim-dap in the after function. before.__raw = '' function() require('lz.n').trigger_load('nvim-dap') end ''; keys = [ { __unkeyed-1 = "du"; __unkeyed-2.__raw = '' function() require('dap.ext.vscode').load_launchjs(nil, {}) require("dapui").toggle() end ''; desc = "Toggle Debugger UI"; } ]; }; }; } ``` -------------------------------- ### Access Nixvim Helpers in NixOS/Home Manager/nix-darwin Source: https://github.com/nix-community/nixvim/blob/main/docs/lib/index.md For NixOS, Home Manager, or nix-darwin modules, access helper functions via `config.lib.nixvim`. ```nix { config, ... }: let helpers = config.lib.nixvim; in { programs.nixvim = { # Your config fooOption = helpers.mkRaw "print('hello')"; }; } ``` -------------------------------- ### Access Nixvim Helpers via `nixvimLib` Source: https://github.com/nix-community/nixvim/blob/main/docs/lib/index.md Access the extended `lib` used in standalone builds via the `nixvimLib` module argument. ```nix { nixvimLib, ... }: { programs.nixvim = { # You can use nixvimLib.nixvim in your config fooOption = nixvimLib.nixvim.mkRaw "print('hello')"; }; } ``` -------------------------------- ### Build Nixvim Package with buildNixvim Source: https://github.com/nix-community/nixvim/blob/main/docs/platforms/standalone.md Use `buildNixvim` to create a Nixvim package from a module or list of modules. This is a simplified wrapper around `evalNixvim`. ```nix buildNixvim { imports = [ ./config ]; nixpkgs.hostPlatform = system; } ``` ```nix (evalNixvim { inherit system; modules = [ ./config ]; }).config.build.package ``` -------------------------------- ### Configure Plugin Lazy Loading with Command Trigger Source: https://github.com/nix-community/nixvim/blob/main/docs/user-guide/lazy-loading.md Enable lazy loading for a plugin and specify a command that will trigger its loading. Ensure the plugin is enabled. ```nix { plugins.grug-far = { enable = true; lazyLoad.settings.cmd = "GrugFar"; }; } ``` -------------------------------- ### Evaluate Nixvim Configuration Source: https://github.com/nix-community/nixvim/blob/main/docs/platforms/standalone.md Use `nixvim.lib.evalNixvim` to evaluate a Nixvim configuration when using it standalone. This function takes the system architecture and a list of modules as arguments. ```nix configuration = nixvim.lib.evalNixvim { inherit system; modules = [ ./config ]; }; ``` -------------------------------- ### Create a Nixvim Plugin Module Source: https://github.com/nix-community/nixvim/blob/main/docs/user-guide/faq.md Define a custom plugin module in a separate Nix file for plugins not yet merged or for temporary modifications. ```nix { lib, ... }: lib.nixvim.plugins.mkNeovimPlugin { # ... } ``` ```nix { # Remove this `programs.nixvim` wrapper for standalone configurations programs.nixvim = { # You could also substitute the filename with the module expression imports = [ ./my-plugin.nix ]; plugins.my-plugin.enable = true; }; } ``` -------------------------------- ### Import Nixvim with Flakes Source: https://github.com/nix-community/nixvim/blob/main/README.md Add this input to your flake configuration to use Nixvim. It follows your system's nixpkgs to ensure compatibility. Adjust the URL for specific Nixvim branches if not using 'nixpkgs-unstable'. ```nix { # ... inputs.nixvim = { url = "github:nix-community/nixvim"; # If you are not running an unstable channel of nixpkgs, select the corresponding branch of Nixvim. # url = "github:nix-community/nixvim/nixos-26.05"; inputs.nixpkgs.follows = "nixpkgs"; }; } ``` -------------------------------- ### Access NixVim Module Options Source: https://github.com/nix-community/nixvim/blob/main/docs/platforms/standalone-legacy.md Legacy NixVim packages expose module options through the `options` attribute. ```nix nvim.options ``` -------------------------------- ### Generate New Plugin Module Source: https://github.com/nix-community/nixvim/blob/main/CONTRIBUTING.md Scaffold a new plugin module and its corresponding test file using the `new-plugin` command. Use `--dry-run` to preview changes before applying them. ```bash nix develop --command new-plugin --package --maintainer ``` -------------------------------- ### Add Extra NixVim Plugins Source: https://github.com/nix-community/nixvim/blob/main/README.md If a plugin does not have a dedicated module, use the `extraPlugins` option to fetch and include it. ```nix { programs.nixvim = { extraPlugins = with pkgs.vimPlugins; [ vim-nix ]; }; } ``` -------------------------------- ### Extend Nixvim Configuration with Modules Source: https://github.com/nix-community/nixvim/blob/main/docs/platforms/standalone.md Extend an existing Nixvim configuration by layering additional modules. This is useful for progressive configuration. ```nix let base = nixvim.lib.evalNixvim { inherit system; modules = [ { extraConfigLua = "-- first stage"; } ]; }; extended = base.extendModules { modules = [ { extraConfigLua = "-- second stage"; } ]; }; in extended.config.build.package ``` -------------------------------- ### Create NixVim Package with makeNixvimWithModule Source: https://github.com/nix-community/nixvim/blob/main/docs/platforms/standalone-legacy.md Use `makeNixvimWithModule` to create a NixVim package, accepting an attribute set including the module path. The `module` field is required. ```nix nixvim.legacyPackages.${system}.makeNixvimWithModule { module = ./config; } ``` -------------------------------- ### Enable NixVim Colorscheme Module Source: https://github.com/nix-community/nixvim/blob/main/README.md To enable a supported colorscheme, activate its module within the NixVim configuration. ```nix { programs.nixvim = { # Enable gruvbox colorschemes.gruvbox.enable = true; }; } ``` -------------------------------- ### Import Nixvim Configuration within Submodule Source: https://github.com/nix-community/nixvim/blob/main/docs/lib/index.md Import Nixvim configuration files directly within the `programs.nixvim.imports` list. ```nix # home-config.nix { # Imported modules are scoped within the `programs.nixvim` submodule programs.nixvim.imports = [ ./nixvim.nix ]; } ``` -------------------------------- ### Extend Existing NixVim Package Source: https://github.com/nix-community/nixvim/blob/main/docs/platforms/standalone-legacy.md Packages created with legacy APIs expose an `extend` function to incrementally add configurations. This is the legacy approach; the modern equivalent is `configuration.extendModules`. ```nix { makeNixvim }: let first = makeNixvim { extraConfigLua = "-- first stage"; }; second = first.extend { extraConfigLua = "-- second stage"; }; third = second.extend { extraConfigLua = "-- third stage"; }; in third ``` -------------------------------- ### Generate Multiple Keymap Aliases Source: https://github.com/nix-community/nixvim/blob/main/docs/user-guide/faq.md Create multiple keymap entries with the same action and description by mapping over a list of keys using the built-in `map` function. ```nix { keymaps = (map (key: { inherit key; action = ""; options.desc = "My cool keymapping"; }) ["" "" ""]) ++ [ # Other keymaps... ]; } ``` ```nix { keymaps = [ { key = ""; action = ""; options.desc = "My cool keymapping"; } { key = ""; action = ""; options.desc = "My cool keymapping"; } { key = ""; action = ""; options.desc = "My cool keymapping"; } # Other keymaps... ]; } ``` -------------------------------- ### Access Nixvim Package Source: https://github.com/nix-community/nixvim/blob/main/docs/platforms/standalone.md After evaluating the configuration, the wrapped Neovim package is accessible via `configuration.config.build.package`. This allows you to include the Nixvim-packaged Neovim in your system's packages. ```nix { packages.${system}.default = configuration.config.build.package; } ``` -------------------------------- ### Configure Plugin Lazy Loading with File Type Trigger Source: https://github.com/nix-community/nixvim/blob/main/docs/user-guide/lazy-loading.md Enable lazy loading for a plugin and specify a file type that will trigger its loading. Ensure the plugin is enabled. ```nix { plugins.glow = { enable = true; lazyLoad.settings.ft = "markdown"; }; } ``` -------------------------------- ### Create Test Derivation from NixVim Package Source: https://github.com/nix-community/nixvim/blob/main/docs/platforms/standalone-legacy.md Use `check.mkTestDerivationFromNvim` to create a test derivation from an existing NixVim package. ```nix nixvim.lib.${system}.check.mkTestDerivationFromNvim ``` -------------------------------- ### Test Nixvim Configuration with testNixvimWith Source: https://github.com/nix-community/nixvim/blob/main/docs/platforms/standalone.md Use `testNixvimWith` to evaluate a Nixvim configuration and obtain its test derivation. This function is useful for testing configurations directly. ```nix testNixvimWith { inherit system; modules = [ ./config ]; } ``` ```nix (evalNixvim { inherit system; modules = [ ./config ]; }).config.build.test ``` -------------------------------- ### Evaluate Nixvim Configuration Standalone Source: https://github.com/nix-community/nixvim/blob/main/README.md Use this Nix expression to evaluate a Nixvim configuration for standalone usage. It requires fetching the nixvim tarball and defining modules. ```nix let nixvim = import (builtins.fetchTarball { # ... }); configuration = nixvim.lib.evalNixvim { system = builtins.currentSystem; modules = [ { colorschemes.gruvbox.enable = true; } ]; }; in configuration.config.build.package ``` -------------------------------- ### Define a Neovim Plugin with mkNeovimPlugin Source: https://github.com/nix-community/nixvim/blob/main/CONTRIBUTING.md Use `mkNeovimPlugin` to generate a Nix module for Neovim plugins. Configure plugin metadata, options, and settings. ```nix mkNeovimPlugin { name = "example-plugin"; maintainers = [ lib.maintainers.user ]; url = "https://github.com/example/example-plugin"; description = "An example Neovim plugin"; settingsOptions = { option1 = lib.mkOption { type = lib.types.str; default = "default-value"; description = "An example option"; }; }; } ``` -------------------------------- ### Configure Plugin Lazy Loading with Multiple Triggers Source: https://github.com/nix-community/nixvim/blob/main/docs/user-guide/lazy-loading.md Enable lazy loading for a plugin and specify multiple trigger conditions, such as a command and a set of keymaps. Ensure the plugin is enabled. ```nix { plugins.toggleterm = { enable = true; lazyLoad.settings = { cmd = "ToggleTerm"; keys = [ "tg" "gg" ]; }; }; } ``` -------------------------------- ### Build Nixvim Configuration Test Source: https://github.com/nix-community/nixvim/blob/main/docs/platforms/standalone.md Use this derivation to smoke-test your Nixvim configuration. It's typically used within a flake's checks. ```nix { ... }: { checks.${system}.default = configuration.config.build.test; } ``` -------------------------------- ### Standalone Nixvim Configuration Evaluation Source: https://github.com/nix-community/nixvim/blob/main/docs/user-guide/install.md Evaluate a Nixvim configuration for standalone usage. This produces a Neovim package and a test derivation. ```nix configuration = nixvim.lib.evalNixvim { inherit system; modules = [ ./config ]; }; ``` -------------------------------- ### Enable Experimental Nix Features for Flakes Source: https://github.com/nix-community/nixvim/blob/main/README.md This snippet enables the 'nix-command' and 'flakes' experimental features in Nix, which is a prerequisite for using flakes in your NixOS configuration. ```nix { pkgs, lib, ... }: { nix = { settings.experimental-features = [ "nix-command" "flakes" ]; }; } ``` -------------------------------- ### Access Nixvim Helpers in Standalone Build Source: https://github.com/nix-community/nixvim/blob/main/docs/lib/index.md When Nixvim is built standalone, access helper functions via the `lib` module argument. ```nix { lib, ... }: { # You can use lib.nixvim in your config fooOption = lib.nixvim.mkRaw "print('hello')"; } ``` -------------------------------- ### Configure Neovim Options with NixVim Source: https://github.com/nix-community/nixvim/blob/main/README.md Set Neovim configuration options like line numbers and shift width using the `opts` attribute. To disable an option, set its value to `false` instead of using a negation. ```nix { programs.nixvim = { opts = { number = true; # Show line numbers relativenumber = true; # Show relative line numbers shiftwidth = 2; # Tab width should be 2 }; }; } ``` -------------------------------- ### Test Nixvim Configuration with testNixvim Source: https://github.com/nix-community/nixvim/blob/main/docs/platforms/standalone.md Use `testNixvim` to generate a test derivation from an existing Nixvim package. This function is a shortcut for accessing the test derivation of a package. ```nix testNixvim myNvim ``` ```nix myNvim.config.build.test ``` -------------------------------- ### Generate Nix Module for Vim Plugin Source: https://github.com/nix-community/nixvim/blob/main/CONTRIBUTING.md Use `mkVimPlugin` to create a Nix module for a Vim plugin. This function requires basic metadata like name, URL, maintainers, and description. It also supports optional configurations such as `globalPrefix`. ```nix mkVimPlugin { name = "example-plugin"; url = "https://github.com/example/plugin"; maintainers = [ lib.maintainers.user ]; description = "An example Vim plugin."; globalPrefix = "example_"; } ``` -------------------------------- ### Nixvim Flake Configuration Source: https://github.com/nix-community/nixvim/blob/main/docs/user-guide/install.md Integrate Nixvim into your project using flakes by adding it to your inputs. For stable channels, specify the branch. ```nix { inputs.nixvim = { url = "github:nix-community/nixvim"; # If using a stable channel you can use `url = "github:nix-community/nixvim/nixos-"` }; # outputs... } ``` -------------------------------- ### Access Nixvim Helpers in `programs.nixvim` Submodule Source: https://github.com/nix-community/nixvim/blob/main/docs/lib/index.md The extended `lib` is accessible in the `lib` module argument within the `programs.nixvim` submodule. ```nix { lib, ... }: { programs.nixvim = { lib, ... }: { # You can use lib.nixvim in your config fooOption = lib.nixvim.mkRaw "print('hello')"; }; } ``` -------------------------------- ### Create Test Derivation from NixVim Module Source: https://github.com/nix-community/nixvim/blob/main/docs/platforms/standalone-legacy.md Use `check.mkTestDerivationFromNixvimModule` to produce a test derivation. It accepts the same arguments as `makeNixvimWithModule`. ```nix nixvim.lib.${system}.check.mkTestDerivationFromNixvimModule ``` -------------------------------- ### Isolate Conflicting Plugins with `standalonePlugins` Source: https://github.com/nix-community/nixvim/blob/main/docs/user-guide/faq.md Resolve 'collision between' errors when `performance.combinePlugins.enable` is set by isolating one of the conflicting plugins using `performance.combinePlugins.standalonePlugins`. ```nix performance.combinePlugins.standalonePlugins = [ "" ]; ``` -------------------------------- ### Define Key Mappings in NixVim Source: https://github.com/nix-community/nixvim/blob/main/README.md Define custom key mappings for Neovim using the `keymaps` attribute. This allows for custom actions triggered by specific key sequences in various modes. ```nix { programs.nixvim = { keymaps = [ { key = ";"; action = ":"; } { mode = "n"; key = "m"; options.silent = true; action = "!make"; } ]; }; } ``` -------------------------------- ### Enable Lazy Loading for Colorscheme Source: https://github.com/nix-community/nixvim/blob/main/docs/user-guide/lazy-loading.md Enable lazy loading for a specific colorscheme. Nixvim automatically sets up the `colorscheme` trigger to the name of the colorscheme, so it loads when requested. ```nix { colorscheme = "catppuccin"; colorschemes.catppuccin = { enable = true; lazyLoad.enable = true; }; } ``` -------------------------------- ### Access NixVim Configuration Values Source: https://github.com/nix-community/nixvim/blob/main/docs/platforms/standalone-legacy.md Legacy NixVim packages expose the evaluated configuration through the `config` attribute. ```nix nvim.config ``` -------------------------------- ### Assign Raw Lua Code to Nix Option Source: https://github.com/nix-community/nixvim/blob/main/README.md Use the `__raw` attribute to assign a Lua function directly to a Nix option. This is useful when a plugin option expects a Lua function but Nixvim doesn't have a specific Nix option for it. ```nix { some_option.__raw = "function() print('hello, world!') end"; } ``` ```lua { ['some_option'] = function() print('hello, world!') end, } ``` -------------------------------- ### Run a Single Test Interactively Source: https://github.com/nix-community/nixvim/blob/main/CONTRIBUTING.md Use this command to run a specific test in interactive mode, allowing for easier debugging and selection. ```bash nix develop --command tests --interactive ``` -------------------------------- ### Access Nixvim Configuration Values Source: https://github.com/nix-community/nixvim/blob/main/docs/platforms/standalone.md Retrieve evaluated option values from your Nixvim configuration. Useful for referencing Nixvim settings in other Nix configurations. ```nix configuration.config.colorschemes.gruvbox.enable ``` -------------------------------- ### Run a Specific Plugin Test Source: https://github.com/nix-community/nixvim/blob/main/CONTRIBUTING.md Execute a test for a plugin module by its generated test name. This is useful for focusing on changes within a specific plugin. ```bash nix develop --command tests plugins-by-name- ``` -------------------------------- ### Deprecation Comment Format Source: https://github.com/nix-community/nixvim/blob/main/MAINTAINING.md Use this comment format for deprecations, including the addition date and the release number after which it can be removed. ```nix # TODO: Added YYYY-MM-DD, remove after ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.