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

[sugestion] AI completion #4

Closed tofeeh closed 1 month ago

tofeeh commented 5 months ago

How hard would it be to generate suggestions based on n-lines before and m-lines after? But I mean something that will work with LSP.

frankroeder commented 5 months ago

You mean something like autocompletion with copilot? If this is the case, I am not thinking of supporting such a feature. I want this plugin to be something that you query on demand. In case you want to have autocompletion with code before and after n-lines, there are many ways to create appropriate prompts.

I could look something like this:

code before ...

CODE TO COMPLETE

code after ...

Please fill in the missing code for CODE TO COMPLETE.

In case I have misunderstood ... perhaps you would like to explain what you mean in more detail.

tofeeh commented 5 months ago

I was thinking of prompt like:

Task: Code snippet completion. Code Before: [Provide the exact lines of code preceding the line needing completion.] Current Line (Cursor Position Indicated): [Insert the incomplete line with a placeholder indicating where to insert the missing code.] Code After: [Provide the exact lines of code that follow the incomplete line.] Objective: Fill in the placeholder in the "Current Line" with the missing code to ensure a seamless and logical flow from the "Code Before" to the "Code After." The code should be syntactically correct for the specified FileType. FileType: Java

Example (Java): Code Before: public class HelloWorld { public static void main(String[] args) { Current Line: System.out.println("Hd!"); Code After: } } Proper Response: "ello, Wor"

but used like completion. I think https://github.com/tzachar/cmp-ai is done like this, but has very poor way to configure it

frankroeder commented 1 month ago

The new template placeholder (see https://github.com/frankroeder/parrot.nvim?tab=readme-ov-file#utilizing-template-placeholders) provides this functionality to include context before and after the desired snippet. Functionalities similar to autocompletion are not part of this project and explicitly excluded, as they require constant and intransparent analysis of your files.