
Today, OpenAI GPT-3 chatbot has enormous potential. Lately, there’s been a new AI bot in town: ChatGPT.
Releasing ChatGPT, it seems that many ambitious software engineers work on advancing its API via Slack, Line bot, and so on. I was finding luckily a NeoVim plugin that interacts with OpenAI’s GPT-3 chatbot:ChatGPT.nvim
.
- https://github.com/jackMort/ChatGPT.nvim
- (2) ChatGPT - preview of my first neovim plugin [WIP] : neovim
I’m a heavy user who’s enthusiastic to try a new feature of NeoVim, so this time I also began introducing this fascinating plugin. I will share with you how we use it andChatGPT.nvim
works.
Input the touch command to make.openai_key.zsh
file.
$touch$HOME/.openai_key.zsh$vi$HOME/.openai_key.zsh
Modify$HOME/.openai_key.zsh
to set OPEN_API_KEY that is obtainable onthis page.
exportOPENAI_API_KEY=<value>
Add the following code into~/.zshrc
file.
# ChatGPTsource"$HOME/.openai_key.zsh"
The reason why sets up an environment variable via.zsh
is that the ChatGPT NeoVim plugin reads it withos.getenv()
which is the method in python to extract an environment variable.
Execute the following command to load configurations.
$source ~/.zshrc
Let’s move on to the next subject which configures NeoVim. It depends on developers about how the NeoVim configuration is, so the next description might not be suitable for everybody. I would be glad to consider what your configuration is. My NeoVim environment is there.
- P*lugin/package manager*:https://github.com/wbthomason/packer.nvim
- Where writes code: init.lua
If you’ve already handled packer.nvim, installingChatGPT.nvim
is really effortless. Copy and paste the next code in therequire(’packer’)
.
require('packer').startup(function(use)...-- ChatGPT-- https://github.com/jackMort/ChatGPT.nvimuse({"jackMort/ChatGPT.nvim",config=function()require("chatgpt").setup({})end,requires={"MunifTanjim/nui.nvim","nvim-lua/plenary.nvim","nvim-telescope/telescope.nvim"}})...)
Then, install it.
:PackerInstall
Currently, three commands are available inChatGPT.nvim
. So I registered those ininit.lua
as my key bindings.
-- ChatGPT-- https://github.com/jackMort/ChatGPT.nvimvim.keymap.set('n','<Leader>tk','<cmd>:ChatGPT<cr>')vim.keymap.set('n','<Leader>tj','<cmd>:ChatGPTActAs<cr>')vim.keymap.set('n','<Leader>tt','<cmd>:ChatGPTEditWithInstructions<cr>')
Let’s take a look at the screen after pushing the command<Leader>tt
or:ChatGPTEditWithInstructions
: opens an interactive window to edit selected text or the whole window.
Super cool!OpenAI GPT-3 chatbot
returned a response that fixed a bug. Of course, the response fromOpenAI GPT-3 chatbot
might be not always correct and proper, but it will give you great insight and improve your velocity of development.
Top comments(0)
For further actions, you may consider blocking this person and/orreporting abuse