frankroeder / parrot.nvim

parrot.nvim 🦜 - the plugin that brings stochastic parrots to Neovim. This is a gp.nvim-fork focused on simplicity.
Other
219 stars 14 forks source link

Add {{filecontent}} support #17

Closed quolpr closed 2 months ago

quolpr commented 2 months ago

This will unlock such templates:


        template_selection = [[
I have the following content from {{filename}}:

{{filetype}}
{{filecontent}}

And I want to work on part of the code at line_start={{linestart}}, line_end={{lineend}}:

{{filetype}}
{{selection}}

Do this: {{command}}
]],
        template_rewrite = [[
I have the following content from {{filename}}:

{{filetype}}
{{filecontent}}

And I want modify this part of the code at line_start={{linestart}}, line_end={{lineend}}:

{{filetype}}
{{selection}}

Do this:{{command}}

Respond exclusively with the snippet that should replace the selection above.
DO NOT RESPOND WITH ANY TYPE OF COMMENTS, JUST THE CODE!!!
]],
        template_append = [[
I have the following content from {{filename}}:

{{filetype}}
{{filecontent}}

And I want modify this part of the code at line_start={{linestart}}, line_end={{lineend}}:

{{filetype}}
{{selection}}

Do this:{{command}}

Respond exclusively with the snippet that should be appended after the selection above.
DO NOT RESPOND WITH ANY TYPE OF COMMENTS, JUST THE CODE!!!
DO NOT REPEAT ANY CODE FROM ABOVE!!!
]],
        template_prepend = [[
I have the following content from {{filename}}:

{{filetype}}
{{filecontent}}

And I want modify this part of the code at line_start={{linestart}}, line_end={{lineend}}:

{{filetype}}
{{selection}}

{{command}}
Respond exclusively with the snippet that should be prepended before the selection above.
DO NOT RESPOND WITH ANY TYPE OF COMMENTS, JUST THE CODE!!!
DO NOT REPEAT ANY CODE FROM ABOVE!!!
]],
}}
frankroeder commented 2 months ago

This feature should essentially allow you to edit only a small part of the code, but provide more context for the LLM, right? I believe that’s what the chat sessions are designed for. They allow you to provide as much context as you want and allow you to provide a small piece of code that you wish to be edited.

frankroeder commented 2 months ago

Thank you very much, @quolpr, for your pull request. I decided to proceed with pull request #18 and have included an optional placeholder. An example of this has been added to the readme.

quolpr commented 2 months ago

@frankroeder hmm, but I also need linestart and linend 🤔 Also, what do you mean by

have included an optional placeholder

In my PR placeholder is optional too 🤔

frankroeder commented 2 months ago

Yes, your placeholder is also optional. Could you explain to me where linestart and lineend are coming from when you have a visual selection for which you trigger an interactive hook?