If you want to help but don't know where to start, here are some low-risk/isolated tasks:
runtime/
).nvim --clean
("factory defaults").contrib/minimal.lua
with nvim --clean -u contrib/minimal.lua
after making the necessary changes.:edit $NVIM_LOG_FILE
cmake --system-information
for build-related issues.ninja
for faster builds of Nvim.
bash
sudo apt-get install ninja-build
make distclean
make # Nvim build system uses ninja automatically, if available.
ccache
or sccache
for faster rebuilds of Nvim. Nvim will use one
of these automatically if it's found. To disable caching use:
bash
cmake -B build -D CACHE_PRG=OFF
For maintainers: when a PR is ready to merge to master,
Pull requests have two stages: Draft and Ready for review.
Do not add labels like [RFC]
or [WIP]
in the title to indicate the
state of your PR: this just adds noise. Non-Draft PRs are assumed to be open
for comments; if you want feedback from specific people, @
-mention them in
a comment.
Follow the conventional commits guidelines to make reviews easier and to make
the VCS/git logs more valuable (try make lintcommit
). The structure of a commit message is:
type(scope): subject
Problem:
...
Solution:
...
build ci docs feat fix perf refactor revert test vim-patch
(scope)
such as (lsp)
, (treesitter)
, (float)
, …Commit message body (detail):
Solution: ```
Indicate breaking API changes with "!" after the type, and a "BREAKING CHANGE" footer. Example: ``` refactor(provider)!: drop support for Python 2
BREAKING CHANGE: refactor to use Python 3 features since Python 2 is no longer supported.
### Automated builds (CI)
Each pull request must pass the automated builds on [Cirrus CI] and [GitHub Actions].
- CI builds are compiled with [`-Werror`][gcc-warnings], so compiler warnings
will fail the build.
- If any tests fail, the build will fail. See [test/README.md#running-tests][run-tests] to run tests locally.
- CI runs [ASan] and other analyzers.
- To run valgrind locally: `VALGRIND=1 make test`
- To run ASan/UBSan locally: `CC=clang make CMAKE_FLAGS="-DENABLE_ASAN_UBSAN=ON"`.
Note that MSVC requires Release or RelWithDebInfo build type to work properly.
- The [lint](#lint) build checks that the code is formatted correctly and
passes various linter checks.
- CI for FreeBSD runs on [Cirrus CI].
- To see CI results faster in your PR, you can temporarily set `TEST_FILE` in
[test.yml](https://github.com/neovim/neovim/blob/e35b9020b16985eee26e942f9a3f6b045bc3809b/.github/workflows/test.yml#L29).
### Coverity
Coverity runs against the master build. To view the defects you must
[request access](https://scan.coverity.com/projects/neovim-neovim) (Coverity
does not have a "public" view), then you will be approved as soon as
a maintainer sees the email.
- Use this format for commit messages (where `{id}` is the CID (Coverity ID);
([example](https://github.com/neovim/neovim/pull/804))):
fix(coverity/{id}): {description}
- Search the Neovim commit history to find examples:
```bash
git log --oneline --no-merges --grep coverity
ASAN/UBSAN can be used to detect memory errors and other common forms of undefined behavior at runtime in debug builds.
rm -rf build && CMAKE_EXTRA_FLAGS="-DCMAKE_C_COMPILER=clang -DENABLE_ASAN_UBSAN=1" make
ASAN_OPTIONS=log_path=/tmp/nvim_asan nvim args...
/tmp/nvim_asan.{PID}
(or your preferred log_path
) for log files with error messages.You can run the linter locally by:
make lint
bash
make format # or formatc, formatlua
This will format changed Lua and C files with all appropriate flags set.src/uncrustify.cfg
which tries to match
the style-guide. To use the Nvim gq
command with uncrustify
:
vim
if !empty(findfile('src/uncrustify.cfg', ';'))
setlocal formatprg=uncrustify\ -q\ -l\ C\ -c\ src/uncrustify.cfg\ --no-backup
endif
.clang-format
which has drifted from the style-guide, but
is available for reference. To use the Nvim gq
command with clang-format
:
vim
if !empty(findfile('.clang-format', ';'))
setlocal formatprg=clang-format\ -style=file
endif
Set blame.ignoreRevsFile
to ignore noisy commits in git blame:
git config blame.ignoreRevsFile .git-blame-ignore-revs
Recommendation is to use clangd. Can use the maintained config in nvim-lspconfig/clangd.
Explore the source code on the web.
For managing includes in C files, use include-what-you-use.
iwyu
:
bash
cmake --preset iwyu
cmake --build build
bash
make iwyu
See #549 for more details.
Most of the Lua core runtime/
modules are precompiled to
bytecode, so changes to those files won't get used unless you rebuild Nvim or
by passing --luamod-dev
and $VIMRUNTIME
. For example, try adding a function
to runtime/lua/vim/_editor.lua
then:
VIMRUNTIME=./runtime ./build/bin/nvim --luamod-dev
Read :help dev-doc to understand the expected documentation style and conventions.
Many :help
docs are autogenerated from (C or Lua) docstrings. To generate the documentation run:
make doc
To validate the documentation files, run:
make lintdoc
If you need to modify or debug the documentation flow, these are the main files:
./scripts/gen_vimdoc.lua
:
Main doc generator. Parses C and Lua files to render vimdoc files../scripts/luacats_parser.lua
:
Documentation parser for Lua files../scripts/cdoc_parser.lua
:
Documentation parser for C files../scripts/luacats_grammar.lua
:
Lpeg grammar for LuaCATS./scripts/cdoc_grammar.lua
:
Lpeg grammar for C doc comments./scripts/gen_eval_files.lua
:
Generates documentation and Lua type files from metadata files:
runtime/lua/vim/* => runtime/doc/lua.txt
runtime/lua/vim/* => runtime/doc/lua.txt
runtime/lua/vim/lsp/ => runtime/doc/lsp.txt
src/nvim/api/* => runtime/doc/api.txt
src/nvim/eval.lua => runtime/doc/builtin.txt
src/nvim/options.lua => runtime/doc/options.txt
./scripts/lintdoc.lua
: Validation and linting of documentation files.
Use LuaLS annotations in Lua docstrings to annotate parameter types, return types, etc. See :help dev-lua-doc.
lua
--- {Brief}
---
--- {Long explanation}
---
--- @param arg1 type {description}
--- @param arg2 type {description}
--- ...
---
--- @return type {description}
table
, string
, number
, ...). Multiple valid types are separated by a bar (string|table
). Indicate optional parameters via type|nil
.@nodoc
.@private
.
@deprecated
.To build Nvim using a different commit of a dependency change the appropriate
URL in cmake.deps/deps.txt
. For example, to use a different version of luajit
replace the value in LUAJIT_URL
with the wanted commit hash:
LUAJIT_URL https://github.com/LuaJIT/LuaJIT/archive/<sha>.tar.gz
Set DEPS_IGNORE_SHA
to TRUE
in cmake.deps/CMakeLists.txt
to skip hash
check from cmake.
Alternatively, you may point the URL as a local path where the repository is.
This is convenient when bisecting a problem in a dependency with git bisect
.
This may require running make distclean
between each build. Hash checking is
always skipped in this case regardless of DEPS_IGNORE_SHA
.
LUAJIT_URL /home/user/luajit
Reviewing can be done on GitHub, but you may find it easier to do locally. Using GitHub CLI, you can create a new branch with the contents of a pull request, e.g. #1820:
gh pr checkout https://github.com/neovim/neovim/pull/1820
Use git log -p master..FETCH_HEAD
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.