CoderCookE / vim-chatgpt

Vim Plugin For ChatGPT
The Unlicense
230 stars 29 forks source link

Extend ChatGPT Prompts with User Custom Prompts #28

Closed CoderCookE closed 10 months ago

CoderCookE commented 10 months ago

In the chatgpt.vim plugin, added functionality to extend the default prompt templates with user-defined custom prompts. This change allows the users to create their own prompts by defining the g:chat_gpt_custom_prompts variable. This enhances the flexibility and applicability of the ChatGPT plugin in different usage scenarios.

To add new prompts or override existing prompts:

let g:chat_gpt_custom_prompts = {'hi': 'do you think this is good enough?', 'fix': 'this does not work'}
command! -range -nargs=? Hi call SendHighlightedCodeToChatGPT('hi', <q-args>)

ToDo: Fix the popup menu.

MesRot commented 10 months ago

Is there point in storing the prompts in Dict? You could do it in a following manner:

command! -range -nargs=? Ask call SendHighlightedCodeToChatGPT('',<q-args>)
command! -range -nargs=? Explain call SendHighlightedCodeToChatGPT('Can you explain it?', <q-args>)
command! -range -nargs=? Rewrite call SendHighlightedCodeToChatGPT('Can you rewrite it more idiomatically?', <q-args>)
...

and refactor the whole dictionary approach in the SendHighlightedCodeToChatGPT

I'll try to think about a way to add the custom prompts to the popup menu

Edit: The Dict helps selecting the function from the popup menu, probably thats why it is used