diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e027907c..1b28a967 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -198,11 +198,13 @@ For example this option will render something like: > **Example**: `"Hello, world!"` ```nix -foo = lib.mkOption { - type = lib.types.nullOr lib.types.str; - description = "Some string"; - default = null; - example = "Hello, world!"; +{ + foo = lib.mkOption { + type = lib.types.nullOr lib.types.str; + description = "Some string"; + default = null; + example = "Hello, world!"; + }; } ``` @@ -222,7 +224,7 @@ example = lib.literalExpression '' { foo = lib.nixvim.mkRaw "foo"; } -'' +''; ``` Another example where `literalExpression` is beneficial is when your example includes multi-line strings. @@ -238,13 +240,13 @@ example = lib.literalExpression '' several lines! '''; } -'' +''; ``` On very rare occasions, you may wish to include some non-code text within your example. This can be done by wrapping a markdown string with `lib.literalMD`. E.g: -`````nix +````nix example = lib.literalMD '' This will render as normal text. @@ -253,8 +255,8 @@ example = lib.literalMD '' ```nix This will render as nix code. ``` -'' -````` +''; +```` See also: [Writing NixOS Modules: Option Declarations](https://nixos.org/manual/nixos/unstable/#sec-option-declarations) (NixOS Manual). diff --git a/docs/lib/index.md b/docs/lib/index.md index f44bedba..8931435f 100644 --- a/docs/lib/index.md +++ b/docs/lib/index.md @@ -26,6 +26,7 @@ in ``` The extended `lib` is also accessible in the `lib` module argument in the `programs.nixvim` submodule: + ```nix { programs.nixvim = diff --git a/docs/platforms/standalone.md b/docs/platforms/standalone.md index a7f627de..77b5eb94 100644 --- a/docs/platforms/standalone.md +++ b/docs/platforms/standalone.md @@ -34,11 +34,11 @@ This function is recursive, meaning that it can be applied an arbitrary number o ```nix {makeNixvim}: let - first = makeNixvim { extraConfigLua = "-- first stage"; }; - second = first.extend {extraConfigLua = "-- second stage";}; - third = second.extend {extraConfigLua = "-- third stage";}; + first = makeNixvim { extraConfigLua = "-- first stage"; }; + second = first.extend {extraConfigLua = "-- second stage";}; + third = second.extend {extraConfigLua = "-- third stage";}; in - third +third ``` This will generate a `init.lua` that will contain the comments from each stages: @@ -61,10 +61,10 @@ Given a Nixvim derivation it is possible to access the module options using `" "" ""]) - ++ [ - # Other keymaps... - ]; +{ + keymaps = + (builtins.map (key: { + inherit key; + action = ""; + options.desc = "My cool keymapping"; + }) ["" "" ""]) + ++ [ + # Other keymaps... + ]; +} ``` This maps a list of keys into a list of similar [`keymaps`]. It is equivalent to: ```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... -]; +{ + keymaps = [ + { + key = ""; + action = ""; + options.desc = "My cool keymapping"; + } + { + key = ""; + action = ""; + options.desc = "My cool keymapping"; + } + { + key = ""; + action = ""; + options.desc = "My cool keymapping"; + } + # Other keymaps... + ]; +} ``` [`map`]: https://nixos.org/manual/nix/stable/language/builtins#builtins-map diff --git a/docs/user-guide/install.md b/docs/user-guide/install.md index a9c12f4c..18f9daa0 100644 --- a/docs/user-guide/install.md +++ b/docs/user-guide/install.md @@ -22,22 +22,23 @@ Nixvim is also available for nix flakes, or directly through an import. For a direct import you can add Nixvim to your configuration as follows: ```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 - }); + 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... ``` When using flakes you can simply add `nixvim` to the inputs: ```nix { - inputs.nixvim = { - url = "github:nix-community/nixvim"; - # If using a stable channel you can use `url = "github:nix-community/nixvim/nixos-"` - }; + inputs.nixvim = { + url = "github:nix-community/nixvim"; + # If using a stable channel you can use `url = "github:nix-community/nixvim/nixos-"` + }; - # outputs... + # outputs... } ``` diff --git a/docs/user-guide/lazy-loading.md b/docs/user-guide/lazy-loading.md index 2b6a9493..681d64ec 100644 --- a/docs/user-guide/lazy-loading.md +++ b/docs/user-guide/lazy-loading.md @@ -55,35 +55,32 @@ is done through the `lazyLoad.settings` option. Load on command: ```nix -plugins = { - grug-far = { +{ + plugins.grug-far = { enable = true; - lazyLoad = { - settings = { - cmd = "GrugFar"; - }; - }; + lazyLoad.settings.cmd = "GrugFar"; }; -}; +} ``` Load on file type: ```nix -plugins = { - glow = { +{ + plugins.glow = { enable = true; lazyLoad.settings.ft = "markdown"; }; +} ``` Different load conditions: ```nix -plugins.toggleterm = { - enable = true; - lazyLoad = { - settings = { +{ + plugins.toggleterm = { + enable = true; + lazyLoad.settings = { cmd = "ToggleTerm"; keys = [ "tg" @@ -91,36 +88,37 @@ plugins.toggleterm = { ]; }; }; -}; +} ``` Load on keymap with dependency: ```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"; - } - ]; - }; +{ + 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"; + } + ]; }; + }; +} ``` ### Colorschemes @@ -130,35 +128,39 @@ set up the `colorscheme` trigger to the name of the `colorscheme` so that it is lazy loaded when the `colorscheme` is requested. ```nix -colorscheme = "catppuccin"; -colorschemes.catppuccin = { - enable = true; - lazyLoad.enable = true; -}; +{ + colorscheme = "catppuccin"; + colorschemes.catppuccin = { + enable = true; + lazyLoad.enable = true; + }; +} ``` To configure special integrations after `catppuccin` has been set up (while still letting Nixvim manage lazy loading and the default `after`): ```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 -}; +{ + 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 + }; +} ```