ScriptsJul 28, 2026·3 min read

nvim-cmp — Completion Engine for Neovim Written in Lua

Auto-completion plugin for Neovim supporting LSP, buffer, path, and snippet sources.

Agent ready

Ready-to-run agent install

This asset can be installed after the agent chooses its runtime, checks the plan, and runs the matching command.

Native · 98/100Policy: allow
Agent surface
Any MCP/CLI agent
Kind
Skill
Install
Single
Trust
Trust: Established
Entrypoint
nvim-cmp Overview
Direct install command
npx -y tokrepo@latest install 19121dab-8a1c-11f1-9bc6-00163e2b0d79 --target codex

Run after dry-run confirms the install plan.

Introduction

nvim-cmp is a completion engine for Neovim written entirely in Lua. It provides a flexible, extensible framework for autocompletion that integrates with Neovim's built-in LSP client and supports a wide range of completion sources through a plugin architecture. The repository is hrsh7th/nvim-cmp on GitHub with approximately 9,472 stars.

What nvim-cmp Does

nvim-cmp collects completion candidates from multiple configurable sources—LSP servers, buffer words, file paths, snippets—and presents them in a unified popup menu. Users can navigate, filter, and confirm completions with customizable key mappings. The plugin handles fuzzy matching, sorting, and deduplication of candidates across sources.

Architecture Overview

The core engine manages the completion pipeline: triggering, source collection, filtering, sorting, and rendering. Each completion source is a separate plugin that implements a simple interface. The matching system supports fuzzy, substring, and exact modes. A formatting layer lets users customize how each candidate appears in the menu. The snippet integration layer connects with engines like LuaSnip or vsnip for expand-and-jump behavior.

Self-Hosting & Configuration

nvim-cmp runs locally inside Neovim. Install the core plugin and desired source plugins via your package manager. Configuration is done through cmp.setup() in Lua, where you specify sources, mappings, snippet expansion, formatting, and sorting. Separate cmp.setup.cmdline() calls configure command-line completion. No external servers or services are required.

Key Features

  • Extensible source plugin system (LSP, buffer, path, snippets, cmdline)
  • Fuzzy matching with configurable sorting and filtering
  • Custom formatting for completion menu items
  • Ghost text preview of selected completions
  • Native LSP integration via cmp-nvim-lsp
  • Snippet expand-and-jump support through multiple engines
  • Command-line completion for search and Ex commands

Comparison with Similar Tools

Compared to coc.nvim, nvim-cmp is Lua-native and does not require Node.js, resulting in lower overhead. Unlike Neovim's built-in omnifunc, nvim-cmp provides asynchronous multi-source completion with a richer UI. coq_nvim offers a similar Lua-based approach but uses a SQLite backend for matching, while nvim-cmp relies on in-memory filtering. nvim-cmp's modular source system makes it straightforward to add or remove completion providers.

FAQ

Q: Does nvim-cmp require an LSP server? A: No. LSP is one source among many. You can use buffer, path, or snippet sources without any LSP server configured.

Q: How do I add snippet support? A: Install a snippet engine plugin (e.g., LuaSnip) and its corresponding cmp source (cmp_luasnip), then configure the snippet.expand function in cmp.setup.

Q: Can I use nvim-cmp for command-line completion? A: Yes. Use cmp.setup.cmdline() with the cmp-cmdline source to get completion in Neovim's command line.

Sources

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets