gpt-vim : brings chat gpt to Vim and NVim
script karma |
Rating 7/4,
Downloaded by 877 |
Comments, bugs, improvements
|
Vim wiki
|
created by |
ayman khamouma |
|
script type |
utility |
|
description |
# vim-gpt
This plugin brings chat gpt to Vim and NVim
The purpose of this pugin is to assist you for your various development tasks.
Demo time: https://github.com/kamou/gpt-vim/blob/master/uml2rust.gif
## Current Features
- Chat with GPT (currently gpt3.5-turbo) in a separate buffer. The output is in markdown.
- GPT can recall previous messages from the current session.
- Selected text/code is appended to the prompt.
- GPT is aware of the language of your current buffer.
- Multiple sessions. You can save a session and continue the conversation later if needed.
## Requirements
Requirement can be installed using the following command:
```
pip3 install -r requirements.txt
```
## Installation
```vim
Plug 'kamou/gpt-vim'
```
## Available commands
```
:call gpt#Assist(0) # Launch the prompt
:'<,'>call gpt#Assist(1) # Launch the prompt and append the current selection
```
## Default keymapping configuration
```
nmap <silent> gpa <Plug>(gpt-vim-assist)
xmap <silent> gpa <Plug>(gpt-vim-assist-vis)
vmap <silent> gpa <Plug>(gpt-vim-assist-vis)
```
You may update it in you .vimrc file.
## GPT buffer keys
- `r` reset current session memory, GPT will forget everything, the buffer will be cleared
- `q` close gpt buffer. Memory is kept untouched, gpt will recall previous (most recent) messages.
- `s` save the current session history
- `L` list previously saved sessions (press enter to load selected session)
- `c` Cancel the current stream. (The answer will be lost, and not saved in the database)
- `Y` Enter Yank Mode. [Experimental, mapping willl change soon]
## Yank Mode
- `j` Cycle down to next fenced code block.
- `k` Cycle up to next fenced code block.
- `<cr>` Copy current block and leave Yank Mode.
## Session list keys
- `q` close the list
- `d` delete the session under the cursor
- `<cr>` select the session under the cursor
- `s`: Open the conversation under the cursor in a horizontal split.
- `v`: Open the conversation under the cursor in a vertical split.
|
|
install details |
## Requirements
- an openai [api key](https://platform.openai.com/account/api-keys) (add `g:gpt_api_key` to your config)
- sqlite3, openai and tiktoken python package
```sh
pip install sqlite3
pip install openai
pip install tiktoken
```
## Installation
```vim
Plug 'kamou/gpt-vim'
```
## Available commands
```
:call gpt#assist([sessionname]) # Launch the prompt
:'<,'>call gpt#visual_assist([sessionname]) # Launch the prompt and append the current selection
```
## Sample keymapping configuration
```
map <silent> <leader><space> :<C-U>call gpt#assist()<cr>
xnoremap <silent> <leader><space> :'<,'>call gpt#visual_assist()<cr>
vnoremap <silent> <leader><space> :'<,'>call gpt#visual_assist()<cr>
``` |
|
script versions (upload new version)
Click on the package to download.
ip used for rating: 18.97.14.80
|