docs: clarify wording; add examples and remove redundancies

This commit is contained in:
raf 2025-05-05 14:57:32 +03:00
commit f1d72cf076
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
15 changed files with 262 additions and 90 deletions

View file

@ -1,13 +1,20 @@
# Configuring {#sec-configuring-plugins}
Just making the plugin to your Neovim configuration available might not always
be enough. In that case, you can write custom lua config using either
`config.vim.lazy.plugins.*.setupOpts` `config.vim.extraPlugins.*.setup` or
`config.vim.luaConfigRC`.
be enough., for example, if the plugin requires a setup table. In that case, you
can write custom Lua configuration using one of
The first option uses an extended version of `lz.n`'s PluginSpec. `setupModule`
and `setupOpt` can be used if the plugin uses a `require('module').setup(...)`
pattern. Otherwise, the `before` and `after` hooks should do what you need.
- `config.vim.lazy.plugins.*.setupOpts`
- `config.vim.extraPlugins.*.setup`
- `config.vim.luaConfigRC`.
## Lazy Plugins {#ch-vim-lazy-plugins}
`config.vim.lazy.plugins.*.setupOpts` is useful for lazy-loading plugins, and
uses an extended version of `lz.n's` `PluginSpec` to expose a familiar
interface. `setupModule` and `setupOpt` can be used if the plugin uses a
`require('module').setup(...)` pattern. Otherwise, the `before` and `after`
hooks should do what you need.
```nix
{
@ -25,7 +32,9 @@ pattern. Otherwise, the `before` and `after` hooks should do what you need.
}
```
The second option uses an attribute set, which maps DAG section names to a
## Standard API {#ch-vim-extra-plugins}
`vim.extraPlugins` uses an attribute set, which maps DAG section names to a
custom type, which has the fields `package`, `after`, `setup`. They allow you to
set the package of the plugin, the sections its setup code should be after (note
that the `extraPlugins` option has its own DAG scope), and the its setup code
@ -48,29 +57,36 @@ respectively. For example:
}
```
The third option also uses an attribute set, but this one is resolved as a DAG
### Setup using luaConfigRC {#setup-using-luaconfigrc}
`vim.luaConfigRC` also uses an attribute set, but this one is resolved as a DAG
directly. The attribute names denote the section names, and the values lua code.
For example:
```nix
{
# this will create an "aquarium" section in your init.lua with the contents of your custom config
# which will be *appended* to the rest of your configuration, inside your init.vim
# This will create a section called "aquarium" in the 'init.lua' with the
# contents of your custom configuration. By default 'entryAnywhere' is implied
# in DAGs, so this will be inserted to an arbitrary position. In the case you
# wish to control the position of this section with more precision, please
# look into the DAGs section of the manual.
config.vim.luaConfigRC.aquarium = "vim.cmd('colorscheme aquiarum')";
}
```
<!-- deno-fmt-ignore-start -->
[DAG system]: #ch-using-dags
[DAG section]: #ch-dag-entries
::: {.note}
One of the greatest strengths of nvf is the ability to order
snippets of configuration via the DAG system. It will allow specifying positions
of individual sections of configuration as needed. nvf provides helper functions
One of the **greatest strengths** of **nvf** is the ability to order
configuration snippets precisely using the [DAG system]. DAGs
are a very powerful mechanism that allows specifying positions
of individual sections of configuration as needed. We provide helper functions
in the extended library, usually under `inputs.nvf.lib.nvim.dag` that you may
use.
Please refer to the [DAG section](#ch-dag-entries) in the nvf manual
Please refer to the [DAG section] in the nvf manual
to find out more about the DAG system.
:::
<!-- deno-fmt-ignore-end -->