Robitx / gp.nvim

Gp.nvim (GPT prompt) Neovim AI plugin: ChatGPT sessions & Instructable text/code operations & Speech to text [OpenAI]
MIT License
537 stars 50 forks source link

feat: possibility to go to normal mode, while response is generated (GpChatNew) #57

Closed divramod closed 7 months ago

divramod commented 7 months ago

hey hey,

sometimes the reponse takes some time, but there are already peaces generated, i want to integrate into my code. for these cases, it would be helpful to be able to go to normal mode and navigate/copy parts of the still beeing generated response. currently it is possible to go to normal mode, but every time a new response character is written, the cursor jumps back to the reponse (last) line in the buffer.

sounds a little difficult at first glance to me? but would improve my workflow a lot (saves time), because i do not need to wait for the finished reponse.

keep up the great work!

Robitx commented 7 months ago

@divramod hey, thanks for the coffee :slightly_smiling_face:

For code operations such as GpRewrite this would be dangerous since people might start edit existing code and remove/add lines which could get the answer generated on wrong lines. Solution for this would be to keep a reference line via extmarks (will do in the future https://github.com/Robitx/gp.nvim/issues/59)

For chats (where the use case is to move, select and yank) this should be fine, please check the latest version. I still move the cursor to the end once the response finishes, but you can disable this behavior via chat_free_cursor = true.

divramod commented 7 months ago

awesome, thx! you are welcome ☕️

i hoped, that vim has something like extmarks, or better that you will have a solution in mind to solve this also for the code operations.

for chat_free_cursor = true, this was one of the things i had in mind to ask next. until now i usually waited until the finish of the response and then started going to the relevant parts i wanted to copy. it often happened then, that i already started selecting text but the cursor jumped back to the end after changing the topic. zwei fliegen mit einer klappe 🤣

Robitx commented 7 months ago

All text generations are now positioned relatively to extmarks and it's also possible to free cursor for code operations via:

-- auto select command response (easier chaining of commands)
-- if false it also frees up the buffer cursor for further editing elsewhere
command_auto_select_response = true,