yetone / avante.nvim

Use your Neovim like using Cursor AI IDE!
Apache License 2.0
5.2k stars 173 forks source link

Make "edit" action dot-repeatable. #365

Open JeanMertz opened 2 weeks ago

JeanMertz commented 2 weeks ago

Say I have a bunch of undocumented functions.

I select the first function, and tell it to "add documentation with LuaLS type annotations".

The edit is successful (awesome, btw!) but now I want to do the same for the next 5 functions. Obviously in the same file, I can (probably) just select them all at once, but ideally, I could just . repeat my last edit similar to other edit actions I do in my buffer.

oxysoft commented 2 weeks ago

You mean the <leader>ae action right? I agree, a 'semantic action repeat' would be insane. In fact, you could even make it work when there is no selection by asking the LLM to recognize the common pattern at the caret location, and choose by itself a visual selection to refactor first before running the prompt.

Such an intermediate LLM module could be more generalized as well and trained over time locally by user data which is collected passively - every time the user makes a manual selection and fires off an edit refactor, we can look at the selection and learn the reverse process: given this prompt with this caret location, what be an appropriate selection range? Ideally we would collect a large dataset but it's gonna be hard to find volunteers. Just spitballin', but I believe to create the ultimate integration of LLM intelligence in editors, small intermediate modules like these need to be thought up and invented on the fly in order to create things that make even Cursor look weak in comparison.

yetone commented 2 weeks ago

Thank you for the suggestion, I will look into how to implement it.

yetone commented 2 weeks ago

Do you expect the functionality to require selecting the code block in advance before pressing .?

aarnphm commented 2 weeks ago

i think they are suggesting a vim-repeat for semantic action

JeanMertz commented 2 weeks ago

Yeah, although initially, I would like for me to make a selection, and then dot-repeat would trigger the last edit query and apply to diff in one go.

aarnphm commented 2 weeks ago

very initial scuffed first idea that doesn't involve state machine:

aarnphm commented 1 week ago

Thinking more about this, best is to have a snippet over advanced configuration for users who want to use this instead of building this into the core offering.

This can be setup via setup hooks in lazy or otherwise (autocmd).