feat: enable override prompt templates directory (#2387)
This commit is contained in:
28
README.md
28
README.md
@@ -1116,7 +1116,9 @@ By default, `avante.nvim` provides three different modes to interact with: `plan
|
||||
- `suggesting`: Used with `require("avante").get_suggestion():suggest()` on Tab flow.
|
||||
- `cursor-planning`: Used with `require("avante").toggle()` on Tab flow, but only when cursor planning mode is enabled.
|
||||
|
||||
Users can customize the system prompts via `Config.system_prompt`. We recommend calling this in a custom Autocmds depending on your need:
|
||||
Users can customize the system prompts via `Config.system_prompt` or `Config.override_prompt_dir`.
|
||||
|
||||
`Config.system_prompt` allows you to set a global system prompt. We recommend calling this in a custom Autocmds depending on your need:
|
||||
|
||||
```lua
|
||||
vim.api.nvim_create_autocmd("User", {
|
||||
@@ -1127,7 +1129,29 @@ vim.api.nvim_create_autocmd("User", {
|
||||
vim.keymap.set("n", "<leader>am", function() vim.api.nvim_exec_autocmds("User", { pattern = "ToggleMyPrompt" }) end, { desc = "avante: toggle my prompt" })
|
||||
```
|
||||
|
||||
If one wish to custom prompts for each mode, `avante.nvim` will check for project root based on the given buffer whether it contains
|
||||
`Config.override_prompt_dir` allows you to specify a directory containing your own custom prompt templates, which will override the built-in templates. This is useful if you want to maintain a set of custom prompts outside of your Neovim configuration. It can be a string representing the directory path, or a function that returns a string representing the directory path.
|
||||
|
||||
```lua
|
||||
-- Example: Override with prompts from a specific directory
|
||||
require("avante").setup({
|
||||
override_prompt_dir = vim.fn.expand("~/.config/nvim/avante_prompts"),
|
||||
})
|
||||
|
||||
-- Example: Override with prompts from a function (dynamic directory)
|
||||
require("avante").setup({
|
||||
override_prompt_dir = function()
|
||||
-- Your logic to determine the prompt directory
|
||||
return vim.fn.expand("~/.config/nvim/my_dynamic_prompts")
|
||||
end,
|
||||
})
|
||||
```
|
||||
|
||||
> [!WARNING]
|
||||
>
|
||||
> If you customize `base.avanterules`, please ensure that `{% block custom_prompt %}{% endblock %}` and `{% block extra_prompt %}{% endblock %}` exist, otherwise the entire plugin may become unusable.
|
||||
> If you are unsure about the specific reasons or what you are doing, please do not override the built-in prompts. The built-in prompts work very well.
|
||||
|
||||
If you wish to custom prompts for each mode, `avante.nvim` will check for project root based on the given buffer whether it contains
|
||||
the following patterns: `*.{mode}.avanterules`.
|
||||
|
||||
The rules for root hierarchy:
|
||||
|
||||
Reference in New Issue
Block a user