|
1 | 1 | # Repository Guidelines |
2 | 2 |
|
3 | 3 | ## Project Structure & Module Organization |
4 | | -Core Lua modules live in `lua/gitsigns/` (config, handlers, utilities) and should stay pure so specs can require them directly. |
5 | | -User-facing commands and autocmds are wired in `plugin/gitsigns.vim`, while help files under `doc/` get regenerated by `gen_help.lua`. |
6 | | -Specs plus fixtures sit in `test/`, relying on helpers in `test/gs_helpers.lua`. |
7 | | -Tooling binaries (Stylua, nvim-test, EmmyLua) are cached in `deps/`. |
| 4 | +- Core Lua modules live in `lua/gitsigns/` (config, handlers, utilities). |
| 5 | +- User-facing commands are wired in `plugin/gitsigns.vim` |
| 6 | +- Help files under `doc/` get regenerated by `gen_help.lua`. |
| 7 | +- Specs plus fixtures sit in `test/`, relying on helpers in `test/gs_helpers.lua`. |
| 8 | +- Tooling binaries (Stylua, nvim-test, EmmyLua) are cached in `deps/`. |
8 | 9 |
|
9 | 10 | ## Build, Test, and Development Commands |
10 | 11 | - `make build`: run Stylua over `lua/` + `test/`, then regenerate help files before committing. |
11 | 12 | - `make test [FILTER=pattern]`: execute the functional suite via nvim-test with the default Neovim runner. |
12 | 13 | - `make test-010`, `make test-011`, `make test-nightly`: confirm compatibility with multiple Neovim versions. |
13 | 14 | - `make doc` / `make doc-check`: regenerate help from `lua/gitsigns/config.lua` and fail if docs drift. |
14 | | -- `make stylua-check` or `make stylua-run`: lint or autoformat Lua sources. |
| 15 | +- `make format-check` or `make format`: lint or autoformat Lua sources. |
15 | 16 | - `make emmylua-check`: run optional static analysis after fetching the analyzer. |
16 | 17 |
|
17 | 18 | ## Coding Style & Naming Conventions |
18 | | -Stylua enforces 2-space indentation, 100-character columns, Unix line endings, and `auto_prefer_single` quotes (`.stylua.toml`). |
19 | | -Public modules export tables named after their file (e.g., `require('gitsigns.diff')`); local helpers stay snake_case. |
20 | | -Keep API naming aligned with existing commands (`setup`, `attach`, `preview_hunk`) and prefer keyed tables over positional args. |
21 | | -Wrap Neovim APIs in utility functions when tests need to mock them, and run `make stylua-run` before pushing. |
| 19 | +- Lua code must have emmylua/LuaCATS type annotations |
| 20 | +- 2-space indentation, 100-character columns, single quotes for strings. |
| 21 | +- Run `make format` after changing any code |
22 | 22 |
|
23 | 23 | ## Testing Guidelines |
24 | | -Specs reside in `test/*_spec.lua` and run under the `nvim-test` harness, which provisions a headless Neovim plus RPC helpers. |
25 | | -Every bug fix must include a spec that reproduces the regression and asserts the desired buffer state, co-located with related modules (for example, `hunk_spec.lua` for hunk logic). |
26 | | -Use `test/gs_helpers.lua` utilities instead of shelling out to Git, and reset repo fixtures between assertions. |
27 | | -Keep tests deterministic by guarding optional Git features and running the version matrix (`make test-010 && make test-nightly`) when Neovim internals are touched. |
| 24 | +- Every bug fix must include a spec that reproduces the regression and asserts the desired buffer state, co-located with related modules (for example, `hunk_spec.lua` for hunk logic). |
| 25 | +- Keep tests deterministic by guarding optional Git features and running the version matrix (`make test-010 && make test-nightly`) when Neovim internals are touched. |
28 | 26 |
|
29 | 27 | ## Commit & Pull Request Guidelines |
30 | | -History follows a lightweight Conventional Commit style: `<type>(<scope>): <verb phrase>` (for instance, `fix(blame): close blame window on bufhidden`), so match that pattern and keep subjects under 72 characters. |
31 | | -Each PR should recap the bug, list manual or automated verification, link upstream issues, and mention doc help updates when behavior changes. |
32 | | -Ensure `make build`, the relevant `make test-*`, and `make doc-check` all pass locally. |
| 28 | +- History follows a Conventional Commit style: `<type>(<scope>): <verb phrase>` (for instance, `fix(blame): close blame window on bufhidden`), so match that pattern and keep subjects under 72 characters. |
| 29 | +- Ensure `make build`, the relevant `make test-*`, and `make doc-check` all pass locally. |
0 commit comments