Skip to content

Commit

Permalink
docs: update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
olimorris committed Feb 5, 2024
1 parent ddf7613 commit cfa266b
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 19 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@
Use the <a href="https://platform.openai.com/docs/guides/text-generation/chat-completions-api">OpenAI APIs</a> directly in Neovim. Use it to chat, author and advise you on your code.
</p>

## :warning: Disclaimer
> [!IMPORTANT]
> This plugin is provided as-is and is primarily developed for my own workflows. As such, I offer no guarantees of regular updates or support. Bug fixes and feature enhancements will be implemented at my discretion, and only if they align with my personal use-case. Feel free to fork the project and customize it to your needs, but please understand my involvement in further development will be minimal.
This plugin has been created purely for my own use. Whilst I've made it publically available, I will _not_ accept any enhancement requests. Feel free to submit your own PR but I will be very selective about what I accept. Finally, I will only fix bugs if they relate to my own workflow.
<p align="center">
<img src="https://github.com/olimorris/codecompanion.nvim/assets/9512444/5e5a5e54-c1d9-4fe2-8ae0-1cfbfdd6cea5" alt="Header" />
</p>

<!-- panvimdoc-ignore-end -->

Expand Down
58 changes: 41 additions & 17 deletions doc/codecompanion.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ INSTALLATION *codecompanion-installation*
"olimorris/codecompanion.nvim",
dependencies = {
"nvim-treesitter/nvim-treesitter",
"nvim-lua/plenary.nvim",
{
"stevearc/dressing.nvim", -- Optional: Improves the default Neovim UI
opts = {},
Expand All @@ -54,6 +55,7 @@ INSTALLATION *codecompanion-installation*
end,
requires = {
"nvim-treesitter/nvim-treesitter",
"nvim-lua/plenary.nvim",
"stevearc/dressing.nvim"
}
})
Expand All @@ -68,7 +70,7 @@ CONFIGURATION *codecompanion-configuration*
Click to see the default configuration ~

>lua
{
require("codecompanion").setup({
api_key = "OPENAI_API_KEY", -- Your API key
org_api_key = "OPENAI_ORG_KEY", -- Your organisation API key
base_url = "https://api.openai.com", -- The URL to use for the API requests
Expand Down Expand Up @@ -98,16 +100,17 @@ Click to see the default configuration ~
height = 10,
},
chat = { -- Options for the chat strategy
type = "buffer", -- buffer|float
type = "float", -- float|buffer
show_settings = false, -- Show the model settings in the chat window
float = {
float = { -- Options for the floating window
border = "single",
buflisted = false,
max_height = 0,
max_width = 0,
padding = 1,
},
},
win_options = {
win_options = { -- Options for the chat buffer
cursorcolumn = false,
cursorline = false,
foldcolumn = "0",
Expand All @@ -119,20 +122,21 @@ Click to see the default configuration ~
},
},
keymaps = {
["<C-c>"] = "keymaps.close", -- Close the chat (can be toggled back)
["<C-s>"] = "keymaps.save", -- Save the chat buffer and trigger the API
["<C-c>"] = "keymaps.close", -- Close the chat buffer
["q"] = "keymaps.cancel_request", -- Cancel the currently streaming request
["gd"] = "keymaps.delete", -- Delete the chat permanently (cannot be toggled)
["gc"] = "keymaps.clear", -- Clear the contents of the chat
["ga"] = "keymaps.codeblock", -- Insert a codeblock in the chat
["ga"] = "keymaps.codeblock", -- Insert a codeblock into the chat
["gs"] = "keymaps.save_conversation", -- Save the current chat as a conversation
["]"] = "keymaps.next", -- Move to the next header in the chat
["["] = "keymaps.previous", -- Move to the previous header in the chat
},
log_level = "ERROR", -- TRACE|DEBUG|ERROR
send_code = true, -- Send code context to the API?
show_token_count = true, -- Show the token count for the current chat?
silence_notifications = false, -- Silence notifications for actions like saving conversations?
use_default_actions = true, -- Use the default actions in the action palette?
}
})
<


Expand All @@ -158,6 +162,14 @@ The author recommends pairing with edgy.nvim
<


HIGHLIGHT GROUPS ~

The plugin sets a number of highlights during setup:

- `CodeCompanionTokens` - Virtual text showing the token count when in a chat buffer
- `CodeCompanionVirtualText` - All other virtual text in the chat buffer


USAGE *codecompanion-usage*

The plugin has a number of commands:
Expand Down Expand Up @@ -224,9 +236,9 @@ KEYMAPS
When in the chat buffer, there are number of keymaps available to you (which
can be changed in the config):

- `<C-c>` - Close/hide the buffer (can be toggled back)
- `q` - Cancel streaming from the API
- `gd` - Delete the buffer (cannot be toggled back)
- `<C-s>` - Save the buffer and trigger a response from the GenAI
- `<C-c>` - Close the buffer
- `q` - Cancel streaming from the GenAI
- `gc` - Clear the buffer’s contents
- `ga` - Add a codeblock
- `gs` - Save the chat as a conversation
Expand All @@ -237,15 +249,16 @@ can be changed in the config):
CONVERSATIONS

Chat Buffers are not automatically saved to disk, owing to them being an
`acwrite` buftype (see |buftype|). However, the plugin allows for this via the
notion of Conversations and pressing `gs` in the buffer. Conversations can then
be restored via the Action Palette and the _Load conversations_ action.
`acwrite` buffer (see |buftype|). However, the plugin allows for this via the
notion of Conversations. By pressing `gs` in the buffer, the current chat will
be saved. Conversations can then be restored via the Action Palette and the
_Load conversations_ action.


SETTINGS

If `display.chat.show_settings` is set to `true`, at the very top of the chat
buffer will be the parameters which can be changed to affect the API’s
buffer will be the GenAI parameters which can be changed to affect the API’s
response back to you. This enables fine-tuning and parameter tweaking
throughout the chat. You can find more detail about them by moving the cursor
over them or referring to the Chat Completions reference guide
Expand Down Expand Up @@ -276,6 +289,13 @@ OpenAI.
**Note**Both of these actions allow for visually selected code to be sent to
the chat buffer as code blocks.

OPEN CHATS

This action enables users to easily navigate between their open chat buffers. A
chat buffer maybe deleted (and removed from this action) by pressing `<C-q>`
when in the chat buffer.


CODE AUTHOR

This action utilises the `author` strategy. This action can be useful for
Expand Down Expand Up @@ -312,14 +332,18 @@ The plugin fires the following events during its lifecycle:

- `CodeCompanionRequest` - Fired during the API request. Outputs `data.status` with a value of `started` or `finished`
- `CodeCompanionConversation` - Fired after a conversation has been saved to disk
- `CodeCompanionChat` - Fired at various points during the chat buffer. Comes with the following attributes:
- `data.action = close_buffer` - For when a chat buffer has been permanently closed
- `data.action = hide_buffer` - For when a chat buffer is now hidden
- `data.action = show_buffer` - For when a chat buffer is now visible after being hidden

Events can be hooked into as follows:

>lua
local group = vim.api.nvim_create_augroup("CodeCompanionHooks", {})

vim.api.nvim_create_autocmd({ "User" }, {
pattern = "CodeCompanion",
pattern = "CodeCompanionRequest",
group = group,
callback = function(request)
print(request.data.status) -- outputs "started" or "finished"
Expand All @@ -335,7 +359,7 @@ HEIRLINE.NVIM ~
If you use the fantastic Heirline.nvim
<https://github.com/rebelot/heirline.nvim> plugin, consider the following
snippet to display an icon in the statusline whilst CodeCompanion is speaking
to the LLM:
to a GenAI model:

>lua
local GenAI = {
Expand Down

0 comments on commit cfa266b

Please sign in to comment.