Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
piersolenski committed Sep 1, 2023
1 parent 5a641a5 commit 54939b6
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ use({
{
-- Default AI popup type
popup_type = "popup" | "horizontal" | "vertical",
-- An alternative way to set your OpenAI api key
-- An alternative way to set your API key
openai_api_key = "sk-xxxxxxxxxxxxxx",
-- ChatGPT Model
openai_model_id = "gpt-3.5-turbo",
Expand All @@ -82,36 +82,40 @@ use({
language = "english",
-- Any additional instructions
additional_instructions = "Start the reply with 'OH HAI THERE'",
-- Default search engine, can be overridden by passing an option to WtfSeatch
-- Default search engine, can be overridden by passing an option to WtfSeatch
search_engine = "google" | "duck_duck_go" | "stack_overflow" | "github",
-- Callbacks
hooks = {
request_started = nil,
request_finished = nil,
},
}
```


## 🚀 Usage

`wtf.nvim` works by sending the line's diagnostic messages along with contextual information (such as the offending code, file type and severity level) to various sources you can configure.

To use it, whenever you have an hint, warning or error in an LSP enabled environment, invoke one of the commands anywhere on that line in Normal mode:
To use it, whenever you have an hint, warning or error in an LSP enabled environment, invoke one of the commands:

| Command | Description |
| -- | -- |
| `:Wtf [additional_instructions]` | Sends the current line along with all diagnostic messages to ChatGPT. Additional instructions can also be specified, which might be useful if you want to refine the response further.
| `:WtfSearch [search_engine]` | Uses a search engine (defaults to the one in the setup or Google if not provided) to search for the **first** diagnostic. It will attempt to filter out unrelated strings specific to your local environment, such as file paths, for broader results.
| Command | Modes | Description |
| -- | -- | -- |
| `:Wtf [additional_instructions]` | Normal, Visual | Sends the diagnostic messages for a line or visual range to ChatGPT, along with the code if the context has been set to `true`. Additional instructions can also be specified, which might be useful if you want to refine the response further.
| `:WtfSearch [search_engine]` | Normal | Uses a search engine (defaults to the one in the setup or Google if not provided) to search for the **first** diagnostic. It will attempt to filter out unrelated strings specific to your local environment, such as file paths, for broader results.

### Custom status hooks

You can add custom hooks to update your status line or other UI elements, for example, this code updates the status line colour to yellow whilst the request is in progress.

```lua
vim.g["wtf_hooks"] = {
request_started = function()
vim.cmd("hi StatusLine ctermbg=NONE ctermfg=yellow")
end,
request_finished = vim.schedule_wrap(function()
vim.cmd("hi StatusLine ctermbg=NONE ctermfg=NONE")
end)
}
hooks = {
request_started = function()
vim.cmd("hi StatusLine ctermbg=NONE ctermfg=yellow")
end,
request_finished = vim.schedule_wrap(function()
vim.cmd("hi StatusLine ctermbg=NONE ctermfg=NONE")
end),
},
```

### Lualine Status Component
Expand All @@ -133,3 +137,4 @@ require('lualine').setup({
- [Pretty TypeScript Errors](https://github.com/yoavbls/pretty-ts-errors)
- [backseat.nvim](https://github.com/james1236/backseat.nvim/)
- [CodeGPT.nvim](https://github.com/dpayne/CodeGPT.nvim)

0 comments on commit 54939b6

Please sign in to comment.