cmp-ai  by tzachar

AI source for nvim-cmp, enabling remote code completion

created 2 years ago
255 stars

Top 99.2% on sourcepulse

GitHubView on GitHub
Project Summary

This plugin provides AI-powered code completion for Neovim, integrating with the nvim-cmp autocompletion engine. It supports multiple AI providers, including HuggingFace, OpenAI, Codestral, Ollama, and Google Bard, enabling developers to leverage large language models for context-aware suggestions directly within their editor.

How It Works

The plugin acts as a custom source for nvim-cmp, querying specified AI providers with context from the current buffer (lines before and after the cursor). It handles API interactions, response parsing, and formatting of suggestions for nvim-cmp. The design allows for flexible configuration of providers, models, and context sensitivity, including custom prompt engineering for specific models.

Quick Start & Requirements

  • Install via plugin manager (e.g., Lazy):
    require("lazy").setup({
        {'tzachar/cmp-ai', dependencies = 'nvim-lua/plenary.nvim'},
        {'hrsh7th/nvim-cmp', dependencies = {'tzachar/cmp-ai'}},
    })
    
  • Configure nvim-cmp to include cmp_ai as a source.
  • Requires nvim-lua/plenary.nvim.
  • Additional dependencies: curl for Codestral, OpenAI, HuggingFace; dsdanielpark/Bard-API for Google Bard.
  • API keys for respective services must be set as environment variables (e.g., HF_API_KEY, OPENAI_API_KEY).

Highlighted Details

  • Supports multiple AI backends: HuggingFace, SantaCoder, OpenAI Chat, Codestral, Ollama, Google Bard, Tabby.
  • Configurable context window (max_lines) and request timeout (max_timeout_seconds).
  • Options for run_on_every_keystroke and ignoring specific file types.
  • Integrates with lspkind for pretty-printed completion menu items.
  • Allows custom sorting of AI completions within the nvim-cmp menu.

Maintenance & Community

  • Primarily maintained by tzachar.
  • No explicit community links (Discord/Slack) or roadmap mentioned in the README.

Licensing & Compatibility

  • License not explicitly stated in the README.

Limitations & Caveats

  • Requires external API keys and potentially other plugins for specific providers.
  • Performance and suggestion quality are dependent on the chosen AI provider and model.
  • max_timeout_seconds is not supported for Google Bard.
Health Check
Last commit

3 months ago

Responsiveness

1 day

Pull Requests (30d)
0
Issues (30d)
0
Star History
13 stars in the last 90 days

Explore Similar Projects

Feedback? Help us improve.