feat: adding chunking feature, adding preview and partial accepting
This commit is contained in:
80
README.md
80
README.md
@@ -1,46 +1,66 @@
|
||||
<!-- README.md -->
|
||||
# ChatGPT NeoVim Plugin (Updated for YAML and Default Prompt Blocks)
|
||||
# ChatGPT NeoVim Plugin (Extensively Updated with Chunking)
|
||||
|
||||
This plugin integrates a ChatGPT O1 model workflow into Neovim. It allows you to generate prompts containing:
|
||||
- An **initial prompt** configured via a `.chatgpt_config.yaml` file in your project root.
|
||||
- A list of directories (also specified in the `.chatgpt_config.yaml`) from which it gathers the complete project structure and file contents.
|
||||
- The content of the current file you are editing and the project's `README.md`, if present.
|
||||
- Prompts are combined and copied to your clipboard, ready to be pasted into ChatGPT O1.
|
||||
This plugin integrates a ChatGPT O1 model workflow into Neovim. It allows you to:
|
||||
|
||||
The ChatGPT O1 model is then expected to return modifications in a **YAML** format. You will then use the `:ChatGPTPaste` command to read these changes from the clipboard and apply them to your files.
|
||||
1. Generate prompts containing:
|
||||
- An **initial prompt** (from `.chatgpt_config.yaml`)
|
||||
- A list of directories (also specified in `.chatgpt_config.yaml`) from which it gathers the project structure and file contents
|
||||
- **Interactive file selection** if enabled, so you can pick exactly which directories to include
|
||||
- Any **initial files** you define (e.g., `README.md`, etc.)
|
||||
|
||||
## Default Prompt Blocks
|
||||
2. Copy these prompts to your clipboard to paste into ChatGPT O1.
|
||||
3. Receive YAML changes from ChatGPT, then run `:ChatGPTPaste` to apply them or supply additional files.
|
||||
|
||||
The configuration now supports specifying one or more "default prompt blocks." These blocks allow you to quickly switch between different kinds of specialized instructions for ChatGPT. For example:
|
||||
- **go-development**: Focused on Go (Golang) coding best practices, idiomatic patterns, and Go-specific guidance.
|
||||
- **typo3-development**: Focused on TYPO3 development practices, TypoScript, and extension coding guidelines.
|
||||
- **basic-prompt**: A generic prompt that explains how to return modifications in the required YAML structure.
|
||||
## New Key Features
|
||||
|
||||
If you specify multiple blocks in `default_prompt_blocks`, their instructions are concatenated. This lets you combine multiple focus areas or start with a base prompt and add a specialized layer on top.
|
||||
- **Chunking** (`enable_chunking: true`): If the combined prompt or file request is too large (exceeds `token_limit`), the plugin automatically splits it into multiple chunks. Each chunk is opened in its own buffer, and the first chunk is copied to your clipboard. You can paste them sequentially into ChatGPT to work around size limitations.
|
||||
- **Partial Acceptance**: If `partial_acceptance: true`, you can open a buffer that lists the final changes. Remove or comment out lines you don’t want, then only those changes are applied.
|
||||
- **Preview Changes**: If `preview_changes: true`, you get a buffer showing proposed changes before you apply them.
|
||||
- **Interactive File Selection**: If `interactive_file_selection: true`, you choose which directories from `.chatgpt_config.yaml` get included in the prompt, reducing token usage.
|
||||
- **Improved Debug**: If `improved_debug: true`, debug logs go into a dedicated `ChatGPT_Debug_Log` buffer for easier reading.
|
||||
|
||||
## Example Configuration
|
||||
|
||||
Below is an example `.chatgpt_config.yaml` that sets a custom initial prompt, limits directories to scan, and selects default prompt blocks:
|
||||
## Example `.chatgpt_config.yaml`
|
||||
|
||||
```yaml
|
||||
initial_prompt: "You are a coding assistant who will provide modifications in YAML form."
|
||||
directories:
|
||||
- "lua"
|
||||
- "plugin"
|
||||
project_name: "chatgpt_nvim"
|
||||
default_prompt_blocks:
|
||||
- "basic-prompt"
|
||||
- "go-development"
|
||||
- "workflow-prompt"
|
||||
directories:
|
||||
- "."
|
||||
initial_files:
|
||||
- "README.md"
|
||||
debug: false
|
||||
enable_chunking: true
|
||||
preview_changes: true
|
||||
interactive_file_selection: true
|
||||
partial_acceptance: true
|
||||
improved_debug: true
|
||||
token_limit: 3000
|
||||
```
|
||||
|
||||
With this configuration:
|
||||
- The prompt shown to ChatGPT will include both the "basic-prompt" and "go-development" instructions, as well as the user’s message.
|
||||
- Only the `lua` and `plugin` directories of your project will be included in the prompt.
|
||||
|
||||
## Usage
|
||||
|
||||
1. Run `:ChatGPT` and enter your message. The combined prompt is copied to your clipboard.
|
||||
2. Paste it into the ChatGPT O1 model.
|
||||
3. Copy the YAML response from ChatGPT into your clipboard.
|
||||
4. Run `:ChatGPTPaste` to apply the changes to your files.
|
||||
1. **`:ChatGPT`**
|
||||
- If `interactive_file_selection` is on, you’ll pick directories to include.
|
||||
- A buffer `ChatGPT_Prompt.md` opens to type your instructions.
|
||||
- Save & close with `:wq` → If `enable_chunking` is on and the prompt exceeds `token_limit`, it’s split into multiple chunks. Each chunk is opened in a buffer, and the first one is copied to your clipboard.
|
||||
|
||||
This workflow allows you to iterate quickly, making changes guided by AI while keeping a clear history and a structured approach.
|
||||
2. **Paste Prompt to ChatGPT**
|
||||
- If multiple chunks exist, copy/paste them one by one in ChatGPT.
|
||||
|
||||
3. **`:ChatGPTPaste`**
|
||||
- The plugin reads the YAML from your clipboard. If it requests more files, the plugin might chunk that request too if large.
|
||||
- If final changes are provided:
|
||||
- Optionally preview them (`preview_changes`).
|
||||
- Optionally partially accept them (`partial_acceptance`).
|
||||
- Then the plugin writes/deletes files as specified.
|
||||
|
||||
## Troubleshooting & Tips
|
||||
- Adjust `token_limit` in `.chatgpt_config.yaml` as needed.
|
||||
- If partial acceptance is confusing, remember to remove or prepend `#` to lines you don’t want before saving and closing the buffer.
|
||||
- If chunking occurs, ensure you copy/paste **all chunks** into ChatGPT in the correct order.
|
||||
- Check `ChatGPT_Debug_Log` if `improved_debug` is on, or the Neovim messages if `debug` is on, for detailed info.
|
||||
|
||||
Enjoy your improved, more flexible ChatGPT Neovim plugin with chunking support!
|
||||
|
||||
Reference in New Issue
Block a user