Neovim plugin logo

Neovim plugin

Free

ChatGPT integration for Neovim

FreeFree tier
Inputs: textOutputs: text
Type
Open Source

About Neovim plugin

ChatGPT.nvim is a Neovim plugin that integrates OpenAI's ChatGPT API directly into the editor, enabling users to generate natural language responses, get code assistance, and perform various text processing tasks without leaving Neovim. It features interactive Q&A, persona-based conversations, context-aware code completion, and a rich set of customizable actions such as grammar correction, translation, code optimization, and bug fixing. The plugin enhances the editing experience with rich message rendering, including styled code blocks, markdown formatting, and diff highlighting. It is open-source and free to use, requiring only an OpenAI API key and curl.

Key Features

Interactive Q&A sessions with OpenAI's ChatGPT
Persona-based conversations using prompts from Awesome ChatGPT Prompts
Code editing assistance with interactive editing window tailored for coding tasks
Code completion similar to GitHub Copilot, suggesting snippets based on context
Customizable actions for grammar correction, translation, keyword generation, docstring creation, test addition, code optimization, summarization, bug fixing, code explanation, Roxygen editing, and code readability analysis
User-defined custom actions via JSON file
Rich message rendering with styled code blocks, markdown formatting, diff highlighting, and sender indicators
Inline context references using @ to add LSP definitions or project file context
Supports custom OpenAI API hosts and Azure deployments

Pros & Cons

Pros
  • Free and open-source with no licensing fees
  • Deep integration within Neovim, enhancing existing workflows
  • Highly customizable with user-defined actions and persona prompts
  • Rich rendering of responses with syntax highlighting and markdown
  • Supports context from LSP and project files for more relevant responses
  • Works with any OpenAI-compatible API (including Azure)
Cons
  • Requires an OpenAI API key, which incurs usage costs separate from ChatGPT Plus
  • Dependency on curl and external API, introducing network latency
  • Limited to the capabilities and availability of the OpenAI API
  • No built-in support for offline models or local LLMs

Best For

Interactive code explanation and learningRapid code generation and completionRefactoring and code optimizationBug finding and fixingGenerating docstrings and commentsGrammar and style correction in natural language textTranslation and keyword extractionSummarizing code or documentation

FAQ

How do I install ChatGPT.nvim?
Ensure curl is installed, obtain an API key from OpenAI, and configure the plugin by providing the API key via an executable command (api_key_cmd) or environment variable (OPENAI_API_KEY). Then follow the standard Neovim plugin installation procedure for your plugin manager.
Do I need a ChatGPT Plus subscription to use this plugin?
No. A ChatGPT Plus subscription does not include the required API credits. You need to purchase API credits separately from OpenAI's API billing page.
Can I use a custom OpenAI API host?
Yes, you can set a custom API host via the configuration option api_host_cmd or the environment variable OPENAI_API_HOST, which is useful if you cannot access OpenAI directly or want to use Azure deployments.
What kind of actions can I automate?
The plugin comes with built-in actions for tasks like grammar correction, translation, keyword generation, docstring creation, test addition, code optimization, summarization, bug fixing, code explanation, Roxygen editing, and code readability analysis. You can also define your own actions using a JSON file.