| name | add-nixvim-plugin |
| description | Add Neovim plugins not available in NixVim's official plugin set using extraPlugins and extraConfigLua. Use this skill when the user requests adding a plugin by GitHub URL or mentions a plugin that doesn't exist as a native NixVim module. |
Add NixVim Plugin
Overview
Add custom Neovim plugins to NixVim using extraPlugins when the plugin isn't available in NixVim's official plugin set. This skill guides through fetching plugin information, creating configuration files, and maintaining consistency with the existing plugin structure.
When to Use This Skill
Use this skill when:
- User provides a GitHub URL for a Neovim plugin
- User requests a plugin that doesn't have a native NixVim module (e.g.,
plugins.plugin-name) - User asks how to add plugins not in NixVim
Do NOT use this skill when:
- The plugin already has native NixVim support (use the standard
plugins.plugin-nameconfiguration) - User is asking about configuring an already-added plugin
Workflow
Step 1: Gather Plugin Information
Fetch information about the plugin from its GitHub repository:
- Use WebFetch to visit the plugin's GitHub URL
- Extract:
- Plugin purpose and key features
- Default configuration structure
- Any setup requirements
- Latest stable commit hash or release tag
Step 2: Determine Plugin Category
Identify the appropriate subdirectory in config/plugins/:
ui/- UI enhancements, windows, buffersediting/- Text editing, manipulationlsp/- Language server relatednavigation/- Movement, jumpinggit/- Git integrationfiles/- File managementcompletion/- Completion enginessearch/- Search and replaceterminal/- Terminal integrationworkflow/- Productivity, helperstesting/- Test frameworksstatusline/- Status line pluginstreesitter/- Treesitter relatedsnippets/- Snippet enginesai/- AI assistantslangs/- Language-specific
Step 3: Create Plugin Configuration File
Create config/plugins/<category>/<plugin-name>.nix with this structure:
# ABOUTME: [Brief description of what the plugin does]
# ABOUTME: [Secondary description line if needed]
{pkgs, ...}: {
extraPlugins = [
(pkgs.vimUtils.buildVimPlugin {
name = "plugin-name";
src = pkgs.fetchFromGitHub {
owner = "github-username";
repo = "repo-name";
rev = "commit-hash-or-tag";
sha256 = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="; # Use fake hash initially
};
})
];
extraConfigLua = ''
require("plugin-name").setup({
-- Start with minimal default configuration
-- Add essential settings only
})
'';
keymaps = [
{
mode = "n";
key = "<leader>xy";
action = "<cmd>PluginCommand<CR>";
options = {
desc = "Brief description";
silent = true;
};
}
];
}
Important notes:
- Start with fake SHA256 hash - Nix will provide correct hash on first build
- Follow existing keymap groups (
<leader>f= file,<leader>u= UI,<leader>w= window, etc.) - Keep initial configuration minimal - add incrementally as needed
- Include ABOUTME comments at the top of the file
Step 4: Update default.nix
Add the new plugin file to config/default.nix imports in the appropriate section:
{
imports = [
# ... other imports
./plugins/<category>/<plugin-name>.nix
];
}
Maintain alphabetical or logical ordering within each section.
Step 5: Update Documentation
Update three locations to document the new plugin:
5a. Update recent_plugins in config/options.nix
Add entry at the TOP of the recent_plugins table (around line 96):
{
name = "plugin-name",
date = "YYYY-MM-DD", -- Today's date
description = "Brief description of functionality",
keymaps = {
"<leader>xy = Action Description",
-- additional keymaps
},
usage = "How to use the plugin, key features"
},
5b. Add whichkey entries in config/plugins/workflow/whichkey.nix
Add entries to the spec array for each keymap:
{
"__unkeyed-1" = "<leader>xy";
desc = "Action Description";
icon = {
icon = ""; # Choose appropriate Nerd Font icon
color = "blue"; # Choose appropriate color
};
}
Icon colors available: blue, yellow, orange, cyan, purple, green, red, azure
5c. Update WISHLIST.md (if applicable)
If the plugin was on the wishlist, mark it as completed or remove the entry.
Step 6: Build and Test
- Stage files:
git add .(required for Nix flakes) - Build:
nix buildorjust build - If SHA256 hash error occurs:
- Copy correct hash from error message
- Update the config file with correct hash
- Build again
- Test:
nix run .orjust run
Step 7: Lazy Loading (Optional)
If the plugin should be lazy-loaded to improve startup time:
- Read
references/lazy-loading.mdfor detailed patterns - Modify the plugin configuration to use lz.n
- Test that the plugin loads correctly when triggered
Common lazy-loading scenarios:
- Load on command:
cmd = "CommandName" - Load on keypress:
keys = "<leader>key" - Load on event:
event = "BufEnter" - Load on filetype:
ft = "python"
Troubleshooting
Build fails with "file not found"
- Ensure
git add .was run before building - Nix flakes only see tracked files
Wrong SHA256 hash error
- Expected on first build
- Copy correct hash from error message
- Update config file and rebuild
Plugin not loading
- Check plugin is imported in
config/default.nix - Verify
extraConfigLuahas no syntax errors - Ensure plugin name matches exactly (case-sensitive)
Formatter changes files
- Pre-commit hooks with alejandra automatically format Nix files
- This is expected behavior
Resources
See references/lazy-loading.md for detailed lazy loading configuration patterns.