Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tdfacer/explain-it.nvim
Simple and effective AI integration with your favorite Neovim text editor! Ask a question, and let robots expl[AI]n-it!
https://github.com/tdfacer/explain-it.nvim
chatgpt developer-tools lua neovim plugin vim
Last synced: 3 months ago
JSON representation
Simple and effective AI integration with your favorite Neovim text editor! Ask a question, and let robots expl[AI]n-it!
- Host: GitHub
- URL: https://github.com/tdfacer/explain-it.nvim
- Owner: tdfacer
- License: mit
- Created: 2023-05-30T03:34:15.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-02-19T23:12:45.000Z (9 months ago)
- Last Synced: 2024-04-16T02:42:33.902Z (7 months ago)
- Topics: chatgpt, developer-tools, lua, neovim, plugin, vim
- Language: Lua
- Homepage:
- Size: 70.3 KB
- Stars: 18
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
expl[AI]n-it.nvim
> Simple and effective AI integration with your favorite Neovim text editor! Ask a question, and let robotsexpl[AI]n-it
!
![](https://github.com/trevordf/gifs/blob/main/explain-it.png)## See it in Action (click to expand)
#### Explain Code
Visually select a block of text in your buffer, and have ChatGPT tell you what it does! Optionally customize the prompt included in your request.
![](https://github.com/trevordf/gifs/blob/main/explain_code.gif)
#### Summarize a Block of Text
Sick of reading documents? Have ChatGPT summarize what your buffer says.
![](https://github.com/trevordf/gifs/blob/main/summarize.gif)
#### Explain Code ex. 2
Have questions on the full buffer? Shortcut to include everything in your request, no visual selection necessary.
![](https://github.com/trevordf/gifs/blob/main/explain_code_2.gif)
#### Write Unit Tests
Jump start your unit tests by letting ChatGPT take the first crack at writing them for you.
![](https://github.com/trevordf/gifs/blob/main/speed_up.gif)
#### Write Code
Stub out what you need done, and let ChatGPT fill in the blanks.
![](https://github.com/trevordf/gifs/blob/main/write_fibonacci.gif)
## 🚀 Try it in Docker
> Try it in a minimal container, no commitment necessary
1. Set your API key in your terminal (`export CHAT_GPT_API_KEY=`)
1. Execute `make docker`![](https://github.com/trevordf/gifs/blob/main/docker.png)
## ⚡️ Features
> Neovim integration with the ChatGPT API
- Send your entire buffer to ChatGPT APIs! This will allow you to do things like:
- Explain what code does
- Generate code snippets
- Write unit tests
- Fetch non-code responses, such as document generation or answering questions
- Keybindings for quick integration with separate models
- Write responses to text files for persistence
- Visual selection is supported to## 📋 Installation
Package manager
Snippet[wbthomason/packer.nvim](https://github.com/wbthomason/packer.nvim)
```lua
use ({
'tdfacer/explain-it.nvim',
requires = {
"rcarriga/nvim-notify",
},
config = function ()
require "explain-it".setup {
-- Prints useful log messages
debug = true,
-- Customize notification window width
max_notification_width = 200,
-- Retry API calls
max_retries = 3,
-- Customize response text file persistence location
output_directory = "/tmp/chat_output",
-- Toggle splitting responses in notification window
split_responses = false,
-- Set token limit to prioritize keeping costs low, or increasing quality/length of responses
token_limit = 2000,
-- Per-filetype default prompt questions
default_prompts = {
["markdown"] = "Answer this question:",
["txt"] = "Explain this block of text:",
["lua"] = "What does this code do?",
["zsh"] = "Answer this question:",
},
}
end
})
```[folke/lazy.nvim](https://github.com/folke/lazy.nvim)
```lua
{ "tdfacer/explain-it.nvim",
dependencies = "rcarriga/nvim-notify",
config = function ()
require "explain-it".setup {
-- Prints useful log messages
debug = true,
-- Customize notification window width
max_notification_width = 20,
-- Retry API calls
max_retries = 3,
-- Customize response text file persistence location
output_directory = "/tmp/chat_output",
-- Toggle splitting responses in notification window
split_responses = false,
-- Set token limit to prioritize keeping costs low, or increasing quality/length of responses
token_limit = 2000,
-- Per-filetype default prompt questions
default_prompts = {
["markdown"] = "Answer this question:",
["txt"] = "Explain this block of text:",
["lua"] = "What does this code do?",
["zsh"] = "Answer this question:",
},
}
end
},
```## ☄ Getting started
1. Sign up for paid account at https://platform.openai.com/signup
1. Be sure to note pricing! It is recommended to use something like privacy.com to make sure that you do not accidentally exceed your price limit. Note that there is a separate charge for _ChatGPT_ usage and _API_ usage. We're after _API_.
1. After adding payment info, copy your API key and set it as an environment variable in your shell. Here is a command that will add this to your `.zshrc` file:
```
echo 'export CHAT_GPT_API_KEY=' >> ~/.zshrc
```
1. Install the Plugin using your favorite package manager as described above## ⚙ Configuration
* Sensible default config values have been set. Customize values using the the standard `setup` function.
* See `M.options` [here]([url](https://github.com/tdfacer/explain-it.nvim/blob/main/lua/explain-it/config.lua#L5)) for a full list of options.## ⌨ Contributing
PRs and issues are always welcome. Make sure to provide as much context as possible when opening one. See [CONTRIBUTING.md](./CONTRIBUTING.md).