Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Robitx authored Dec 10, 2023
1 parent 1c9e85e commit 1f9c8fe
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ Trying to keep things as native as possible - reusing and integrating well with

# Install

## 1. Install the plugin with your preferred package manager:
## 1. Install the plugin <!-- {doc=gp.nvim-install-the-plugin} -->

Snippets for your preferred package manager:
```lua
-- lazy.nvim
{
Expand Down Expand Up @@ -88,7 +89,7 @@ use({
})
```

## 2. OpenAI API key
## 2. OpenAI API key <!-- {doc=gp.nvim-openai-api-key} -->

Make sure you have OpenAI API key. [Get one here](https://platform.openai.com/account/api-keys) and use it in the [config](#4-configuration). Also consider setting up [usage limits](https://platform.openai.com/account/billing/limits) so you won't get suprised at the end of the month.

Expand All @@ -104,7 +105,7 @@ The OpenAI API key can be passed to the plugin in multiple ways:

If `openai_api_key` is a table, Gp runs it asynchronously to avoid blocking Neovim (password managers can take a second or two).

## 3. Dependencies
## 3. Dependencies <!-- {doc=gp.nvim-dependencies} -->

The core plugin only needs `curl` installed to make calls to OpenAI API and `grep` for ChatFinder. So Linux, BSD and Mac OS should be covered.

Expand All @@ -116,14 +117,15 @@ Voice commands (`:GpWhisper*`) depend on `SoX` (Sound eXchange) to handle audio
- Redhat/CentOS: `yum install sox`
- NixOS: `nix-env -i sox`

## 4. Configuration
## 4. Configuration <!-- {doc=gp.nvim-configuration} -->

Bellow are the default values, but I suggest starting with minimal config possible (just `openai_api_key` if you don't have `OPENAI_API_KEY` env set up). Defaults change over time to improve things, options might get deprecated and so on - it's better to change only things where the default doesn't fit your needs.
https://github.com/Robitx/gp.nvim/blob/7d802f54fb503f27fc9722656efddb05a533f4cf/lua/gp/config.lua#L8-L350

# Usage

## GpChat commands
## Chat commands <!-- {doc=gp.nvim-chat-commands} -->

#### `:GpChatNew` <!-- {doc=:GpChatNew} -->
Open a fresh chat in the current window. It can be either empty or include the visual selection or specified range as context. This command also supports subcommands for layout specification:

Expand Down Expand Up @@ -157,7 +159,7 @@ Request a new GPT response for the current chat. Usin`:GpChatRespond N` request
#### `:GpChatDelete` <!-- {doc=:GpChatDelete} -->
Delete the current chat. By default requires confirmation before delete, which can be disabled in config using `chat_confirm_delete = false,`.

## Text/Code operation commands
## Text/Code operation commands <!-- {doc=gp.nvim-text-code-operation-commands} -->
- `:GpRewrite`<a id="gprewrite"></a>
: Opens a dialog for entering a prompt. After providing prompt instructions into the dialog, the generated response replaces the current line in the normal/insert mode, selected lines in visual mode, or the specified range (for example `:%GpRewrite` would apply the rewrite to the entire buffer).

Expand Down Expand Up @@ -235,7 +237,7 @@ Delete the current chat. By default requires confirmation before delete, which c
- Run your own custom hook commands:
- `:GpInspectPlugin` - inspect GPT prompt plugin object

## GpDone autocommand to run consequent actions
## GpDone autocommand <!-- {doc=gp.nvim-gpdone-autocommand} -->

Commands like `GpRewrite`, `GpAppend` etc. run asynchronously and generate event `GpDone`, so you can define autocmd (like auto formating) to run when gp finishes:

Expand All @@ -250,7 +252,8 @@ Commands like `GpRewrite`, `GpAppend` etc. run asynchronously and generate event
})
```

## Custom instructions per repository
## Custom instructions <!-- {doc=gp.nvim-custom-instructions} -->


By calling `:GpContext` you can make `.gp.md` markdown file in a root of a repository. Commands such as `:GpRewrite`, `:GpAppend` etc. will respect instructions provided in this file (works better with gpt4, gpt 3.5 doesn't always listen to system commands). For example:

Expand All @@ -263,7 +266,7 @@ Use Early return/Guard Clauses pattern to avoid excessive nesting.

Here is [another example](https://github.com/Robitx/gp.nvim/blob/main/.gp.md).

## Scripting and multifile edits
## Scripting <!-- {doc=gp.nvim-scripting} -->

`GpDone` event + `.gp.md` custom instructions provide a possibility to run gp.nvim using headless (neo)vim from terminal or shell script. So you can let gp run edits accross many files if you put it in a loop.

Expand Down

0 comments on commit 1f9c8fe

Please sign in to comment.