1
0
Fork 0
mirror of https://github.com/nix-community/nixvim.git synced 2025-12-16 14:01:10 +01:00

docs: format nix examples in options

This commit is contained in:
Zexin Yuan 2025-12-12 19:26:32 +08:00 committed by Gaétan Lepage
parent d52007581e
commit 297e2e0b65
17 changed files with 293 additions and 265 deletions

View file

@ -130,7 +130,9 @@ lib.nixvim.plugins.mkNeovimPlugin {
for example, you could reuse some colors from the builtin colorschemes: for example, you could reuse some colors from the builtin colorschemes:
```nix ```nix
{
base03.__raw = "base16.colorschemes['catppuccin'].base06"; base03.__raw = "base16.colorschemes['catppuccin'].base06";
}
``` ```
[plugin's source code]: https://github.com/RRethy/base16-nvim/blob/master/lua/colors/init.lua [plugin's source code]: https://github.com/RRethy/base16-nvim/blob/master/lua/colors/init.lua

View file

@ -176,17 +176,17 @@ lib.nixvim.plugins.mkNeovimPlugin {
Example: Example:
```nix ```nix
{ {
cmp = true; cmp = true;
gitsigns = true; gitsigns = true;
nvimtree = true; nvimtree = true;
treesitter = true; treesitter = true;
notify = false; notify = false;
mini = { mini = {
enabled = true; enabled = true;
indentscope_color = ""; indentscope_color = "";
}; };
} }
``` ```
Default: see plugin source. Default: see plugin source.

View file

@ -92,25 +92,25 @@ lib.nixvim.plugins.mkNeovimPlugin {
Example: Example:
```nix ```nix
{ {
wave = { wave = {
ui = { ui = {
float = { float = {
bg = "none"; bg = "none";
}; };
};
};
dragon = {
syn = {
parameter = "yellow";
}; };
}; };
dragon = { all = {
syn = { ui = {
parameter = "yellow"; bg_gutter = "none";
}; };
}; };
all = { }
ui = {
bg_gutter = "none";
};
};
}
``` ```
''; '';
@ -119,10 +119,10 @@ lib.nixvim.plugins.mkNeovimPlugin {
Example: Example:
```nix ```nix
{ {
sumiInk0 = "#000000"; sumiInk0 = "#000000";
fujiWhite = "#FFFFFF"; fujiWhite = "#FFFFFF";
} }
``` ```
''; '';
}; };

View file

@ -202,27 +202,27 @@ lib.nixvim.plugins.mkNeovimPlugin {
Example: Example:
```nix ```nix
{ {
all = { all = {
red = "#ff0000"; red = "#ff0000";
};
nightfox = {
red = "#c94f6d";
};
dayfox = {
blue = {
base = "#4d688e";
bright = "#4e75aa";
dim = "#485e7d";
}; };
nightfox = { };
red = "#c94f6d"; nordfox = {
}; bg1 = "#2e3440";
dayfox = { sel0 = "#3e4a5b";
blue = { sel1 = "#4f6074";
base = "#4d688e"; comment = "#60728a";
bright = "#4e75aa"; };
dim = "#485e7d"; }
};
};
nordfox = {
bg1 = "#2e3440";
sel0 = "#3e4a5b";
sel1 = "#4f6074";
comment = "#60728a";
};
}
``` ```
''; '';
@ -250,23 +250,23 @@ lib.nixvim.plugins.mkNeovimPlugin {
Example: Example:
```nix ```nix
{ {
all = { all = {
syntax = { syntax = {
keyword = "magenta"; keyword = "magenta";
conditional = "magenta.bright"; conditional = "magenta.bright";
number = "orange.dim"; number = "orange.dim";
};
git = {
changed = "#f4a261";
};
}; };
nightfox = { git = {
syntax = { changed = "#f4a261";
operator = "orange";
};
}; };
} };
nightfox = {
syntax = {
operator = "orange";
};
};
}
``` ```
''; '';
@ -293,16 +293,16 @@ lib.nixvim.plugins.mkNeovimPlugin {
Example: Example:
```nix ```nix
{ {
all = { all = {
Whitespace.link = "Comment"; Whitespace.link = "Comment";
IncSearch.bg = "palette.cyan"; IncSearch.bg = "palette.cyan";
}, },
nightfox.PmenuSel = { nightfox.PmenuSel = {
bg = "#73daca"; bg = "#73daca";
fg = "bg0"; fg = "bg0";
}; };
} }
``` ```
''; '';
}; };

View file

@ -260,18 +260,18 @@ lib.nixvim.plugins.mkNeovimPlugin {
The keys will be automatically translated to raw lua: The keys will be automatically translated to raw lua:
```nix ```nix
{ {
"vim.diagnostic.severity.INFO".enabled = true; "vim.diagnostic.severity.INFO".enabled = true;
"vim.diagnostic.severity.WARN".enabled = true; "vim.diagnostic.severity.WARN".enabled = true;
} }
``` ```
will result in the following lua: will result in the following lua:
```lua ```lua
{ {
-- Note the table keys are not string literals: -- Note the table keys are not string literals:
[vim.diagnostic.severity.INFO] = { ['enabled'] = true }, [vim.diagnostic.severity.INFO] = { ['enabled'] = true },
[vim.diagnostic.severity.WARN] = { ['enabled'] = true }, [vim.diagnostic.severity.WARN] = { ['enabled'] = true },
} }
``` ```
''; '';
}; };

View file

@ -15,34 +15,38 @@ lib.nixvim.plugins.mkNeovimPlugin {
For example: For example:
```nix ```nix
plugins.blink-cmp = { {
enable = true; plugins.blink-cmp = {
settings.sources.providers = { enable = true;
latex-symbols = { settings.sources.providers = {
module = "blink-cmp-latex"; latex-symbols = {
name = "Latex"; module = "blink-cmp-latex";
opts = { name = "Latex";
# set to true to insert the latex command instead of the symbol opts = {
insert_command = false # 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: And then you can add it to blink-cmp's `sources.default` option:
```nix ```nix
plugins.blink-cmp = { {
enable = true; plugins.blink-cmp = {
settings.sources.default = [ enable = true;
"lsp" settings.sources.default = [
"path" "lsp"
"luasnip" "path"
"buffer" "luasnip"
"latex-symbols" "buffer"
]; "latex-symbols"
}; ];
};
}
``` ```
''; '';

View file

@ -15,33 +15,37 @@ lib.nixvim.plugins.mkNeovimPlugin {
For example: For example:
```nix ```nix
plugins.blink-cmp = { {
enable = true; plugins.blink-cmp = {
settings.sources.providers = { enable = true;
spell = { settings.sources.providers = {
module = "blink-cmp-spell"; spell = {
name = "Spell"; module = "blink-cmp-spell";
score_offset = 100; name = "Spell";
opts = { score_offset = 100;
opts = {
};
}; };
}; };
}; };
}; }
``` ```
And then you can add it to blink-cmp's `sources.default` option: And then you can add it to blink-cmp's `sources.default` option:
```nix ```nix
plugins.blink-cmp = { {
enable = true; plugins.blink-cmp = {
settings.sources.default = [ enable = true;
"lsp" settings.sources.default = [
"path" "lsp"
"luasnip" "path"
"buffer" "luasnip"
"spell" "buffer"
]; "spell"
}; ];
};
}
``` ```
''; '';

View file

@ -19,43 +19,47 @@ lib.nixvim.plugins.mkNeovimPlugin {
For example: For example:
```nix ```nix
plugins.blink-cmp = { {
enable = true; plugins.blink-cmp = {
settings.sources.providers = { enable = true;
copilot = { settings.sources.providers = {
async = true; copilot = {
module = "blink-copilot"; async = true;
name = "copilot"; module = "blink-copilot";
score_offset = 100; name = "copilot";
# Optional configurations score_offset = 100;
opts = { # Optional configurations
max_completions = 3; opts = {
max_attempts = 4; max_completions = 3;
kind = "Copilot"; max_attempts = 4;
debounce = 750; kind = "Copilot";
auto_refresh = { debounce = 750;
backward = true; auto_refresh = {
forward = true; backward = true;
forward = true;
};
}; };
}; };
}; };
}; };
}; }
``` ```
And then you can add it to blink-cmp's `sources.default` option: And then you can add it to blink-cmp's `sources.default` option:
```nix ```nix
plugins.blink-cmp = { {
enable = true; plugins.blink-cmp = {
settings.sources.default = [ enable = true;
"lsp" settings.sources.default = [
"path" "lsp"
"luasnip" "path"
"buffer" "luasnip"
"copilot" "buffer"
]; "copilot"
}; ];
};
}
``` ```
''; '';

View file

@ -44,16 +44,18 @@ lib.nixvim.plugins.mkNeovimPlugin {
And then you can add it to blink-cmp's `sources.default` option: And then you can add it to blink-cmp's `sources.default` option:
```nix ```nix
plugins.blink-cmp = { {
enable = true; plugins.blink-cmp = {
settings.sources.default = [ enable = true;
"lsp" settings.sources.default = [
"path" "lsp"
"luasnip" "path"
"buffer" "luasnip"
"ripgrep" "buffer"
]; "ripgrep"
}; ];
};
}
``` ```
''; '';

View file

@ -16,6 +16,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
Hop doesnt set any keybindings; you will have to define them by yourself. Hop doesnt set any keybindings; you will have to define them by yourself.
If you want to create a key binding from within nixvim: If you want to create a key binding from within nixvim:
```nix ```nix
{
keymaps = [ keymaps = [
{ {
key = "f"; key = "f";
@ -68,6 +69,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
options.remap = true; options.remap = true;
} }
]; ];
}
``` ```
''; '';

View file

@ -302,12 +302,12 @@ lib.nixvim.plugins.mkNeovimPlugin {
For example, For example,
```nix ```nix
[ {} { paths = ./path/to/snippets; } ] [ {} { paths = ./path/to/snippets; } ]
``` ```
will generate the following lua: will generate the following lua:
```lua ```lua
require("luasnip.loaders.from_vscode").lazy_load({}) 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({['paths'] = {'/nix/store/.../path/to/snippets'}})
``` ```
''; '';
}; };

View file

@ -13,6 +13,7 @@ lib.nixvim.plugins.mkVimPlugin {
The `settings` option will not let you define the options starting with `sandwich#`. The `settings` option will not let you define the options starting with `sandwich#`.
For those, you can directly use the `globals` option: For those, you can directly use the `globals` option:
```nix ```nix
{
globals."sandwich#magicchar#f#patterns" = [ globals."sandwich#magicchar#f#patterns" = [
{ {
header.__raw = "[[\<\%(\h\k*\.\)*\h\k*]]"; header.__raw = "[[\<\%(\h\k*\.\)*\h\k*]]";
@ -21,6 +22,7 @@ lib.nixvim.plugins.mkVimPlugin {
footer = ""; footer = "";
} }
]; ];
}
``` ```
''; '';

View file

@ -39,28 +39,28 @@ in
Default: Default:
```nix ```nix
[ [
{ {
type = "files"; type = "files";
header = [" MRU"]; header = [" MRU"];
} }
{ {
type = "dir"; type = "dir";
header = [{__raw = "' MRU' .. vim.loop.cwd()";}]; header = [{__raw = "' MRU' .. vim.loop.cwd()";}];
} }
{ {
type = "sessions"; type = "sessions";
header = [" Sessions"]; header = [" Sessions"];
} }
{ {
type = "bookmarks"; type = "bookmarks";
header = [" Bookmarks"]; header = [" Bookmarks"];
} }
{ {
type = "commands"; type = "commands";
header = [" Commands"]; header = [" Commands"];
} }
] ]
``` ```
''; '';
}; };
@ -100,12 +100,12 @@ in
Example: Example:
```nix ```nix
[ [
":help reference" ":help reference"
["Vim Reference" "h ref"] ["Vim Reference" "h ref"]
{h = "h ref";} {h = "h ref";}
{m = ["My magical function" "call Magic()"];} {m = ["My magical function" "call Magic()"];}
] ]
``` ```
''; '';
@ -204,11 +204,11 @@ in
Example: Example:
```nix ```nix
[ [
"\.vimgolf" "\.vimgolf"
"^/tmp" "^/tmp"
"/project/.*/documentation" "/project/.*/documentation"
] ]
``` ```
''; '';
@ -261,7 +261,7 @@ in
Example: Example:
```nix ```nix
["setlocal" "winheight"] ["setlocal" "winheight"]
``` ```
Internally this simply does: Internally this simply does:
- `:global/setlocal/delete` - `:global/setlocal/delete`
@ -279,11 +279,11 @@ in
Example: Example:
```nix ```nix
[ [
"g:startify_session_savevars" "g:startify_session_savevars"
"g:startify_session_savecmds" "g:startify_session_savecmds"
"g:random_plugin_use_feature" "g:random_plugin_use_feature"
] ]
``` ```
''; '';
@ -292,9 +292,9 @@ in
Example: Example:
```nix ```nix
[ [
"silent !pdfreader ~/latexproject/main.pdf &" "silent !pdfreader ~/latexproject/main.pdf &"
] ]
``` ```
''; '';

View file

@ -40,6 +40,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
If you'd like more control, you could instead specify which packages to install. For example: If you'd like more control, you could instead specify which packages to install. For example:
```nix ```nix
{
plugins.treesitter = { plugins.treesitter = {
enable = true; enable = true;
@ -58,6 +59,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
yaml yaml
]; ];
}; };
}
``` ```
### Installing tree-sitter grammars from nvim-treesitter ### 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. or use the `plugins.treesitter.settings.ensure_installed` option to specify grammars you want the plugin to fetch and install.
```nix ```nix
{
plugins.treesitter = { plugins.treesitter = {
enable = true; 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`. NOTE: You can combine the functionality of `plugins.treesitter.nixGrammars` and `plugins.treesitter.settings.ensure_installed`.

View file

@ -28,32 +28,35 @@ lib.nixvim.plugins.mkNeovimPlugin {
#### With auto-enabled sources #### With auto-enabled sources
```nix ```nix
plugins.cmp = { {
autoEnableSources = true; plugins.cmp = {
settings.sources = [ autoEnableSources = true;
{ name = "nvim_lsp"; }
{ name = "path"; }
{ name = "buffer"; }
];
};
```
#### Without auto-enabled sources
```nix
plugins = {
cmp = {
autoEnableSources = false;
settings.sources = [ settings.sources = [
{ name = "nvim_lsp"; } { name = "nvim_lsp"; }
{ name = "path"; } { name = "path"; }
{ name = "buffer"; } { 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;
};
}
``` ```
''; '';

View file

@ -41,6 +41,7 @@ let
if you don't want to see `buffer` source items while `nvim-lsp` source is available: if you don't want to see `buffer` source items while `nvim-lsp` source is available:
```nix ```nix
{
sources = [ sources = [
{ {
name = "nvim_lsp"; name = "nvim_lsp";
@ -51,6 +52,7 @@ let
group_index = 2; group_index = 2;
} }
]; ];
}
``` ```
''; '';

View file

@ -108,7 +108,6 @@ in
type = with types; listOf (maybeRaw str); type = with types; listOf (maybeRaw str);
pluginDefault = { }; pluginDefault = { };
example = { example = {
"<LANGUAGE1>" = [ "<LANGUAGE1>" = [
"<WORD1>" "<WORD1>"
"<WORD2>" "<WORD2>"
@ -122,9 +121,9 @@ in
Lists of additional words that should not be counted as spelling errors. Lists of additional words that should not be counted as spelling errors.
This setting is language-specific, so use an attrs of the format This setting is language-specific, so use an attrs of the format
```nix ```nix
{ {
... ...
}; };
``` ```
where <LANGUAGE> denotes the language code in `settings.language`. where <LANGUAGE> 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). 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 This setting is language-specific, so use an attrs of the format
```nix ```nix
{ {
"<LANGUAGE1>" = [ "<LANGUAGE1>" = [
"<WORD1>" "<WORD1>"
"<WORD2>" "<WORD2>"
...
];
"<LANGUAGE2>" = [
"<WORD1>"
"<WORD2>"
];
... ...
}; ];
"<LANGUAGE2>" = [
"<WORD1>"
"<WORD2>"
];
...
};
``` ```
where `<LANGUAGE>` denotes the language code in `settings.language` and `<RULE>` the ID of where `<LANGUAGE>` denotes the language code in `settings.language` and `<RULE>` the ID of
the LanguageTool rule. the LanguageTool rule.
@ -184,18 +183,18 @@ in
Lists of rules that should be enabled (if disabled by default by LanguageTool). 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 This setting is language-specific, so use an attrs of the format
```nix ```nix
{ {
"<LANGUAGE1>" = [ "<LANGUAGE1>" = [
"<WORD1>" "<WORD1>"
"<WORD2>" "<WORD2>"
...
];
"<LANGUAGE2>" = [
"<WORD1>"
"<WORD2>"
];
... ...
}; ];
"<LANGUAGE2>" = [
"<WORD1>"
"<WORD2>"
];
...
};
``` ```
where `<LANGUAGE>` denotes the language code in `settings.language` and `<RULE>` the ID of where `<LANGUAGE>` denotes the language code in `settings.language` and `<RULE>` the ID of
the LanguageTool rule. the LanguageTool rule.
@ -217,18 +216,18 @@ in
within a specific sentence). within a specific sentence).
This setting is language-specific, so use an attrs of the format This setting is language-specific, so use an attrs of the format
```nix ```nix
{ {
"<LANGUAGE1>" = [ "<LANGUAGE1>" = [
"<JSON1>" "<JSON1>"
"<JSON2>" "<JSON2>"
...
];
"<LANGUAGE2>" = [
"<JSON1>"
"<JSON2>"
];
... ...
}; ];
"<LANGUAGE2>" = [
"<JSON1>"
"<JSON2>"
];
...
};
``` ```
where `<LANGUAGE>` denotes the language code in `settings.language` and `<JSON>` is a JSON where `<LANGUAGE>` denotes the language code in `settings.language` and `<JSON>` is a JSON
string containing information about the rule and sentence. string containing information about the rule and sentence.