vim.completion

Configure nvim-cmp and LuaSnip for context-aware autocompletion in Neovim.

4|Updated Sep 25, 2024
One-click install
npx skills add https://github.com/khulnasoft/init.lua --skill vim-completion
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vim.completion
Source: https://github.com/khulnasoft/init.lua/tree/main/skills/vim.completion
Command: npx skills add https://github.com/khulnasoft/init.lua --skill vim-completion

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill streamlines Neovim coding sessions by providing fast, context-aware autocompletion and ready-to-use snippets, reducing keystrokes and context switching.

Core Features & Use Cases

  • Autocompletion framework: nvim-cmp delivers dynamic suggestions from LSP, buffer words, and AI sources like Copilot.
  • Snippet engine: LuaSnip enables fast code expansion with placeholders and navigation.
  • Integrations: Works with Copilot, nvim_lsp, and other sources to assemble relevant completions across languages.
  • Snippet packs: Includes popular collections (e.g., Friendly Snippets) for quick templates.

Quick Start

Install and enable nvim-cmp and LuaSnip, then configure your Neovim init to load completion sources.

Frequently Asked Questions about vim.completion

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up context-aware autocompletion in Neovim?

Context-aware autocompletion in Neovim requires configuring the nvim-cmp plugin alongside LuaSnip to deliver dynamic suggestions from LSP, buffer words, and AI sources like Copilot.

Can I use Copilot and LSP sources together for code completion in Neovim?

Yes, Copilot and LSP sources can be assembled together in Neovim. The nvim-cmp framework integrates nvim_lsp, copilot, and buffer sources to provide relevant completions across multiple languages.

What is the best way to expand snippets with placeholders in Neovim?

Snippet expansion with placeholders in Neovim is handled by the LuaSnip engine, which enables fast code template insertion and navigation. Popular collections like Friendly Snippets provide ready-to-use templates.

Do I need nvim-cmp and LuaSnip to enable snippet insertion in Neovim?

Yes, nvim-cmp and LuaSnip are required dependencies for snippet insertion. You must install and enable both plugins, then configure your Neovim init file to load completion sources.

Why does my Neovim completion framework suggest irrelevant buffer words instead of LSP snippets?

Completion relevance depends on configuring nvim-cmp sources correctly. You must explicitly load nvim_lsp, copilot, and buffer sources in your Neovim init to ensure context-aware suggestions prioritize appropriate templates.

Does Neovim autocompletion work across different programming languages?

Neovim autocompletion works across languages by relying on LSP, Copilot, and buffer sources. The nvim-cmp plugin assembles relevant completions dynamically regardless of the specific programming language used.