Guidance for coding agents working in this repository.
- This repo is a Nix flake that builds a Nixvim (Neovim) configuration.
- Primary languages are
NixandLua. - Flake entry point is
flake.nix. - Main module trees are
config/,options/,lib/,lua/,overlays/, andmodules/.
- No
.cursor/rules/,.cursorrules, or.github/copilot-instructions.mdfiles were found in this repo. - If those files are added later, treat them as additional constraints and merge them into this guide.
- Preferred environment is
nix develop. - One-off command execution uses
nix develop -c <cmd>. - Dev shell tools (from
shell.nix):nil,statix,nixfmt,stylua,prettier. - Supported flake systems are
x86_64-linuxandaarch64-linux.
- Build default package:
nix build .#default. - Build explicit system package:
nix build .#packages.x86_64-linux.default. - Show available outputs:
nix flake show. - Build home-manager module consumers through downstream HM config (not directly from this flake).
- Run Neovim app:
nix run .#nvim. - Print generated
init.lua:nix run .#nixvim-print-init.
- Nix lint (all):
nix develop -c statix check .. - Nix lint (single file):
nix develop -c statix check config/tools/telescope.nix. - Nix format (all):
nix develop -c nixfmt .. - Nix format check (single file):
nix develop -c nixfmt --check flake.nix. - Lua format (all):
nix develop -c stylua .. - Lua format check (single file):
nix develop -c stylua --check lua/utils/root.lua. - Prettier check:
nix develop -c prettier --check .. - Prettier write:
nix develop -c prettier --write ..
- Canonical validation:
nix flake check. - All systems:
nix flake check --all-systems. - Checks are defined in
flake/checks.nixand include:checks.<system>.nvimBuildchecks.<system>.nvimStartup(headless startup smoke test)checks.<system>.nixfmtchecks.<system>.prettierchecks.<system>.statixchecks.<system>.stylua
- There is no unit-test runner with named tests.
- The closest equivalent to "run one test" is building one check attribute.
- Run one startup smoke check:
nix build .#checks.x86_64-linux.nvimStartup. - Run one formatting/lint check:
nix build .#checks.x86_64-linux.stylua(orstatix,nixfmt,prettier). - Run one output build:
nix build .#packages.x86_64-linux.default. - For tight iteration, run single-file checks (
statix,nixfmt --check,stylua --check) before full flake checks.
config/default.nixauto-imports all*.nixfiles underconfig/except itself.options/default.nixauto-imports all*.nixfiles underoptions/except itself.config/default.nixexports Lua files fromlua/viaextraFiles.- Files prefixed with
_are intentionally excluded by auto-loading logic. - Add new modules as standalone files in existing trees; avoid manual import wiring unless pattern changes.
- Use 2-space indentation and keep lines near 120 chars.
- Prefer explicit attr sets with trailing semicolons.
- Keep function arg sets multiline and stable (commonly
{ config, lib, lib', pkgs, ... }:). - Keep
let ... inblocks focused and short. - Prefer
lib.mkIf/lib.mkMergeover ad-hoc branching. - Prefer deterministic ordering for attrs and lists (alphabetic or conceptual groups).
- Reuse
lib'namespaces before adding duplicated helpers. - Use
__rawplus/* lua */ '' ... ''when embedding Lua callbacks in Nix. - Follow existing plugin patterns under
plugins.<name>.
- Formatting is governed by
.stylua.toml: 2 spaces, width 120, auto-prefer single quotes. - Use module pattern
local M = {}...return M. - Keep
require(...)at top-level unless lazy-loading is intentional. - Use
utils.lazy_require(...)for deferred optional modules. - Keep functions focused; avoid deep nesting when possible.
- Add EmmyLua annotations for non-trivial APIs (
--- @param,--- @return,--- @class,--- @alias).
- Nix imports should be relative and composable.
- In embedded Lua from Nix config, prefer global
Utils.<module>provided byconfig/luaset.nix. - In Lua modules, use
require('utils')family consistently. - Avoid hard-coding plugin internals when helper wrappers already exist.
- Prefer typed options with
lib.mkOptionandlib.types.*in Nix modules. - For plugin options, follow patterns used in
options/plugins/. - Preserve explicit normalization/conversion paths (for example root and LSP helpers).
- In Lua, guard optional values (
nilchecks) before field access.
- Nix filenames use kebab-case (example:
render-markdown.nix). - Lua filenames use snake_case (example:
quick_settings.lua). - Lua module table is typically
M. - Nix option and attr names use lowerCamelCase when ecosystem conventions expect it.
- Keymap descriptions (
desc) should be title case and action-oriented.
- Use
pcall(require, ...)for optional dependencies. - Fail fast in Nix helpers with
throwon invalid inputs. - Surface user-facing Lua errors via
vim.notify(..., vim.log.levels.ERROR, ...). - Keep fallbacks explicit (for example fallback to CWD in root detection).
- Keep lazy-loading infra in
config/core/lz-n.nix. - Default to lazy-loading when low-risk and behavior-preserving.
- Preferred triggers:
cmdfor command tools,ftfor filetype plugins,eventfor deferred startup. - Ensure keymaps, setup hooks, and plugin integrations still work after lazy-loading.
- Add
pcall(require, ...)guards when code may run before plugin load.
- Use Conventional Commit style seen in history (
feat(...),fix(...),refactor(...),docs(...)). - For
lua/changes, scope commits by feature area, not genericutilswhen possible. - Example scope pattern:
feat(tools/oil): ....
- Scan related files before editing; follow local patterns over personal preference.
- Prefer small, surgical changes.
- Run targeted checks first, then broader checks.
- Do not edit
flake.lockunless dependency updates are intentional. - Avoid adding new tooling unless clearly required.
nix flake check --all-systems