nvim-cmp
A completion plugin for neovim coded in Lua.
nvim-cmp is a plugin for the Neovim text editor that adds powerful auto-completion, pulling suggestions from multiple pluggable sources such as language servers, file paths, and open buffers.
nvim-cmp is a completion engine plugin for Neovim, a highly configurable text editor popular among programmers. Completion, in this context, means the feature where the editor suggests words, function names, or code snippets as you type, and you can press a key to accept the suggestion. Without a plugin like this, Neovim's built-in completion is limited; nvim-cmp replaces and greatly extends it.
The plugin is written in Lua, which is the scripting language Neovim uses for configuration and plugins. Rather than providing completions directly, nvim-cmp acts as a central engine that pulls suggestions from separate "sources." Each source is its own plugin installed separately. One source might pull suggestions from the language server running in the background (which understands your code's structure), another from the current file's text, another from file paths on disk, and so on. This separation means you mix and match exactly the sources you want.
Setting it up requires writing a small configuration file in Lua that tells nvim-cmp which sources to use, which keyboard shortcuts to bind for accepting or dismissing suggestions, and how the completion window should behave. The README provides a full example configuration to start from. You also need to choose a snippet engine, which handles code template expansion. Several are supported, and the configuration example shows commented-out lines for each option.
The project is maintained as a personal hobby project by its author. Bug reports are accepted, but fixes are not guaranteed unless the report includes a minimal configuration that reproduces the problem. Keyboard mapping presets that come with the plugin may change without notice, so users are advised to define their own key mappings rather than relying on defaults.
More completion sources and advanced configuration examples are listed on the project's GitHub wiki.
Where it fits
- Get intelligent code completion in Neovim by connecting language server, snippet, and file path sources in one engine.
- Customize exactly which completion sources appear and configure keyboard shortcuts for accepting or dismissing suggestions.
- Replace Neovim's limited built-in completion with a more powerful engine that combines multiple sources you choose.