From 297e2e0b65a6788fecc6acabd77361b87544005e Mon Sep 17 00:00:00 2001 From: Zexin Yuan Date: Fri, 12 Dec 2025 19:26:32 +0800 Subject: [PATCH] docs: format nix examples in options --- colorschemes/base16/default.nix | 2 + colorschemes/catppuccin/default.nix | 22 ++--- colorschemes/kanagawa/default.nix | 44 ++++----- colorschemes/nightfox/default.nix | 90 +++++++++---------- plugins/by-name/barbar/default.nix | 18 ++-- plugins/by-name/blink-cmp-latex/default.nix | 44 ++++----- plugins/by-name/blink-cmp-spell/default.nix | 42 +++++---- plugins/by-name/blink-copilot/default.nix | 60 +++++++------ plugins/by-name/blink-ripgrep/default.nix | 22 ++--- plugins/by-name/hop/default.nix | 2 + plugins/by-name/luasnip/default.nix | 6 +- plugins/by-name/sandwich/default.nix | 2 + plugins/by-name/startify/settings-options.nix | 84 ++++++++--------- plugins/by-name/treesitter/default.nix | 4 + plugins/cmp/default.nix | 41 +++++---- plugins/cmp/options/sources-option.nix | 2 + .../lsp/language-servers/ltex-settings.nix | 73 ++++++++------- 17 files changed, 293 insertions(+), 265 deletions(-) diff --git a/colorschemes/base16/default.nix b/colorschemes/base16/default.nix index e9024c71..6eae6bd7 100644 --- a/colorschemes/base16/default.nix +++ b/colorschemes/base16/default.nix @@ -130,7 +130,9 @@ lib.nixvim.plugins.mkNeovimPlugin { for example, you could reuse some colors from the builtin colorschemes: ```nix + { base03.__raw = "base16.colorschemes['catppuccin'].base06"; + } ``` [plugin's source code]: https://github.com/RRethy/base16-nvim/blob/master/lua/colors/init.lua diff --git a/colorschemes/catppuccin/default.nix b/colorschemes/catppuccin/default.nix index 4815ae73..905f4767 100644 --- a/colorschemes/catppuccin/default.nix +++ b/colorschemes/catppuccin/default.nix @@ -176,17 +176,17 @@ lib.nixvim.plugins.mkNeovimPlugin { Example: ```nix - { - cmp = true; - gitsigns = true; - nvimtree = true; - treesitter = true; - notify = false; - mini = { - enabled = true; - indentscope_color = ""; - }; - } + { + cmp = true; + gitsigns = true; + nvimtree = true; + treesitter = true; + notify = false; + mini = { + enabled = true; + indentscope_color = ""; + }; + } ``` Default: see plugin source. diff --git a/colorschemes/kanagawa/default.nix b/colorschemes/kanagawa/default.nix index de6861be..9ac808b9 100644 --- a/colorschemes/kanagawa/default.nix +++ b/colorschemes/kanagawa/default.nix @@ -92,25 +92,25 @@ lib.nixvim.plugins.mkNeovimPlugin { Example: ```nix - { - wave = { - ui = { - float = { - bg = "none"; - }; + { + wave = { + ui = { + float = { + bg = "none"; + }; + }; + }; + dragon = { + syn = { + parameter = "yellow"; }; - }; - dragon = { - syn = { - parameter = "yellow"; - }; - }; - all = { - ui = { - bg_gutter = "none"; - }; - }; - } + }; + all = { + ui = { + bg_gutter = "none"; + }; + }; + } ``` ''; @@ -119,10 +119,10 @@ lib.nixvim.plugins.mkNeovimPlugin { Example: ```nix - { - sumiInk0 = "#000000"; - fujiWhite = "#FFFFFF"; - } + { + sumiInk0 = "#000000"; + fujiWhite = "#FFFFFF"; + } ``` ''; }; diff --git a/colorschemes/nightfox/default.nix b/colorschemes/nightfox/default.nix index a799ebd9..0834efd9 100644 --- a/colorschemes/nightfox/default.nix +++ b/colorschemes/nightfox/default.nix @@ -202,27 +202,27 @@ lib.nixvim.plugins.mkNeovimPlugin { Example: ```nix - { - all = { - red = "#ff0000"; + { + all = { + red = "#ff0000"; + }; + nightfox = { + red = "#c94f6d"; + }; + dayfox = { + blue = { + base = "#4d688e"; + bright = "#4e75aa"; + dim = "#485e7d"; }; - nightfox = { - red = "#c94f6d"; - }; - dayfox = { - blue = { - base = "#4d688e"; - bright = "#4e75aa"; - dim = "#485e7d"; - }; - }; - nordfox = { - bg1 = "#2e3440"; - sel0 = "#3e4a5b"; - sel1 = "#4f6074"; - comment = "#60728a"; - }; - } + }; + nordfox = { + bg1 = "#2e3440"; + sel0 = "#3e4a5b"; + sel1 = "#4f6074"; + comment = "#60728a"; + }; + } ``` ''; @@ -250,23 +250,23 @@ lib.nixvim.plugins.mkNeovimPlugin { Example: ```nix - { - all = { - syntax = { - keyword = "magenta"; - conditional = "magenta.bright"; - number = "orange.dim"; - }; - git = { - changed = "#f4a261"; - }; + { + all = { + syntax = { + keyword = "magenta"; + conditional = "magenta.bright"; + number = "orange.dim"; }; - nightfox = { - syntax = { - operator = "orange"; - }; + git = { + changed = "#f4a261"; }; - } + }; + nightfox = { + syntax = { + operator = "orange"; + }; + }; + } ``` ''; @@ -293,16 +293,16 @@ lib.nixvim.plugins.mkNeovimPlugin { Example: ```nix - { - all = { - Whitespace.link = "Comment"; - IncSearch.bg = "palette.cyan"; - }, - nightfox.PmenuSel = { - bg = "#73daca"; - fg = "bg0"; - }; - } + { + all = { + Whitespace.link = "Comment"; + IncSearch.bg = "palette.cyan"; + }, + nightfox.PmenuSel = { + bg = "#73daca"; + fg = "bg0"; + }; + } ``` ''; }; diff --git a/plugins/by-name/barbar/default.nix b/plugins/by-name/barbar/default.nix index 0792cc1f..938d8fde 100644 --- a/plugins/by-name/barbar/default.nix +++ b/plugins/by-name/barbar/default.nix @@ -260,18 +260,18 @@ lib.nixvim.plugins.mkNeovimPlugin { The keys will be automatically translated to raw lua: ```nix - { - "vim.diagnostic.severity.INFO".enabled = true; - "vim.diagnostic.severity.WARN".enabled = true; - } + { + "vim.diagnostic.severity.INFO".enabled = true; + "vim.diagnostic.severity.WARN".enabled = true; + } ``` will result in the following lua: ```lua - { - -- Note the table keys are not string literals: - [vim.diagnostic.severity.INFO] = { ['enabled'] = true }, - [vim.diagnostic.severity.WARN] = { ['enabled'] = true }, - } + { + -- Note the table keys are not string literals: + [vim.diagnostic.severity.INFO] = { ['enabled'] = true }, + [vim.diagnostic.severity.WARN] = { ['enabled'] = true }, + } ``` ''; }; diff --git a/plugins/by-name/blink-cmp-latex/default.nix b/plugins/by-name/blink-cmp-latex/default.nix index 217ef044..afa576c5 100644 --- a/plugins/by-name/blink-cmp-latex/default.nix +++ b/plugins/by-name/blink-cmp-latex/default.nix @@ -15,34 +15,38 @@ lib.nixvim.plugins.mkNeovimPlugin { For example: ```nix - plugins.blink-cmp = { - enable = true; - settings.sources.providers = { - latex-symbols = { - module = "blink-cmp-latex"; - name = "Latex"; - opts = { - # set to true to insert the latex command instead of the symbol - insert_command = false + { + plugins.blink-cmp = { + enable = true; + settings.sources.providers = { + latex-symbols = { + module = "blink-cmp-latex"; + name = "Latex"; + opts = { + # set to true to insert the latex command instead of the symbol + insert_command = false + }; }; }; }; - }; + } ``` And then you can add it to blink-cmp's `sources.default` option: ```nix - plugins.blink-cmp = { - enable = true; - settings.sources.default = [ - "lsp" - "path" - "luasnip" - "buffer" - "latex-symbols" - ]; - }; + { + plugins.blink-cmp = { + enable = true; + settings.sources.default = [ + "lsp" + "path" + "luasnip" + "buffer" + "latex-symbols" + ]; + }; + } ``` ''; diff --git a/plugins/by-name/blink-cmp-spell/default.nix b/plugins/by-name/blink-cmp-spell/default.nix index 5782a6d5..9dca4483 100644 --- a/plugins/by-name/blink-cmp-spell/default.nix +++ b/plugins/by-name/blink-cmp-spell/default.nix @@ -15,33 +15,37 @@ lib.nixvim.plugins.mkNeovimPlugin { For example: ```nix - plugins.blink-cmp = { - enable = true; - settings.sources.providers = { - spell = { - module = "blink-cmp-spell"; - name = "Spell"; - score_offset = 100; - opts = { + { + plugins.blink-cmp = { + enable = true; + settings.sources.providers = { + spell = { + module = "blink-cmp-spell"; + name = "Spell"; + score_offset = 100; + opts = { + }; }; }; }; - }; + } ``` And then you can add it to blink-cmp's `sources.default` option: ```nix - plugins.blink-cmp = { - enable = true; - settings.sources.default = [ - "lsp" - "path" - "luasnip" - "buffer" - "spell" - ]; - }; + { + plugins.blink-cmp = { + enable = true; + settings.sources.default = [ + "lsp" + "path" + "luasnip" + "buffer" + "spell" + ]; + }; + } ``` ''; diff --git a/plugins/by-name/blink-copilot/default.nix b/plugins/by-name/blink-copilot/default.nix index 353b5f7e..4137d973 100644 --- a/plugins/by-name/blink-copilot/default.nix +++ b/plugins/by-name/blink-copilot/default.nix @@ -19,43 +19,47 @@ lib.nixvim.plugins.mkNeovimPlugin { For example: ```nix - plugins.blink-cmp = { - enable = true; - settings.sources.providers = { - copilot = { - async = true; - module = "blink-copilot"; - name = "copilot"; - score_offset = 100; - # Optional configurations - opts = { - max_completions = 3; - max_attempts = 4; - kind = "Copilot"; - debounce = 750; - auto_refresh = { - backward = true; - forward = true; + { + plugins.blink-cmp = { + enable = true; + settings.sources.providers = { + copilot = { + async = true; + module = "blink-copilot"; + name = "copilot"; + score_offset = 100; + # Optional configurations + opts = { + max_completions = 3; + max_attempts = 4; + kind = "Copilot"; + debounce = 750; + auto_refresh = { + backward = true; + forward = true; + }; }; }; }; }; - }; + } ``` And then you can add it to blink-cmp's `sources.default` option: ```nix - plugins.blink-cmp = { - enable = true; - settings.sources.default = [ - "lsp" - "path" - "luasnip" - "buffer" - "copilot" - ]; - }; + { + plugins.blink-cmp = { + enable = true; + settings.sources.default = [ + "lsp" + "path" + "luasnip" + "buffer" + "copilot" + ]; + }; + } ``` ''; diff --git a/plugins/by-name/blink-ripgrep/default.nix b/plugins/by-name/blink-ripgrep/default.nix index 95df9e5e..786e3c39 100644 --- a/plugins/by-name/blink-ripgrep/default.nix +++ b/plugins/by-name/blink-ripgrep/default.nix @@ -44,16 +44,18 @@ lib.nixvim.plugins.mkNeovimPlugin { And then you can add it to blink-cmp's `sources.default` option: ```nix - plugins.blink-cmp = { - enable = true; - settings.sources.default = [ - "lsp" - "path" - "luasnip" - "buffer" - "ripgrep" - ]; - }; + { + plugins.blink-cmp = { + enable = true; + settings.sources.default = [ + "lsp" + "path" + "luasnip" + "buffer" + "ripgrep" + ]; + }; + } ``` ''; diff --git a/plugins/by-name/hop/default.nix b/plugins/by-name/hop/default.nix index 2068a7b0..50e0da4c 100644 --- a/plugins/by-name/hop/default.nix +++ b/plugins/by-name/hop/default.nix @@ -16,6 +16,7 @@ lib.nixvim.plugins.mkNeovimPlugin { Hop doesn’t set any keybindings; you will have to define them by yourself. If you want to create a key binding from within nixvim: ```nix + { keymaps = [ { key = "f"; @@ -68,6 +69,7 @@ lib.nixvim.plugins.mkNeovimPlugin { options.remap = true; } ]; + } ``` ''; diff --git a/plugins/by-name/luasnip/default.nix b/plugins/by-name/luasnip/default.nix index e038cbe6..c07cff4e 100644 --- a/plugins/by-name/luasnip/default.nix +++ b/plugins/by-name/luasnip/default.nix @@ -302,12 +302,12 @@ lib.nixvim.plugins.mkNeovimPlugin { For example, ```nix - [ {} { paths = ./path/to/snippets; } ] + [ {} { paths = ./path/to/snippets; } ] ``` will generate the following lua: ```lua - require("luasnip.loaders.from_vscode").lazy_load({}) - require("luasnip.loaders.from_vscode").lazy_load({['paths'] = {'/nix/store/.../path/to/snippets'}}) + require("luasnip.loaders.from_vscode").lazy_load({}) + require("luasnip.loaders.from_vscode").lazy_load({['paths'] = {'/nix/store/.../path/to/snippets'}}) ``` ''; }; diff --git a/plugins/by-name/sandwich/default.nix b/plugins/by-name/sandwich/default.nix index 4275a338..97a741ab 100644 --- a/plugins/by-name/sandwich/default.nix +++ b/plugins/by-name/sandwich/default.nix @@ -13,6 +13,7 @@ lib.nixvim.plugins.mkVimPlugin { The `settings` option will not let you define the options starting with `sandwich#`. For those, you can directly use the `globals` option: ```nix + { globals."sandwich#magicchar#f#patterns" = [ { header.__raw = "[[\<\%(\h\k*\.\)*\h\k*]]"; @@ -21,6 +22,7 @@ lib.nixvim.plugins.mkVimPlugin { footer = ""; } ]; + } ``` ''; diff --git a/plugins/by-name/startify/settings-options.nix b/plugins/by-name/startify/settings-options.nix index be03f43b..fa380296 100644 --- a/plugins/by-name/startify/settings-options.nix +++ b/plugins/by-name/startify/settings-options.nix @@ -39,28 +39,28 @@ in Default: ```nix - [ - { - type = "files"; - header = [" MRU"]; - } - { - type = "dir"; - header = [{__raw = "' MRU' .. vim.loop.cwd()";}]; - } - { - type = "sessions"; - header = [" Sessions"]; - } - { - type = "bookmarks"; - header = [" Bookmarks"]; - } - { - type = "commands"; - header = [" Commands"]; - } - ] + [ + { + type = "files"; + header = [" MRU"]; + } + { + type = "dir"; + header = [{__raw = "' MRU' .. vim.loop.cwd()";}]; + } + { + type = "sessions"; + header = [" Sessions"]; + } + { + type = "bookmarks"; + header = [" Bookmarks"]; + } + { + type = "commands"; + header = [" Commands"]; + } + ] ``` ''; }; @@ -100,12 +100,12 @@ in Example: ```nix - [ - ":help reference" - ["Vim Reference" "h ref"] - {h = "h ref";} - {m = ["My magical function" "call Magic()"];} - ] + [ + ":help reference" + ["Vim Reference" "h ref"] + {h = "h ref";} + {m = ["My magical function" "call Magic()"];} + ] ``` ''; @@ -204,11 +204,11 @@ in Example: ```nix - [ - "\.vimgolf" - "^/tmp" - "/project/.*/documentation" - ] + [ + "\.vimgolf" + "^/tmp" + "/project/.*/documentation" + ] ``` ''; @@ -261,7 +261,7 @@ in Example: ```nix - ["setlocal" "winheight"] + ["setlocal" "winheight"] ``` Internally this simply does: - `:global/setlocal/delete` @@ -279,11 +279,11 @@ in Example: ```nix - [ - "g:startify_session_savevars" - "g:startify_session_savecmds" - "g:random_plugin_use_feature" - ] + [ + "g:startify_session_savevars" + "g:startify_session_savecmds" + "g:random_plugin_use_feature" + ] ``` ''; @@ -292,9 +292,9 @@ in Example: ```nix - [ - "silent !pdfreader ~/latexproject/main.pdf &" - ] + [ + "silent !pdfreader ~/latexproject/main.pdf &" + ] ``` ''; diff --git a/plugins/by-name/treesitter/default.nix b/plugins/by-name/treesitter/default.nix index 5e0e224a..db76b252 100644 --- a/plugins/by-name/treesitter/default.nix +++ b/plugins/by-name/treesitter/default.nix @@ -40,6 +40,7 @@ lib.nixvim.plugins.mkNeovimPlugin { If you'd like more control, you could instead specify which packages to install. For example: ```nix + { plugins.treesitter = { enable = true; @@ -58,6 +59,7 @@ lib.nixvim.plugins.mkNeovimPlugin { yaml ]; }; + } ``` ### Installing tree-sitter grammars from nvim-treesitter @@ -69,6 +71,7 @@ lib.nixvim.plugins.mkNeovimPlugin { or use the `plugins.treesitter.settings.ensure_installed` option to specify grammars you want the plugin to fetch and install. ```nix + { plugins.treesitter = { enable = true; @@ -84,6 +87,7 @@ lib.nixvim.plugins.mkNeovimPlugin { ]; }; }; + } ``` NOTE: You can combine the functionality of `plugins.treesitter.nixGrammars` and `plugins.treesitter.settings.ensure_installed`. diff --git a/plugins/cmp/default.nix b/plugins/cmp/default.nix index c97be1d3..ab7f9883 100644 --- a/plugins/cmp/default.nix +++ b/plugins/cmp/default.nix @@ -28,32 +28,35 @@ lib.nixvim.plugins.mkNeovimPlugin { #### With auto-enabled sources ```nix - plugins.cmp = { - autoEnableSources = true; - settings.sources = [ - { name = "nvim_lsp"; } - { name = "path"; } - { name = "buffer"; } - ]; - }; - ``` - - #### Without auto-enabled sources - ```nix - plugins = { - cmp = { - autoEnableSources = false; + { + plugins.cmp = { + autoEnableSources = true; settings.sources = [ { name = "nvim_lsp"; } { name = "path"; } { name = "buffer"; } ]; }; - cmp-nvim-lsp.enable = true; - cmp-path.enable = true; - cmp-buffer.enable = true; - }; + } + ``` + #### Without auto-enabled sources + ```nix + { + plugins = { + cmp = { + autoEnableSources = false; + settings.sources = [ + { name = "nvim_lsp"; } + { name = "path"; } + { name = "buffer"; } + ]; + }; + cmp-nvim-lsp.enable = true; + cmp-path.enable = true; + cmp-buffer.enable = true; + }; + } ``` ''; diff --git a/plugins/cmp/options/sources-option.nix b/plugins/cmp/options/sources-option.nix index 95aa0038..03b0786a 100644 --- a/plugins/cmp/options/sources-option.nix +++ b/plugins/cmp/options/sources-option.nix @@ -41,6 +41,7 @@ let if you don't want to see `buffer` source items while `nvim-lsp` source is available: ```nix + { sources = [ { name = "nvim_lsp"; @@ -51,6 +52,7 @@ let group_index = 2; } ]; + } ``` ''; diff --git a/plugins/lsp/language-servers/ltex-settings.nix b/plugins/lsp/language-servers/ltex-settings.nix index deda8dea..fade86f1 100644 --- a/plugins/lsp/language-servers/ltex-settings.nix +++ b/plugins/lsp/language-servers/ltex-settings.nix @@ -108,7 +108,6 @@ in type = with types; listOf (maybeRaw str); pluginDefault = { }; example = { - "" = [ "" "" @@ -122,9 +121,9 @@ in Lists of additional words that should not be counted as spelling errors. This setting is language-specific, so use an attrs of the format ```nix - { - ... - }; + { + ... + }; ``` where denotes the language code in `settings.language`. @@ -148,18 +147,18 @@ in Lists of rules that should be disabled (if enabled by default by LanguageTool). This setting is language-specific, so use an attrs of the format ```nix - { - "" = [ - "" - "" - ... - ]; - "" = [ - "" - "" - ]; + { + "" = [ + "" + "" ... - }; + ]; + "" = [ + "" + "" + ]; + ... + }; ``` where `` denotes the language code in `settings.language` and `` the ID of the LanguageTool rule. @@ -184,18 +183,18 @@ in Lists of rules that should be enabled (if disabled by default by LanguageTool). This setting is language-specific, so use an attrs of the format ```nix - { - "" = [ - "" - "" - ... - ]; - "" = [ - "" - "" - ]; + { + "" = [ + "" + "" ... - }; + ]; + "" = [ + "" + "" + ]; + ... + }; ``` where `` denotes the language code in `settings.language` and `` the ID of the LanguageTool rule. @@ -217,18 +216,18 @@ in within a specific sentence). This setting is language-specific, so use an attrs of the format ```nix - { - "" = [ - "" - "" - ... - ]; - "" = [ - "" - "" - ]; + { + "" = [ + "" + "" ... - }; + ]; + "" = [ + "" + "" + ]; + ... + }; ``` where `` denotes the language code in `settings.language` and `` is a JSON string containing information about the rule and sentence.