Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yuki-yano/ai-review.vim
https://github.com/yuki-yano/ai-review.vim
Last synced: 20 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/yuki-yano/ai-review.vim
- Owner: yuki-yano
- License: other
- Created: 2023-01-18T11:25:42.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-09-21T03:58:23.000Z (about 1 year ago)
- Last Synced: 2024-08-02T01:25:47.358Z (3 months ago)
- Language: TypeScript
- Size: 77.1 KB
- Stars: 30
- Watchers: 1
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-ChatGPT-repositories - ai-review.vim - Count your code, quickly. (Others)
- awesome-vim-llm-plugins - yuki-yano/ai-review.vim
README
# ai-review.vim
The ai-review.vim plugin harnesses the power of OpenAI's API for conducting code reviews and more.
## Dependencies
This plugin relies on [denops.vim](https://github.com/vim-denops/denops.vim) and [ddu.vim](https://github.com/Shougo/ddu.vim).
Instead of ddu.vim, you can use [nui.nvim](https://github.com/MunifTanjim/nui.nvim) which enables you to use functionality beyond history management with Fuzzy Finder.
## Demo
https://user-images.githubusercontent.com/5423775/218340551-7bac325a-d21e-4865-9cde-389766497b57.mp4
## How to Use
First, set your `OPENAI_API_KEY` environment variable.
If you want to use it on a selected range, please set ddu as follows.```vim
call ddu#custom#patch_global({
\ 'kindOptions': {
\ 'ai-review-request': {
\ 'defaultAction': 'open',
\ },
\ 'ai-review-log': {
\ 'defaultAction': 'resume',
\ },
\ }
\ })
```Then, activate the plugin by executing `:AiReview` or `:'<,'>AiReview`.
By default, it is set to use the `gpt-3.5-turbo` model. If you want to use GPT-4, please call `ai_review#config` with `gpt-4`.
```vim
call ai_review#config({ 'chat_gpt': { 'model': 'gpt-4' } })
```If you want to use with Azure OpenAI Service, you'll need to include an endpoint and an api-version:
```vim
call ai_review#config({ 'chat_gpt': { 'model': 'gpt-4', 'azure': { 'use': v:true, 'url': 'https://YOUR_RESOURCE_NAME.openai.azure.com/openai/deployments/YOUR_DEPLOYMENT_NAME', 'api_version': '2023-07-01-preview' } } })
```If you want to use nui.nvim instead of ddu, please set as follows:
```vim
call ai_review#config({ 'backend': 'nui' })
```To get the default value of the setting, please execute `ai_review#get_default_config`.
## Request preset
The request preset is defined as a list of objects of the following type (expressed in TypeScript).
The request and preview can be defined with Vim script's funcref or Lua function, and you can modify it by setting the list of objects to `call ai_review#config({ 'chat_gpt': { 'requests': [] } })`.
(Ref: https://github.com/yuki-yano/ai-review.vim/blob/main/autoload/ai_review/open_ai/request.vim)
```typescript
type Request = {
title: string;
request: (opts: {
file_type: string;
first_line: number;
last_line: number;
bufnr: number;
}) => {
context: string;
text: string;
code: string;
file_type: string;
};
preview: (opts: {
file_type: string;
first_line: number;
last_line: number;
bufnr: number;
}) => string;
};
```## History Management
The commands `:AiReviewSave` and `:AiReviewLoad` allow you to easily save and retrieve your chat history.
The log save location is set to `call ai_review#config`. The default is `~/.cache/vim/ai-review`.
```vim
call ai_review#config({ 'log_dir': 'path/to/dir' })
```Additionally, you can display the history using ddu with the `:AiReviewLog` command.
## Requirements
This plugin requires
- [denops.vim](https://github.com/vim-denops/denops.vim)
- [ddu.vim](https://github.com/Shougo/ddu.vim)### Optional
When using nui.nvim instead of ddu.vim:
- [nui.nvim](https://github.com/MunifTanjim/nui.nvim)
## Acknowledgements
Special thanks to [butler.vim](https://github.com/lambdalisue/butler.vim) contributors.