2014-02-24 16:32:15 -07:00
# Contributing to Neovim
2016-08-09 21:47:04 -07:00
Getting started
---------------
2014-02-24 16:32:15 -07:00
2016-08-09 21:47:04 -07:00
If you want to help but don't know where to start, here are some
low-risk/isolated tasks:
2015-03-09 16:20:15 -07:00
2017-06-06 06:02:51 -07:00
- [Merge a Vim patch].
2016-08-09 21:47:04 -07:00
- Try a [complexity:low] issue.
2019-01-08 11:58:06 -07:00
- Fix bugs found by [Clang ](#clang-scan-build ), [PVS ](#pvs-studio ) or
[Coverity ](#coverity ).
2017-04-17 14:52:38 -07:00
Developer guidelines
--------------------
2019-01-08 11:58:06 -07:00
- Nvim contributors should read `:help dev` .
2017-04-17 14:52:38 -07:00
- External UI developers should read `:help dev-ui` .
2017-12-27 11:30:23 -07:00
- API client developers should read `:help dev-api-client` .
- Nvim developers are _strongly encouraged_ to install `ninja` for faster builds.
```
sudo apt-get install ninja-build
make distclean
make # Nvim build system uses ninja automatically, if available.
```
2016-08-09 21:47:04 -07:00
Reporting problems
------------------
2015-03-09 16:20:15 -07:00
2019-01-08 11:58:06 -07:00
- [Check the FAQ][wiki-faq].
- [Search existing issues][github-issues] (including closed!)
2016-06-03 12:05:44 -07:00
- Update Neovim to the latest version to see if your problem persists.
2017-06-06 06:02:51 -07:00
- Disable plugins incrementally, to narrow down the cause of the issue.
2017-11-14 02:47:49 -07:00
- When reporting a crash, [include a stacktrace ](https://github.com/neovim/neovim/wiki/Development-tips#backtrace-linux ).
2017-06-06 06:02:51 -07:00
- [Bisect][git-bisect] to the cause of a regression, if you are able. This is _extremely_ helpful.
- Check `$NVIM_LOG_FILE` , if it exists.
2019-01-08 11:58:06 -07:00
- Include `cmake --system-information` for build-related issues.
2016-06-03 12:05:44 -07:00
2016-08-09 21:47:04 -07:00
Pull requests ("PRs")
---------------------
2016-06-03 12:05:44 -07:00
2017-04-17 14:52:38 -07:00
- To avoid duplicate work, create a `[WIP]` pull request as soon as possible.
2017-06-06 06:02:51 -07:00
- Avoid cosmetic changes to unrelated files in the same commit.
2016-06-03 12:05:44 -07:00
- Use a [feature branch][git-feature-branch] instead of the master branch.
2017-04-17 14:52:38 -07:00
- Use a **rebase workflow** for small PRs.
- After addressing review comments, it's fine to rebase and force-push.
- Use a **merge workflow** for big, high-risk PRs.
- Merge `master` into your PR when there are conflicts or when master
introduces breaking changes.
- Use the `ri` git alias:
```
[alias]
2017-05-08 11:28:41 -07:00
ri = "!sh -c 't=\"${1:-master}\"; s=\"${2:-HEAD}\"; mb=\"$(git merge-base \"$t\" \"$s\")\"; if test \"x$mb\" = x ; then o=\"$t\"; else lm=\"$(git log -n1 --merges \"$t..$s\" --pretty=%H)\"; if test \"x$lm\" = x ; then o=\"$mb\"; else o=\"$lm\"; fi; fi; test $# -gt 0 && shift; test $# -gt 0 && shift; git rebase --interactive \"$o\" \"$@\"'"
2017-04-17 14:52:38 -07:00
```
2017-04-06 15:31:39 -07:00
This avoids unnecessary rebases yet still allows you to combine related
commits, separate monolithic commits, etc.
2017-04-17 14:52:38 -07:00
- Do not edit commits that come before the merge commit.
- During a squash/fixup, use `exec make -C build unittest` between each
pick/edit/reword.
2015-04-21 14:35:06 -07:00
2016-08-23 20:49:09 -07:00
### Stages: WIP, RFC, RDY
2015-04-21 14:35:06 -07:00
2016-08-23 20:49:09 -07:00
Pull requests have three stages: `[WIP]` (Work In Progress), `[RFC]` (Request
For Comment) and `[RDY]` (Ready).
2015-03-09 16:20:15 -07:00
2016-08-23 20:49:09 -07:00
- Untagged PRs are assumed to be `[RFC]` , i.e. you are requesting a review.
- Prepend `[WIP]` to the PR title if you are _not_ requesting feedback and the
2016-08-09 21:47:04 -07:00
work is still in flux.
2016-08-23 20:49:09 -07:00
- Prepend `[RDY]` to the PR title if you are _done_ with the PR and are only
waiting on it to be merged.
For example, a typical workflow is:
1. You open a `[WIP]` PR where the work is _not_ ready for feedback, you just want to
let others know what you are doing.
2. Once the PR is ready for review, you replace `[WIP]` in the title with `[RFC]` .
You may add fix up commits to address issues that come up during review.
3. Once the PR is ready for merging, you rebase/squash your work appropriately and
then replace `[RFC]` in the title with `[RDY]` .
2015-03-09 16:20:15 -07:00
2016-06-03 12:05:44 -07:00
### Commit messages
2015-03-09 16:20:15 -07:00
2016-06-03 12:05:44 -07:00
Follow [commit message hygiene][hygiene] to *make reviews easier* and to make
the VCS/git logs more valuable.
2015-03-09 16:20:15 -07:00
2016-06-03 12:05:44 -07:00
- Try to keep the first line under 72 characters.
- **Prefix the commit subject with a _scope_ :** `doc:` , `test:` , `foo.c:` ,
`runtime:` , ...
2019-01-08 11:58:06 -07:00
- Subject line for commits with only style/lint changes can be a single
word: `style` or `lint` .
2016-06-03 12:05:44 -07:00
- A blank line must separate the subject from the description.
- Use the _imperative voice_ : "Fix bug" rather than "Fixed bug" or "Fixes bug."
2015-03-09 16:20:15 -07:00
2016-06-03 12:05:44 -07:00
### Automated builds (CI)
2015-03-09 16:20:15 -07:00
2019-01-08 11:58:06 -07:00
Each pull request must pass the automated builds on [Travis CI], [QuickBuild]
2017-06-06 06:02:51 -07:00
and [AppVeyor].
2015-03-09 16:20:15 -07:00
2017-06-06 06:02:51 -07:00
- CI builds are compiled with [`-Werror`][gcc-warnings], so compiler warnings
will fail the build.
2016-06-03 12:05:44 -07:00
- If any tests fail, the build will fail.
2017-11-14 02:47:49 -07:00
See [test/README.md#running-tests][run-tests] to run tests locally.
2016-06-03 12:05:44 -07:00
Passing locally doesn't guarantee passing the CI build, because of the
different compilers and platforms tested against.
2017-07-29 09:51:31 -07:00
- CI runs [ASan] and other analyzers.
- To run valgrind locally: `VALGRIND=1 make test`
- To run Clang ASan/UBSan locally: `CC=clang make CMAKE_FLAGS="-DCLANG_ASAN_UBSAN=ON"`
2016-06-03 12:05:44 -07:00
- The `lint` build ([#3174][3174]) checks modified lines _and their immediate
neighbors_. This is to encourage incrementally updating the legacy style to
meet our style guidelines.
- [How to investigate QuickBuild failures ](https://github.com/neovim/neovim/pull/4718#issuecomment-217631350 )
2015-03-09 16:20:15 -07:00
2017-01-31 00:53:16 -07:00
QuickBuild uses this invocation:
mkdir -p build/${params.get("buildType")} \
& & cd build/${params.get("buildType")} \
& & cmake -G "Unix Makefiles" -DBUSTED_OUTPUT_TYPE=TAP -DCMAKE_BUILD_TYPE=${params.get("buildType")}
-DTRAVIS_CI_BUILD=ON ../.. & & ${node.getAttribute("make", "make")}
VERBOSE=1 nvim unittest-prereqs functionaltest-prereqs
2017-06-05 18:43:53 -07:00
### Clang scan-build
2019-01-08 11:58:06 -07:00
View the [Clang report] to see potential bugs found by the Clang
[scan-build ](https://clang-analyzer.llvm.org/scan-build.html ) analyzer.
2017-06-05 18:43:53 -07:00
2019-01-08 11:58:06 -07:00
- Search the Neovim commit history to find examples:
```
git log --oneline --no-merges --grep clang
```
- To verify a fix locally, run `scan-build` like this:
```
rm -rf build/
scan-build --use-analyzer=/usr/bin/clang make
```
2015-03-09 16:20:15 -07:00
2019-01-08 11:58:06 -07:00
### PVS-Studio
2015-03-09 16:20:15 -07:00
2019-01-08 11:58:06 -07:00
View the [PVS report ](https://neovim.io/doc/reports/pvs/PVS-studio.html.d/ ) to
see potential bugs found by [PVS Studio ](https://www.viva64.com/en/pvs-studio/ ).
2015-03-09 16:20:15 -07:00
2019-01-08 11:58:06 -07:00
- Use this format for commit messages (where `{id}` is the PVS warning-id)):
```
PVS/V{id}: {description}
```
- Search the Neovim commit history to find examples:
```
git log --oneline --no-merges --grep PVS
```
- Try `./scripts/pvscheck.sh` to run PVS locally.
2015-03-09 16:20:15 -07:00
2019-01-08 11:58:06 -07:00
### Coverity
2016-06-03 12:05:44 -07:00
2019-01-08 11:58:06 -07:00
[Coverity ](https://scan.coverity.com/projects/neovim-neovim ) runs against the
master build. To view the defects, just request access; you will be approved.
2017-04-17 14:52:38 -07:00
2019-01-08 11:58:06 -07:00
- Use this format for commit messages (where `{id}` is the CID (Coverity ID);
([example](https://github.com/neovim/neovim/pull/804))):
```
coverity/{id}: {description}
```
- Search the Neovim commit history to find examples:
```
git log --oneline --no-merges --grep coverity
```
2017-04-17 14:52:38 -07:00
2016-08-09 21:47:04 -07:00
Reviewing
---------
2016-06-03 12:05:44 -07:00
To help review pull requests, start with [this checklist][review-checklist].
2015-03-09 16:20:15 -07:00
Reviewing can be done on GitHub, but you may find it easier to do locally.
2016-06-03 12:05:44 -07:00
Using [`hub`][hub], you can create a new branch with the contents of a pull
request, e.g. [#1820][1820]:
2014-05-07 19:33:41 -07:00
2015-03-09 16:20:15 -07:00
hub checkout https://github.com/neovim/neovim/pull/1820
Use [`git log -p master..FETCH_HEAD`][git-history-filtering] to list all
commits in the feature branch which aren't in the `master` branch; `-p`
shows each commit's diff. To show the whole surrounding function of a change
as context, use the `-W` argument as well.
[gcc-warnings]: https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
2017-12-27 11:30:23 -07:00
[git-bisect]: http://git-scm.com/book/en/v2/Git-Tools-Debugging-with-Git
2015-03-09 16:20:15 -07:00
[git-feature-branch]: https://www.atlassian.com/git/tutorials/comparing-workflows
[git-history-filtering]: https://www.atlassian.com/git/tutorials/git-log/filtering-the-commit-history
[git-history-rewriting]: http://git-scm.com/book/en/v2/Git-Tools-Rewriting-History
[git-rebasing]: http://git-scm.com/book/en/v2/Git-Branching-Rebasing
[github-issues]: https://github.com/neovim/neovim/issues
2016-06-03 12:05:44 -07:00
[1820]: https://github.com/neovim/neovim/pull/1820
2015-03-09 16:20:15 -07:00
[hub]: https://hub.github.com/
2016-06-03 12:05:44 -07:00
[hygiene]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
2015-04-19 13:17:45 -07:00
[style-guide]: http://neovim.io/develop/style-guide.xml
2016-06-03 12:05:44 -07:00
[ASan]: http://clang.llvm.org/docs/AddressSanitizer.html
2017-11-14 02:47:49 -07:00
[run-tests]: https://github.com/neovim/neovim/blob/master/test/README.md#running-tests
2015-04-21 14:35:06 -07:00
[wiki-faq]: https://github.com/neovim/neovim/wiki/FAQ
2016-06-03 12:05:44 -07:00
[review-checklist]: https://github.com/neovim/neovim/wiki/Code-review-checklist
[3174]: https://github.com/neovim/neovim/issues/3174
2019-01-08 11:58:06 -07:00
[Travis CI]: https://travis-ci.org/neovim/neovim
[QuickBuild]: http://neovim-qb.szakmeister.net/dashboard
2017-06-06 06:02:51 -07:00
[AppVeyor]: https://ci.appveyor.com/project/neovim/neovim
[Merge a Vim patch]: https://github.com/neovim/neovim/wiki/Merging-patches-from-upstream-Vim
2019-01-08 11:58:06 -07:00
[Clang report]: https://neovim.io/doc/reports/clang/
2016-08-09 21:47:04 -07:00
[complexity:low]: https://github.com/neovim/neovim/issues?q=is%3Aopen+is%3Aissue+label%3Acomplexity%3Alow