1
0
Fork 0
mirror of https://github.com/nix-community/nixvim.git synced 2025-12-16 22:11:09 +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:
```nix
{
base03.__raw = "base16.colorschemes['catppuccin'].base06";
}
```
[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:
```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.

View file

@ -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";
}
```
'';
};

View file

@ -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";
};
}
```
'';
};

View file

@ -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 },
}
```
'';
};

View file

@ -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"
];
};
}
```
'';

View file

@ -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"
];
};
}
```
'';

View file

@ -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"
];
};
}
```
'';

View file

@ -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"
];
};
}
```
'';

View file

@ -16,6 +16,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
Hop doesnt 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;
}
];
}
```
'';

View file

@ -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'}})
```
'';
};

View file

@ -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 = "";
}
];
}
```
'';

View file

@ -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 &"
]
```
'';

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:
```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`.

View file

@ -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;
};
}
```
'';

View file

@ -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;
}
];
}
```
'';

View file

@ -108,7 +108,6 @@ in
type = with types; listOf (maybeRaw str);
pluginDefault = { };
example = {
"<LANGUAGE1>" = [
"<WORD1>"
"<WORD2>"
@ -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 <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).
This setting is language-specific, so use an attrs of the format
```nix
{
"<LANGUAGE1>" = [
"<WORD1>"
"<WORD2>"
...
];
"<LANGUAGE2>" = [
"<WORD1>"
"<WORD2>"
];
{
"<LANGUAGE1>" = [
"<WORD1>"
"<WORD2>"
...
};
];
"<LANGUAGE2>" = [
"<WORD1>"
"<WORD2>"
];
...
};
```
where `<LANGUAGE>` denotes the language code in `settings.language` and `<RULE>` 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
{
"<LANGUAGE1>" = [
"<WORD1>"
"<WORD2>"
...
];
"<LANGUAGE2>" = [
"<WORD1>"
"<WORD2>"
];
{
"<LANGUAGE1>" = [
"<WORD1>"
"<WORD2>"
...
};
];
"<LANGUAGE2>" = [
"<WORD1>"
"<WORD2>"
];
...
};
```
where `<LANGUAGE>` denotes the language code in `settings.language` and `<RULE>` 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
{
"<LANGUAGE1>" = [
"<JSON1>"
"<JSON2>"
...
];
"<LANGUAGE2>" = [
"<JSON1>"
"<JSON2>"
];
{
"<LANGUAGE1>" = [
"<JSON1>"
"<JSON2>"
...
};
];
"<LANGUAGE2>" = [
"<JSON1>"
"<JSON2>"
];
...
};
```
where `<LANGUAGE>` denotes the language code in `settings.language` and `<JSON>` is a JSON
string containing information about the rule and sentence.