Introduction to NeoAI.nvim
NeoAI.nvim is an advanced Neovim plugin that integrates the capabilities of OpenAI's GPT-4 model directly into your text editor. Designed to cater to developers and writers, this plugin facilitates code generation, text rewriting, and insightful suggestions that align contextually with your work. It stands out due to its user-friendly interface, enabling seamless interactions with artificial intelligence to streamline productivity.
Motivation
The driving force behind NeoAI.nvim is to merge AI-powered chat assistants, like ChatGPT, into a developer's workflow in Neovim, enhancing efficiency without disrupting the natural flow of coding. The plugin aims to support focused, productive work rather than mere entertainment. By delivering a harmonious integration, NeoAI.nvim seeks to enhance a coder's productivity and enrich the overall coding experience.
Installation
To install NeoAI, a preferred plugin manager can be used. For instance, with vim-plug, users need to add:
Plug 'MunifTanjim/nui.nvim'
Plug 'Bryley/neoai.nvim'
in their init.vim
or .vimrc
files and run :PlugInstall
. Additionally, it requires a crucial dependency, nui.nvim
, and the system should have curl installed. Alternatively, lazy.nvim and packer are also supported with respective configurations as detailed in the project documentation.
Usage
To operate NeoAI.nvim, it is critical to have an OpenAI API key. This can be obtained and configured according to the project's instructions. By saving this key as OPENAI_API_KEY
in the environment variables, users can start leveraging the AI features provided by the plugin.
Note: NeoAI.nvim does not take responsibility for any incidental charges incurred through its usage. Users are advised to regularly monitor their OpenAI usage and set usage limits to avoid unforeseen expenses.
Modes of Operation
NeoAI.nvim offers three primary modes for interaction:
Normal GUI Mode
This default mode opens a side GUI using the :NeoAI
command, resembling a typical chat interface for easy communication with the AI. Text submission and customization options are available, providing a responsive user experience.
Context Mode
In Context Mode, users can provide additional context to the AI model by highlighting text in the buffer and using the :NeoAIContext
command. This mode is particularly useful for seeking clarifications on code segments or enhancing textual content.
Inject Mode
Inject Mode operates without opening the GUI. By using :NeoAIInject
, users can swiftly send prompts to the AI, which then inserts the resulting output directly into the editor's buffer, facilitating quick AI-assisted coding or text editing.
Shortcut Features
NeoAI.nvim incorporates shortcuts for efficient use. Two built-in shortcuts are provided:
- Text Summarization: Improves the readability of selected text using
<leader>as
. - Git Commit Message Generation: Automatically generates concise and clear git commit messages.
Configuration
Customization of NeoAI.nvim is vital for optimizing its utility. Users can alter settings through a configuration setup that defines UI aspects, model preferences, output handling, and more.
require("neoai").setup({
ui = {
output_popup_text = "NeoAI",
input_popup_text = "Prompt",
width = 30,
output_popup_height = 80,
submit = "<Enter>",
},
models = {
{
name = "openai",
model = "gpt-3.5-turbo",
params = nil,
},
},
-- Further options available...
})
User Commands
NeoAI.nvim supports several user commands for convenient operations, such as opening, closing, toggling AI windows, and injecting responses into the text buffer with or without contexts. A detailed list of available commands provides users with a comprehensive understanding of achieving tasks efficiently.
Future Enhancements
The roadmap for NeoAI.nvim includes expanding its capabilities with multiple chat sessions, improved error detection, integration with popular tools like Telescope, and support for other AI services.
License
NeoAI.nvim is open-source and licensed under the MIT License, ensuring that it remains accessible and modifiable for developers worldwide.
In summary, NeoAI.nvim is an innovative plugin that transforms how developers interact with AI technologies within their coding environments. By streamlining communication with AI and enhancing intuitive coding assistance, it significantly boosts productivity while maintaining a seamless and non-disruptive workflow.