explaingit

hrsh7th/nvim-cmp

9,419LuaAudience · developerComplexity · 3/5Setup · moderate

TLDR

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.

Mindmap

mindmap
  root((nvim-cmp))
    What it does
      Code completion engine
      Multi-source suggestions
      Snippet expansion
    Tech Stack
      Lua
      Neovim
    Use Cases
      LSP code completion
      File path completion
      Buffer word completion
    Setup
      Lua config file
      Choose snippet engine
      Install sources separately
    Customization
      Key mappings
      Completion sources
      Window appearance
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Get intelligent code completion in Neovim by connecting language server, snippet, and file path sources in one engine.

USE CASE 2

Customize exactly which completion sources appear and configure keyboard shortcuts for accepting or dismissing suggestions.

USE CASE 3

Replace Neovim's limited built-in completion with a more powerful engine that combines multiple sources you choose.

Tech stack

LuaNeovim

Getting it running

Difficulty · moderate Time to first run · 30min

Requires writing a Lua config file, picking a snippet engine, and installing each completion source as a separate plugin.

In plain English

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.

Copy-paste prompts

Prompt 1
Write me a minimal nvim-cmp configuration in Lua that enables LSP completions and snippet expansion with LuaSnip.
Prompt 2
How do I add file path completion as a nvim-cmp source and bind Tab to accept the top suggestion?
Prompt 3
Show me how to configure nvim-cmp to show completions from both the current buffer and an installed language server.
Prompt 4
What nvim-cmp sources should I install if I am writing Python in Neovim with pyright as my language server?
Prompt 5
How do I change the icons shown next to each completion kind in the nvim-cmp popup window?
Open on GitHub → Explain another repo

← hrsh7th on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.