Home Explore Blog Models CI



nixpkgs

3rd chunk of `doc/languages-frameworks/vim.section.md`
c89b85f391be81fcad608f61b0d31967b1f98454e919475d0000000100000dfb
Some plugins require overrides in order to function properly. Overrides are placed in [overrides.nix](https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/editors/vim/plugins/overrides.nix). Overrides are most often required when a plugin requires some dependencies, or extra steps are required during the build process. For example `deoplete-fish` requires both `deoplete-nvim` and `vim-fish`, and so the following override was added:

```nix
{
  deoplete-fish = super.deoplete-fish.overrideAttrs (old: {
    dependencies = with super; [
      deoplete-nvim
      vim-fish
    ];
  });
}
```

Sometimes plugins require an override that must be changed when the plugin is updated. This can cause issues when Vim plugins are auto-updated but the associated override isn't updated. For these plugins, the override should be written so that it specifies all information required to install the plugin, and running `nix-shell -p vimPluginsUpdater --run vim-plugins-updater` doesn't change the derivation for the plugin. Manually updating the override is required to update these types of plugins. An example of such a plugin is `LanguageClient-neovim`.

To add a new plugin, run `nix-shell -p vimPluginsUpdater --run 'vim-plugins-updater add "[owner]/[name]"'`. **NOTE**: This script automatically commits to your git repository. Be sure to check out a fresh branch before running.

Finally, there are some plugins that are also packaged in nodePackages because they have Javascript-related build steps, such as running webpack. Those plugins are not listed in `vim-plugin-names` or managed by `vimPluginsUpdater` at all, and are included separately in `overrides.nix`. Currently, all these plugins are related to the `coc.nvim` ecosystem of the Language Server Protocol integration with Vim/Neovim.

## Updating plugins in nixpkgs {#updating-plugins-in-nixpkgs}

Run the update script with a GitHub API token that has at least `public_repo` access. Running the script without the token is likely to result in rate-limiting (429 errors). For steps on creating an API token, please refer to [GitHub's token documentation](https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token).

```sh
nix-shell -p vimPluginsUpdater --run 'vim-plugins-updater --github-token=mytoken' # or set GITHUB_TOKEN environment variable
```

Alternatively, set the number of processes to a lower count to avoid rate-limiting.

```sh
nix-shell -p vimPluginsUpdater --run 'vim-plugins-updater --proc 1'
```

To update only specific plugins, list them after the `update` command:

```sh
nix-shell -p vimPluginsUpdater --run 'vim-plugins-updater update "nvim-treesitter" "mini.nvim" "mini-nvim"'
```

The updater script accepts plugin arguments in different formats:

- `"mini.nvim"` := The GitHub repository name, the raw plugin name, or the alias defined in `vim-plugin-names`.
- `"mini-nvim"` := The normalized plugin name, which matches the attribute name generated in `generated.nix`

## How to maintain an out-of-tree overlay of vim plugins? {#vim-out-of-tree-overlays}

You can use the updater script to generate basic packages out of a custom vim
plugin list:

```
nix-shell -p vimPluginsUpdater --run vim-plugins-updater -i vim-plugin-names -o generated.nix --no-commit
```

with the contents of `vim-plugin-names` being for example:

```
repo,branch,alias
pwntester/octo.nvim,,
```

You can then reference the generated vim plugins via:

```nix
{
  myVimPlugins = pkgs.vimPlugins.extend ((pkgs.callPackage ./generated.nix { }));
}
```


Title: Nixpkgs Vim Plugin Management: Overrides, Additions, Updates, and Out-of-Tree Overlays
Summary
This document details how to manage Vim plugins within Nixpkgs, focusing on overrides, adding new plugins, updating existing ones, and creating out-of-tree overlays. Overrides, stored in `overrides.nix`, are crucial for plugins requiring dependencies or special build steps, with some needing manual updates. New plugins can be added using the `vim-plugins-updater` script, which automatically commits changes. Plugins with JavaScript-related build steps (like those in the `coc.nvim` ecosystem) are managed separately in `overrides.nix`. To update plugins, the `vim-plugins-updater` script should be run with a GitHub API token to avoid rate-limiting, or with a lower process count. The script supports updating all plugins or specific ones by name, accepting various naming formats. Finally, it explains how to maintain out-of-tree overlays of Vim plugins by using the updater script to generate packages from a custom plugin list.