2024-04-20 03:57:11 +00:00
|
|
|
# Configuring {#sec-configuring-plugins}
|
2023-12-09 19:03:58 +00:00
|
|
|
|
2024-11-04 15:50:50 +00:00
|
|
|
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`.
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
```nix
|
|
|
|
{
|
|
|
|
config.vim.lazy.plugins = {
|
2024-11-10 18:57:55 +00:00
|
|
|
aerial.nvim = {
|
2024-11-10 19:48:43 +00:00
|
|
|
# ^^^^^^^^^ this name should match the package.pname or package.name
|
2024-11-04 15:50:50 +00:00
|
|
|
package = aerial-nvim;
|
|
|
|
|
|
|
|
setupModule = "aerial";
|
|
|
|
setupOpts = {option_name = false;};
|
|
|
|
|
|
|
|
after = "print('aerial loaded')";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
The second option 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
|
2024-07-20 08:30:48 +00:00
|
|
|
scope), and the its setup code respectively. For example:
|
|
|
|
|
|
|
|
```nix
|
|
|
|
config.vim.extraPlugins = with pkgs.vimPlugins; {
|
|
|
|
aerial = {
|
|
|
|
package = aerial-nvim;
|
|
|
|
setup = "require('aerial').setup {}";
|
|
|
|
};
|
|
|
|
|
|
|
|
harpoon = {
|
|
|
|
package = harpoon;
|
|
|
|
setup = "require('harpoon').setup {}";
|
|
|
|
after = ["aerial"]; # place harpoon configuration after aerial
|
|
|
|
};
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2024-11-04 15:50:50 +00:00
|
|
|
The third option also uses an attribute set, but this one is resolved as a DAG
|
2024-07-20 08:30:48 +00:00
|
|
|
directly. The attribute names denote the section names, and the values lua code.
|
|
|
|
For example:
|
2023-12-09 19:03:58 +00:00
|
|
|
|
|
|
|
```nix
|
|
|
|
{
|
2024-07-20 08:30:48 +00:00
|
|
|
# this will create an "aquarium" section in your init.lua with the contents of your custom config
|
2023-12-09 19:03:58 +00:00
|
|
|
# which will be *appended* to the rest of your configuration, inside your init.vim
|
2024-07-20 08:30:48 +00:00
|
|
|
config.vim.luaConfigRC.aquarium = "vim.cmd('colorscheme aquiarum')";
|
2023-12-09 19:03:58 +00:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
:::{.note}
|
2024-04-27 12:44:37 +00:00
|
|
|
If your configuration needs to be put in a specific place in the config, you
|
|
|
|
can use functions from `inputs.nvf.lib.nvim.dag` to order it. Refer to
|
|
|
|
https://github.com/nix-community/home-manager/blob/master/modules/lib/dag.nix
|
|
|
|
to find out more about the DAG system.
|
2023-12-09 19:03:58 +00:00
|
|
|
:::
|
|
|
|
|
2024-04-27 12:44:37 +00:00
|
|
|
If you successfully made your plugin work, please feel free to create a PR to
|
|
|
|
add it to **nvf** or open an issue with your findings so that we can make it
|
|
|
|
available for everyone easily.
|