https://github.com/cmpadden/chatblade.nvim
Chatblade integration for Neovim
https://github.com/cmpadden/chatblade.nvim
chatblade chatgpt llm neovim
Last synced: over 1 year ago
JSON representation
Chatblade integration for Neovim
- Host: GitHub
- URL: https://github.com/cmpadden/chatblade.nvim
- Owner: cmpadden
- Created: 2024-02-15T21:49:02.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-03T20:11:07.000Z (over 2 years ago)
- Last Synced: 2024-03-03T21:25:20.520Z (over 2 years ago)
- Topics: chatblade, chatgpt, llm, neovim
- Language: Lua
- Homepage:
- Size: 547 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Setup
### Prerequisites
1. Install the [Chatblade](https://github.com/npiv/chatblade) CLI
2. Set the `OPENAI_API_KEY` environment variable
### Installation & Configuration
```lua
-- lazy.nvim
{
"cmpadden/chatblade.nvim",
keys = {
{ "x", ":Chatblade", mode = "v" },
},
cmd = {
"Chatblade",
"ChatbladeSessionStart",
"ChatbladeSessionStop",
"ChatbladeSessionDelete",
},
opts = {
prompt = "programmer",
raw = true,
extract = true,
only = true,
temperature = 0.8,
include_filetype = true,
insert_as_comment = true,
}
}
```
## Usage
### Bindings
Select text, and send it to Chatblade with your key binding of choice. For the example
of `x`, you can visually select a line or paragraph, send it to Chatblade, and
the response will be inserted below your cursor.
```
vipx
```
### Commands
The following user commands have been made available. This allows you to handle sessions
so that you can send snippets to Chatblade, and ask follow-up questions with persisted
context.
| Command | Parameters | Description |
| ---------------------- | --------- | ----------------------------------------------------------------- |
| Chatblade | `string?` | Prompt Chatblade with visual selection and/or an additional query |
| ChatbladeSessionStart | `string` | Start a session to persist context |
| ChatbladeSessionStop | `nil` | Stop the currently active Chatblade session |
| ChatbladeSessionDelete | `string` | Delete the specified Chatblade session |
### Options
| Property | Type | Description |
| --------------------- | ---------- | ---------------------------------------------------------------------------------------------------------- |
| **prompt** | `string?` | Prompt to use found in the `~/.config/chatblade` directory (Default `nil`) |
| **raw** | `boolean?` | Whether to return results in pure text (Default `true`) |
| **extract** | `boolean?` | Whether to extract code from response (Default `true`) |
| **only** | `boolean?` | Only display the response, not the original query (Default `true`) |
| **temperature** | `float?` | Lower values for result in more consistent outputs, whereas higher is more creative (Default 0.0; Max 2.0) |
| **include_filetype** | `boolean?` | Include filetype metadata in the prompt from active buffer (`vim.bo.filetype`) |
| **insert_as_comment** | `boolean?` | Inserts response as a comment using the `commentstring` defined for the active filetype |
## Motivation
If all you wish to do is to pass text to `chatblade` from your Neovim session, then you may be better off defining a key binding like so:
```lua
vim.keymap.set("v", "x", ':!chatblade -e -r')
```
However, _chatblade.nvim_ intends to offer some quality of life improvements over such a bindings.