Repository

gpt4o

Blazing fast πŸš€ code assistant in NeoVim powered by GPT-4o ✨, offering intelligent code completion and editing to elevate developer productivity.

README

gpt4o.nvim

Blazing fast πŸš€ code assistant in NeoVim powered by GPT-4o ✨, offering intelligent code completion and editing to elevate developer productivity. πŸš„

(Work In Progress ⚠️ )

Features

  • Context-aware suggestions 🌍
  • Project files accounted πŸ…
  • Recent change awareness πŸ“œ
  • Real-time code completion ⏰
  • Incremental streaming result ⏳
  • Edit existing code bases πŸ› οΈ
  • Able to see diagnostics ⚠️
  • Fix your code in place πŸ“
  • Auto-move around cursor 🚦
  • Terminal output included πŸ’»
  • Auto-embed for related files πŸ€“
  • Multi-language support 🌐
  • Customizable settings βš™οΈ
  • Edit-mode and chat-mode πŸ’¬
  • Lightweight and efficient ⚑
  • Async execution for performance πŸ’ͺ
  • Ready to use out of the box πŸ“¦

Installation

To install gpt4o.nvim, first make sure you have python3 support on your NeoVim πŸ™Œ

You may do this by running:

python3 -m pip install neovim openai tiktoken

So far, by running :checkhealth provider.python, you should see:

OK: Latest pynvim is installed.

Now, let's install this plugin with your plguin manager ☺️

packer.nvim

Add the following to your ~/.config/nvim/init.lua:

use {
    'archibate/gpt4o.nvim',
    run = ':silent! UpdateRemotePlugins',
}

Then, run :PackerInstall in NeoVim.

lazy.nvim

Add the following to your ~/.config/nvim/init.lua:

vim-plug

Add the following to your ~/.config/nvim/init.vim:

Plug 'archibate/gpt4o.nvim'

Then, run :PlugInstall in NeoVim.

After that, run :UpdateRemotePlugins to setup our python3 plugin (if your plugin manager didn't setup it automatically).

LLM providers

We are almost done! The only thing remain is to find an LLM provider.

@archibate's free service

Worry not, this plugin can be used directly by default! No need to configure any provider.

This is all thanks to the free service at https://142857.red provided by @archibate just for you πŸ’•

The default free service is only provided as a trial for people who have difficulty in registering LLM accounts. The server is deployed in Hangzhou, China, hosted by Aliyun.

I will not try to save or trace any of your data! However, there is also no warranty if the poor server is being accidentally attacked or shutdown.

So, for advanced users, it's suggested to configure your own LLM provider if possible. This would not only save @archibate's poor salary, but also improve your data security as well.

OpenAI (gpt4o)

Goto OpenAI platform, create a new API key. You want to register an OpenAI account if you haven't yet.

There is a free trial of $5 budget if I recall correctly. Each invocation will consume this budget, and if the free trial has been exhausted, you'll need to set up a payment method (e.g. VISA) to continue using the service.

The API key will look like this: sk-xxxxxxxxxxxxx, do not share it with other people.

Then, append a line to your ~/.bashrc (~/.zshrc for Zsh users):

export OPENAI_API_KEY="sk-xxxxxxxxxxxxx"

Restart your shell, enter NeoVim and try run :GPT and have fun!

The plugin will invoke https://api.openai.com in the background for you for code completion 😎

DeepSeek (deepseek-coder)

DeepSeek is a Chinese company that specializes in AI-driven programming tools and code assistance solutions, which is kinda Messiah for Chinese students who could't afford an VISA card. Their slogan is:

Unravel the mystery of AGI with curiosity. Answer the essential question with long-termism 😎

DeepSeek conveniently provides an OpenAI compatible API at https://api.deepseek.com. As you may have already guessed, goto DeepSeek Platform to obtain an API key. Register an DeepSeek account if you haven't one yet.

They provide Β₯20 free trial for every new customer too; but make sure you use it within 1 month! Otherwise, it seems to become expired and no longer usable. ☹️

Anyway, append these lines to your ~/.bashrc (~/.zshrc for Zsh users):

export OPENAI_BASE_URL="https://api.deepseek.com"
export OPENAI_API_KEY="sk-xxxxxxxxxxxxx"

Note that OPENAI_BASE_URL is required for overriding the default OpenAI API into an OpenAI-compatible API (https://api.deepseek.com in this case).

Usage

TODO: Showcase Work In Progress ⚠️

:GPTEdit
:GPTEdit please optimize this function

Contributing

Contributions are welcome! If you'd like to help improve gpt4o.nvim, please open a pull request or issue on the repository. Here are some ways you can contribute:

  • Report bugs or suggest new features to help us enhance functionality.
  • Submit code contributions to fix bugs or add new features, following the project's coding standards.
  • Improve documentation by submitting edits or examples to assist other users in using gpt4o.nvim effectively.
  • Share your experiences and best practices in the community forums to foster collaboration and knowledge sharing.
  • Engage with other developers by participating in discussions or providing feedback on proposed changes.
  • Create tutorials or guides that showcase how to leverage gpt4o.nvim for various use cases and programming languages.
  • Test updates and new features thoroughly to ensure they perform as expected and report any issues encountered during testing.
  • Promote gpt4o.nvim in relevant developer communities to increase awareness and user adoption.

We appreciate your involvement and look forward to your contributions!

License

This project is licensed under the MIT License. See the LICENSE file for details. By contributing to this project, you agree that your contributions will also be licensed under the same MIT License.

Fun Fact

The README above is written with gpt4o.nvim πŸ˜„
awesome-face